diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-06-11 03:56:35 +0800 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-06-24 17:45:38 +0800 |
commit | 096e82cbc6e05aa693991d215cefe0ace429d497 (patch) | |
tree | 7d2a1f7716d3731982f385e0f5cb056cb8f1fb47 /libempathy-gtk/empathy-status-preset-dialog.c | |
parent | 01de3488d0287dc430582faab72932f846ec09dc (diff) | |
download | gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar.gz gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar.bz2 gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar.lz gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar.xz gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.tar.zst gsoc2013-empathy-096e82cbc6e05aa693991d215cefe0ace429d497.zip |
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.
Diffstat (limited to 'libempathy-gtk/empathy-status-preset-dialog.c')
-rw-r--r-- | libempathy-gtk/empathy-status-preset-dialog.c | 38 |
1 files 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", |