1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2006-2007 Imendio AB
4 * Copyright (C) 2007-2008 Collabora Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301 USA
21 * Authors: Martyn Russell <martyn@imendio.com>
22 * Xavier Claessens <xclaesse@gmail.com>
31 #include <glib/gi18n.h>
32 #include <glib/gprintf.h>
34 #include <telepathy-glib/interfaces.h>
36 #include <libempathy/empathy-tp-roomlist.h>
37 #include <libempathy/empathy-chatroom.h>
38 #include <libempathy/empathy-utils.h>
39 #include <libempathy/empathy-dispatcher.h>
41 #include <libempathy-gtk/empathy-account-chooser.h>
42 #include <libempathy-gtk/empathy-ui-utils.h>
44 #include "empathy-new-chatroom-dialog.h"
46 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
47 #include <libempathy/empathy-debug.h>
50 EmpathyTpRoomlist *room_list;
51 /* Currently selected account */
53 /* Signal id of the "status-changed" signal connected on the currently
55 gulong status_changed_id;
58 GtkWidget *vbox_widgets;
59 GtkWidget *table_info;
60 GtkWidget *label_account;
61 GtkWidget *account_chooser;
62 GtkWidget *label_server;
63 GtkWidget *entry_server;
64 GtkWidget *label_room;
65 GtkWidget *entry_room;
66 GtkWidget *expander_browse;
67 GtkWidget *hbox_expander;
71 GtkWidget *button_join;
72 GtkWidget *label_error_message;
73 GtkWidget *viewport_error;
74 } EmpathyNewChatroomDialog;
77 EmpathyAccountChooserFilterResultCallback callback;
92 static void new_chatroom_dialog_response_cb (GtkWidget *widget,
94 EmpathyNewChatroomDialog *dialog);
95 static void new_chatroom_dialog_destroy_cb (GtkWidget *widget,
96 EmpathyNewChatroomDialog *dialog);
97 static void new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog);
98 static void new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog);
99 static void new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog);
100 static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
101 EmpathyNewChatroomDialog *dialog);
102 static void new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist *room_list,
103 EmpathyNewChatroomDialog *dialog);
104 static void new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
105 EmpathyChatroom *chatroom,
106 EmpathyNewChatroomDialog *dialog);
107 static void new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
109 EmpathyNewChatroomDialog *dialog);
110 static void start_listing_error_cb (EmpathyTpRoomlist *room_list,
112 EmpathyNewChatroomDialog *dialog);
113 static void stop_listing_error_cb (EmpathyTpRoomlist *room_list,
115 EmpathyNewChatroomDialog *dialog);
116 static void new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog);
117 static void new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
119 GtkTreeViewColumn *column,
120 EmpathyNewChatroomDialog *dialog);
121 static void new_chatroom_dialog_model_selection_changed (GtkTreeSelection *selection,
122 EmpathyNewChatroomDialog *dialog);
123 static void new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog);
124 static void new_chatroom_dialog_entry_changed_cb (GtkWidget *entry,
125 EmpathyNewChatroomDialog *dialog);
126 static void new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog *dialog);
127 static void new_chatroom_dialog_browse_stop (EmpathyNewChatroomDialog *dialog);
128 static void new_chatroom_dialog_entry_server_activate_cb (GtkWidget *widget,
129 EmpathyNewChatroomDialog *dialog);
130 static void new_chatroom_dialog_expander_browse_activate_cb (GtkWidget *widget,
131 EmpathyNewChatroomDialog *dialog);
132 static gboolean new_chatroom_dialog_entry_server_focus_out_cb (GtkWidget *widget,
133 GdkEventFocus *event,
134 EmpathyNewChatroomDialog *dialog);
135 static void new_chatroom_dialog_button_close_error_clicked_cb (GtkButton *button,
136 EmpathyNewChatroomDialog *dialog);
138 static EmpathyNewChatroomDialog *dialog_p = NULL;
142 conn_prepared_cb (GObject *conn,
143 GAsyncResult *result,
146 FilterCallbackData *data = user_data;
147 GError *myerr = NULL;
148 TpCapabilities *caps;
150 if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
151 data->callback (FALSE, data->user_data);
152 g_slice_free (FilterCallbackData, data);
155 caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
156 data->callback (tp_capabilities_supports_text_chatrooms (caps),
159 g_slice_free (FilterCallbackData, data);
163 * empathy_account_chooser_filter_supports_multichat:
164 * @account: a #TpAccount
165 * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
166 * @callback_data: data passed to the @callback
167 * @user_data: user data or %NULL
169 * An #EmpathyAccountChooserFilterFunc that returns accounts that both
170 * support multiuser text chat and are connected.
172 * Returns (via the callback) TRUE if @account both supports muc and is connected
175 empathy_account_chooser_filter_supports_multichat (
177 EmpathyAccountChooserFilterResultCallback callback,
178 gpointer callback_data,
181 TpConnection *connection;
182 FilterCallbackData *cb_data;
183 GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
185 if (tp_account_get_connection_status (account, NULL) !=
186 TP_CONNECTION_STATUS_CONNECTED) {
187 callback (FALSE, callback_data);
191 /* check if CM supports multiuser text chat */
192 connection = tp_account_get_connection (account);
193 if (connection == NULL) {
194 callback (FALSE, callback_data);
198 cb_data = g_slice_new0 (FilterCallbackData);
199 cb_data->callback = callback;
200 cb_data->user_data = callback_data;
201 tp_proxy_prepare_async (connection, features, conn_prepared_cb,
206 empathy_new_chatroom_dialog_show (GtkWindow *parent)
208 EmpathyNewChatroomDialog *dialog;
210 GtkSizeGroup *size_group;
214 gtk_window_present (GTK_WINDOW (dialog_p->window));
218 dialog_p = dialog = g_new0 (EmpathyNewChatroomDialog, 1);
220 filename = empathy_file_lookup ("empathy-new-chatroom-dialog.ui", "src");
221 gui = empathy_builder_get_file (filename,
222 "new_chatroom_dialog", &dialog->window,
223 "table_info", &dialog->table_info,
224 "label_account", &dialog->label_account,
225 "label_server", &dialog->label_server,
226 "label_room", &dialog->label_room,
227 "entry_server", &dialog->entry_server,
228 "entry_room", &dialog->entry_room,
229 "treeview", &dialog->treeview,
230 "button_join", &dialog->button_join,
231 "expander_browse", &dialog->expander_browse,
232 "hbox_expander", &dialog->hbox_expander,
233 "label_error_message", &dialog->label_error_message,
234 "viewport_error", &dialog->viewport_error,
238 empathy_builder_connect (gui, dialog,
239 "new_chatroom_dialog", "response", new_chatroom_dialog_response_cb,
240 "new_chatroom_dialog", "destroy", new_chatroom_dialog_destroy_cb,
241 "entry_server", "changed", new_chatroom_dialog_entry_changed_cb,
242 "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb,
243 "entry_server", "focus-out-event", new_chatroom_dialog_entry_server_focus_out_cb,
244 "entry_room", "changed", new_chatroom_dialog_entry_changed_cb,
245 "expander_browse", "activate", new_chatroom_dialog_expander_browse_activate_cb,
246 "button_close_error", "clicked", new_chatroom_dialog_button_close_error_clicked_cb,
249 g_object_unref (gui);
251 g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog_p);
253 /* Label alignment */
254 size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
256 gtk_size_group_add_widget (size_group, dialog->label_account);
257 gtk_size_group_add_widget (size_group, dialog->label_server);
258 gtk_size_group_add_widget (size_group, dialog->label_room);
260 g_object_unref (size_group);
262 /* Set up chatrooms treeview */
263 new_chatroom_dialog_model_setup (dialog);
266 dialog->throbber = gtk_spinner_new ();
267 gtk_box_pack_start (GTK_BOX (dialog->hbox_expander), dialog->throbber,
270 /* Account chooser for custom */
271 dialog->account_chooser = empathy_account_chooser_new ();
272 empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
273 empathy_account_chooser_filter_supports_multichat,
275 gtk_table_attach_defaults (GTK_TABLE (dialog->table_info),
276 dialog->account_chooser,
278 gtk_widget_show (dialog->account_chooser);
280 g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed",
281 G_CALLBACK (new_chatroom_dialog_account_changed_cb),
283 new_chatroom_dialog_account_changed_cb (GTK_COMBO_BOX (dialog->account_chooser),
287 gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
288 GTK_WINDOW (parent));
291 gtk_widget_show (dialog->window);
295 new_chatroom_dialog_response_cb (GtkWidget *widget,
297 EmpathyNewChatroomDialog *dialog)
299 if (response == GTK_RESPONSE_OK) {
300 new_chatroom_dialog_join (dialog);
303 gtk_widget_destroy (widget);
307 new_chatroom_dialog_destroy_cb (GtkWidget *widget,
308 EmpathyNewChatroomDialog *dialog)
310 if (dialog->room_list) {
311 g_object_unref (dialog->room_list);
313 g_object_unref (dialog->model);
315 if (dialog->account != NULL) {
316 g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
317 g_object_unref (dialog->account);
324 new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog)
328 GtkTreeSelection *selection;
331 view = GTK_TREE_VIEW (dialog->treeview);
333 g_signal_connect (view, "row-activated",
334 G_CALLBACK (new_chatroom_dialog_model_row_activated_cb),
338 store = gtk_list_store_new (COL_COUNT,
339 G_TYPE_STRING, /* Invite */
340 G_TYPE_STRING, /* Password */
341 G_TYPE_STRING, /* Name */
342 G_TYPE_STRING, /* Room */
343 G_TYPE_STRING, /* Member count */
344 G_TYPE_INT, /* Member count int */
345 G_TYPE_STRING); /* Tool tip */
347 dialog->model = GTK_TREE_MODEL (store);
348 gtk_tree_view_set_model (view, dialog->model);
349 gtk_tree_view_set_tooltip_column (view, COL_TOOLTIP);
350 gtk_tree_view_set_search_column (view, COL_NAME);
353 selection = gtk_tree_view_get_selection (view);
354 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
355 COL_NAME, GTK_SORT_ASCENDING);
357 g_signal_connect (selection, "changed",
358 G_CALLBACK (new_chatroom_dialog_model_selection_changed),
362 new_chatroom_dialog_model_add_columns (dialog);
366 new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog)
369 GtkTreeViewColumn *column;
370 GtkCellRenderer *cell;
373 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
375 view = GTK_TREE_VIEW (dialog->treeview);
377 cell = gtk_cell_renderer_pixbuf_new ();
381 "stock-size", GTK_ICON_SIZE_MENU,
383 column = gtk_tree_view_column_new_with_attributes (NULL,
385 "stock-id", COL_INVITE_ONLY,
388 gtk_tree_view_column_set_sort_column_id (column, COL_INVITE_ONLY);
389 gtk_tree_view_append_column (view, column);
391 column = gtk_tree_view_column_new_with_attributes (NULL,
393 "stock-id", COL_NEED_PASSWORD,
396 gtk_tree_view_column_set_sort_column_id (column, COL_NEED_PASSWORD);
397 gtk_tree_view_append_column (view, column);
399 cell = gtk_cell_renderer_text_new ();
403 "ellipsize", PANGO_ELLIPSIZE_END,
406 column = gtk_tree_view_column_new_with_attributes (_("Chat Room"),
411 gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
412 gtk_tree_view_column_set_expand (column, TRUE);
413 gtk_tree_view_append_column (view, column);
415 cell = gtk_cell_renderer_text_new ();
419 "ellipsize", PANGO_ELLIPSIZE_END,
420 "alignment", PANGO_ALIGN_RIGHT,
422 column = gtk_tree_view_column_new_with_attributes (_("Members"),
427 gtk_tree_view_column_set_sort_column_id (column, COL_MEMBERS_INT);
428 gtk_tree_view_append_column (view, column);
432 update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog)
435 gboolean sensitive = FALSE;
438 room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
439 if (EMP_STR_EMPTY (room))
442 if (dialog->account == NULL)
445 if (tp_account_get_connection_status (dialog->account, NULL) !=
446 TP_CONNECTION_STATUS_CONNECTED)
452 gtk_widget_set_sensitive (dialog->button_join, sensitive);
456 new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
458 EmpathyAccountChooser *account_chooser;
459 const gchar *protocol;
461 account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
463 if (dialog->account == NULL)
466 protocol = tp_account_get_protocol (dialog->account);
468 gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), "");
470 /* hardcode here known protocols */
471 if (strcmp (protocol, "jabber") == 0) {
472 gtk_widget_set_sensitive (dialog->entry_server, TRUE);
474 else if (strcmp (protocol, "local-xmpp") == 0) {
475 gtk_widget_set_sensitive (dialog->entry_server, FALSE);
477 else if (strcmp (protocol, "irc") == 0) {
478 gtk_widget_set_sensitive (dialog->entry_server, FALSE);
481 gtk_widget_set_sensitive (dialog->entry_server, TRUE);
484 update_join_button_sensitivity (dialog);
486 /* Final set up of the dialog */
487 gtk_widget_grab_focus (dialog->entry_room);
491 account_status_changed_cb (TpAccount *account,
495 gchar *dbus_error_name,
497 EmpathyNewChatroomDialog *self)
499 update_join_button_sensitivity (self);
503 new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
504 EmpathyNewChatroomDialog *dialog)
506 EmpathyAccountChooser *account_chooser;
507 gboolean listing = FALSE;
508 gboolean expanded = FALSE;
509 TpConnection *connection;
510 EmpathyDispatcher *dispatcher;
511 GList *classes = NULL;
513 if (dialog->room_list) {
514 g_object_unref (dialog->room_list);
515 dialog->room_list = NULL;
518 gtk_spinner_stop (GTK_SPINNER (dialog->throbber));
519 gtk_widget_hide (dialog->throbber);
520 new_chatroom_dialog_model_clear (dialog);
522 if (dialog->account != NULL) {
523 g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
524 g_object_unref (dialog->account);
527 account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
528 dialog->account = empathy_account_chooser_dup_account (account_chooser);
529 connection = empathy_account_chooser_get_connection (account_chooser);
530 if (dialog->account == NULL)
533 dialog->status_changed_id = g_signal_connect (dialog->account,
534 "status-changed", G_CALLBACK (account_status_changed_cb), dialog);
536 dispatcher = empathy_dispatcher_dup_singleton ();
538 if (connection != NULL) {
539 classes = empathy_dispatcher_find_requestable_channel_classes (dispatcher,
540 connection, TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
541 TP_HANDLE_TYPE_NONE, NULL);
544 if (classes != NULL) {
545 /* Roomlist channels are supported */
546 dialog->room_list = empathy_tp_roomlist_new (dialog->account);
547 g_list_free (classes);
550 dialog->room_list = NULL;
553 g_object_unref (dispatcher);
555 if (dialog->room_list) {
556 g_signal_connect (dialog->room_list, "destroy",
557 G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb),
559 g_signal_connect (dialog->room_list, "new-room",
560 G_CALLBACK (new_chatroom_dialog_new_room_cb),
562 g_signal_connect (dialog->room_list, "notify::is-listing",
563 G_CALLBACK (new_chatroom_dialog_listing_cb),
565 g_signal_connect (dialog->room_list, "error::start",
566 G_CALLBACK (start_listing_error_cb),
568 g_signal_connect (dialog->room_list, "error::stop",
569 G_CALLBACK (stop_listing_error_cb),
572 expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse));
574 gtk_widget_hide (dialog->viewport_error);
575 gtk_widget_set_sensitive (dialog->treeview, TRUE);
576 new_chatroom_dialog_browse_start (dialog);
579 listing = empathy_tp_roomlist_is_listing (dialog->room_list);
581 gtk_spinner_start (GTK_SPINNER (dialog->throbber));
582 gtk_widget_show (dialog->throbber);
586 gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL);
589 new_chatroom_dialog_update_widgets (dialog);
593 new_chatroom_dialog_button_close_error_clicked_cb (GtkButton *button,
594 EmpathyNewChatroomDialog *dialog)
596 gtk_widget_hide (dialog->viewport_error);
600 new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist *room_list,
601 EmpathyNewChatroomDialog *dialog)
603 g_object_unref (dialog->room_list);
604 dialog->room_list = NULL;
608 new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
609 EmpathyChatroom *chatroom,
610 EmpathyNewChatroomDialog *dialog)
613 GtkTreeSelection *selection;
618 const gchar *need_password;
619 const gchar *invite_only;
622 DEBUG ("New chatroom listed: %s (%s)",
623 empathy_chatroom_get_name (chatroom),
624 empathy_chatroom_get_room (chatroom));
627 view = GTK_TREE_VIEW (dialog->treeview);
628 selection = gtk_tree_view_get_selection (view);
629 store = GTK_LIST_STORE (dialog->model);
630 members = g_strdup_printf ("%d", empathy_chatroom_get_members_count (chatroom));
631 tmp = g_strdup_printf ("<b>%s</b>", empathy_chatroom_get_name (chatroom));
632 /* Translators: Room/Join's roomlist tooltip. Parameters are a channel name,
633 yes/no, yes/no and a number. */
634 tooltip = g_strdup_printf (_("%s\nInvite required: %s\nPassword required: %s\nMembers: %s"),
636 empathy_chatroom_get_invite_only (chatroom) ? _("Yes") : _("No"),
637 empathy_chatroom_get_need_password (chatroom) ? _("Yes") : _("No"),
640 invite_only = (empathy_chatroom_get_invite_only (chatroom) ?
641 GTK_STOCK_INDEX : NULL);
642 need_password = (empathy_chatroom_get_need_password (chatroom) ?
643 GTK_STOCK_DIALOG_AUTHENTICATION : NULL);
645 gtk_list_store_append (store, &iter);
646 gtk_list_store_set (store, &iter,
647 COL_NEED_PASSWORD, need_password,
648 COL_INVITE_ONLY, invite_only,
649 COL_NAME, empathy_chatroom_get_name (chatroom),
650 COL_ROOM, empathy_chatroom_get_room (chatroom),
651 COL_MEMBERS, members,
652 COL_MEMBERS_INT, empathy_chatroom_get_members_count (chatroom),
653 COL_TOOLTIP, tooltip,
661 start_listing_error_cb (EmpathyTpRoomlist *room_list,
663 EmpathyNewChatroomDialog *dialog)
665 gtk_label_set_text (GTK_LABEL (dialog->label_error_message), _("Could not start room listing"));
666 gtk_widget_show_all (dialog->viewport_error);
667 gtk_widget_set_sensitive (dialog->treeview, FALSE);
671 stop_listing_error_cb (EmpathyTpRoomlist *room_list,
673 EmpathyNewChatroomDialog *dialog)
675 gtk_label_set_text (GTK_LABEL (dialog->label_error_message), _("Could not stop room listing"));
676 gtk_widget_show_all (dialog->viewport_error);
677 gtk_widget_set_sensitive (dialog->treeview, FALSE);
681 new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
683 EmpathyNewChatroomDialog *dialog)
687 listing = empathy_tp_roomlist_is_listing (room_list);
689 /* Update the throbber */
691 gtk_spinner_start (GTK_SPINNER (dialog->throbber));
692 gtk_widget_show (dialog->throbber);
694 gtk_spinner_stop (GTK_SPINNER (dialog->throbber));
695 gtk_widget_hide (dialog->throbber);
700 new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog)
704 store = GTK_LIST_STORE (dialog->model);
705 gtk_list_store_clear (store);
709 new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
711 GtkTreeViewColumn *column,
712 EmpathyNewChatroomDialog *dialog)
714 gtk_widget_activate (dialog->button_join);
718 new_chatroom_dialog_model_selection_changed (GtkTreeSelection *selection,
719 EmpathyNewChatroomDialog *dialog)
724 gchar *server = NULL;
726 if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
730 gtk_tree_model_get (model, &iter, COL_ROOM, &room, -1);
731 server = strstr (room, "@");
737 gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), server ? server : "");
738 gtk_entry_set_text (GTK_ENTRY (dialog->entry_room), room ? room : "");
744 new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
746 EmpathyAccountChooser *account_chooser;
749 const gchar *server = NULL;
750 gchar *room_name = NULL;
752 room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
753 server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server));
755 account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
756 account = empathy_account_chooser_get_account (account_chooser);
758 if (!EMP_STR_EMPTY (server)) {
759 room_name = g_strconcat (room, "@", server, NULL);
761 room_name = g_strdup (room);
764 g_strstrip (room_name);
766 DEBUG ("Requesting channel for '%s'", room_name);
767 empathy_dispatcher_join_muc (account, room_name,
768 gtk_get_current_event_time ());
774 new_chatroom_dialog_entry_changed_cb (GtkWidget *entry,
775 EmpathyNewChatroomDialog *dialog)
777 if (entry == dialog->entry_room) {
778 update_join_button_sensitivity (dialog);
780 /* FIXME: Select the room in the list */
785 new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog *dialog)
787 new_chatroom_dialog_model_clear (dialog);
788 if (dialog->room_list) {
789 empathy_tp_roomlist_start (dialog->room_list);
794 new_chatroom_dialog_browse_stop (EmpathyNewChatroomDialog *dialog)
796 if (dialog->room_list) {
797 empathy_tp_roomlist_stop (dialog->room_list);
802 new_chatroom_dialog_entry_server_activate_cb (GtkWidget *widget,
803 EmpathyNewChatroomDialog *dialog)
805 new_chatroom_dialog_browse_start (dialog);
809 new_chatroom_dialog_expander_browse_activate_cb (GtkWidget *widget,
810 EmpathyNewChatroomDialog *dialog)
814 expanded = gtk_expander_get_expanded (GTK_EXPANDER (widget));
816 new_chatroom_dialog_browse_stop (dialog);
817 gtk_window_set_resizable (GTK_WINDOW (dialog->window), FALSE);
819 gtk_widget_hide (dialog->viewport_error);
820 gtk_widget_set_sensitive (dialog->treeview, TRUE);
821 new_chatroom_dialog_browse_start (dialog);
822 gtk_window_set_resizable (GTK_WINDOW (dialog->window), TRUE);
827 new_chatroom_dialog_entry_server_focus_out_cb (GtkWidget *widget,
828 GdkEventFocus *event,
829 EmpathyNewChatroomDialog *dialog)
833 expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse));
835 new_chatroom_dialog_browse_start (dialog);