From bf6f2b56d3a8a03cde5cee2469057d5e44933eed Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 14:20:14 +0100 Subject: PresenceChooser: remove unused #define FLASH_TIMEOUT --- libempathy-gtk/empathy-presence-chooser.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 45dd9da9e..66d516c40 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -66,9 +66,6 @@ * Widget which extends #GtkComboBoxEntry to change presence. */ -/* Flashing delay for icons (milliseconds). */ -#define FLASH_TIMEOUT 500 - #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyPresenceChooser) /* For custom message dialog */ -- cgit v1.2.3 From 8f42bd47699c9453aae13f9169a27a4d9bb80bb2 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 20:02:28 +0100 Subject: PresetDialog test: quit cleanly Previously one had to kill the process, but by just switching to gtk_dialog_run() we get more functionality for less code. :D --- tests/interactive/test-empathy-status-preset-dialog.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/interactive/test-empathy-status-preset-dialog.c b/tests/interactive/test-empathy-status-preset-dialog.c index 6602e4f28..e71852509 100644 --- a/tests/interactive/test-empathy-status-preset-dialog.c +++ b/tests/interactive/test-empathy-status-preset-dialog.c @@ -17,7 +17,9 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Authors: Davyd Madeley + * Authors: + * Danielle Madeley + * Will Thompson */ #include @@ -40,10 +42,7 @@ main (int argc, char **argv) empathy_status_presets_get_all (); dialog = empathy_status_preset_dialog_new (NULL); - - gtk_widget_show (dialog); - - gtk_main (); + gtk_dialog_run (GTK_DIALOG (dialog)); return 0; } -- cgit v1.2.3 From 6e61e4ff4b72e31a1f31205c9db3dc6cea8e64a1 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 20:07:35 +0100 Subject: PresetDialog: make the window taller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The element we really care about the size of is the list of statuses past. So I moved the horizontal size request to that—the window has 6px of padding or so, so this makes it pretty much exactly the same width—and made the height request be in the golden ratio to it. I'm probably unusual in having enough statuses to fill my laptop screen vertically, but, subjectively, this makes the dialog look less stubby even now I've removed them all to test. https://bugzilla.gnome.org/show_bug.cgi?id=630943 --- libempathy-gtk/empathy-status-preset-dialog.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index 07d8f14b9..fcc868ebd 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -3,8 +3,6 @@ - 420 - 260 True 6 vertical @@ -26,6 +24,8 @@ + 408 + 252 True True never -- cgit v1.2.3 From 49887f9ba8d3442b193759806f0371b07428718b Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 20:18:59 +0100 Subject: PresetDialog: make Add button less huge. I tried and failed to make it the same size as the other two buttons, so this will have to do. --- libempathy-gtk/empathy-status-preset-dialog.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index fcc868ebd..c287f8e2e 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -106,6 +106,7 @@ True + False 1 -- cgit v1.2.3 From 01de3488d0287dc430582faab72932f846ec09dc Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 20:51:20 +0100 Subject: PresetDialog: Don't allow resizing status preset dialog It's big enough. --- libempathy-gtk/empathy-status-preset-dialog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 2c36cb332..293798431 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -523,6 +523,7 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) _("Edit Custom Messages")); gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); + gtk_window_set_resizable (GTK_WINDOW (self), FALSE); filename = empathy_file_lookup ("empathy-status-preset-dialog.ui", "libempathy-gtk"); -- cgit v1.2.3 From 096e82cbc6e05aa693991d215cefe0ace429d497 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 20:56:35 +0100 Subject: PresetDialog: Allow >1 status to be removed at a time. This is pretty niche but we may as well. I want it sometimes. There's no reason to disallow it, and it's not like it adds any significant complexity. --- libempathy-gtk/empathy-status-preset-dialog.c | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 293798431..7dc77afa0 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -304,27 +304,19 @@ status_preset_dialog_preset_selection_changed (GtkTreeSelection *selection, { /* update the sensitivity of the Remove button */ gtk_widget_set_sensitive (remove_button, - gtk_tree_selection_get_selected (selection, NULL, NULL)); + gtk_tree_selection_count_selected_rows (selection) != 0); } static void -status_preset_dialog_preset_remove (GtkButton *button, - EmpathyStatusPresetDialog *self) +foreach_removed_status (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) { - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; TpConnectionPresenceType state; char *status; - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->presets_treeview)); - - g_return_if_fail (gtk_tree_selection_get_selected (selection, - &model, &iter)); - - gtk_tree_model_get (model, &iter, + gtk_tree_model_get (model, iter, PRESETS_STORE_STATE, &state, PRESETS_STORE_STATUS, &status, -1); @@ -333,7 +325,18 @@ status_preset_dialog_preset_remove (GtkButton *button, empathy_status_presets_remove (state, status); g_free (status); +} +static void +status_preset_dialog_preset_remove (GtkButton *button, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (priv->presets_treeview)); + gtk_tree_selection_selected_foreach (selection, foreach_removed_status, NULL); status_preset_dialog_presets_update (self); } @@ -517,6 +520,7 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) EmpathyStatusPresetDialogPriv); GtkBuilder *gui; GtkWidget *toplevel_vbox, *remove_button, *entry; + GtkTreeSelection *selection; char *filename; gtk_window_set_title (GTK_WINDOW (self), @@ -536,11 +540,13 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) NULL); g_free (filename); - g_signal_connect (gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->presets_treeview)), + selection = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (priv->presets_treeview)); + g_signal_connect (selection, "changed", G_CALLBACK (status_preset_dialog_preset_selection_changed), remove_button); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); g_signal_connect (entry, "activate", -- cgit v1.2.3 From 901256e30ba93abc86dfd3826ee28f322251c673 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 21:09:33 +0100 Subject: PresetDialog: Select text cell of freshly-added status This means you can just mash Enter to edit your mistake. It's more useful than leaving the text entry focused. It also helps hide a bug where the entry doesn't get cleared if you just start typing another message. So previously, typing: HelloMiaow would give you two statuses, "Hello" and "MiaowEnter Custom Message". It didn't seem worth fixing this much more since Gtk+ 3.2 will probably grow native support for placeholder text: --- libempathy-gtk/empathy-status-preset-dialog.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 7dc77afa0..8176e9ea7 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -65,6 +65,9 @@ struct _EmpathyStatusPresetDialogPriv int block_add_combo_changed; GtkWidget *presets_treeview; + GtkTreeViewColumn *column; + GtkCellRenderer *text_cell; + GtkWidget *add_combobox; GtkWidget *add_button; @@ -278,6 +281,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) status_preset_dialog_presets_update (self); column = gtk_tree_view_column_new (); + priv->column = column; gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); renderer = gtk_cell_renderer_pixbuf_new (); @@ -286,6 +290,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) "icon-name", PRESETS_STORE_ICON_NAME); renderer = gtk_cell_renderer_text_new (); + priv->text_cell = renderer; gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_add_attribute (column, renderer, "text", PRESETS_STORE_STATUS); @@ -460,14 +465,13 @@ status_preset_dialog_add_preset (GtkWidget *widget, GtkTreePath *path; path = gtk_tree_model_get_path (model, &iter); - - gtk_tree_selection_select_iter ( - gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->presets_treeview)), - &iter); - gtk_tree_view_scroll_to_cell ( - GTK_TREE_VIEW (priv->presets_treeview), - path, NULL, - FALSE, 0., 0.); + gtk_tree_view_set_cursor_on_cell ( + GTK_TREE_VIEW (priv->presets_treeview), + path, + priv->column, + priv->text_cell, + FALSE); + gtk_widget_grab_focus (priv->presets_treeview); break; } } -- cgit v1.2.3 From 05fb4bd53ec98426d0880b0557031b2579ec96de Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 10 Jun 2011 21:15:35 +0100 Subject: PresetDialog: Don't leak path when focusing freshly-created status (This was not introduced by my changes.) --- libempathy-gtk/empathy-status-preset-dialog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 8176e9ea7..12305558a 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -472,6 +472,7 @@ status_preset_dialog_add_preset (GtkWidget *widget, priv->text_cell, FALSE); gtk_widget_grab_focus (priv->presets_treeview); + gtk_tree_path_free (path); break; } } -- cgit v1.2.3 From fb207a362a266da923f6f87c91c0dd649cfa9183 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 24 Jun 2011 11:09:28 +0100 Subject: PresetDialog: GNOME 3-ify the remove button Yum yum joined-toolbar! --- libempathy-gtk/empathy-status-preset-dialog.c | 12 ++++- libempathy-gtk/empathy-status-preset-dialog.ui | 70 ++++++++++++++++---------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 12305558a..30c5c6b9d 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -524,9 +524,11 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogPriv); GtkBuilder *gui; - GtkWidget *toplevel_vbox, *remove_button, *entry; + GtkWidget *toplevel_vbox, *presets_sw, *remove_toolbar, *remove_button, + *entry; GtkTreeSelection *selection; char *filename; + GtkStyleContext *context; gtk_window_set_title (GTK_WINDOW (self), _("Edit Custom Messages")); @@ -538,13 +540,21 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) "libempathy-gtk"); gui = empathy_builder_get_file (filename, "toplevel-vbox", &toplevel_vbox, + "presets-sw", &presets_sw, "presets-treeview", &priv->presets_treeview, + "remove-toolbar", &remove_toolbar, "remove-button", &remove_button, "add-combobox", &priv->add_combobox, "add-button", &priv->add_button, NULL); g_free (filename); + /* join the remove toolbar to the treeview */ + context = gtk_widget_get_style_context (presets_sw); + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); + context = gtk_widget_get_style_context (remove_toolbar); + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); + selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (priv->presets_treeview)); g_signal_connect (selection, diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index c287f8e2e..b39e9a77b 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -23,48 +23,64 @@ - - 408 - 252 + True - True - never - etched-in + False - + + 408 + 252 True True - False + never + etched-in + + + True + True + False + + + + True + True + 0 + - - - 1 - - - - - True - end - - gtk-remove + True - False - True - True - True + False + 1 + + + + Remove + True + False + True + gtk-remove + + + False + True + + False - False - 0 + True + 1 - False - 2 + True + True + 1 -- cgit v1.2.3 From 712f9da4f80e0426ca449431ffbe6cd3373adf12 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 24 Jun 2011 11:44:35 +0100 Subject: PresetDialog: make status icon in entry non-activatable It's not meaningfully activatable; this has the effect of making it not glow on mouse-over, and preventing the cursor from changing from a caret back to a pointer. --- libempathy-gtk/empathy-status-preset-dialog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 30c5c6b9d..a106a88f2 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -564,6 +564,9 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); + gtk_entry_set_icon_activatable (GTK_ENTRY (entry), + GTK_ENTRY_ICON_PRIMARY, + FALSE); g_signal_connect (entry, "activate", G_CALLBACK (status_preset_dialog_add_preset), self); g_signal_connect (entry, "button-press-event", -- cgit v1.2.3 From 896aa85c871372227e96906420659e38d091f2ac Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 24 Jun 2011 11:56:34 +0100 Subject: PresetDialog: remove support for adding statuses entirely We already have a way to do this, namely on the contact list itself. So this dialog now becomes just a way to edit/remove the existing statuses. The margins on the VBox are chosen to make its right-hand edge line up exactly with the right-hand edge of the Close button in the dialog. --- libempathy-gtk/empathy-status-preset-dialog.c | 258 +------------------------ libempathy-gtk/empathy-status-preset-dialog.ui | 81 +------- 2 files changed, 4 insertions(+), 335 deletions(-) diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index a106a88f2..e68f080fb 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -68,9 +68,6 @@ struct _EmpathyStatusPresetDialogPriv GtkTreeViewColumn *column; GtkCellRenderer *text_cell; - GtkWidget *add_combobox; - GtkWidget *add_button; - GtkTreeIter selected_iter; gboolean add_combo_changed; char *saved_status; @@ -150,69 +147,6 @@ status_preset_dialog_presets_update (EmpathyStatusPresetDialog *self) } } -static void -status_preset_add_combo_reset (EmpathyStatusPresetDialog *self) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkWidget *entry; - - entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); - gtk_entry_set_text (GTK_ENTRY (entry), ""); - - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->add_combobox), - &priv->selected_iter); -} - -static void -status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkWidget *combobox = priv->add_combobox; - GtkListStore *store; - GtkCellRenderer *renderer; - guint i; - - store = gtk_list_store_new (ADD_COMBO_N_COLS, - G_TYPE_UINT, /* ADD_COMBO_STATE */ - G_TYPE_STRING, /* ADD_COMBO_ICON_NAME */ - G_TYPE_STRING, /* ADD_COMBO_STATUS */ - G_TYPE_STRING); /* ADD_COMBO_DEFAULT_TEXT */ - - gtk_combo_box_set_model (GTK_COMBO_BOX (combobox), - GTK_TREE_MODEL (store)); - g_object_unref (store); - - gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combobox), - ADD_COMBO_DEFAULT_TEXT); - - for (i = 0; i < G_N_ELEMENTS (states); i++) { - gtk_list_store_insert_with_values (store, NULL, -1, - ADD_COMBO_STATE, states[i], - ADD_COMBO_ICON_NAME, empathy_icon_name_for_presence (states[i]), - ADD_COMBO_STATUS, empathy_presence_get_default_message (states[i]), - ADD_COMBO_DEFAULT_TEXT, "", - -1); - } - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox)); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE); - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer, - "icon-name", ADD_COMBO_ICON_NAME); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE); - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer, - "text", ADD_COMBO_STATUS); - g_object_set (renderer, - "style", PANGO_STYLE_ITALIC, - "foreground", "Gray", /* FIXME - theme */ - NULL); - - gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); -} - static void status_preset_dialog_status_edited (GtkCellRendererText *renderer, char *path_str, @@ -345,177 +279,6 @@ status_preset_dialog_preset_remove (GtkButton *button, status_preset_dialog_presets_update (self); } -static void -status_preset_dialog_set_add_combo_changed (EmpathyStatusPresetDialog *self, - gboolean state, - gboolean reset_text) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkWidget *entry; - - entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); - - priv->add_combo_changed = state; - gtk_widget_set_sensitive (priv->add_button, state); - - if (state) { - gtk_widget_override_color (entry, 0, NULL); - } else { - GdkRGBA color; - - if (gdk_rgba_parse (&color, "Gray")) /* FIXME - theme */ - gtk_widget_override_color (entry, 0, &color); - - if (reset_text) { - priv->block_add_combo_changed++; - gtk_entry_set_text (GTK_ENTRY (entry), - _("Enter Custom Message")); - priv->block_add_combo_changed--; - } - } -} - -static void -status_preset_dialog_add_combo_changed (GtkComboBox *combo, - EmpathyStatusPresetDialog *self) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkWidget *entry; - GtkTreeModel *model; - GtkTreeIter iter; - - if (priv->block_add_combo_changed) return; - - model = gtk_combo_box_get_model (combo); - entry = gtk_bin_get_child (GTK_BIN (combo)); - - if (gtk_combo_box_get_active_iter (combo, &iter)) { - char *icon_name; - - priv->selected_iter = iter; - gtk_tree_model_get (model, &iter, - PRESETS_STORE_ICON_NAME, &icon_name, - -1); - - gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), - GTK_ENTRY_ICON_PRIMARY, - icon_name); - - g_free (icon_name); - - status_preset_dialog_set_add_combo_changed (self, FALSE, TRUE); - if (priv->saved_status && strlen (priv->saved_status) > 0) { - gtk_entry_set_text (GTK_ENTRY (entry), - priv->saved_status); - } - } else { - g_free (priv->saved_status); - priv->saved_status = g_strdup ( - gtk_entry_get_text (GTK_ENTRY (entry))); - - status_preset_dialog_set_add_combo_changed (self, - strlen (priv->saved_status) > 0, FALSE); - } -} - -static void -status_preset_dialog_add_preset (GtkWidget *widget, - EmpathyStatusPresetDialog *self) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *entry; - TpConnectionPresenceType state, cstate; - const char *status; - char *cstatus; - gboolean valid, match = FALSE; - - g_return_if_fail (priv->add_combo_changed); - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->add_combobox)); - entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); - - status = gtk_entry_get_text (GTK_ENTRY (entry)); - gtk_tree_model_get (model, &priv->selected_iter, - PRESETS_STORE_STATE, &state, - -1); - - DEBUG ("ADD PRESET (%i, %s)\n", state, status); - empathy_status_presets_set_last (state, status); - - status_preset_dialog_presets_update (self); - - /* select the added status*/ - model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->presets_treeview)); - for (valid = gtk_tree_model_get_iter_first (model, &iter); - valid; - valid = gtk_tree_model_iter_next (model, &iter)) { - - gtk_tree_model_get (model, &iter, - PRESETS_STORE_STATE, &cstate, - PRESETS_STORE_STATUS, &cstatus, - -1); - - match = (cstate == state) && (strcmp (cstatus, status) == 0); - - g_free (cstatus); - - if (match) { - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_set_cursor_on_cell ( - GTK_TREE_VIEW (priv->presets_treeview), - path, - priv->column, - priv->text_cell, - FALSE); - gtk_widget_grab_focus (priv->presets_treeview); - gtk_tree_path_free (path); - break; - } - } - - if (!match) g_warning ("No match"); - - status_preset_add_combo_reset (self); -} - -static gboolean -status_preset_dialog_add_combo_press_event (GtkWidget *widget, - GdkEventButton *event, - EmpathyStatusPresetDialog *self) -{ - if (!gtk_widget_has_focus (widget)) { - /* if the widget isn't focused, focus it and select the text */ - gtk_widget_grab_focus (widget); - gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); - - return TRUE; - } - - return FALSE; -} - -static gboolean -status_preset_dialog_add_combo_focus_out (GtkWidget *widget, - GdkEventFocus *event, - EmpathyStatusPresetDialog *self) -{ - EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - const char *status; - - gtk_editable_set_position (GTK_EDITABLE (widget), 0); - - status = gtk_entry_get_text (GTK_ENTRY (widget)); - status_preset_dialog_set_add_combo_changed (self, - priv->add_combo_changed && strlen (status) > 0, - TRUE); - - return FALSE; -} - static void empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) { @@ -524,8 +287,7 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogPriv); GtkBuilder *gui; - GtkWidget *toplevel_vbox, *presets_sw, *remove_toolbar, *remove_button, - *entry; + GtkWidget *toplevel_vbox, *presets_sw, *remove_toolbar, *remove_button; GtkTreeSelection *selection; char *filename; GtkStyleContext *context; @@ -544,8 +306,6 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) "presets-treeview", &priv->presets_treeview, "remove-toolbar", &remove_toolbar, "remove-button", &remove_button, - "add-combobox", &priv->add_combobox, - "add-button", &priv->add_button, NULL); g_free (filename); @@ -563,27 +323,11 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) remove_button); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); - entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); - gtk_entry_set_icon_activatable (GTK_ENTRY (entry), - GTK_ENTRY_ICON_PRIMARY, - FALSE); - g_signal_connect (entry, "activate", - G_CALLBACK (status_preset_dialog_add_preset), self); - g_signal_connect (entry, "button-press-event", - G_CALLBACK (status_preset_dialog_add_combo_press_event), - self); - g_signal_connect (entry, "focus-out-event", - G_CALLBACK (status_preset_dialog_add_combo_focus_out), - self); - empathy_builder_connect (gui, self, "remove-button", "clicked", status_preset_dialog_preset_remove, - "add-combobox", "changed", status_preset_dialog_add_combo_changed, - "add-button", "clicked", status_preset_dialog_add_preset, NULL); status_preset_dialog_setup_presets_treeview (self); - status_preset_dialog_setup_add_combobox (self); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), toplevel_vbox, TRUE, TRUE, 0); diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index b39e9a77b..359a02f9e 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -2,30 +2,11 @@ - - True - 6 - vertical - 6 - - - True - 0 - Saved Status Messages - add-combobox - - - - - - False - 0 - - - - + True False + 5 + 5 408 @@ -77,60 +58,4 @@ - - True - True - 1 - - - - - True - 0 - Save _New Status Message - True - add-combobox - - - - - - False - 3 - - - - - True - 3 - - - True - True - - - 0 - - - - - gtk-add - True - False - True - True - True - - - False - 1 - - - - - False - 4 - - - -- cgit v1.2.3