Mercurial > pidgin
comparison src/gtkstatusbox.c @ 13121:e2a94ab60a7e
[gaim-migrate @ 15483]
Set the text on the gtkstatusbox based on gaim_savedstatus_get_current()
instead of based on the active menu item in the status dropdown.
This fixes what is shown on the status box when using an unpopular status.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 04 Feb 2006 21:42:02 +0000 |
parents | 328e8cf2fb02 |
children | d33a225fcb80 |
comparison
equal
deleted
inserted
replaced
13120:f62d14ba98f6 | 13121:e2a94ab60a7e |
---|---|
312 char *text = NULL, *title; | 312 char *text = NULL, *title; |
313 char aa_color[8]; | 313 char aa_color[8]; |
314 GdkPixbuf *pixbuf; | 314 GdkPixbuf *pixbuf; |
315 GtkTreePath *path; | 315 GtkTreePath *path; |
316 GtkStyle *style; | 316 GtkStyle *style; |
317 | 317 GaimSavedStatus *saved_status; |
318 gboolean show_buddy_icons; | |
319 | |
320 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); | |
318 style = gtk_widget_get_style(GTK_WIDGET(status_box)); | 321 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
319 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | 322 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
320 style->text_aa[GTK_STATE_NORMAL].red >> 8, | 323 style->text_aa[GTK_STATE_NORMAL].red >> 8, |
321 style->text_aa[GTK_STATE_NORMAL].green >> 8, | 324 style->text_aa[GTK_STATE_NORMAL].green >> 8, |
322 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | 325 style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
323 | 326 |
324 if (status_box->title != NULL) | 327 saved_status = gaim_savedstatus_get_current(); |
325 title = g_markup_escape_text(status_box->title, -1); | 328 |
326 else | 329 title = g_markup_escape_text(gaim_savedstatus_get_title(saved_status), -1); |
327 title = g_strdup(""); | |
328 | 330 |
329 if (status_box->error) { | 331 if (status_box->error) { |
330 gchar *tmp = g_markup_escape_text(status_box->error, -1); | 332 gchar *tmp = g_markup_escape_text(status_box->error, -1); |
331 text = g_strdup_printf("<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", | 333 text = g_strdup_printf("<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", |
332 tmp); | 334 tmp); |
335 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", | 337 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", |
336 aa_color, _("Typing")); | 338 aa_color, _("Typing")); |
337 } else if (status_box->connecting) { | 339 } else if (status_box->connecting) { |
338 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", | 340 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", |
339 aa_color, _("Connecting")); | 341 aa_color, _("Connecting")); |
340 } else if (status_box->desc) { | 342 } else if (!gaim_savedstatus_is_transient(saved_status)) { |
341 gchar *tmp = g_markup_escape_text(status_box->desc, -1); | 343 const gchar *message; |
342 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", | 344 message = gaim_savedstatus_get_message(saved_status); |
343 aa_color, tmp); | 345 if (message != NULL) |
344 g_free(tmp); | 346 { |
345 } | 347 gchar *stripped; |
346 | 348 stripped = gaim_markup_strip_html(message); |
347 if (status_box->account) { | 349 gaim_util_chrreplace(stripped, '\n', ' '); |
348 char *text2 = g_strdup_printf("%s\n<span size=\"smaller\">%s</span>", | 350 text = g_strdup_printf("<span size=\"smaller\" color=\"%s\">%s</span>", |
351 aa_color, stripped); | |
352 g_free(stripped); | |
353 } | |
354 } | |
355 | |
356 if (status_box->account != NULL) { | |
357 char *tmp = g_strdup_printf("%s\n<span size=\"smaller\">%s</span>", | |
349 gaim_account_get_username(status_box->account), | 358 gaim_account_get_username(status_box->account), |
350 text ? text : title); | 359 text ? text : title); |
351 g_free(text); | 360 g_free(text); |
352 text = text2; | 361 text = tmp; |
353 } else if (text) { | 362 } else if (text != NULL) { |
354 char *text2 = g_strdup_printf("%s\n%s", title, text); | 363 char *separator; |
364 char *tmp; | |
365 separator = show_buddy_icons ? "\n" : " - "; | |
366 tmp = g_strdup_printf("%s%s%s", title, separator, text); | |
355 g_free(text); | 367 g_free(text); |
356 text = text2; | 368 text = tmp; |
357 } else { | 369 } else { |
358 text = g_strdup(title); | 370 text = g_strdup(title); |
359 } | 371 } |
360 g_free(title); | 372 g_free(title); |
361 | 373 |
374 /* Figure out what pixbuf to use */ | |
362 if (status_box->connecting) | 375 if (status_box->connecting) |
363 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | 376 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; |
364 else if (status_box->error) | 377 else if (status_box->error) |
365 pixbuf = status_box->error_pixbuf; | 378 pixbuf = status_box->error_pixbuf; |
366 else if (status_box->typing) | 379 else if (status_box->typing) |
367 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | 380 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; |
368 else | 381 else |
369 pixbuf = status_box->pixbuf; | 382 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
383 gaim_savedstatus_get_type(saved_status), | |
384 show_buddy_icons ? 1.0 : 0.5); | |
370 | 385 |
371 /* | 386 /* |
372 * Only two columns are used in this list store (does it | 387 * Only two columns are used in this list store (does it |
373 * really need to be a list store?) | 388 * really need to be a list store?) |
374 */ | 389 */ |
515 GaimSavedStatus *saved = cur->data; | 530 GaimSavedStatus *saved = cur->data; |
516 const gchar *message; | 531 const gchar *message; |
517 gchar *stripped = NULL; | 532 gchar *stripped = NULL; |
518 | 533 |
519 /* Get an appropriate status icon */ | 534 /* Get an appropriate status icon */ |
520 pixbuf = gaim_gtk_create_gaim_icon_with_status(gaim_savedstatus_get_type(saved), | 535 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
536 gaim_savedstatus_get_type(saved), | |
521 show_buddy_icons ? 1.0 : 0.5); | 537 show_buddy_icons ? 1.0 : 0.5); |
522 | 538 |
523 if (gaim_savedstatus_is_transient(saved)) | 539 if (gaim_savedstatus_is_transient(saved)) |
524 { | 540 { |
525 /* | 541 /* |
744 | 760 |
745 static void | 761 static void |
746 current_status_pref_changed_cb(const char *name, GaimPrefType type, | 762 current_status_pref_changed_cb(const char *name, GaimPrefType type, |
747 gconstpointer val, gpointer data) | 763 gconstpointer val, gpointer data) |
748 { | 764 { |
749 GtkGaimStatusBox *box = data; | 765 GtkGaimStatusBox *status_box = data; |
750 | 766 |
751 /* Make sure our current status is added to the list of popular statuses */ | 767 /* Make sure our current status is added to the list of popular statuses */ |
752 gtk_gaim_status_box_regenerate(box); | 768 gtk_gaim_status_box_regenerate(status_box); |
753 | 769 |
754 if (box->account) | 770 if (status_box->account != NULL) |
755 update_to_reflect_account_status(box, box->account, | 771 update_to_reflect_account_status(status_box, status_box->account, |
756 gaim_account_get_active_status(box->account)); | 772 gaim_account_get_active_status(status_box->account)); |
757 else | 773 else |
758 update_to_reflect_current_status(box); | 774 update_to_reflect_current_status(status_box); |
775 | |
776 gtk_gaim_status_box_refresh(status_box); | |
759 } | 777 } |
760 | 778 |
761 static void | 779 static void |
762 buddy_list_details_pref_changed_cb(const char *name, GaimPrefType type, | 780 buddy_list_details_pref_changed_cb(const char *name, GaimPrefType type, |
763 gconstpointer val, gpointer data) | 781 gconstpointer val, gpointer data) |
764 { | 782 { |
765 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; | 783 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; |
766 | 784 |
767 cache_pixbufs(status_box); | 785 cache_pixbufs(status_box); |
768 gtk_gaim_status_box_regenerate(status_box); | 786 gtk_gaim_status_box_regenerate(status_box); |
769 update_size(status_box); | 787 gtk_gaim_status_box_refresh(status_box); |
770 } | 788 } |
771 | 789 |
772 static void | 790 static void |
773 spellcheck_prefs_cb(const char *name, GaimPrefType type, | 791 spellcheck_prefs_cb(const char *name, GaimPrefType type, |
774 gconstpointer value, gpointer data) | 792 gconstpointer value, gpointer data) |
826 GtkTextBuffer *buffer; | 844 GtkTextBuffer *buffer; |
827 | 845 |
828 status_box->imhtml_visible = FALSE; | 846 status_box->imhtml_visible = FALSE; |
829 status_box->connecting = FALSE; | 847 status_box->connecting = FALSE; |
830 status_box->typing = FALSE; | 848 status_box->typing = FALSE; |
831 status_box->title = NULL; | |
832 status_box->pixbuf = NULL; | 849 status_box->pixbuf = NULL; |
833 status_box->toggle_button = gtk_toggle_button_new(); | 850 status_box->toggle_button = gtk_toggle_button_new(); |
834 status_box->hbox = gtk_hbox_new(FALSE, 6); | 851 status_box->hbox = gtk_hbox_new(FALSE, 6); |
835 status_box->cell_view = gtk_cell_view_new(); | 852 status_box->cell_view = gtk_cell_view_new(); |
836 status_box->vsep = gtk_vseparator_new(); | 853 status_box->vsep = gtk_vseparator_new(); |
1336 TITLE_COLUMN, &text, | 1353 TITLE_COLUMN, &text, |
1337 DESC_COLUMN, &desc, | 1354 DESC_COLUMN, &desc, |
1338 ICON_COLUMN, &pixbuf, | 1355 ICON_COLUMN, &pixbuf, |
1339 DATA_COLUMN, &data, | 1356 DATA_COLUMN, &data, |
1340 -1); | 1357 -1); |
1341 if (status_box->title) | |
1342 g_free(status_box->title); | |
1343 status_box->title = text; | |
1344 if (status_box->desc && desc) | |
1345 g_free(status_box->desc); | |
1346 status_box->desc = desc; | |
1347 if (status_box->pixbuf) | 1358 if (status_box->pixbuf) |
1348 g_object_unref(status_box->pixbuf); | 1359 g_object_unref(status_box->pixbuf); |
1349 status_box->pixbuf = pixbuf; | 1360 status_box->pixbuf = pixbuf; |
1350 if (status_box->typing) | 1361 if (status_box->typing) |
1351 g_source_remove(status_box->typing); | 1362 g_source_remove(status_box->typing); |
1363 } | 1374 } |
1364 | 1375 |
1365 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) | 1376 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
1366 { | 1377 { |
1367 gaim_gtk_status_editor_show(NULL); | 1378 gaim_gtk_status_editor_show(NULL); |
1379 // TODO: This shouldn't be neccessary? | |
1368 update_to_reflect_current_status(status_box); | 1380 update_to_reflect_current_status(status_box); |
1369 return; | 1381 return; |
1370 } | 1382 } |
1371 | 1383 |
1372 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) | 1384 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
1373 { | 1385 { |
1374 gaim_gtk_status_window_show(); | 1386 gaim_gtk_status_window_show(); |
1387 // TODO: This shouldn't be neccessary? | |
1375 update_to_reflect_current_status(status_box); | 1388 update_to_reflect_current_status(status_box); |
1376 return; | 1389 return; |
1377 } | 1390 } |
1378 } | 1391 } |
1379 | 1392 |