[empathy: 17/19] Preserve the status message across combo box changes



commit 5b4b6de8f4bc1484184ee469e1c976e1e7d96034
Author: Davyd Madeley <davyd madeley id au>
Date:   Thu Apr 23 19:47:52 2009 +0800

    Preserve the status message across combo box changes
---
 libempathy-gtk/empathy-status-preset-dialog.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c
index 0fe577d..f7171e4 100644
--- a/libempathy-gtk/empathy-status-preset-dialog.c
+++ b/libempathy-gtk/empathy-status-preset-dialog.c
@@ -63,6 +63,7 @@ struct _EmpathyStatusPresetDialogPriv
 
 	GtkTreeIter selected_iter;
 	gboolean add_combo_changed;
+	char *saved_status;
 };
 
 enum
@@ -83,11 +84,22 @@ enum
 };
 
 static void
+empathy_status_preset_dialog_finalize (GObject *self)
+{
+	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
+
+	g_free (priv->saved_status);
+
+	G_OBJECT_CLASS (empathy_status_preset_dialog_parent_class)->finalize (self);
+}
+
+static void
 empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class)
 {
 	GObjectClass *gobject_class;
 
 	gobject_class = G_OBJECT_CLASS (class);
+	gobject_class->finalize = empathy_status_preset_dialog_finalize;
 
 	g_type_class_add_private (gobject_class,
 			sizeof (EmpathyStatusPresetDialogPriv));
@@ -371,12 +383,17 @@ status_preset_dialog_add_combo_changed (GtkComboBox *combo,
 		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 {
-		const char *status;
+		g_free (priv->saved_status);
+		priv->saved_status = g_strdup (
+				gtk_entry_get_text (GTK_ENTRY (entry)));
 
-		status = gtk_entry_get_text (GTK_ENTRY (entry));
 		status_preset_dialog_set_add_combo_changed (self,
-				strlen (status) > 0, FALSE);
+				strlen (priv->saved_status) > 0, FALSE);
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]