aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-04-26 17:19:27 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-05-10 16:23:52 +0800
commit98c9a19291744ca7e62ad470ef1f012761b58830 (patch)
treec4484e23e1dceefbf1e8c744250c71e0a102d09b /src
parent3d4484b2968f1ed4e16b763b6ccda97636f10ab8 (diff)
downloadgsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar.gz
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar.bz2
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar.lz
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar.xz
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.tar.zst
gsoc2013-empathy-98c9a19291744ca7e62ad470ef1f012761b58830.zip
chatroom-dialog: re-order some functions
Let's just get rid of all these stupid prototypes. https://bugzilla.gnome.org/show_bug.cgi?id=674860
Diffstat (limited to 'src')
-rw-r--r--src/empathy-new-chatroom-dialog.c654
1 files changed, 299 insertions, 355 deletions
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index b4d1c2105..efff2da01 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -88,157 +88,8 @@ enum
COL_COUNT
};
-static void new_chatroom_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_destroy_cb (GtkWidget *widget,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_model_add_columns (
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_update_widgets (
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_account_ready_cb (
- EmpathyAccountChooser *combobox,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_roomlist_destroy_cb (
- EmpathyTpRoomlist *room_list,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
- EmpathyChatroom *chatroom,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
- gpointer unused,
- EmpathyNewChatroomDialog *dialog);
-static void start_listing_error_cb (EmpathyTpRoomlist *room_list,
- GError *error,
- EmpathyNewChatroomDialog *dialog);
-static void stop_listing_error_cb (EmpathyTpRoomlist *room_list,
- GError *error,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_model_selection_changed (
- GtkTreeSelection *selection,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_entry_changed_cb (GtkWidget *entry,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_browse_stop (EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_entry_server_activate_cb (GtkWidget *widget,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_expander_browse_activate_cb (GtkWidget *widget,
- EmpathyNewChatroomDialog *dialog);
-static gboolean new_chatroom_dialog_entry_server_focus_out_cb (
- GtkWidget *widget,
- GdkEventFocus *event,
- EmpathyNewChatroomDialog *dialog);
-static void new_chatroom_dialog_button_close_error_clicked_cb (
- GtkButton *button,
- EmpathyNewChatroomDialog *dialog);
-
static EmpathyNewChatroomDialog *dialog_p = NULL;
-
-void
-empathy_new_chatroom_dialog_show (GtkWindow *parent)
-{
- EmpathyNewChatroomDialog *dialog;
- GtkBuilder *gui;
- GtkSizeGroup *size_group;
- gchar *filename;
-
- if (dialog_p)
- {
- gtk_window_present (GTK_WINDOW (dialog_p->window));
- return;
- }
-
- dialog_p = dialog = g_new0 (EmpathyNewChatroomDialog, 1);
-
- filename = empathy_file_lookup ("empathy-new-chatroom-dialog.ui", "src");
- gui = empathy_builder_get_file (filename,
- "new_chatroom_dialog", &dialog->window,
- "table_grid", &dialog->table_grid,
- "label_account", &dialog->label_account,
- "label_server", &dialog->label_server,
- "label_room", &dialog->label_room,
- "entry_server", &dialog->entry_server,
- "entry_room", &dialog->entry_room,
- "treeview", &dialog->treeview,
- "button_join", &dialog->button_join,
- "expander_browse", &dialog->expander_browse,
- "hbox_expander", &dialog->hbox_expander,
- "label_error_message", &dialog->label_error_message,
- "viewport_error", &dialog->viewport_error,
- NULL);
- g_free (filename);
-
- empathy_builder_connect (gui, dialog,
- "new_chatroom_dialog", "response", new_chatroom_dialog_response_cb,
- "new_chatroom_dialog", "destroy", new_chatroom_dialog_destroy_cb,
- "entry_server", "changed", new_chatroom_dialog_entry_changed_cb,
- "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb,
- "entry_server", "focus-out-event", new_chatroom_dialog_entry_server_focus_out_cb,
- "entry_room", "changed", new_chatroom_dialog_entry_changed_cb,
- "expander_browse", "activate", new_chatroom_dialog_expander_browse_activate_cb,
- "button_close_error", "clicked", new_chatroom_dialog_button_close_error_clicked_cb,
- NULL);
-
- g_object_unref (gui);
-
- g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog_p);
-
- /* Label alignment */
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- gtk_size_group_add_widget (size_group, dialog->label_account);
- gtk_size_group_add_widget (size_group, dialog->label_server);
- gtk_size_group_add_widget (size_group, dialog->label_room);
-
- g_object_unref (size_group);
-
- /* Set up chatrooms treeview */
- new_chatroom_dialog_model_setup (dialog);
-
- /* Add throbber */
- dialog->throbber = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (dialog->hbox_expander), dialog->throbber,
- TRUE, TRUE, 0);
-
- dialog->gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
-
- /* Account chooser for custom */
- dialog->account_chooser = empathy_account_chooser_new ();
- empathy_account_chooser_set_filter (
- EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
- empathy_account_chooser_filter_supports_chatrooms, NULL);
- gtk_grid_attach (GTK_GRID (dialog->table_grid), dialog->account_chooser,
- 1, 0, 1, 1);
- gtk_widget_show (dialog->account_chooser);
-
- g_signal_connect (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser), "ready",
- G_CALLBACK (new_chatroom_dialog_account_ready_cb), dialog);
- g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed",
- G_CALLBACK (new_chatroom_dialog_account_changed_cb), dialog);
- new_chatroom_dialog_account_changed_cb (
- GTK_COMBO_BOX (dialog->account_chooser), dialog);
-
- if (parent)
- {
- gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
- GTK_WINDOW (parent));
- }
-
- gtk_widget_show (dialog->window);
-}
-
static void
new_chatroom_dialog_store_last_account (GSettings *gsettings,
EmpathyAccountChooser *account_chooser)
@@ -258,6 +109,35 @@ new_chatroom_dialog_store_last_account (GSettings *gsettings,
}
static void
+new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
+{
+ EmpathyAccountChooser *account_chooser;
+ TpAccount *account;
+ const gchar *room;
+ const gchar *server = NULL;
+ gchar *room_name = NULL;
+
+ room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
+ server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server));
+
+ account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
+ account = empathy_account_chooser_get_account (account_chooser);
+
+ if (!EMP_STR_EMPTY (server))
+ room_name = g_strconcat (room, "@", server, NULL);
+ else
+ room_name = g_strdup (room);
+
+ g_strstrip (room_name);
+
+ DEBUG ("Requesting channel for '%s'", room_name);
+
+ empathy_join_muc (account, room_name, empathy_get_current_action_time ());
+
+ g_free (room_name);
+}
+
+static void
new_chatroom_dialog_response_cb (GtkWidget *widget,
gint response,
EmpathyNewChatroomDialog *dialog)
@@ -293,46 +173,6 @@ new_chatroom_dialog_destroy_cb (GtkWidget *widget,
}
static void
-new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog)
-{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeSelection *selection;
-
- /* View */
- view = GTK_TREE_VIEW (dialog->treeview);
-
- g_signal_connect (view, "row-activated",
- G_CALLBACK (new_chatroom_dialog_model_row_activated_cb), dialog);
-
- /* Store/Model */
- store = gtk_list_store_new (COL_COUNT,
- G_TYPE_STRING, /* Invite */
- G_TYPE_STRING, /* Password */
- G_TYPE_STRING, /* Name */
- G_TYPE_STRING, /* Room */
- G_TYPE_STRING, /* Member count */
- G_TYPE_INT, /* Member count int */
- G_TYPE_STRING); /* Tool tip */
-
- dialog->model = GTK_TREE_MODEL (store);
- gtk_tree_view_set_model (view, dialog->model);
- gtk_tree_view_set_tooltip_column (view, COL_TOOLTIP);
- gtk_tree_view_set_search_column (view, COL_NAME);
-
- /* Selection */
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
- COL_NAME, GTK_SORT_ASCENDING);
-
- g_signal_connect (selection, "changed",
- G_CALLBACK (new_chatroom_dialog_model_selection_changed), dialog);
-
- /* Columns */
- new_chatroom_dialog_model_add_columns (dialog);
-}
-
-static void
new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog)
{
GtkTreeView *view;
@@ -393,6 +233,81 @@ new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog)
}
static void
+new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ EmpathyNewChatroomDialog *dialog)
+{
+ gtk_widget_activate (dialog->button_join);
+}
+
+static void
+new_chatroom_dialog_model_selection_changed (GtkTreeSelection *selection,
+ EmpathyNewChatroomDialog *dialog)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *room = NULL;
+ gchar *server = NULL;
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, COL_ROOM, &room, -1);
+ server = strstr (room, "@");
+ if (server)
+ {
+ *server = '\0';
+ server++;
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), server ? server : "");
+ gtk_entry_set_text (GTK_ENTRY (dialog->entry_room), room ? room : "");
+
+ g_free (room);
+}
+
+static void
+new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
+
+ /* View */
+ view = GTK_TREE_VIEW (dialog->treeview);
+
+ g_signal_connect (view, "row-activated",
+ G_CALLBACK (new_chatroom_dialog_model_row_activated_cb), dialog);
+
+ /* Store/Model */
+ store = gtk_list_store_new (COL_COUNT,
+ G_TYPE_STRING, /* Invite */
+ G_TYPE_STRING, /* Password */
+ G_TYPE_STRING, /* Name */
+ G_TYPE_STRING, /* Room */
+ G_TYPE_STRING, /* Member count */
+ G_TYPE_INT, /* Member count int */
+ G_TYPE_STRING); /* Tool tip */
+
+ dialog->model = GTK_TREE_MODEL (store);
+ gtk_tree_view_set_model (view, dialog->model);
+ gtk_tree_view_set_tooltip_column (view, COL_TOOLTIP);
+ gtk_tree_view_set_search_column (view, COL_NAME);
+
+ /* Selection */
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ COL_NAME, GTK_SORT_ASCENDING);
+
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (new_chatroom_dialog_model_selection_changed), dialog);
+
+ /* Columns */
+ new_chatroom_dialog_model_add_columns (dialog);
+}
+
+static void
update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog)
{
const gchar *room;
@@ -505,101 +420,6 @@ new_chatroom_dialog_account_ready_cb (EmpathyAccountChooser *combobox,
}
static void
-new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
- EmpathyNewChatroomDialog *dialog)
-{
- EmpathyAccountChooser *account_chooser;
- gboolean listing = FALSE;
- gboolean expanded = FALSE;
- TpConnection *connection;
- TpCapabilities *caps;
-
- if (dialog->room_list)
- {
- g_object_unref (dialog->room_list);
- dialog->room_list = NULL;
- }
-
- gtk_spinner_stop (GTK_SPINNER (dialog->throbber));
- gtk_widget_hide (dialog->throbber);
- new_chatroom_dialog_model_clear (dialog);
-
- if (dialog->account != NULL)
- {
- g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
- g_object_unref (dialog->account);
- }
-
- account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
- dialog->account = empathy_account_chooser_dup_account (account_chooser);
- connection = empathy_account_chooser_get_connection (account_chooser);
- if (dialog->account == NULL)
- goto out;
-
- dialog->status_changed_id = g_signal_connect (dialog->account,
- "status-changed", G_CALLBACK (account_status_changed_cb), dialog);
-
- /* empathy_account_chooser_filter_supports_chatrooms ensures that the
- * account has a connection and CAPABILITIES has been prepared. */
- g_assert (connection != NULL);
- g_assert (tp_proxy_is_prepared (connection,
- TP_CONNECTION_FEATURE_CAPABILITIES));
- caps = tp_connection_get_capabilities (connection);
-
- if (tp_capabilities_supports_room_list (caps, NULL))
- {
- /* Roomlist channels are supported */
- dialog->room_list = empathy_tp_roomlist_new (dialog->account);
- }
- else
- {
- dialog->room_list = NULL;
- }
-
- if (dialog->room_list)
- {
- g_signal_connect (dialog->room_list, "destroy",
- G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog);
- g_signal_connect (dialog->room_list, "new-room",
- G_CALLBACK (new_chatroom_dialog_new_room_cb), dialog);
- g_signal_connect (dialog->room_list, "notify::is-listing",
- G_CALLBACK (new_chatroom_dialog_listing_cb), dialog);
- g_signal_connect (dialog->room_list, "error::start",
- G_CALLBACK (start_listing_error_cb), dialog);
- g_signal_connect (dialog->room_list, "error::stop",
- G_CALLBACK (stop_listing_error_cb), dialog);
-
- expanded = gtk_expander_get_expanded (
- GTK_EXPANDER (dialog->expander_browse));
- if (expanded)
- {
- gtk_widget_hide (dialog->viewport_error);
- gtk_widget_set_sensitive (dialog->treeview, TRUE);
- new_chatroom_dialog_browse_start (dialog);
- }
-
- listing = empathy_tp_roomlist_is_listing (dialog->room_list);
- if (listing)
- {
- gtk_spinner_start (GTK_SPINNER (dialog->throbber));
- gtk_widget_show (dialog->throbber);
- }
- }
-
- gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL);
-
-out:
- new_chatroom_dialog_update_widgets (dialog);
-}
-
-static void
-new_chatroom_dialog_button_close_error_clicked_cb (GtkButton *button,
- EmpathyNewChatroomDialog *dialog)
-{
- gtk_widget_hide (dialog->viewport_error);
-}
-
-static void
new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist *room_list,
EmpathyNewChatroomDialog *dialog)
{
@@ -656,28 +476,6 @@ new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
}
static void
-start_listing_error_cb (EmpathyTpRoomlist *room_list,
- GError *error,
- EmpathyNewChatroomDialog *dialog)
-{
- gtk_label_set_text (GTK_LABEL (dialog->label_error_message),
- _("Could not start room listing"));
- gtk_widget_show_all (dialog->viewport_error);
- gtk_widget_set_sensitive (dialog->treeview, FALSE);
-}
-
-static void
-stop_listing_error_cb (EmpathyTpRoomlist *room_list,
- GError *error,
- EmpathyNewChatroomDialog *dialog)
-{
- gtk_label_set_text (GTK_LABEL (dialog->label_error_message),
- _("Could not stop room listing"));
- gtk_widget_show_all (dialog->viewport_error);
- gtk_widget_set_sensitive (dialog->treeview, FALSE);
-}
-
-static void
new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
gpointer unused,
EmpathyNewChatroomDialog *dialog)
@@ -700,6 +498,28 @@ new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
}
static void
+start_listing_error_cb (EmpathyTpRoomlist *room_list,
+ GError *error,
+ EmpathyNewChatroomDialog *dialog)
+{
+ gtk_label_set_text (GTK_LABEL (dialog->label_error_message),
+ _("Could not start room listing"));
+ gtk_widget_show_all (dialog->viewport_error);
+ gtk_widget_set_sensitive (dialog->treeview, FALSE);
+}
+
+static void
+stop_listing_error_cb (EmpathyTpRoomlist *room_list,
+ GError *error,
+ EmpathyNewChatroomDialog *dialog)
+{
+ gtk_label_set_text (GTK_LABEL (dialog->label_error_message),
+ _("Could not stop room listing"));
+ gtk_widget_show_all (dialog->viewport_error);
+ gtk_widget_set_sensitive (dialog->treeview, FALSE);
+}
+
+static void
new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog)
{
GtkListStore *store;
@@ -709,67 +529,106 @@ new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog)
}
static void
-new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathyNewChatroomDialog *dialog)
+new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog *dialog)
{
- gtk_widget_activate (dialog->button_join);
+ new_chatroom_dialog_model_clear (dialog);
+ if (dialog->room_list)
+ empathy_tp_roomlist_start (dialog->room_list);
}
static void
-new_chatroom_dialog_model_selection_changed (GtkTreeSelection *selection,
+new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *room = NULL;
- gchar *server = NULL;
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
+ EmpathyAccountChooser *account_chooser;
+ gboolean listing = FALSE;
+ gboolean expanded = FALSE;
+ TpConnection *connection;
+ TpCapabilities *caps;
- gtk_tree_model_get (model, &iter, COL_ROOM, &room, -1);
- server = strstr (room, "@");
- if (server)
+ if (dialog->room_list)
{
- *server = '\0';
- server++;
+ g_object_unref (dialog->room_list);
+ dialog->room_list = NULL;
}
- gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), server ? server : "");
- gtk_entry_set_text (GTK_ENTRY (dialog->entry_room), room ? room : "");
+ gtk_spinner_stop (GTK_SPINNER (dialog->throbber));
+ gtk_widget_hide (dialog->throbber);
+ new_chatroom_dialog_model_clear (dialog);
- g_free (room);
-}
+ if (dialog->account != NULL)
+ {
+ g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
+ g_object_unref (dialog->account);
+ }
-static void
-new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
-{
- EmpathyAccountChooser *account_chooser;
- TpAccount *account;
- const gchar *room;
- const gchar *server = NULL;
- gchar *room_name = NULL;
+ account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
+ dialog->account = empathy_account_chooser_dup_account (account_chooser);
+ connection = empathy_account_chooser_get_connection (account_chooser);
+ if (dialog->account == NULL)
+ goto out;
- room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
- server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server));
+ dialog->status_changed_id = g_signal_connect (dialog->account,
+ "status-changed", G_CALLBACK (account_status_changed_cb), dialog);
- account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
- account = empathy_account_chooser_get_account (account_chooser);
+ /* empathy_account_chooser_filter_supports_chatrooms ensures that the
+ * account has a connection and CAPABILITIES has been prepared. */
+ g_assert (connection != NULL);
+ g_assert (tp_proxy_is_prepared (connection,
+ TP_CONNECTION_FEATURE_CAPABILITIES));
+ caps = tp_connection_get_capabilities (connection);
- if (!EMP_STR_EMPTY (server))
- room_name = g_strconcat (room, "@", server, NULL);
+ if (tp_capabilities_supports_room_list (caps, NULL))
+ {
+ /* Roomlist channels are supported */
+ dialog->room_list = empathy_tp_roomlist_new (dialog->account);
+ }
else
- room_name = g_strdup (room);
+ {
+ dialog->room_list = NULL;
+ }
- g_strstrip (room_name);
+ if (dialog->room_list)
+ {
+ g_signal_connect (dialog->room_list, "destroy",
+ G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog);
+ g_signal_connect (dialog->room_list, "new-room",
+ G_CALLBACK (new_chatroom_dialog_new_room_cb), dialog);
+ g_signal_connect (dialog->room_list, "notify::is-listing",
+ G_CALLBACK (new_chatroom_dialog_listing_cb), dialog);
+ g_signal_connect (dialog->room_list, "error::start",
+ G_CALLBACK (start_listing_error_cb), dialog);
+ g_signal_connect (dialog->room_list, "error::stop",
+ G_CALLBACK (stop_listing_error_cb), dialog);
- DEBUG ("Requesting channel for '%s'", room_name);
+ expanded = gtk_expander_get_expanded (
+ GTK_EXPANDER (dialog->expander_browse));
+ if (expanded)
+ {
+ gtk_widget_hide (dialog->viewport_error);
+ gtk_widget_set_sensitive (dialog->treeview, TRUE);
+ new_chatroom_dialog_browse_start (dialog);
+ }
- empathy_join_muc (account, room_name, empathy_get_current_action_time ());
+ listing = empathy_tp_roomlist_is_listing (dialog->room_list);
+ if (listing)
+ {
+ gtk_spinner_start (GTK_SPINNER (dialog->throbber));
+ gtk_widget_show (dialog->throbber);
+ }
+ }
- g_free (room_name);
+ gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL);
+
+out:
+ new_chatroom_dialog_update_widgets (dialog);
+}
+
+static void
+new_chatroom_dialog_button_close_error_clicked_cb (GtkButton *button,
+ EmpathyNewChatroomDialog *dialog)
+{
+ gtk_widget_hide (dialog->viewport_error);
}
static void
@@ -785,14 +644,6 @@ new_chatroom_dialog_entry_changed_cb (GtkWidget *entry,
}
static void
-new_chatroom_dialog_browse_start (EmpathyNewChatroomDialog *dialog)
-{
- new_chatroom_dialog_model_clear (dialog);
- if (dialog->room_list)
- empathy_tp_roomlist_start (dialog->room_list);
-}
-
-static void
new_chatroom_dialog_browse_stop (EmpathyNewChatroomDialog *dialog)
{
if (dialog->room_list)
@@ -840,3 +691,96 @@ new_chatroom_dialog_entry_server_focus_out_cb (GtkWidget *widget,
return FALSE;
}
+
+void
+empathy_new_chatroom_dialog_show (GtkWindow *parent)
+{
+ EmpathyNewChatroomDialog *dialog;
+ GtkBuilder *gui;
+ GtkSizeGroup *size_group;
+ gchar *filename;
+
+ if (dialog_p)
+ {
+ gtk_window_present (GTK_WINDOW (dialog_p->window));
+ return;
+ }
+
+ dialog_p = dialog = g_new0 (EmpathyNewChatroomDialog, 1);
+
+ filename = empathy_file_lookup ("empathy-new-chatroom-dialog.ui", "src");
+ gui = empathy_builder_get_file (filename,
+ "new_chatroom_dialog", &dialog->window,
+ "table_grid", &dialog->table_grid,
+ "label_account", &dialog->label_account,
+ "label_server", &dialog->label_server,
+ "label_room", &dialog->label_room,
+ "entry_server", &dialog->entry_server,
+ "entry_room", &dialog->entry_room,
+ "treeview", &dialog->treeview,
+ "button_join", &dialog->button_join,
+ "expander_browse", &dialog->expander_browse,
+ "hbox_expander", &dialog->hbox_expander,
+ "label_error_message", &dialog->label_error_message,
+ "viewport_error", &dialog->viewport_error,
+ NULL);
+ g_free (filename);
+
+ empathy_builder_connect (gui, dialog,
+ "new_chatroom_dialog", "response", new_chatroom_dialog_response_cb,
+ "new_chatroom_dialog", "destroy", new_chatroom_dialog_destroy_cb,
+ "entry_server", "changed", new_chatroom_dialog_entry_changed_cb,
+ "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb,
+ "entry_server", "focus-out-event", new_chatroom_dialog_entry_server_focus_out_cb,
+ "entry_room", "changed", new_chatroom_dialog_entry_changed_cb,
+ "expander_browse", "activate", new_chatroom_dialog_expander_browse_activate_cb,
+ "button_close_error", "clicked", new_chatroom_dialog_button_close_error_clicked_cb,
+ NULL);
+
+ g_object_unref (gui);
+
+ g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog_p);
+
+ /* Label alignment */
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ gtk_size_group_add_widget (size_group, dialog->label_account);
+ gtk_size_group_add_widget (size_group, dialog->label_server);
+ gtk_size_group_add_widget (size_group, dialog->label_room);
+
+ g_object_unref (size_group);
+
+ /* Set up chatrooms treeview */
+ new_chatroom_dialog_model_setup (dialog);
+
+ /* Add throbber */
+ dialog->throbber = gtk_spinner_new ();
+ gtk_box_pack_start (GTK_BOX (dialog->hbox_expander), dialog->throbber,
+ TRUE, TRUE, 0);
+
+ dialog->gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+
+ /* Account chooser for custom */
+ dialog->account_chooser = empathy_account_chooser_new ();
+ empathy_account_chooser_set_filter (
+ EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
+ empathy_account_chooser_filter_supports_chatrooms, NULL);
+ gtk_grid_attach (GTK_GRID (dialog->table_grid), dialog->account_chooser,
+ 1, 0, 1, 1);
+ gtk_widget_show (dialog->account_chooser);
+
+ g_signal_connect (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser), "ready",
+ G_CALLBACK (new_chatroom_dialog_account_ready_cb), dialog);
+ g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed",
+ G_CALLBACK (new_chatroom_dialog_account_changed_cb), dialog);
+ new_chatroom_dialog_account_changed_cb (
+ GTK_COMBO_BOX (dialog->account_chooser), dialog);
+
+ if (parent)
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog->window),
+ GTK_WINDOW (parent));
+ }
+
+ gtk_widget_show (dialog->window);
+}