changeset 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 e29845c34565
children dbe0198ced4b
files plugins/docklet/docklet.c src/gtksavedstatuses.c src/gtksavedstatuses.h src/gtkstatusbox.c
diffstat 4 files changed, 53 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/docklet/docklet.c	Wed Feb 08 05:07:43 2006 +0000
+++ b/plugins/docklet/docklet.c	Wed Feb 08 05:36:13 2006 +0000
@@ -360,7 +360,10 @@
 static void
 show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data)
 {
-	gaim_gtk_status_editor_show(NULL);
+	GaimSavedStatus *saved_status;
+	saved_status = gaim_savedstatus_get_current();
+	gaim_gtk_status_editor_show(FALSE,
+		gaim_savedstatus_is_transient(saved_status) ? saved_status : NULL);
 }
 
 static void
@@ -458,8 +461,8 @@
 
 	gaim_separator(submenu);
 
-	new_menu_item_with_gaim_icon(submenu, _("New Status..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL);
-	new_menu_item_with_gaim_icon(submenu, _("Saved Status..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(gaim_gtk_status_window_show), NULL, 0, 0, NULL);
+	new_menu_item_with_gaim_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL);
+	new_menu_item_with_gaim_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(gaim_gtk_status_window_show), NULL, 0, 0, NULL);
 
 	return menuitem;
 }
--- 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",
--- a/src/gtksavedstatuses.h	Wed Feb 08 05:07:43 2006 +0000
+++ b/src/gtksavedstatuses.h	Wed Feb 08 05:36:13 2006 +0000
@@ -42,10 +42,20 @@
  * Shows a status editor (used for adding a new saved status or
  * editing an already existing saved status).
  *
- * @param status The saved status to edit, or @c NULL if you
- *               want to add a new saved status.
+ * @param edit   TRUE if we want to edit an existing saved
+ *               status or FALSE to create a new one.  You
+ *               can not edit transient statuses--they don't
+ *               have titles.  If you want to edit a transient
+ *               status, set this to FALSE and seed the dialog
+ *               with the transient status using the status
+ *               parameter to this function.
+ * @param status If edit is TRUE then this should be a
+ *               pointer to the GaimSavedStatus to edit.
+ *               If edit is FALSE then this can be NULL,
+ *               or you can pass in a saved status to
+ *               seed the initial values of the new status.
  */
-void gaim_gtk_status_editor_show(GaimSavedStatus *status);
+void gaim_gtk_status_editor_show(gboolean edit, GaimSavedStatus *status);
 
 /**
  * Creates a dropdown menu of saved statuses and calls a callback
--- a/src/gtkstatusbox.c	Wed Feb 08 05:07:43 2006 +0000
+++ b/src/gtkstatusbox.c	Wed Feb 08 05:36:13 2006 +0000
@@ -1400,7 +1400,11 @@
 
 		if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM)
 		{
-			gaim_gtk_status_editor_show(NULL);
+			GaimSavedStatus *saved_status;
+			saved_status = gaim_savedstatus_get_current();
+			gaim_gtk_status_editor_show(FALSE,
+				gaim_savedstatus_is_transient(saved_status)
+					? saved_status : NULL);
 			status_menu_refresh_iter(status_box);
 			return;
 		}