From e57f5cfac0d04a01dd94bf4404cd17d5f4706c8a Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Thu, 16 Apr 2009 11:57:08 -0400 Subject: [PATCH] Modify deeply the join chatroom dialog. The rationale is that the room list is now loaded when the expander is open. It will refresh it if is open and the server is changed. --- src/empathy-new-chatroom-dialog.c | 83 ++++++++++----------- src/empathy-new-chatroom-dialog.ui | 112 ++++++++--------------------- 2 files changed, 70 insertions(+), 125 deletions(-) diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c index 75ab742c..9993d752 100644 --- a/src/empathy-new-chatroom-dialog.c +++ b/src/empathy-new-chatroom-dialog.c @@ -59,13 +59,9 @@ typedef struct { GtkWidget *account_chooser; GtkWidget *label_server; GtkWidget *entry_server; - GtkWidget *togglebutton_refresh; GtkWidget *label_room; GtkWidget *entry_room; - GtkWidget *vbox_browse; - GtkWidget *image_status; - GtkWidget *label_status; - GtkWidget *hbox_status; + GtkWidget *expander_browse; GtkWidget *throbber; GtkWidget *treeview; GtkTreeModel *model; @@ -111,7 +107,10 @@ static void new_chatroom_dialog_browse_start (EmpathyNewC 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_togglebutton_refresh_toggled_cb (GtkWidget *widget, +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 EmpathyNewChatroomDialog *dialog_p = NULL; @@ -140,13 +139,9 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent) "label_room", &dialog->label_room, "entry_server", &dialog->entry_server, "entry_room", &dialog->entry_room, - "togglebutton_refresh", &dialog->togglebutton_refresh, - "vbox_browse", &dialog->vbox_browse, - "image_status", &dialog->image_status, - "label_status", &dialog->label_status, - "hbox_status", &dialog->hbox_status, "treeview", &dialog->treeview, "button_join", &dialog->button_join, + "expander_browse", &dialog->expander_browse, NULL); g_free (filename); @@ -155,8 +150,9 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent) "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, - "togglebutton_refresh", "toggled", new_chatroom_dialog_togglebutton_refresh_toggled_cb, + "expander_browse", "activate", new_chatroom_dialog_expander_browse_activate_cb, NULL); g_object_unref (gui); @@ -179,9 +175,10 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent) dialog->throbber = ephy_spinner_new (); ephy_spinner_set_size (EPHY_SPINNER (dialog->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show (dialog->throbber); - - gtk_box_pack_start (GTK_BOX (dialog->hbox_status), dialog->throbber, - FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (dialog->table_info), + dialog->throbber, + 2, 3, 0, 1, + 0, 0, 0, 0); /* Account chooser for custom */ dialog->account_chooser = empathy_account_chooser_new (); @@ -190,7 +187,7 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent) NULL); gtk_table_attach_defaults (GTK_TABLE (dialog->table_info), dialog->account_chooser, - 1, 3, 0, 1); + 1, 2, 0, 1); gtk_widget_show (dialog->account_chooser); g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed", @@ -275,7 +272,6 @@ new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog) GtkCellRenderer *cell; view = GTK_TREE_VIEW (dialog->treeview); - gtk_tree_view_set_headers_visible (view, FALSE); cell = gtk_cell_renderer_text_new (); g_object_set (cell, @@ -312,19 +308,15 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) /* hardcode here known protocols */ if (strcmp (protocol, "jabber") == 0) { gtk_widget_set_sensitive (dialog->entry_server, TRUE); - gtk_widget_show (dialog->vbox_browse); - } else if (strcmp (protocol, "local-xmpp") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); - gtk_widget_show (dialog->vbox_browse); } else if (strcmp (protocol, "irc") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); - gtk_widget_show (dialog->vbox_browse); - } else { + } + else { gtk_widget_set_sensitive (dialog->entry_server, TRUE); - gtk_widget_show (dialog->vbox_browse); } room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); @@ -356,7 +348,7 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox, account = empathy_account_chooser_get_account (account_chooser); dialog->room_list = empathy_tp_roomlist_new (account); - if (dialog->room_list) { + if (dialog->room_list) { g_signal_connect (dialog->room_list, "destroy", G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog); @@ -425,16 +417,6 @@ new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list, } else { ephy_spinner_stop (EPHY_SPINNER (dialog->throbber)); } - - /* Update the refresh toggle button */ - g_signal_handlers_block_by_func (dialog->togglebutton_refresh, - new_chatroom_dialog_togglebutton_refresh_toggled_cb, - dialog); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->togglebutton_refresh), - listing); - g_signal_handlers_unblock_by_func (dialog->togglebutton_refresh, - new_chatroom_dialog_togglebutton_refresh_toggled_cb, - dialog); } static void @@ -542,22 +524,35 @@ static void new_chatroom_dialog_entry_server_activate_cb (GtkWidget *widget, EmpathyNewChatroomDialog *dialog) { - new_chatroom_dialog_togglebutton_refresh_toggled_cb (dialog->togglebutton_refresh, - dialog); + new_chatroom_dialog_browse_start (dialog); } static void -new_chatroom_dialog_togglebutton_refresh_toggled_cb (GtkWidget *widget, - EmpathyNewChatroomDialog *dialog) +new_chatroom_dialog_expander_browse_activate_cb (GtkWidget *widget, + EmpathyNewChatroomDialog *dialog) { - gboolean toggled; + gboolean expanded; - toggled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - - if (toggled) { - new_chatroom_dialog_browse_start (dialog); - } else { + expanded = gtk_expander_get_expanded (GTK_EXPANDER (widget)); + if (expanded) { new_chatroom_dialog_browse_stop (dialog); + gtk_window_set_resizable (GTK_WINDOW (dialog->window), FALSE); + } else { + new_chatroom_dialog_browse_start (dialog); + gtk_window_set_resizable (GTK_WINDOW (dialog->window), TRUE); } } +static gboolean +new_chatroom_dialog_entry_server_focus_out_cb (GtkWidget *widget, + GdkEventFocus *event, + EmpathyNewChatroomDialog *dialog) +{ + gboolean expanded; + + expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse)); + if (expanded) { + new_chatroom_dialog_browse_start (dialog); + } + return FALSE; +} diff --git a/src/empathy-new-chatroom-dialog.ui b/src/empathy-new-chatroom-dialog.ui index 04927be2..ba7a326e 100644 --- a/src/empathy-new-chatroom-dialog.ui +++ b/src/empathy-new-chatroom-dialog.ui @@ -4,28 +4,26 @@ True 5 - Join New + Join Room join_new_chatroom - False 350 GDK_WINDOW_TYPE_HINT_DIALOG False True - 6 True 5 - 18 + 5 True 3 3 - 6 - 6 + 5 + 5 @@ -38,30 +36,28 @@ True Enter the room name to join here or click on one or more rooms in the list. True - 32 + 25 1 3 2 3 - + GTK_FILL - + True - True - Re_fresh + 0 + _Room: True + entry_room - 2 - 3 - 1 - 2 + 2 + 3 GTK_FILL - @@ -73,23 +69,9 @@ 1 - 2 + 3 1 2 - - - - - - True - 0 - _Room: - True - entry_room - - - 2 - 3 GTK_FILL @@ -121,50 +103,18 @@ + + False + False + - + True - 6 - - - True - 6 - - - True - 3 - - - True - 2 - gtk-find - - - False - False - - - - - True - 0 - Browse: - True - - - 1 - - - - - - - - - + True + 350 150 True True @@ -175,14 +125,17 @@ True True - This list represents all chat rooms hosted on the server you have entered. - False + 0 + False - - 1 - + + + + True + Room List + @@ -191,8 +144,6 @@ - False - False 1 @@ -205,7 +156,7 @@ True True True - gtk-close + gtk-cancel True @@ -228,7 +179,7 @@ True - gtk-execute + gtk-jump-to False @@ -238,7 +189,7 @@ True - Join + _Join True @@ -265,7 +216,6 @@ - togglebutton_refresh button_cancel button_join -- 2.39.2