pidgin/gtkstatusbox.c

branch
next.minor
changeset 29628
7ba47b28bda9
parent 29496
8807ee3e55c5
parent 28781
aa9d7de793fb
child 29686
f9dee36112d0
equal deleted inserted replaced
29627:06ed2b4fb291 29628:7ba47b28bda9
77 static gint get_statusbox_index(PidginStatusBox *box, PurpleSavedStatus *saved_status); 77 static gint get_statusbox_index(PidginStatusBox *box, PurpleSavedStatus *saved_status);
78 static PurpleAccount* check_active_accounts_for_identical_statuses(void); 78 static PurpleAccount* check_active_accounts_for_identical_statuses(void);
79 79
80 static void pidgin_status_box_pulse_typing(PidginStatusBox *status_box); 80 static void pidgin_status_box_pulse_typing(PidginStatusBox *status_box);
81 static void pidgin_status_box_refresh(PidginStatusBox *status_box); 81 static void pidgin_status_box_refresh(PidginStatusBox *status_box);
82 static void status_menu_refresh_iter(PidginStatusBox *status_box); 82 static void status_menu_refresh_iter(PidginStatusBox *status_box, gboolean status_changed);
83 static void pidgin_status_box_regenerate(PidginStatusBox *status_box); 83 static void pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed);
84 static void pidgin_status_box_changed(PidginStatusBox *box); 84 static void pidgin_status_box_changed(PidginStatusBox *box);
85 static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); 85 static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition);
86 static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); 86 static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
87 static gboolean pidgin_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); 87 static gboolean pidgin_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event);
88 static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box); 88 static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box);
302 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, PurpleStatus *newstatus, PidginStatusBox *status_box) 302 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, PurpleStatus *newstatus, PidginStatusBox *status_box)
303 { 303 {
304 if (status_box->account == account) 304 if (status_box->account == account)
305 update_to_reflect_account_status(status_box, account, newstatus); 305 update_to_reflect_account_status(status_box, account, newstatus);
306 else if (status_box->token_status_account == account) 306 else if (status_box->token_status_account == account)
307 status_menu_refresh_iter(status_box); 307 status_menu_refresh_iter(status_box, TRUE);
308 } 308 }
309 309
310 static gboolean 310 static gboolean
311 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box) 311 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box)
312 { 312 {
313 if (event->button == 3) { 313 if (event->button == 3) {
314 GtkWidget *menu_item; 314 GtkWidget *menu_item;
315 const char *path;
315 316
316 if (box->icon_box_menu) 317 if (box->icon_box_menu)
317 gtk_widget_destroy(box->icon_box_menu); 318 gtk_widget_destroy(box->icon_box_menu);
318 319
319 box->icon_box_menu = gtk_menu_new(); 320 box->icon_box_menu = gtk_menu_new();
323 box, 0, 0, NULL); 324 box, 0, 0, NULL);
324 325
325 menu_item = pidgin_new_item_from_stock(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE, 326 menu_item = pidgin_new_item_from_stock(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE,
326 G_CALLBACK(remove_buddy_icon_cb), 327 G_CALLBACK(remove_buddy_icon_cb),
327 box, 0, 0, NULL); 328 box, 0, 0, NULL);
328 if (purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon") == NULL) 329 if (!(path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"))
330 || !*path)
329 gtk_widget_set_sensitive(menu_item, FALSE); 331 gtk_widget_set_sensitive(menu_item, FALSE);
330 332
331 gtk_menu_popup(GTK_MENU(box->icon_box_menu), NULL, NULL, NULL, NULL, 333 gtk_menu_popup(GTK_MENU(box->icon_box_menu), NULL, NULL, NULL, NULL,
332 event->button, event->time); 334 event->button, event->time);
333 335
557 if (statusbox->account) 559 if (statusbox->account)
558 statusbox->token_status_account = NULL; 560 statusbox->token_status_account = NULL;
559 else 561 else
560 statusbox->token_status_account = check_active_accounts_for_identical_statuses(); 562 statusbox->token_status_account = check_active_accounts_for_identical_statuses();
561 563
562 pidgin_status_box_regenerate(statusbox); 564 pidgin_status_box_regenerate(statusbox, TRUE);
563 565
564 break; 566 break;
565 default: 567 default:
566 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); 568 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
567 break; 569 break;
819 * 821 *
820 * Maybe we could accomplish this by triggering off the mouse and 822 * Maybe we could accomplish this by triggering off the mouse and
821 * keyboard signals instead of the changed signal? 823 * keyboard signals instead of the changed signal?
822 */ 824 */
823 static void 825 static void
824 status_menu_refresh_iter(PidginStatusBox *status_box) 826 status_menu_refresh_iter(PidginStatusBox *status_box, gboolean status_changed)
825 { 827 {
826 PurpleSavedStatus *saved_status; 828 PurpleSavedStatus *saved_status;
827 PurpleStatusPrimitive primitive; 829 PurpleStatusPrimitive primitive;
828 gint index; 830 gint index;
829 const char *message; 831 const char *message;
910 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path); 912 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path);
911 gtk_tree_path_free(path); 913 gtk_tree_path_free(path);
912 } else 914 } else
913 status_box->active_row = NULL; 915 status_box->active_row = NULL;
914 916
915 message = purple_savedstatus_get_message(saved_status); 917 if (status_changed) {
916 if (!purple_savedstatus_is_transient(saved_status) || !message || !*message) 918 message = purple_savedstatus_get_message(saved_status);
917 {
918 status_box->imhtml_visible = FALSE;
919 gtk_widget_hide_all(status_box->vbox);
920 }
921 else
922 {
923 status_box->imhtml_visible = TRUE;
924 gtk_widget_show_all(status_box->vbox);
925 919
926 /* 920 /*
921 * If we are going to hide the imhtml, don't retain the
922 * message because showing the old message later is
923 * confusing. If we are going to set the message to a pre-set,
924 * then we need to do this anyway
925 *
927 * Suppress the "changed" signal because the status 926 * Suppress the "changed" signal because the status
928 * was changed programmatically. 927 * was changed programmatically.
929 */ 928 */
930 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); 929 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE);
931 930
932 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); 931 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml));
933 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); 932 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml));
934 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); 933
934 if (!purple_savedstatus_is_transient(saved_status) || !message || !*message)
935 {
936 status_box->imhtml_visible = FALSE;
937 gtk_widget_hide_all(status_box->vbox);
938 }
939 else
940 {
941 status_box->imhtml_visible = TRUE;
942 gtk_widget_show_all(status_box->vbox);
943
944 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0);
945 }
946
935 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); 947 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE);
936 } 948 update_size(status_box);
937 949 }
938 update_size(status_box);
939 950
940 /* Stop suppressing the "changed" signal. */ 951 /* Stop suppressing the "changed" signal. */
941 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); 952 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE);
942 } 953 }
943 954
994 1005
995 /* This returns NULL if the active accounts don't have identical 1006 /* This returns NULL if the active accounts don't have identical
996 * statuses and a token account if they do */ 1007 * statuses and a token account if they do */
997 static PurpleAccount* check_active_accounts_for_identical_statuses(void) 1008 static PurpleAccount* check_active_accounts_for_identical_statuses(void)
998 { 1009 {
999 PurpleAccount *acct = NULL, *acct2; 1010 GList *iter, *active_accts = purple_accounts_get_all_active();
1000 GList *tmp, *tmp2, *active_accts = purple_accounts_get_all_active(); 1011 PurpleAccount *acct1 = NULL;
1001 GList *s, *s1, *s2; 1012 const char *prpl1 = NULL;
1002 1013
1003 for (tmp = active_accts; tmp; tmp = tmp->next) { 1014 if (active_accts) {
1004 acct = tmp->data; 1015 acct1 = active_accts->data;
1005 s = purple_account_get_status_types(acct); 1016 prpl1 = purple_account_get_protocol_id(acct1);
1006 for (tmp2 = tmp->next; tmp2; tmp2 = tmp2->next) { 1017 } else {
1007 acct2 = tmp2->data; 1018 /* there's no enabled account */
1008 1019 return NULL;
1009 /* Only actually look at the statuses if the accounts use the same prpl */ 1020 }
1010 if (strcmp(purple_account_get_protocol_id(acct), purple_account_get_protocol_id(acct2))) { 1021
1011 acct = NULL; 1022 /* start at the second account */
1023 for (iter = active_accts->next; iter; iter = iter->next) {
1024 PurpleAccount *acct2 = iter->data;
1025 GList *s1, *s2;
1026
1027 if (!g_str_equal(prpl1, purple_account_get_protocol_id(acct2))) {
1028 acct1 = NULL;
1029 break;
1030 }
1031
1032 for (s1 = purple_account_get_status_types(acct1),
1033 s2 = purple_account_get_status_types(acct2); s1 && s2;
1034 s1 = s1->next, s2 = s2->next) {
1035 PurpleStatusType *st1 = s1->data, *st2 = s2->data;
1036 /* TODO: Are these enough to consider the statuses identical? */
1037 if (purple_status_type_get_primitive(st1) != purple_status_type_get_primitive(st2)
1038 || strcmp(purple_status_type_get_id(st1), purple_status_type_get_id(st2))
1039 || strcmp(purple_status_type_get_name(st1), purple_status_type_get_name(st2))) {
1040 acct1 = NULL;
1012 break; 1041 break;
1013 } 1042 }
1014 1043 }
1015 s2 = purple_account_get_status_types(acct2); 1044
1016 1045 if (s1 != s2) {/* Will both be NULL if matched */
1017 s1 = s; 1046 acct1 = NULL;
1018 while (s1 && s2) {
1019 PurpleStatusType *st1 = s1->data, *st2 = s2->data;
1020 /* TODO: Are these enough to consider the statuses identical? */
1021 if (purple_status_type_get_primitive(st1) != purple_status_type_get_primitive(st2)
1022 || strcmp(purple_status_type_get_id(st1), purple_status_type_get_id(st2))
1023 || strcmp(purple_status_type_get_name(st1), purple_status_type_get_name(st2))) {
1024 acct = NULL;
1025 break;
1026 }
1027
1028 s1 = s1->next;
1029 s2 = s2->next;
1030 }
1031
1032 if (s1 != s2) {/* Will both be NULL if matched */
1033 acct = NULL;
1034 break;
1035 }
1036 }
1037 if (!acct)
1038 break; 1047 break;
1039 } 1048 }
1049 }
1050
1040 g_list_free(active_accts); 1051 g_list_free(active_accts);
1041 1052
1042 return acct; 1053 return acct1;
1043 } 1054 }
1044 1055
1045 static void 1056 static void
1046 add_account_statuses(PidginStatusBox *status_box, PurpleAccount *account) 1057 add_account_statuses(PidginStatusBox *status_box, PurpleAccount *account)
1047 { 1058 {
1066 GINT_TO_POINTER(purple_status_type_get_primitive(status_type))); 1077 GINT_TO_POINTER(purple_status_type_get_primitive(status_type)));
1067 } 1078 }
1068 } 1079 }
1069 1080
1070 static void 1081 static void
1071 pidgin_status_box_regenerate(PidginStatusBox *status_box) 1082 pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed)
1072 { 1083 {
1073 GtkIconSize icon_size; 1084 GtkIconSize icon_size;
1074 1085
1075 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); 1086 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
1076 1087
1102 1113
1103 pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box)); 1114 pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box));
1104 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New status..."), NULL, NULL); 1115 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New status..."), NULL, NULL);
1105 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved statuses..."), NULL, NULL); 1116 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved statuses..."), NULL, NULL);
1106 1117
1107 status_menu_refresh_iter(status_box); 1118 status_menu_refresh_iter(status_box, status_changed);
1108 pidgin_status_box_refresh(status_box); 1119 pidgin_status_box_refresh(status_box);
1109 1120
1110 } else { 1121 } else {
1111 add_account_statuses(status_box, status_box->account); 1122 add_account_statuses(status_box, status_box->account);
1112 update_to_reflect_account_status(status_box, status_box->account, 1123 update_to_reflect_account_status(status_box, status_box->account,
1154 GTK_IMHTML(status_box->imhtml), TRUE); 1165 GTK_IMHTML(status_box->imhtml), TRUE);
1155 if (status_box->account != NULL) 1166 if (status_box->account != NULL)
1156 update_to_reflect_account_status(status_box, status_box->account, 1167 update_to_reflect_account_status(status_box, status_box->account,
1157 purple_account_get_active_status(status_box->account)); 1168 purple_account_get_active_status(status_box->account));
1158 else { 1169 else {
1159 status_menu_refresh_iter(status_box); 1170 status_menu_refresh_iter(status_box, TRUE);
1160 pidgin_status_box_refresh(status_box); 1171 pidgin_status_box_refresh(status_box);
1161 } 1172 }
1162 return TRUE; 1173 return TRUE;
1163 } 1174 }
1164 1175
1225 1236
1226 status_box->token_status_account = check_active_accounts_for_identical_statuses(); 1237 status_box->token_status_account = check_active_accounts_for_identical_statuses();
1227 1238
1228 /* Regenerate the list if it has changed */ 1239 /* Regenerate the list if it has changed */
1229 if (initial_token_acct != status_box->token_status_account) { 1240 if (initial_token_acct != status_box->token_status_account) {
1230 pidgin_status_box_regenerate(status_box); 1241 pidgin_status_box_regenerate(status_box, TRUE);
1231 } 1242 }
1232 1243
1233 } 1244 }
1234 1245
1235 static void 1246 static void
1236 current_savedstatus_changed_cb(PurpleSavedStatus *now, PurpleSavedStatus *old, PidginStatusBox *status_box) 1247 current_savedstatus_changed_cb(PurpleSavedStatus *now, PurpleSavedStatus *old, PidginStatusBox *status_box)
1237 { 1248 {
1238 /* Make sure our current status is added to the list of popular statuses */ 1249 /* Make sure our current status is added to the list of popular statuses */
1239 pidgin_status_box_regenerate(status_box); 1250 pidgin_status_box_regenerate(status_box, TRUE);
1240 } 1251 }
1241 1252
1242 static void 1253 static void
1243 saved_status_updated_cb(PurpleSavedStatus *status, PidginStatusBox *status_box) 1254 saved_status_updated_cb(PurpleSavedStatus *status, PidginStatusBox *status_box)
1244 { 1255 {
1245 pidgin_status_box_regenerate(status_box); 1256 pidgin_status_box_regenerate(status_box,
1257 purple_savedstatus_get_current() == status);
1246 } 1258 }
1247 1259
1248 static void 1260 static void
1249 spellcheck_prefs_cb(const char *name, PurplePrefType type, 1261 spellcheck_prefs_cb(const char *name, PurplePrefType type,
1250 gconstpointer value, gpointer data) 1262 gconstpointer value, gpointer data)
1888 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL); 1900 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL);
1889 1901
1890 status_box->token_status_account = check_active_accounts_for_identical_statuses(); 1902 status_box->token_status_account = check_active_accounts_for_identical_statuses();
1891 1903
1892 cache_pixbufs(status_box); 1904 cache_pixbufs(status_box);
1893 pidgin_status_box_regenerate(status_box); 1905 pidgin_status_box_regenerate(status_box, TRUE);
1894 1906
1895 purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed", 1907 purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed",
1896 status_box, 1908 status_box,
1897 PURPLE_CALLBACK(current_savedstatus_changed_cb), 1909 PURPLE_CALLBACK(current_savedstatus_changed_cb),
1898 status_box); 1910 status_box);
2289 if (!typing_stock_ids[++status_box->typing_index]) 2301 if (!typing_stock_ids[++status_box->typing_index])
2290 status_box->typing_index = 0; 2302 status_box->typing_index = 0;
2291 pidgin_status_box_refresh(status_box); 2303 pidgin_status_box_refresh(status_box);
2292 } 2304 }
2293 2305
2294 static gboolean
2295 message_changed(const char *one, const char *two)
2296 {
2297 if (one == NULL && two == NULL)
2298 return FALSE;
2299
2300 if (one == NULL || two == NULL)
2301 return TRUE;
2302
2303 return (g_utf8_collate(one, two) != 0);
2304 }
2305
2306 static void 2306 static void
2307 activate_currently_selected_status(PidginStatusBox *status_box) 2307 activate_currently_selected_status(PidginStatusBox *status_box)
2308 { 2308 {
2309 PidginStatusBoxItemType type; 2309 PidginStatusBoxItemType type;
2310 gpointer data; 2310 gpointer data;
2351 } 2351 }
2352 } 2352 }
2353 2353
2354 if (status_box->account == NULL) { 2354 if (status_box->account == NULL) {
2355 PurpleStatusType *acct_status_type = NULL; 2355 PurpleStatusType *acct_status_type = NULL;
2356 const char *id = NULL; /* id of acct_status_type */
2356 PurpleStatusPrimitive primitive = GPOINTER_TO_INT(data); 2357 PurpleStatusPrimitive primitive = GPOINTER_TO_INT(data);
2357 /* Global */ 2358 /* Global */
2358 /* Save the newly selected status to prefs.xml and status.xml */ 2359 /* Save the newly selected status to prefs.xml and status.xml */
2359 2360
2360 /* Has the status really been changed? */ 2361 /* Has the status really been changed? */
2361 if (status_box->token_status_account) { 2362 if (status_box->token_status_account) {
2362 gint active; 2363 gint active;
2363 PurpleStatus *status; 2364 PurpleStatus *status;
2364 const char *id = NULL;
2365 GtkTreePath *path = gtk_tree_row_reference_get_path(status_box->active_row); 2365 GtkTreePath *path = gtk_tree_row_reference_get_path(status_box->active_row);
2366 active = gtk_tree_path_get_indices(path)[0]; 2366 active = gtk_tree_path_get_indices(path)[0];
2367 2367
2368 gtk_tree_path_free(path); 2368 gtk_tree_path_free(path);
2369 2369
2370 status = purple_account_get_active_status(status_box->token_status_account); 2370 status = purple_account_get_active_status(status_box->token_status_account);
2371 2371
2372 acct_status_type = find_status_type_by_index(status_box->token_status_account, active); 2372 acct_status_type = find_status_type_by_index(status_box->token_status_account, active);
2373 id = purple_status_type_get_id(acct_status_type); 2373 id = purple_status_type_get_id(acct_status_type);
2374 2374
2375 if (strncmp(id, purple_status_get_id(status), strlen(id)) == 0) 2375 if (g_str_equal(id, purple_status_get_id(status)) &&
2376 purple_strequal(message, purple_status_get_attr_string(status, "message")))
2376 { 2377 {
2377 /* Selected status and previous status is the same */ 2378 /* Selected status and previous status is the same */
2378 if (!message_changed(message, purple_status_get_attr_string(status, "message"))) 2379 PurpleSavedStatus *ss = purple_savedstatus_get_current();
2379 { 2380 /* Make sure that statusbox displays the correct thing.
2380 PurpleSavedStatus *ss = purple_savedstatus_get_current(); 2381 * It can get messed up if the previous selection was a
2381 /* Make sure that statusbox displays the correct thing. 2382 * saved status that wasn't supported by this account */
2382 * It can get messed up if the previous selection was a 2383 if ((purple_savedstatus_get_type(ss) == primitive)
2383 * saved status that wasn't supported by this account */ 2384 && purple_savedstatus_is_transient(ss)
2384 if ((purple_savedstatus_get_type(ss) == primitive) 2385 && purple_savedstatus_has_substatuses(ss))
2385 && purple_savedstatus_is_transient(ss) 2386 changed = FALSE;
2386 && purple_savedstatus_has_substatuses(ss))
2387 changed = FALSE;
2388 }
2389 } 2387 }
2390 } else { 2388 } else {
2391 saved_status = purple_savedstatus_get_current(); 2389 saved_status = purple_savedstatus_get_current();
2392 if (purple_savedstatus_get_type(saved_status) == primitive && 2390 if (purple_savedstatus_get_type(saved_status) == primitive &&
2393 !purple_savedstatus_has_substatuses(saved_status)) 2391 !purple_savedstatus_has_substatuses(saved_status) &&
2392 purple_strequal(purple_savedstatus_get_message(saved_status), message))
2394 { 2393 {
2395 if (!message_changed(purple_savedstatus_get_message(saved_status), message)) 2394 changed = FALSE;
2396 changed = FALSE;
2397 } 2395 }
2398 } 2396 }
2399 2397
2400 if (changed) 2398 if (changed)
2401 { 2399 {
2402 /* Manually find the appropriate transient acct */ 2400 /* Manually find the appropriate transient status */
2403 if (status_box->token_status_account) { 2401 if (status_box->token_status_account) {
2404 GList *iter = purple_savedstatuses_get_all(); 2402 GList *iter = purple_savedstatuses_get_all();
2405 GList *tmp, *active_accts = purple_accounts_get_all_active(); 2403 GList *tmp, *active_accts = purple_accounts_get_all_active();
2406 2404
2407 for (; iter != NULL; iter = iter->next) { 2405 for (; iter != NULL; iter = iter->next) {
2408 PurpleSavedStatus *ss = iter->data; 2406 PurpleSavedStatus *ss = iter->data;
2409 const char *ss_msg = purple_savedstatus_get_message(ss); 2407 const char *ss_msg = purple_savedstatus_get_message(ss);
2408 /* find a known transient status that is the same as the
2409 * new selected one */
2410 if ((purple_savedstatus_get_type(ss) == primitive) && purple_savedstatus_is_transient(ss) && 2410 if ((purple_savedstatus_get_type(ss) == primitive) && purple_savedstatus_is_transient(ss) &&
2411 purple_savedstatus_has_substatuses(ss) && /* Must have substatuses */ 2411 purple_savedstatus_has_substatuses(ss) && /* Must have substatuses */
2412 !message_changed(ss_msg, message)) 2412 purple_strequal(ss_msg, message))
2413 { 2413 {
2414 gboolean found = FALSE; 2414 gboolean found = FALSE;
2415 /* The currently enabled accounts must have substatuses for all the active accts */ 2415 /* this status must have substatuses for all the active accts */
2416 for(tmp = active_accts; tmp != NULL; tmp = tmp->next) { 2416 for(tmp = active_accts; tmp != NULL; tmp = tmp->next) {
2417 PurpleAccount *acct = tmp->data; 2417 PurpleAccount *acct = tmp->data;
2418 PurpleSavedStatusSub *sub = purple_savedstatus_get_substatus(ss, acct); 2418 PurpleSavedStatusSub *sub = purple_savedstatus_get_substatus(ss, acct);
2419 if (sub) { 2419 if (sub) {
2420 const PurpleStatusType *sub_type = purple_savedstatus_substatus_get_type(sub); 2420 const PurpleStatusType *sub_type = purple_savedstatus_substatus_get_type(sub);
2421 const char *subtype_status_id = purple_status_type_get_id(sub_type); 2421 const char *subtype_status_id = purple_status_type_get_id(sub_type);
2422 if (subtype_status_id && !strcmp(subtype_status_id, 2422 if (purple_strequal(subtype_status_id, id)) {
2423 purple_status_type_get_id(acct_status_type)))
2424 found = TRUE; 2423 found = TRUE;
2424 break;
2425 }
2425 } 2426 }
2426 } 2427 }
2427 if (!found) 2428
2428 continue; 2429 if (found) {
2429 saved_status = ss; 2430 saved_status = ss;
2430 break; 2431 break;
2432 }
2431 } 2433 }
2432 } 2434 }
2433 2435
2434 g_list_free(active_accts); 2436 g_list_free(active_accts);
2435 2437
2468 active = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(status_box), "active")); 2470 active = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(status_box), "active"));
2469 2471
2470 status_type = find_status_type_by_index(status_box->account, active); 2472 status_type = find_status_type_by_index(status_box->account, active);
2471 id = purple_status_type_get_id(status_type); 2473 id = purple_status_type_get_id(status_type);
2472 2474
2473 if (strncmp(id, purple_status_get_id(status), strlen(id)) == 0) 2475 if (g_str_equal(id, purple_status_get_id(status)) &&
2476 purple_strequal(message, purple_status_get_attr_string(status, "message")))
2474 { 2477 {
2475 /* Selected status and previous status is the same */ 2478 /* Selected status and previous status is the same */
2476 if (!message_changed(message, purple_status_get_attr_string(status, "message"))) 2479 changed = FALSE;
2477 changed = FALSE;
2478 } 2480 }
2479 2481
2480 if (changed) 2482 if (changed)
2481 { 2483 {
2482 if (message) 2484 if (message)
2562 static void remove_typing_cb(PidginStatusBox *status_box) 2564 static void remove_typing_cb(PidginStatusBox *status_box)
2563 { 2565 {
2564 if (status_box->typing == 0) 2566 if (status_box->typing == 0)
2565 { 2567 {
2566 /* Nothing has changed, so we don't need to do anything */ 2568 /* Nothing has changed, so we don't need to do anything */
2567 status_menu_refresh_iter(status_box); 2569 status_menu_refresh_iter(status_box, FALSE);
2568 return; 2570 return;
2569 } 2571 }
2570 2572
2571 gtk_imhtml_set_populate_primary_clipboard( 2573 gtk_imhtml_set_populate_primary_clipboard(
2572 GTK_IMHTML(status_box->imhtml), TRUE); 2574 GTK_IMHTML(status_box->imhtml), TRUE);
2620 if (purple_savedstatus_get_type(saved_status) == PURPLE_STATUS_AVAILABLE) 2622 if (purple_savedstatus_get_type(saved_status) == PURPLE_STATUS_AVAILABLE)
2621 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_AWAY); 2623 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_AWAY);
2622 pidgin_status_editor_show(FALSE, 2624 pidgin_status_editor_show(FALSE,
2623 purple_savedstatus_is_transient(saved_status) 2625 purple_savedstatus_is_transient(saved_status)
2624 ? saved_status : NULL); 2626 ? saved_status : NULL);
2625 status_menu_refresh_iter(status_box); 2627 status_menu_refresh_iter(status_box, FALSE);
2626 return; 2628 return;
2627 } 2629 }
2628 2630
2629 if (type == PIDGIN_STATUS_BOX_TYPE_SAVED) 2631 if (type == PIDGIN_STATUS_BOX_TYPE_SAVED)
2630 { 2632 {
2631 pidgin_status_window_show(); 2633 pidgin_status_window_show();
2632 status_menu_refresh_iter(status_box); 2634 status_menu_refresh_iter(status_box, FALSE);
2633 return; 2635 return;
2634 } 2636 }
2635 } 2637 }
2636 2638
2637 /* 2639 /*

mercurial