aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavyd Madeley <davyd@madeley.id.au>2009-04-23 15:49:42 +0800
committerDavyd Madeley <davyd@madeley.id.au>2009-04-23 15:49:42 +0800
commita41c75aceabdee7a14e54f5314d4cafc8eab9020 (patch)
tree74dc87e9388616b08c639c464b03abc5cd22633b
parent40b9a5d3b177c458555342a90a56934a40564f59 (diff)
downloadgsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar.gz
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar.bz2
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar.lz
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar.xz
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.tar.zst
gsoc2013-empathy-a41c75aceabdee7a14e54f5314d4cafc8eab9020.zip
Make it possible to edit a status message by double-clicking on it
-rw-r--r--libempathy-gtk/empathy-status-preset-dialog.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c
index 76ae06d40..4913e4b86 100644
--- a/libempathy-gtk/empathy-status-preset-dialog.c
+++ b/libempathy-gtk/empathy-status-preset-dialog.c
@@ -186,6 +186,53 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self)
}
static void
+status_preset_dialog_status_edited (GtkCellRendererText *renderer,
+ char *path_str,
+ char *new_status,
+ EmpathyStatusPresetDialog *self)
+{
+ EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ McPresence state;
+ char *old_status;
+ gboolean valid;
+
+ if (strlen (new_status) == 0) {
+ /* status is empty, ignore */
+ return;
+ }
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->presets_treeview));
+ path = gtk_tree_path_new_from_string (path_str);
+ valid = gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+
+ if (!valid) return;
+
+ gtk_tree_model_get (model, &iter,
+ PRESETS_STORE_STATE, &state,
+ PRESETS_STORE_STATUS, &old_status,
+ -1);
+
+ if (!strcmp (old_status, new_status)) {
+ /* statuses are the same */
+ g_free (old_status);
+ return;
+ }
+
+ DEBUG ("EDITED STATUS (%s) -> (%s)\n", old_status, new_status);
+
+ empathy_status_presets_remove (state, old_status);
+ empathy_status_presets_set_last (state, new_status);
+
+ g_free (old_status);
+
+ status_preset_dialog_presets_update (self);
+}
+
+static void
status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
{
EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
@@ -217,6 +264,11 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_add_attribute (column, renderer,
"text", PRESETS_STORE_STATUS);
+ g_object_set (renderer,
+ "editable", TRUE,
+ NULL);
+ g_signal_connect (renderer, "edited",
+ G_CALLBACK (status_preset_dialog_status_edited), self);
}
static void