diff src/gtksavedstatuses.c @ 13175:488619ad7ed5

[gaim-migrate @ 15538] If you're not using a saved status and you select "New..." in the gtkstatusbox then the new status dialog will be seeded with your current message and stuff. rlaager told me to do this. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Feb 2006 05:36:13 +0000
parents 07ecd51f1f07
children dbe0198ced4b
line wrap: on
line diff
--- a/src/gtksavedstatuses.c	Wed Feb 08 05:07:43 2006 +0000
+++ b/src/gtksavedstatuses.c	Wed Feb 08 05:36:13 2006 +0000
@@ -252,7 +252,7 @@
 static void
 status_window_add_cb(GtkButton *button, gpointer user_data)
 {
-	gaim_gtk_status_editor_show(NULL);
+	gaim_gtk_status_editor_show(FALSE, NULL);
 }
 
 static void
@@ -265,7 +265,7 @@
 	gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1);
 	saved_status = gaim_savedstatus_find(title);
 	g_free(title);
-	gaim_gtk_status_editor_show(saved_status);
+	gaim_gtk_status_editor_show(TRUE, saved_status);
 }
 
 static void
@@ -695,9 +695,9 @@
 	unformatted = gaim_markup_strip_html(message);
 
 	/*
-	 * If we're editing an old status, then lookup the old status (it's
-	 * possible that it has been deleted or renamed or something, and
-	 * no longer exists).
+	 * If we're editing an old status, then lookup the old status.
+	 * Note: It is possible that it has been deleted or renamed
+	 *       or something, and no longer exists.
 	 */
 	if (dialog->original_title != NULL)
 	{
@@ -997,7 +997,7 @@
 }
 
 void
-gaim_gtk_status_editor_show(GaimSavedStatus *saved_status)
+gaim_gtk_status_editor_show(gboolean edit, GaimSavedStatus *saved_status)
 {
 	GtkTreeIter iter;
 	StatusEditor *dialog;
@@ -1018,26 +1018,34 @@
 	GtkWidget *win;
 	GList *focus_chain = NULL;
 
+	if (edit)
+	{
+		g_return_if_fail(saved_status != NULL);
+		g_return_if_fail(!gaim_savedstatus_is_transient(saved_status));
+	}
+
 	/* Find a possible window for this saved status and present it */
-	if (status_window) {
-		if (status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) {
-			gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter,
-								STATUS_WINDOW_COLUMN_WINDOW, &dialog,
-								-1);
-			if (dialog) {
-				gtk_window_present(GTK_WINDOW(dialog->window));
-				return;
-			}
+	if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status)))
+	{
+		gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter,
+							STATUS_WINDOW_COLUMN_WINDOW, &dialog,
+							-1);
+		if (dialog != NULL)
+		{
+			gtk_window_present(GTK_WINDOW(dialog->window));
+			return;
 		}
 	}
 
 	dialog = g_new0(StatusEditor, 1);
-	if (status_window)
+	if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_saveds        tatus_get_title(saved_status)))
+	{
 		gtk_list_store_set(status_window->model, &iter,
 							STATUS_WINDOW_COLUMN_WINDOW, dialog,
 							-1);
+	}
 
-	if (saved_status != NULL)
+	if (edit)
 		dialog->original_title = g_strdup(gaim_savedstatus_get_title(saved_status));
 
 	dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -1069,8 +1077,10 @@
 
 	entry = gtk_entry_new();
 	dialog->title = GTK_ENTRY(entry);
-	if (dialog->original_title != NULL)
-		gtk_entry_set_text(GTK_ENTRY(entry), dialog->original_title);
+	if ((saved_status != NULL)
+			&& !gaim_savedstatus_is_transient(saved_status)
+			&& (gaim_savedstatus_get_title(saved_status) != NULL))
+		gtk_entry_set_text(GTK_ENTRY(entry), gaim_savedstatus_get_title(saved_status));
 	gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
 	gtk_widget_show(entry);
 	g_signal_connect(G_OBJECT(entry), "changed",