comparison 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
comparison
equal deleted inserted replaced
13174:e29845c34565 13175:488619ad7ed5
250 } 250 }
251 251
252 static void 252 static void
253 status_window_add_cb(GtkButton *button, gpointer user_data) 253 status_window_add_cb(GtkButton *button, gpointer user_data)
254 { 254 {
255 gaim_gtk_status_editor_show(NULL); 255 gaim_gtk_status_editor_show(FALSE, NULL);
256 } 256 }
257 257
258 static void 258 static void
259 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path, 259 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
260 GtkTreeIter *iter, gpointer user_data) 260 GtkTreeIter *iter, gpointer user_data)
263 GaimSavedStatus *saved_status; 263 GaimSavedStatus *saved_status;
264 264
265 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1); 265 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1);
266 saved_status = gaim_savedstatus_find(title); 266 saved_status = gaim_savedstatus_find(title);
267 g_free(title); 267 g_free(title);
268 gaim_gtk_status_editor_show(saved_status); 268 gaim_gtk_status_editor_show(TRUE, saved_status);
269 } 269 }
270 270
271 static void 271 static void
272 status_window_modify_cb(GtkButton *button, gpointer user_data) 272 status_window_modify_cb(GtkButton *button, gpointer user_data)
273 { 273 {
693 type = gtk_option_menu_get_history(dialog->type) + (GAIM_STATUS_UNSET + 1); 693 type = gtk_option_menu_get_history(dialog->type) + (GAIM_STATUS_UNSET + 1);
694 message = gtk_imhtml_get_markup(dialog->message); 694 message = gtk_imhtml_get_markup(dialog->message);
695 unformatted = gaim_markup_strip_html(message); 695 unformatted = gaim_markup_strip_html(message);
696 696
697 /* 697 /*
698 * If we're editing an old status, then lookup the old status (it's 698 * If we're editing an old status, then lookup the old status.
699 * possible that it has been deleted or renamed or something, and 699 * Note: It is possible that it has been deleted or renamed
700 * no longer exists). 700 * or something, and no longer exists.
701 */ 701 */
702 if (dialog->original_title != NULL) 702 if (dialog->original_title != NULL)
703 { 703 {
704 GtkTreeIter iter; 704 GtkTreeIter iter;
705 705
995 status_editor_add_account(dialog, account, substatus); 995 status_editor_add_account(dialog, account, substatus);
996 } 996 }
997 } 997 }
998 998
999 void 999 void
1000 gaim_gtk_status_editor_show(GaimSavedStatus *saved_status) 1000 gaim_gtk_status_editor_show(gboolean edit, GaimSavedStatus *saved_status)
1001 { 1001 {
1002 GtkTreeIter iter; 1002 GtkTreeIter iter;
1003 StatusEditor *dialog; 1003 StatusEditor *dialog;
1004 GtkSizeGroup *sg; 1004 GtkSizeGroup *sg;
1005 GtkWidget *bbox; 1005 GtkWidget *bbox;
1016 GtkWidget *toolbar; 1016 GtkWidget *toolbar;
1017 GtkWidget *vbox; 1017 GtkWidget *vbox;
1018 GtkWidget *win; 1018 GtkWidget *win;
1019 GList *focus_chain = NULL; 1019 GList *focus_chain = NULL;
1020 1020
1021 if (edit)
1022 {
1023 g_return_if_fail(saved_status != NULL);
1024 g_return_if_fail(!gaim_savedstatus_is_transient(saved_status));
1025 }
1026
1021 /* Find a possible window for this saved status and present it */ 1027 /* Find a possible window for this saved status and present it */
1022 if (status_window) { 1028 if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status)))
1023 if (status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) { 1029 {
1024 gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter, 1030 gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter,
1025 STATUS_WINDOW_COLUMN_WINDOW, &dialog, 1031 STATUS_WINDOW_COLUMN_WINDOW, &dialog,
1026 -1); 1032 -1);
1027 if (dialog) { 1033 if (dialog != NULL)
1028 gtk_window_present(GTK_WINDOW(dialog->window)); 1034 {
1029 return; 1035 gtk_window_present(GTK_WINDOW(dialog->window));
1030 } 1036 return;
1031 } 1037 }
1032 } 1038 }
1033 1039
1034 dialog = g_new0(StatusEditor, 1); 1040 dialog = g_new0(StatusEditor, 1);
1035 if (status_window) 1041 if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_saveds tatus_get_title(saved_status)))
1042 {
1036 gtk_list_store_set(status_window->model, &iter, 1043 gtk_list_store_set(status_window->model, &iter,
1037 STATUS_WINDOW_COLUMN_WINDOW, dialog, 1044 STATUS_WINDOW_COLUMN_WINDOW, dialog,
1038 -1); 1045 -1);
1039 1046 }
1040 if (saved_status != NULL) 1047
1048 if (edit)
1041 dialog->original_title = g_strdup(gaim_savedstatus_get_title(saved_status)); 1049 dialog->original_title = g_strdup(gaim_savedstatus_get_title(saved_status));
1042 1050
1043 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); 1051 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1044 gtk_window_set_role(GTK_WINDOW(win), "status"); 1052 gtk_window_set_role(GTK_WINDOW(win), "status");
1045 gtk_window_set_title(GTK_WINDOW(win), _("Status")); 1053 gtk_window_set_title(GTK_WINDOW(win), _("Status"));
1067 gtk_widget_show(label); 1075 gtk_widget_show(label);
1068 gtk_size_group_add_widget(sg, label); 1076 gtk_size_group_add_widget(sg, label);
1069 1077
1070 entry = gtk_entry_new(); 1078 entry = gtk_entry_new();
1071 dialog->title = GTK_ENTRY(entry); 1079 dialog->title = GTK_ENTRY(entry);
1072 if (dialog->original_title != NULL) 1080 if ((saved_status != NULL)
1073 gtk_entry_set_text(GTK_ENTRY(entry), dialog->original_title); 1081 && !gaim_savedstatus_is_transient(saved_status)
1082 && (gaim_savedstatus_get_title(saved_status) != NULL))
1083 gtk_entry_set_text(GTK_ENTRY(entry), gaim_savedstatus_get_title(saved_status));
1074 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); 1084 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1075 gtk_widget_show(entry); 1085 gtk_widget_show(entry);
1076 g_signal_connect(G_OBJECT(entry), "changed", 1086 g_signal_connect(G_OBJECT(entry), "changed",
1077 G_CALLBACK(editor_title_changed_cb), dialog); 1087 G_CALLBACK(editor_title_changed_cb), dialog);
1078 1088