2 * Copyright (C) 2006-2007 Imendio AB
3 * Copyright (C) 2007-2011 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Martyn Russell <martyn@imendio.com>
21 * Xavier Claessens <xclaesse@gmail.com>
25 #include "empathy-new-chatroom-dialog.h"
27 #include <glib/gi18n.h>
28 #include <tp-account-widgets/tpaw-builder.h>
29 #include <tp-account-widgets/tpaw-utils.h>
31 #include "empathy-account-chooser.h"
32 #include "empathy-gsettings.h"
33 #include "empathy-request-util.h"
34 #include "empathy-ui-utils.h"
35 #include "empathy-utils.h"
37 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
38 #include "empathy-debug.h"
40 G_DEFINE_TYPE (EmpathyNewChatroomDialog
, empathy_new_chatroom_dialog
,
43 struct _EmpathyNewChatroomDialogPriv
45 TpRoomList
*room_list
;
46 /* Currently selected account */
48 /* Signal id of the "status-changed" signal connected on the currently
50 gulong status_changed_id
;
52 GtkWidget
*table_grid
;
53 GtkWidget
*label_account
;
54 GtkWidget
*account_chooser
;
55 GtkWidget
*label_server
;
56 GtkWidget
*entry_server
;
57 GtkWidget
*label_room
;
58 GtkWidget
*entry_room
;
59 GtkWidget
*expander_browse
;
60 GtkWidget
*hbox_expander
;
64 GtkWidget
*button_join
;
65 GtkWidget
*label_error_message
;
66 GtkWidget
*viewport_error
;
83 static EmpathyNewChatroomDialog
*dialog_p
= NULL
;
86 new_chatroom_dialog_store_last_account (GSettings
*gsettings
,
87 EmpathyAccountChooser
*account_chooser
)
90 const char *account_path
;
92 account
= empathy_account_chooser_get_account (account_chooser
);
96 account_path
= tp_proxy_get_object_path (account
);
97 DEBUG ("Storing account path '%s'", account_path
);
99 g_settings_set (gsettings
, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT
,
104 new_chatroom_dialog_join (EmpathyNewChatroomDialog
*self
)
106 EmpathyAccountChooser
*account_chooser
;
109 const gchar
*server
= NULL
;
110 gchar
*room_name
= NULL
;
112 room
= gtk_entry_get_text (GTK_ENTRY (self
->priv
->entry_room
));
113 server
= gtk_entry_get_text (GTK_ENTRY (self
->priv
->entry_server
));
115 account_chooser
= EMPATHY_ACCOUNT_CHOOSER (self
->priv
->account_chooser
);
116 account
= empathy_account_chooser_get_account (account_chooser
);
118 if (!TPAW_STR_EMPTY (server
))
119 room_name
= g_strconcat (room
, "@", server
, NULL
);
121 room_name
= g_strdup (room
);
123 g_strstrip (room_name
);
125 DEBUG ("Requesting channel for '%s'", room_name
);
127 empathy_join_muc (account
, room_name
, empathy_get_current_action_time ());
133 empathy_new_chatroom_dialog_response (GtkDialog
*dialog
,
136 EmpathyNewChatroomDialog
*self
= EMPATHY_NEW_CHATROOM_DIALOG (dialog
);
138 if (response
== GTK_RESPONSE_OK
)
140 new_chatroom_dialog_join (self
);
141 new_chatroom_dialog_store_last_account (self
->priv
->gsettings
,
142 EMPATHY_ACCOUNT_CHOOSER (self
->priv
->account_chooser
));
145 gtk_widget_destroy (GTK_WIDGET (dialog
));
149 new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog
*self
)
152 GtkTreeViewColumn
*column
;
153 GtkCellRenderer
*cell
;
156 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU
, &width
, &height
);
158 view
= GTK_TREE_VIEW (self
->priv
->treeview
);
160 cell
= gtk_cell_renderer_pixbuf_new ();
164 "stock-size", GTK_ICON_SIZE_MENU
,
167 column
= gtk_tree_view_column_new_with_attributes (NULL
, cell
,
168 "stock-id", COL_INVITE_ONLY
, NULL
);
170 gtk_tree_view_column_set_sort_column_id (column
, COL_INVITE_ONLY
);
171 gtk_tree_view_append_column (view
, column
);
173 column
= gtk_tree_view_column_new_with_attributes (NULL
, cell
,
174 "stock-id", COL_NEED_PASSWORD
, NULL
);
176 gtk_tree_view_column_set_sort_column_id (column
, COL_NEED_PASSWORD
);
177 gtk_tree_view_append_column (view
, column
);
179 cell
= gtk_cell_renderer_text_new ();
183 "ellipsize", PANGO_ELLIPSIZE_END
,
186 column
= gtk_tree_view_column_new_with_attributes (_("Chat Room"), cell
,
187 "text", COL_NAME
, NULL
);
189 gtk_tree_view_column_set_sort_column_id (column
, COL_NAME
);
190 gtk_tree_view_column_set_expand (column
, TRUE
);
191 gtk_tree_view_append_column (view
, column
);
193 cell
= gtk_cell_renderer_text_new ();
197 "ellipsize", PANGO_ELLIPSIZE_END
,
198 "alignment", PANGO_ALIGN_RIGHT
,
201 column
= gtk_tree_view_column_new_with_attributes (_("Members"), cell
,
202 "text", COL_MEMBERS
, NULL
);
204 gtk_tree_view_column_set_sort_column_id (column
, COL_MEMBERS_INT
);
205 gtk_tree_view_append_column (view
, column
);
209 new_chatroom_dialog_model_row_activated_cb (GtkTreeView
*tree_view
,
211 GtkTreeViewColumn
*column
,
212 EmpathyNewChatroomDialog
*self
)
214 gtk_widget_activate (self
->priv
->button_join
);
218 new_chatroom_dialog_model_selection_changed (GtkTreeSelection
*selection
,
219 EmpathyNewChatroomDialog
*self
)
224 gchar
*server
= NULL
;
226 if (!gtk_tree_selection_get_selected (selection
, &model
, &iter
))
229 gtk_tree_model_get (model
, &iter
, COL_ROOM
, &room
, -1);
230 server
= strstr (room
, "@");
237 gtk_entry_set_text (GTK_ENTRY (self
->priv
->entry_server
),
238 server
? server
: "");
239 gtk_entry_set_text (GTK_ENTRY (self
->priv
->entry_room
), room
? room
: "");
245 new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog
*self
)
249 GtkTreeSelection
*selection
;
252 view
= GTK_TREE_VIEW (self
->priv
->treeview
);
254 g_signal_connect (view
, "row-activated",
255 G_CALLBACK (new_chatroom_dialog_model_row_activated_cb
), self
);
258 store
= gtk_list_store_new (COL_COUNT
,
259 G_TYPE_STRING
, /* Need password */
260 G_TYPE_STRING
, /* Invite only */
261 G_TYPE_STRING
, /* Name */
262 G_TYPE_STRING
, /* Room */
263 G_TYPE_STRING
, /* Member count */
264 G_TYPE_INT
, /* Member count int */
265 G_TYPE_STRING
); /* Tool tip */
267 self
->priv
->model
= GTK_TREE_MODEL (store
);
268 gtk_tree_view_set_model (view
, self
->priv
->model
);
269 gtk_tree_view_set_tooltip_column (view
, COL_TOOLTIP
);
270 gtk_tree_view_set_search_column (view
, COL_NAME
);
273 selection
= gtk_tree_view_get_selection (view
);
274 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store
),
275 COL_NAME
, GTK_SORT_ASCENDING
);
277 g_signal_connect (selection
, "changed",
278 G_CALLBACK (new_chatroom_dialog_model_selection_changed
), self
);
281 new_chatroom_dialog_model_add_columns (self
);
285 update_join_button_sensitivity (EmpathyNewChatroomDialog
*self
)
288 const gchar
*protocol
;
289 gboolean sensitive
= FALSE
;
291 room
= gtk_entry_get_text (GTK_ENTRY (self
->priv
->entry_room
));
292 protocol
= tp_account_get_protocol_name (self
->priv
->account
);
293 if (TPAW_STR_EMPTY (room
))
296 if (!tp_strdiff (protocol
, "irc") &&
297 (!tp_strdiff (room
, "#") || !tp_strdiff (room
, "&")))
300 if (self
->priv
->account
== NULL
)
303 if (tp_account_get_connection_status (self
->priv
->account
, NULL
) !=
304 TP_CONNECTION_STATUS_CONNECTED
)
310 gtk_widget_set_sensitive (self
->priv
->button_join
, sensitive
);
314 new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog
*self
)
316 const gchar
*protocol
;
318 if (self
->priv
->account
== NULL
)
321 protocol
= tp_account_get_protocol_name (self
->priv
->account
);
323 gtk_entry_set_text (GTK_ENTRY (self
->priv
->entry_server
), "");
325 /* hardcode here known protocols */
326 if (strcmp (protocol
, "jabber") == 0)
327 gtk_widget_set_sensitive (self
->priv
->entry_server
, TRUE
);
328 else if (strcmp (protocol
, "local-xmpp") == 0)
329 gtk_widget_set_sensitive (self
->priv
->entry_server
, FALSE
);
330 else if (strcmp (protocol
, "irc") == 0)
331 gtk_widget_set_sensitive (self
->priv
->entry_server
, FALSE
);
333 gtk_widget_set_sensitive (self
->priv
->entry_server
, TRUE
);
335 if (!tp_strdiff (protocol
, "irc"))
336 gtk_entry_set_text (GTK_ENTRY (self
->priv
->entry_room
), "#");
338 gtk_entry_set_text (GTK_ENTRY (self
->priv
->entry_room
), "");
340 update_join_button_sensitivity (self
);
342 /* Final set up of the dialog */
343 gtk_widget_grab_focus (self
->priv
->entry_room
);
344 gtk_editable_set_position (GTK_EDITABLE (self
->priv
->entry_room
), -1);
348 account_status_changed_cb (TpAccount
*account
,
352 gchar
*dbus_error_name
,
354 EmpathyNewChatroomDialog
*self
)
356 update_join_button_sensitivity (self
);
360 new_chatroom_dialog_select_last_account (GSettings
*gsettings
,
361 EmpathyAccountChooser
*account_chooser
)
363 const gchar
*account_path
;
364 TpAccountManager
*manager
;
365 TpSimpleClientFactory
*factory
;
367 TpConnectionStatus status
;
369 account_path
= g_settings_get_string (gsettings
,
370 EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT
);
371 DEBUG ("Selecting account path '%s'", account_path
);
373 manager
= tp_account_manager_dup ();
374 factory
= tp_proxy_get_factory (manager
);
375 account
= tp_simple_client_factory_ensure_account (factory
, account_path
,
380 status
= tp_account_get_connection_status (account
, NULL
);
381 if (status
== TP_CONNECTION_STATUS_CONNECTED
)
382 empathy_account_chooser_set_account (account_chooser
, account
);
383 g_object_unref (account
);
386 g_object_unref (manager
);
390 new_chatroom_dialog_account_ready_cb (EmpathyAccountChooser
*combobox
,
391 EmpathyNewChatroomDialog
*self
)
393 new_chatroom_dialog_select_last_account (self
->priv
->gsettings
, combobox
);
397 listing_failed_cb (TpRoomList
*room_list
,
399 EmpathyNewChatroomDialog
*self
)
401 gtk_label_set_text (GTK_LABEL (self
->priv
->label_error_message
),
402 _("Failed to list rooms"));
403 gtk_widget_show_all (self
->priv
->viewport_error
);
404 gtk_widget_set_sensitive (self
->priv
->treeview
, FALSE
);
408 new_chatroom_dialog_got_room_cb (TpRoomList
*room_list
,
410 EmpathyNewChatroomDialog
*self
)
415 const gchar
*need_password
;
416 const gchar
*invite_only
;
419 if (tp_str_empty (tp_room_info_get_handle_name (room
)))
421 DEBUG ("Room handle name is empty - Broken CM");
425 DEBUG ("New room listed: %s (%s)", tp_room_info_get_name (room
),
426 tp_room_info_get_handle_name (room
));
429 store
= GTK_LIST_STORE (self
->priv
->model
);
430 members
= g_strdup_printf ("%d", tp_room_info_get_members_count (
432 tmp
= g_strdup_printf ("<b>%s</b>", tp_room_info_get_name (room
));
434 /* Translators: Room/Join's roomlist tooltip. Parameters are a channel name,
435 yes/no, yes/no and a number. */
436 tooltip
= g_strdup_printf (
437 _("%s\nInvite required: %s\nPassword required: %s\nMembers: %s"),
439 tp_room_info_get_invite_only (room
, NULL
) ? _("Yes") : _("No"),
440 tp_room_info_get_requires_password (room
, NULL
) ? _("Yes") : _("No"),
444 invite_only
= (tp_room_info_get_invite_only (room
, NULL
) ?
445 GTK_STOCK_INDEX
: NULL
);
446 need_password
= (tp_room_info_get_requires_password (room
, NULL
) ?
447 GTK_STOCK_DIALOG_AUTHENTICATION
: NULL
);
449 gtk_list_store_insert_with_values (store
, NULL
, -1,
450 COL_NEED_PASSWORD
, need_password
,
451 COL_INVITE_ONLY
, invite_only
,
452 COL_NAME
, tp_room_info_get_name (room
),
453 COL_ROOM
, tp_room_info_get_handle_name (room
),
454 COL_MEMBERS
, members
,
455 COL_MEMBERS_INT
, tp_room_info_get_members_count (room
, NULL
),
456 COL_TOOLTIP
, tooltip
,
464 new_chatroom_dialog_listing_cb (TpRoomList
*room_list
,
466 EmpathyNewChatroomDialog
*self
)
468 /* Update the throbber */
469 if (tp_room_list_is_listing (room_list
))
471 gtk_spinner_start (GTK_SPINNER (self
->priv
->throbber
));
472 gtk_widget_show (self
->priv
->throbber
);
476 gtk_spinner_stop (GTK_SPINNER (self
->priv
->throbber
));
477 gtk_widget_hide (self
->priv
->throbber
);
482 new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog
*self
)
486 store
= GTK_LIST_STORE (self
->priv
->model
);
487 gtk_list_store_clear (store
);
491 new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog
*self
)
493 new_chatroom_dialog_model_clear (self
);
495 if (self
->priv
->room_list
!= NULL
)
496 tp_room_list_start (self
->priv
->room_list
);
500 new_room_list_cb (GObject
*source
,
501 GAsyncResult
*result
,
504 EmpathyNewChatroomDialog
*self
= user_data
;
505 TpRoomList
*room_list
;
506 GError
*error
= NULL
;
508 room_list
= tp_room_list_new_finish (result
, &error
);
509 if (room_list
== NULL
)
511 DEBUG ("Failed to create TpRoomList: %s\n", error
->message
);
512 g_error_free (error
);
516 if (tp_room_list_get_account (room_list
) != self
->priv
->account
)
518 /* Account changed while we were creating this TpRoomList */
519 g_object_unref (room_list
);
523 self
->priv
->room_list
= room_list
;
525 tp_g_signal_connect_object (self
->priv
->room_list
, "got-room",
526 G_CALLBACK (new_chatroom_dialog_got_room_cb
), self
, 0);
527 tp_g_signal_connect_object (self
->priv
->room_list
, "failed",
528 G_CALLBACK (listing_failed_cb
), self
, 0);
529 tp_g_signal_connect_object (self
->priv
->room_list
, "notify::listing",
530 G_CALLBACK (new_chatroom_dialog_listing_cb
), self
, 0);
532 if (gtk_expander_get_expanded (GTK_EXPANDER (self
->priv
->expander_browse
)))
534 gtk_widget_hide (self
->priv
->viewport_error
);
535 gtk_widget_set_sensitive (self
->priv
->treeview
, TRUE
);
536 new_chatroom_dialog_browse_start (self
);
539 if (tp_room_list_is_listing (self
->priv
->room_list
))
541 gtk_spinner_start (GTK_SPINNER (self
->priv
->throbber
));
542 gtk_widget_show (self
->priv
->throbber
);
545 gtk_widget_set_sensitive (self
->priv
->expander_browse
, TRUE
);
547 new_chatroom_dialog_update_widgets (self
);
551 new_chatroom_dialog_account_changed_cb (GtkComboBox
*combobox
,
552 EmpathyNewChatroomDialog
*self
)
554 EmpathyAccountChooser
*account_chooser
;
555 TpConnection
*connection
;
556 TpCapabilities
*caps
;
558 g_clear_object (&self
->priv
->room_list
);
560 gtk_spinner_stop (GTK_SPINNER (self
->priv
->throbber
));
561 gtk_widget_hide (self
->priv
->throbber
);
562 new_chatroom_dialog_model_clear (self
);
564 if (self
->priv
->account
!= NULL
)
566 g_signal_handler_disconnect (self
->priv
->account
,
567 self
->priv
->status_changed_id
);
568 g_object_unref (self
->priv
->account
);
571 account_chooser
= EMPATHY_ACCOUNT_CHOOSER (self
->priv
->account_chooser
);
572 self
->priv
->account
= empathy_account_chooser_dup_account (account_chooser
);
573 connection
= empathy_account_chooser_get_connection (account_chooser
);
574 if (self
->priv
->account
== NULL
)
577 self
->priv
->status_changed_id
= g_signal_connect (self
->priv
->account
,
578 "status-changed", G_CALLBACK (account_status_changed_cb
), self
);
580 /* empathy_account_chooser_filter_supports_chatrooms ensures that the
581 * account has a connection and CAPABILITIES has been prepared. */
582 g_assert (connection
!= NULL
);
583 g_assert (tp_proxy_is_prepared (connection
,
584 TP_CONNECTION_FEATURE_CAPABILITIES
));
585 caps
= tp_connection_get_capabilities (connection
);
587 if (tp_capabilities_supports_room_list (caps
, NULL
))
589 /* Roomlist channels are supported */
590 tp_room_list_new_async (self
->priv
->account
, NULL
, new_room_list_cb
,
594 gtk_widget_set_sensitive (self
->priv
->expander_browse
, FALSE
);
597 new_chatroom_dialog_update_widgets (self
);
601 new_chatroom_dialog_button_close_error_clicked_cb (GtkButton
*button
,
602 EmpathyNewChatroomDialog
*self
)
604 gtk_widget_hide (self
->priv
->viewport_error
);
608 new_chatroom_dialog_entry_changed_cb (GtkWidget
*entry
,
609 EmpathyNewChatroomDialog
*self
)
611 if (entry
== self
->priv
->entry_room
)
613 update_join_button_sensitivity (self
);
615 /* FIXME: Select the room in the list */
620 new_chatroom_dialog_entry_server_activate_cb (GtkWidget
*widget
,
621 EmpathyNewChatroomDialog
*self
)
623 new_chatroom_dialog_browse_start (self
);
627 new_chatroom_dialog_expander_browse_activate_cb (GtkWidget
*widget
,
628 EmpathyNewChatroomDialog
*self
)
632 expanded
= gtk_expander_get_expanded (GTK_EXPANDER (widget
));
635 gtk_window_set_resizable (GTK_WINDOW (self
), FALSE
);
639 gtk_widget_hide (self
->priv
->viewport_error
);
640 gtk_widget_set_sensitive (self
->priv
->treeview
, TRUE
);
641 new_chatroom_dialog_browse_start (self
);
642 gtk_window_set_resizable (GTK_WINDOW (self
), TRUE
);
647 new_chatroom_dialog_entry_server_focus_out_cb (GtkWidget
*widget
,
648 GdkEventFocus
*event
,
649 EmpathyNewChatroomDialog
*self
)
653 expanded
= gtk_expander_get_expanded (
654 GTK_EXPANDER (self
->priv
->expander_browse
));
656 new_chatroom_dialog_browse_start (self
);
662 empathy_new_chatroom_dialog_constructor (GType type
,
664 GObjectConstructParam
*props
)
670 retval
= G_OBJECT (dialog_p
);
671 g_object_ref (retval
);
675 retval
= G_OBJECT_CLASS (
676 empathy_new_chatroom_dialog_parent_class
)->constructor (type
,
679 dialog_p
= EMPATHY_NEW_CHATROOM_DIALOG (retval
);
680 g_object_add_weak_pointer (retval
, (gpointer
) &dialog_p
);
687 empathy_new_chatroom_dialog_show (GtkWindow
*parent
)
691 dialog
= g_object_new (EMPATHY_TYPE_NEW_CHATROOM_DIALOG
, NULL
);
695 gtk_window_set_transient_for (GTK_WINDOW (dialog
),
696 GTK_WINDOW (parent
));
699 gtk_window_present (GTK_WINDOW (dialog
));
704 empathy_new_chatroom_dialog_dispose (GObject
*object
)
706 EmpathyNewChatroomDialog
*self
= EMPATHY_NEW_CHATROOM_DIALOG (object
);
707 void (*chain_up
) (GObject
*) =
708 ((GObjectClass
*) empathy_new_chatroom_dialog_parent_class
)->dispose
;
710 g_clear_object (&self
->priv
->room_list
);
711 g_clear_object (&self
->priv
->model
);
713 if (self
->priv
->account
!= NULL
)
715 g_signal_handler_disconnect (self
->priv
->account
,
716 self
->priv
->status_changed_id
);
717 g_clear_object (&self
->priv
->account
);
720 g_clear_object (&self
->priv
->gsettings
);
722 if (chain_up
!= NULL
)
727 empathy_new_chatroom_dialog_class_init (EmpathyNewChatroomDialogClass
*klass
)
729 GObjectClass
*oclass
= G_OBJECT_CLASS (klass
);
730 GtkDialogClass
*dialog_class
= GTK_DIALOG_CLASS (klass
);
732 oclass
->constructor
= empathy_new_chatroom_dialog_constructor
;
733 oclass
->dispose
= empathy_new_chatroom_dialog_dispose
;
735 dialog_class
->response
= empathy_new_chatroom_dialog_response
;
737 g_type_class_add_private (klass
, sizeof (EmpathyNewChatroomDialogPriv
));
741 empathy_new_chatroom_dialog_init (EmpathyNewChatroomDialog
*self
)
744 GtkSizeGroup
*size_group
;
746 GtkWidget
*vbox
, *content
;
748 self
->priv
= G_TYPE_INSTANCE_GET_PRIVATE (self
,
749 EMPATHY_TYPE_NEW_CHATROOM_DIALOG
, EmpathyNewChatroomDialogPriv
);
751 filename
= empathy_file_lookup ("empathy-new-chatroom-dialog.ui", "src");
752 gui
= tpaw_builder_get_file (filename
,
753 "vbox_new_chatroom", &vbox
,
754 "table_grid", &self
->priv
->table_grid
,
755 "label_account", &self
->priv
->label_account
,
756 "label_server", &self
->priv
->label_server
,
757 "label_room", &self
->priv
->label_room
,
758 "entry_server", &self
->priv
->entry_server
,
759 "entry_room", &self
->priv
->entry_room
,
760 "treeview", &self
->priv
->treeview
,
761 "expander_browse", &self
->priv
->expander_browse
,
762 "hbox_expander", &self
->priv
->hbox_expander
,
763 "label_error_message", &self
->priv
->label_error_message
,
764 "viewport_error", &self
->priv
->viewport_error
,
768 tpaw_builder_connect (gui
, self
,
769 "entry_server", "changed", new_chatroom_dialog_entry_changed_cb
,
770 "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb
,
771 "entry_server", "focus-out-event",
772 new_chatroom_dialog_entry_server_focus_out_cb
,
773 "entry_room", "changed", new_chatroom_dialog_entry_changed_cb
,
774 "expander_browse", "activate",
775 new_chatroom_dialog_expander_browse_activate_cb
,
776 "button_close_error", "clicked",
777 new_chatroom_dialog_button_close_error_clicked_cb
,
781 content
= gtk_dialog_get_content_area (GTK_DIALOG (self
));
782 gtk_container_add (GTK_CONTAINER (content
), vbox
);
784 gtk_dialog_add_button (GTK_DIALOG (self
), GTK_STOCK_CANCEL
,
785 GTK_RESPONSE_CANCEL
);
786 self
->priv
->button_join
= gtk_dialog_add_button (GTK_DIALOG (self
),
787 _("Join"), GTK_RESPONSE_OK
);
789 gtk_dialog_set_default_response (GTK_DIALOG (self
), GTK_RESPONSE_OK
);
791 gtk_window_set_title (GTK_WINDOW (self
), _("Join Room"));
792 gtk_window_set_role (GTK_WINDOW (self
), "join_new_chatroom");
794 g_object_unref (gui
);
796 /* Label alignment */
797 size_group
= gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL
);
799 gtk_size_group_add_widget (size_group
, self
->priv
->label_account
);
800 gtk_size_group_add_widget (size_group
, self
->priv
->label_server
);
801 gtk_size_group_add_widget (size_group
, self
->priv
->label_room
);
803 g_object_unref (size_group
);
805 /* Set up chatrooms treeview */
806 new_chatroom_dialog_model_setup (self
);
809 self
->priv
->throbber
= gtk_spinner_new ();
810 gtk_box_pack_start (GTK_BOX (self
->priv
->hbox_expander
), self
->priv
->throbber
,
813 self
->priv
->gsettings
= g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA
);
815 /* Account chooser for custom */
816 self
->priv
->account_chooser
= empathy_account_chooser_new ();
817 empathy_account_chooser_set_filter (
818 EMPATHY_ACCOUNT_CHOOSER (self
->priv
->account_chooser
),
819 empathy_account_chooser_filter_supports_chatrooms
, NULL
);
820 gtk_grid_attach (GTK_GRID (self
->priv
->table_grid
),
821 self
->priv
->account_chooser
, 1, 0, 1, 1);
822 gtk_widget_show (self
->priv
->account_chooser
);
824 g_signal_connect (EMPATHY_ACCOUNT_CHOOSER (self
->priv
->account_chooser
),
825 "ready", G_CALLBACK (new_chatroom_dialog_account_ready_cb
), self
);
826 g_signal_connect (GTK_COMBO_BOX (self
->priv
->account_chooser
), "changed",
827 G_CALLBACK (new_chatroom_dialog_account_changed_cb
), self
);
828 new_chatroom_dialog_account_changed_cb (
829 GTK_COMBO_BOX (self
->priv
->account_chooser
), self
);