Mercurial > pidgin
comparison src/gtksavedstatuses.c @ 13178:35190e33a785
[gaim-migrate @ 15541]
Clean up some saved status code. Fix a bug where Gaim would crash
when you open a substatus editor then close it, then close the status
editor.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 08 Feb 2006 07:09:41 +0000 |
parents | dbe0198ced4b |
children | 3426bc61bb8b |
comparison
equal
deleted
inserted
replaced
13177:891be2f09b5c | 13178:35190e33a785 |
---|---|
53 enum | 53 enum |
54 { | 54 { |
55 STATUS_WINDOW_COLUMN_TITLE, | 55 STATUS_WINDOW_COLUMN_TITLE, |
56 STATUS_WINDOW_COLUMN_TYPE, | 56 STATUS_WINDOW_COLUMN_TYPE, |
57 STATUS_WINDOW_COLUMN_MESSAGE, | 57 STATUS_WINDOW_COLUMN_MESSAGE, |
58 /** pointer to open window for this saved status */ | 58 /** A hidden column containing a pointer to the editor for this saved status. */ |
59 STATUS_WINDOW_COLUMN_WINDOW, | 59 STATUS_WINDOW_COLUMN_WINDOW, |
60 STATUS_WINDOW_NUM_COLUMNS | 60 STATUS_WINDOW_NUM_COLUMNS |
61 }; | 61 }; |
62 | 62 |
63 /** | 63 /** |
65 * at the bottom of the window when you're editing a particular | 65 * at the bottom of the window when you're editing a particular |
66 * saved status. | 66 * saved status. |
67 */ | 67 */ |
68 enum | 68 enum |
69 { | 69 { |
70 /** A hidden column containing a pointer to the GaimAccount */ | 70 /** A hidden column containing a pointer to the GaimAccount. */ |
71 STATUS_EDITOR_COLUMN_ACCOUNT, | 71 STATUS_EDITOR_COLUMN_ACCOUNT, |
72 /** A hidden column containing a pointer to the substatus dialog */ | 72 /** A hidden column containing a pointer to the editor for this substatus. */ |
73 STATUS_EDITOR_COLUMN_WINDOW, | 73 STATUS_EDITOR_COLUMN_WINDOW, |
74 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, | 74 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, |
75 STATUS_EDITOR_COLUMN_ICON, | 75 STATUS_EDITOR_COLUMN_ICON, |
76 STATUS_EDITOR_COLUMN_SCREENNAME, | 76 STATUS_EDITOR_COLUMN_SCREENNAME, |
77 /** A hidden column containing the ID of this GaimStatusType. */ | 77 /** A hidden column containing the ID of this GaimStatusType. */ |
86 * GaimStatusType when setting a substatus for a particular saved | 86 * GaimStatusType when setting a substatus for a particular saved |
87 * status. | 87 * status. |
88 */ | 88 */ |
89 enum | 89 enum |
90 { | 90 { |
91 /** A hidden column containing a pointer to the GaimAccount. */ | |
92 SUBSTATUS_COLUMN_ACCOUNT, | |
93 SUBSTATUS_COLUMN_ICON, | 91 SUBSTATUS_COLUMN_ICON, |
94 /** A hidden column containing the ID of this GaimStatusType. */ | 92 /** A hidden column containing the ID of this GaimStatusType. */ |
95 SUBSTATUS_COLUMN_STATUS_ID, | 93 SUBSTATUS_COLUMN_STATUS_ID, |
96 SUBSTATUS_COLUMN_STATUS_NAME, | 94 SUBSTATUS_COLUMN_STATUS_NAME, |
97 SUBSTATUS_NUM_COLUMNS | 95 SUBSTATUS_NUM_COLUMNS |
144 status_window_find_savedstatus(GtkTreeIter *iter, const char *title) | 142 status_window_find_savedstatus(GtkTreeIter *iter, const char *title) |
145 { | 143 { |
146 GtkTreeModel *model; | 144 GtkTreeModel *model; |
147 char *cur; | 145 char *cur; |
148 | 146 |
149 if (status_window == NULL || title == NULL) | 147 if ((status_window == NULL) || (title == NULL)) |
150 return FALSE; | 148 return FALSE; |
151 | 149 |
152 model = GTK_TREE_MODEL(status_window->model); | 150 model = GTK_TREE_MODEL(status_window->model); |
153 | 151 |
154 if (!gtk_tree_model_get_iter_first(model, iter)) | 152 if (!gtk_tree_model_get_iter_first(model, iter)) |
155 return FALSE; | 153 return FALSE; |
156 | 154 |
157 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &cur, -1); | 155 do { |
158 if (!strcmp(title, cur)) | |
159 { | |
160 g_free(cur); | |
161 return TRUE; | |
162 } | |
163 g_free(cur); | |
164 | |
165 while (gtk_tree_model_iter_next(model, iter)) | |
166 { | |
167 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &cur, -1); | 156 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &cur, -1); |
168 if (!strcmp(title, cur)) | 157 if (!strcmp(title, cur)) |
169 { | 158 { |
170 g_free(cur); | 159 g_free(cur); |
171 return TRUE; | 160 return TRUE; |
172 } | 161 } |
173 g_free(cur); | 162 g_free(cur); |
174 } | 163 } while (gtk_tree_model_iter_next(model, iter)); |
175 | 164 |
176 return FALSE; | 165 return FALSE; |
177 } | 166 } |
178 | 167 |
179 static gboolean | 168 static gboolean |
498 } | 487 } |
499 | 488 |
500 static gboolean | 489 static gboolean |
501 configure_cb(GtkWidget *widget, GdkEventConfigure *event, StatusWindow *dialog) | 490 configure_cb(GtkWidget *widget, GdkEventConfigure *event, StatusWindow *dialog) |
502 { | 491 { |
503 if (GTK_WIDGET_VISIBLE(widget)) { | 492 if (GTK_WIDGET_VISIBLE(widget)) |
493 { | |
504 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width); | 494 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width); |
505 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height); | 495 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height); |
506 } | 496 } |
507 | 497 |
508 return FALSE; | 498 return FALSE; |
517 GtkWidget *list; | 507 GtkWidget *list; |
518 GtkWidget *vbox; | 508 GtkWidget *vbox; |
519 GtkWidget *win; | 509 GtkWidget *win; |
520 int width, height; | 510 int width, height; |
521 | 511 |
522 if (status_window != NULL) { | 512 if (status_window != NULL) |
513 { | |
523 gtk_window_present(GTK_WINDOW(status_window->window)); | 514 gtk_window_present(GTK_WINDOW(status_window->window)); |
524 return; | 515 return; |
525 } | 516 } |
526 | 517 |
527 status_window = dialog = g_new0(StatusWindow, 1); | 518 status_window = dialog = g_new0(StatusWindow, 1); |
624 | 615 |
625 /************************************************************************** | 616 /************************************************************************** |
626 * Status editor | 617 * Status editor |
627 **************************************************************************/ | 618 **************************************************************************/ |
628 | 619 |
620 static void substatus_editor_cancel_cb(GtkButton *button, gpointer user_data); | |
621 | |
629 static void | 622 static void |
630 status_editor_remove_dialog(StatusEditor *dialog) | 623 status_editor_remove_dialog(StatusEditor *dialog) |
631 { | 624 { |
625 GtkTreeModel *model; | |
632 GtkTreeIter iter; | 626 GtkTreeIter iter; |
633 if (status_window_find_savedstatus(&iter, dialog->original_title)) { | 627 |
628 /* Remove the reference to this dialog from our parent's list store */ | |
629 if (status_window_find_savedstatus(&iter, dialog->original_title)) | |
630 { | |
634 gtk_list_store_set(status_window->model, &iter, | 631 gtk_list_store_set(status_window->model, &iter, |
635 STATUS_WINDOW_COLUMN_WINDOW, NULL, | 632 STATUS_WINDOW_COLUMN_WINDOW, NULL, |
636 -1); | 633 -1); |
637 } | 634 } |
635 | |
636 /* Close any substatus editors that may be open */ | |
637 model = GTK_TREE_MODEL(dialog->model); | |
638 if (gtk_tree_model_get_iter_first(model, &iter)) | |
639 { | |
640 do { | |
641 SubStatusEditor *substatus_dialog; | |
642 | |
643 gtk_tree_model_get(model, &iter, | |
644 STATUS_EDITOR_COLUMN_WINDOW, &substatus_dialog, | |
645 -1); | |
646 if (substatus_dialog != NULL) | |
647 { | |
648 gtk_list_store_set(dialog->model, &iter, | |
649 STATUS_EDITOR_COLUMN_WINDOW, NULL, | |
650 -1); | |
651 substatus_editor_cancel_cb(NULL, substatus_dialog); | |
652 } | |
653 } while (gtk_tree_model_iter_next(model, &iter)); | |
654 } | |
638 } | 655 } |
639 | 656 |
640 | 657 |
641 static gboolean | 658 static gboolean |
642 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) | 659 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) |
643 { | 660 { |
644 StatusEditor *dialog = user_data; | 661 StatusEditor *dialog = user_data; |
645 | 662 |
646 status_editor_remove_dialog(dialog); | 663 status_editor_remove_dialog(dialog); |
647 | |
648 g_free(dialog->original_title); | 664 g_free(dialog->original_title); |
649 g_free(dialog); | 665 g_free(dialog); |
650 | 666 |
651 return FALSE; | 667 return FALSE; |
652 } | 668 } |
655 status_editor_cancel_cb(GtkButton *button, gpointer user_data) | 671 status_editor_cancel_cb(GtkButton *button, gpointer user_data) |
656 { | 672 { |
657 StatusEditor *dialog = user_data; | 673 StatusEditor *dialog = user_data; |
658 | 674 |
659 status_editor_remove_dialog(dialog); | 675 status_editor_remove_dialog(dialog); |
660 | |
661 gtk_widget_destroy(dialog->window); | 676 gtk_widget_destroy(dialog->window); |
662 | |
663 g_free(dialog->original_title); | 677 g_free(dialog->original_title); |
664 g_free(dialog); | 678 g_free(dialog); |
665 } | 679 } |
666 | 680 |
667 static void | 681 static void |
704 GtkTreeIter iter; | 718 GtkTreeIter iter; |
705 | 719 |
706 saved_status = gaim_savedstatus_find(dialog->original_title); | 720 saved_status = gaim_savedstatus_find(dialog->original_title); |
707 | 721 |
708 if (status_window_find_savedstatus(&iter, dialog->original_title)) | 722 if (status_window_find_savedstatus(&iter, dialog->original_title)) |
709 { | |
710 gtk_list_store_remove(status_window->model, &iter); | 723 gtk_list_store_remove(status_window->model, &iter); |
711 } | |
712 } | 724 } |
713 | 725 |
714 if (saved_status == NULL) | 726 if (saved_status == NULL) |
715 { | 727 { |
716 /* This is a new status */ | 728 /* This is a new status */ |
733 else | 745 else |
734 gaim_savedstatus_set_message(saved_status, message); | 746 gaim_savedstatus_set_message(saved_status, message); |
735 | 747 |
736 /* Set any substatuses */ | 748 /* Set any substatuses */ |
737 model = GTK_TREE_MODEL(dialog->model); | 749 model = GTK_TREE_MODEL(dialog->model); |
738 if (gtk_tree_model_get_iter_first(model, &iter)) { | 750 if (gtk_tree_model_get_iter_first(model, &iter)) |
751 { | |
739 do { | 752 do { |
740 GaimAccount *account; | 753 GaimAccount *account; |
741 gboolean enabled; | 754 gboolean enabled; |
742 char *id; | 755 char *id; |
743 char *message; | 756 char *message; |
760 } | 773 } |
761 | 774 |
762 g_free(message); | 775 g_free(message); |
763 g_free(unformatted); | 776 g_free(unformatted); |
764 | 777 |
778 status_editor_remove_dialog(dialog); | |
765 gtk_widget_destroy(dialog->window); | 779 gtk_widget_destroy(dialog->window); |
766 g_free(dialog->original_title); | 780 g_free(dialog->original_title); |
767 | 781 |
768 if (status_window != NULL) | 782 if (status_window != NULL) |
769 add_status_to_saved_status_list(status_window->model, saved_status); | 783 add_status_to_saved_status_list(status_window->model, saved_status); |
770 | 784 |
771 /* If they clicked on "Save & Use" or "Use," then activate the status */ | 785 /* If they clicked on "Save & Use" or "Use," then activate the status */ |
772 if (button != dialog->save_button) | 786 if (button != dialog->save_button) |
773 gaim_savedstatus_activate(saved_status); | 787 gaim_savedstatus_activate(saved_status); |
788 | |
774 g_free(dialog); | 789 g_free(dialog); |
775 } | 790 } |
776 | 791 |
777 static void | 792 static void |
778 editor_title_changed_cb(GtkWidget *widget, gpointer user_data) | 793 editor_title_changed_cb(GtkWidget *widget, gpointer user_data) |
848 { | 863 { |
849 edit_substatus(dialog, account); | 864 edit_substatus(dialog, account); |
850 } | 865 } |
851 else | 866 else |
852 { | 867 { |
853 GaimSavedStatus *saved_status; | |
854 | |
855 /* Remove the substatus */ | 868 /* Remove the substatus */ |
856 saved_status = gaim_savedstatus_find(dialog->original_title); | |
857 gaim_savedstatus_unset_substatus(saved_status, account); | |
858 gtk_list_store_set(dialog->model, &iter, | 869 gtk_list_store_set(dialog->model, &iter, |
859 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, enabled, | 870 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, enabled, |
860 STATUS_EDITOR_COLUMN_STATUS_ID, NULL, | 871 STATUS_EDITOR_COLUMN_STATUS_ID, NULL, |
861 STATUS_EDITOR_COLUMN_STATUS_NAME, NULL, | 872 STATUS_EDITOR_COLUMN_STATUS_NAME, NULL, |
862 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, NULL, | 873 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, NULL, |
1023 g_return_if_fail(saved_status != NULL); | 1034 g_return_if_fail(saved_status != NULL); |
1024 g_return_if_fail(!gaim_savedstatus_is_transient(saved_status)); | 1035 g_return_if_fail(!gaim_savedstatus_is_transient(saved_status)); |
1025 } | 1036 } |
1026 | 1037 |
1027 /* Find a possible window for this saved status and present it */ | 1038 /* Find a possible window for this saved status and present it */ |
1028 if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) | 1039 if (edit && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) |
1029 { | 1040 { |
1030 gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter, | 1041 gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter, |
1031 STATUS_WINDOW_COLUMN_WINDOW, &dialog, | 1042 STATUS_WINDOW_COLUMN_WINDOW, &dialog, |
1032 -1); | 1043 -1); |
1033 if (dialog != NULL) | 1044 if (dialog != NULL) |
1036 return; | 1047 return; |
1037 } | 1048 } |
1038 } | 1049 } |
1039 | 1050 |
1040 dialog = g_new0(StatusEditor, 1); | 1051 dialog = g_new0(StatusEditor, 1); |
1041 if (edit && (status_window != NULL) && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) | 1052 if (edit && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status))) |
1042 { | 1053 { |
1043 gtk_list_store_set(status_window->model, &iter, | 1054 gtk_list_store_set(status_window->model, &iter, |
1044 STATUS_WINDOW_COLUMN_WINDOW, dialog, | 1055 STATUS_WINDOW_COLUMN_WINDOW, dialog, |
1045 -1); | 1056 -1); |
1046 } | 1057 } |
1228 static void | 1239 static void |
1229 substatus_selection_changed_cb(GtkComboBox *box, gpointer user_data) | 1240 substatus_selection_changed_cb(GtkComboBox *box, gpointer user_data) |
1230 { | 1241 { |
1231 SubStatusEditor *select = user_data; | 1242 SubStatusEditor *select = user_data; |
1232 GtkTreeIter iter; | 1243 GtkTreeIter iter; |
1233 GaimAccount *account; | |
1234 char *id; | 1244 char *id; |
1235 GaimStatusType *type; | 1245 GaimStatusType *type; |
1236 | 1246 |
1237 if (!gtk_combo_box_get_active_iter(box, &iter)) | 1247 if (!gtk_combo_box_get_active_iter(box, &iter)) |
1238 return; | 1248 return; |
1239 gtk_tree_model_get(GTK_TREE_MODEL(select->model), &iter, | 1249 gtk_tree_model_get(GTK_TREE_MODEL(select->model), &iter, |
1240 SUBSTATUS_COLUMN_ACCOUNT, &account, | |
1241 SUBSTATUS_COLUMN_STATUS_ID, &id, | 1250 SUBSTATUS_COLUMN_STATUS_ID, &id, |
1242 -1); | 1251 -1); |
1243 type = gaim_account_get_status_type(account, id); | 1252 type = gaim_account_get_status_type(select->account, id); |
1244 g_free(id); | 1253 g_free(id); |
1245 | 1254 |
1246 if (gaim_status_type_get_attr(type, "message") == NULL) | 1255 if (gaim_status_type_get_attr(type, "message") == NULL) |
1247 { | 1256 { |
1248 gtk_widget_set_sensitive(GTK_WIDGET(select->message), FALSE); | 1257 gtk_widget_set_sensitive(GTK_WIDGET(select->message), FALSE); |
1269 model = GTK_TREE_MODEL(status_editor->model); | 1278 model = GTK_TREE_MODEL(status_editor->model); |
1270 | 1279 |
1271 if (!gtk_tree_model_get_iter_first(model, iter)) | 1280 if (!gtk_tree_model_get_iter_first(model, iter)) |
1272 return FALSE; | 1281 return FALSE; |
1273 | 1282 |
1274 gtk_tree_model_get(model, iter, STATUS_EDITOR_COLUMN_ACCOUNT, &cur, -1); | 1283 do { |
1275 if (cur == account) | |
1276 return TRUE; | |
1277 | |
1278 while (gtk_tree_model_iter_next(model, iter)) | |
1279 { | |
1280 gtk_tree_model_get(model, iter, STATUS_EDITOR_COLUMN_ACCOUNT, &cur, -1); | 1284 gtk_tree_model_get(model, iter, STATUS_EDITOR_COLUMN_ACCOUNT, &cur, -1); |
1281 if (cur == account) | 1285 if (cur == account) |
1282 return TRUE; | 1286 return TRUE; |
1283 } | 1287 } while (gtk_tree_model_iter_next(model, iter)); |
1284 | 1288 |
1285 return FALSE; | 1289 return FALSE; |
1286 } | 1290 } |
1287 | 1291 |
1288 static void | 1292 static void |
1289 substatus_editor_remove_dialog(SubStatusEditor *dialog) | 1293 substatus_editor_remove_dialog(SubStatusEditor *dialog) |
1290 { | 1294 { |
1291 GtkTreeIter iter; | 1295 GtkTreeIter iter; |
1292 GaimAccount *account; | 1296 |
1293 | 1297 if (status_editor_find_account_in_treemodel(&iter, dialog->status_editor, dialog->account)) |
1294 gtk_combo_box_get_active_iter(dialog->box, &iter); | 1298 { |
1295 | 1299 /* Remove the reference to this dialog from our parent's list store */ |
1296 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, | |
1297 SUBSTATUS_COLUMN_ACCOUNT, &account, | |
1298 -1); | |
1299 | |
1300 if (status_editor_find_account_in_treemodel(&iter, dialog->status_editor, account)) { | |
1301 gtk_list_store_set(dialog->status_editor->model, &iter, | 1300 gtk_list_store_set(dialog->status_editor->model, &iter, |
1302 STATUS_EDITOR_COLUMN_WINDOW, NULL, | 1301 STATUS_EDITOR_COLUMN_WINDOW, NULL, |
1303 -1); | 1302 -1); |
1304 } | 1303 } |
1305 } | 1304 } |
1306 | 1305 |
1307 static gboolean | 1306 static gboolean |
1308 substatus_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) | 1307 substatus_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) |
1309 { | 1308 { |
1310 SubStatusEditor *dialog = user_data; | 1309 SubStatusEditor *dialog = user_data; |
1310 | |
1311 substatus_editor_remove_dialog(dialog); | 1311 substatus_editor_remove_dialog(dialog); |
1312 | |
1313 g_free(dialog); | 1312 g_free(dialog); |
1314 | 1313 |
1315 return FALSE; | 1314 return FALSE; |
1316 } | 1315 } |
1317 | 1316 |
1318 static void | 1317 static void |
1319 substatus_editor_cancel_cb(GtkButton *button, gpointer user_data) | 1318 substatus_editor_cancel_cb(GtkButton *button, gpointer user_data) |
1320 { | 1319 { |
1321 SubStatusEditor *dialog = user_data; | 1320 SubStatusEditor *dialog = user_data; |
1321 | |
1322 substatus_editor_remove_dialog(dialog); | 1322 substatus_editor_remove_dialog(dialog); |
1323 | |
1324 gtk_widget_destroy(dialog->window); | 1323 gtk_widget_destroy(dialog->window); |
1325 | |
1326 g_free(dialog); | 1324 g_free(dialog); |
1327 } | 1325 } |
1328 | 1326 |
1329 | 1327 |
1330 static void | 1328 static void |
1331 substatus_editor_ok_cb(GtkButton *button, gpointer user_data) | 1329 substatus_editor_ok_cb(GtkButton *button, gpointer user_data) |
1332 { | 1330 { |
1333 SubStatusEditor *dialog = user_data; | 1331 SubStatusEditor *dialog = user_data; |
1334 StatusEditor *status_editor; | 1332 StatusEditor *status_editor; |
1335 GtkTreeIter iter; | 1333 GtkTreeIter iter; |
1336 GaimAccount *account; | |
1337 GaimStatusType *type; | 1334 GaimStatusType *type; |
1338 char *id = NULL; | 1335 char *id = NULL; |
1339 char *message = NULL; | 1336 char *message = NULL; |
1340 const char *name = NULL; | 1337 const char *name = NULL; |
1341 | 1338 |
1342 if (!gtk_combo_box_get_active_iter(dialog->box, &iter)) { | 1339 if (!gtk_combo_box_get_active_iter(dialog->box, &iter)) |
1340 { | |
1343 gtk_widget_destroy(dialog->window); | 1341 gtk_widget_destroy(dialog->window); |
1344 g_free(dialog); | 1342 g_free(dialog); |
1345 return; | 1343 return; |
1346 } | 1344 } |
1347 | 1345 |
1348 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, | 1346 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, |
1349 SUBSTATUS_COLUMN_ACCOUNT, &account, | |
1350 SUBSTATUS_COLUMN_STATUS_ID, &id, | 1347 SUBSTATUS_COLUMN_STATUS_ID, &id, |
1351 -1); | 1348 -1); |
1352 type = gaim_account_get_status_type(account, id); | 1349 type = gaim_account_get_status_type(dialog->account, id); |
1353 if (gaim_status_type_get_attr(type, "message") != NULL) | 1350 if (gaim_status_type_get_attr(type, "message") != NULL) |
1354 message = gtk_imhtml_get_text(GTK_IMHTML(dialog->message), NULL, NULL); | 1351 message = gtk_imhtml_get_text(GTK_IMHTML(dialog->message), NULL, NULL); |
1355 name = gaim_status_type_get_name(type); | 1352 name = gaim_status_type_get_name(type); |
1356 | 1353 |
1357 status_editor = dialog->status_editor; | 1354 status_editor = dialog->status_editor; |
1358 | 1355 |
1359 if (status_editor_find_account_in_treemodel(&iter, status_editor, account)) | 1356 if (status_editor_find_account_in_treemodel(&iter, status_editor, dialog->account)) |
1360 { | 1357 { |
1361 gtk_list_store_set(status_editor->model, &iter, | 1358 gtk_list_store_set(status_editor->model, &iter, |
1362 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, TRUE, | 1359 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, TRUE, |
1363 STATUS_EDITOR_COLUMN_STATUS_ID, id, | 1360 STATUS_EDITOR_COLUMN_STATUS_ID, id, |
1364 STATUS_EDITOR_COLUMN_STATUS_NAME, name, | 1361 STATUS_EDITOR_COLUMN_STATUS_NAME, name, |
1400 | 1397 |
1401 status_editor_find_account_in_treemodel(&iter, status_editor, account); | 1398 status_editor_find_account_in_treemodel(&iter, status_editor, account); |
1402 gtk_tree_model_get(GTK_TREE_MODEL(status_editor->model), &iter, | 1399 gtk_tree_model_get(GTK_TREE_MODEL(status_editor->model), &iter, |
1403 STATUS_EDITOR_COLUMN_WINDOW, &dialog, | 1400 STATUS_EDITOR_COLUMN_WINDOW, &dialog, |
1404 -1); | 1401 -1); |
1405 if (dialog) { | 1402 if (dialog != NULL) |
1403 { | |
1406 gtk_window_present(GTK_WINDOW(dialog->window)); | 1404 gtk_window_present(GTK_WINDOW(dialog->window)); |
1407 return; | 1405 return; |
1408 } | 1406 } |
1409 | 1407 |
1410 dialog = g_new0(SubStatusEditor, 1); | 1408 dialog = g_new0(SubStatusEditor, 1); |
1411 gtk_list_store_set(status_editor->model, &iter, | 1409 gtk_list_store_set(status_editor->model, &iter, |
1412 STATUS_EDITOR_COLUMN_WINDOW, dialog, | 1410 STATUS_EDITOR_COLUMN_WINDOW, dialog, |
1413 -1); | 1411 -1); |
1414 dialog->status_editor = status_editor; | 1412 dialog->status_editor = status_editor; |
1413 dialog->account = account; | |
1415 | 1414 |
1416 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 1415 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
1417 gtk_window_set_role(GTK_WINDOW(win), "substatus"); | 1416 gtk_window_set_role(GTK_WINDOW(win), "substatus"); |
1418 tmp = g_strdup_printf(_("Status for %s"), gaim_account_get_username(account)); | 1417 tmp = g_strdup_printf(_("Status for %s"), gaim_account_get_username(account)); |
1419 gtk_window_set_title(GTK_WINDOW(win), tmp); | 1418 gtk_window_set_title(GTK_WINDOW(win), tmp); |
1421 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); | 1420 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); |
1422 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); | 1421 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); |
1423 | 1422 |
1424 g_signal_connect(G_OBJECT(win), "delete_event", | 1423 g_signal_connect(G_OBJECT(win), "delete_event", |
1425 G_CALLBACK(substatus_editor_destroy_cb), dialog); | 1424 G_CALLBACK(substatus_editor_destroy_cb), dialog); |
1426 g_signal_connect(G_OBJECT(status_editor->window), "destroy", | |
1427 G_CALLBACK(substatus_editor_cancel_cb), dialog); | |
1428 | 1425 |
1429 /* Setup the vbox */ | 1426 /* Setup the vbox */ |
1430 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); | 1427 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
1431 gtk_container_add(GTK_CONTAINER(win), vbox); | 1428 gtk_container_add(GTK_CONTAINER(win), vbox); |
1432 gtk_widget_show(vbox); | 1429 gtk_widget_show(vbox); |
1443 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 1440 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1444 gtk_widget_show(label); | 1441 gtk_widget_show(label); |
1445 gtk_size_group_add_widget(sg, label); | 1442 gtk_size_group_add_widget(sg, label); |
1446 | 1443 |
1447 dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS, | 1444 dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS, |
1448 G_TYPE_POINTER, | |
1449 GDK_TYPE_PIXBUF, | 1445 GDK_TYPE_PIXBUF, |
1450 G_TYPE_STRING, | 1446 G_TYPE_STRING, |
1451 G_TYPE_STRING); | 1447 G_TYPE_STRING); |
1452 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(dialog->model)); | 1448 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(dialog->model)); |
1453 dialog->box = GTK_COMBO_BOX(combo); | 1449 dialog->box = GTK_COMBO_BOX(combo); |
1544 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); | 1540 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); |
1545 name = gaim_status_type_get_name(status_type); | 1541 name = gaim_status_type_get_name(status_type); |
1546 | 1542 |
1547 gtk_list_store_append(dialog->model, &iter); | 1543 gtk_list_store_append(dialog->model, &iter); |
1548 gtk_list_store_set(dialog->model, &iter, | 1544 gtk_list_store_set(dialog->model, &iter, |
1549 SUBSTATUS_COLUMN_ACCOUNT, account, | |
1550 SUBSTATUS_COLUMN_ICON, pixbuf, | 1545 SUBSTATUS_COLUMN_ICON, pixbuf, |
1551 SUBSTATUS_COLUMN_STATUS_ID, id, | 1546 SUBSTATUS_COLUMN_STATUS_ID, id, |
1552 SUBSTATUS_COLUMN_STATUS_NAME, name, | 1547 SUBSTATUS_COLUMN_STATUS_NAME, name, |
1553 -1); | 1548 -1); |
1554 if (pixbuf != NULL) | 1549 if (pixbuf != NULL) |
1609 for (cur = sorted, i = 0; | 1604 for (cur = sorted, i = 0; |
1610 cur != NULL; | 1605 cur != NULL; |
1611 cur = g_list_next(cur)) | 1606 cur = g_list_next(cur)) |
1612 { | 1607 { |
1613 GaimSavedStatus *status = (GaimSavedStatus *)cur->data; | 1608 GaimSavedStatus *status = (GaimSavedStatus *)cur->data; |
1614 if (!gaim_savedstatus_is_transient(status)) { | 1609 if (!gaim_savedstatus_is_transient(status)) |
1610 { | |
1615 gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), | 1611 gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), |
1616 gaim_savedstatus_get_title(status)); | 1612 gaim_savedstatus_get_title(status)); |
1617 if (status == current_status) | 1613 if (status == current_status) |
1618 index = i; | 1614 index = i; |
1619 i++; | 1615 i++; |