comparison src/gtkstatusbox.c @ 12595:3169cd6727ad

[gaim-migrate @ 14925] I've been meaning to spend the time to commit these changes separately, but it's been a couple days without me finding the time... 1. Allow the creation of GaimStatusTypes by passing NULL for the name and/or id. The core uses the default name and/or id. This eliminates quite a bit of duplication in the prpls. 2. Make statuses more consistent. For example, in some prpls, "Busy" was descended from the UNAVAILABLE primitive and on others it was a case of AWAY. Another example... "On Vacation" is definitely an EXTENDED_AWAY not an AWAY. 3. Rename some pixmaps to elminate some special cases. The names of the pixmaps should now match the primitive default IDs. 4. Rename the HIDDEN primitive to INVISIBLE, since we seem to be using that term everywhere. In conjunction with #1, more duplication was eliminated. 5. Add a MOBILE status primitive. It's not used now. It'll be needed in the (hopefully not-too-distant) future, so I'm planning ahead. 6. Shrink the status select for small blist folks. Now if someone can get rid of that stupid extra padding, we'll be set (well, after we deal with imhtml space issues). I've fought with this for many many hours over several days and I can't get it. It's clear that the combo box is requesting more space than is really necessary, but I don't know why. This is really my first go at anything significant status-related. Everyone should check their favorite prpls carefully to make sure I didn't break anything. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 21 Dec 2005 08:24:17 +0000
parents 7bbd410442cb
children 037a673ba862
comparison
equal deleted inserted replaced
12594:3d34460ecfd6 12595:3169cd6727ad
342 */ 342 */
343 static void 343 static void
344 update_to_reflect_current_status(GtkGaimStatusBox *status_box) 344 update_to_reflect_current_status(GtkGaimStatusBox *status_box)
345 { 345 {
346 GaimSavedStatus *saved_status; 346 GaimSavedStatus *saved_status;
347 GaimStatusPrimitive primitive; 347 guint index;
348 const char *message; 348 const char *message;
349 349
350 /* this function is inappropriate for ones with accounts */ 350 /* this function is inappropriate for ones with accounts */
351 if (status_box->account) 351 if (status_box->account)
352 return; 352 return;
357 * Suppress the "changed" signal because the status 357 * Suppress the "changed" signal because the status
358 * was changed programmatically. 358 * was changed programmatically.
359 */ 359 */
360 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); 360 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE);
361 361
362 primitive = gaim_savedstatus_get_type(saved_status); 362 if (gaim_savedstatus_has_substatuses(saved_status))
363 if (gaim_savedstatus_has_substatuses(saved_status) || 363 index = 5;
364 ((primitive != GAIM_STATUS_AVAILABLE) &&
365 (primitive != GAIM_STATUS_OFFLINE) &&
366 (primitive != GAIM_STATUS_AWAY) &&
367 (primitive != GAIM_STATUS_HIDDEN)))
368 {
369 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 5);
370 }
371 else 364 else
372 { 365 {
373 if (primitive == GAIM_STATUS_AVAILABLE) 366 switch (gaim_savedstatus_get_type(saved_status))
374 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); 367 {
375 if (primitive == GAIM_STATUS_OFFLINE) 368 case GAIM_STATUS_AVAILABLE:
376 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); 369 index = 0;
377 else if (primitive == GAIM_STATUS_AWAY) 370 break;
378 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); 371 case GAIM_STATUS_AWAY:
379 else if (primitive == GAIM_STATUS_HIDDEN) 372 index = 1;
380 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); 373 break;
381 } 374 case GAIM_STATUS_INVISIBLE:
375 index = 2;
376 break;
377 case GAIM_STATUS_OFFLINE:
378 index = 3;
379 break;
380 default:
381 index = 5;
382 break;
383 }
384 }
385 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index);
382 386
383 message = gaim_savedstatus_get_message(saved_status); 387 message = gaim_savedstatus_get_message(saved_status);
384 if (!message || !*message) 388 if (!message || !*message)
385 { 389 {
386 status_box->imhtml_visible = FALSE; 390 status_box->imhtml_visible = FALSE;
414 { 418 {
415 GaimAccount *account; 419 GaimAccount *account;
416 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; 420 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4;
417 GtkIconSize icon_size; 421 GtkIconSize icon_size;
418 422
419 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); 423 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"))
424 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
425 else
426 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL);
420 427
421 /* Unset the model while clearing it */ 428 /* Unset the model while clearing it */
422 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL); 429 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL);
423 gtk_list_store_clear(status_box->dropdown_store); 430 gtk_list_store_clear(status_box->dropdown_store);
424 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); 431 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store));
435 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE, 442 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE,
436 icon_size, "GtkGaimStatusBox"); 443 icon_size, "GtkGaimStatusBox");
437 /* hacks */ 444 /* hacks */
438 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AVAILABLE, pixbuf, _("Available"), NULL); 445 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AVAILABLE, pixbuf, _("Available"), NULL);
439 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AWAY, pixbuf2, _("Away"), NULL); 446 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AWAY, pixbuf2, _("Away"), NULL);
440 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_HIDDEN, pixbuf4, _("Invisible"), NULL); 447 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_INVISIBLE, pixbuf4, _("Invisible"), NULL);
441 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_OFFLINE, pixbuf3, _("Offline"), NULL); 448 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_OFFLINE, pixbuf3, _("Offline"), NULL);
442 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); 449 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box));
443 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("Custom..."), NULL); 450 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("Custom..."), NULL);
444 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL); 451 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL);
445 452
509 return FALSE; 516 return FALSE;
510 } 517 }
511 #endif 518 #endif
512 519
513 static void 520 static void
521 cache_pixbufs(GtkGaimStatusBox *status_box)
522 {
523 GtkIconSize icon_size;
524
525 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"))
526 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_TWO_LINE);
527 else
528 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL_TWO_LINE);
529
530 if (status_box->error_pixbuf != NULL)
531 gdk_pixbuf_unref(status_box->error_pixbuf);
532
533 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE,
534 icon_size, "GtkGaimStatusBox");
535 if (status_box->connecting_pixbufs[0] != NULL)
536 gdk_pixbuf_unref(status_box->connecting_pixbufs[0]);
537 if (status_box->connecting_pixbufs[1] != NULL)
538 gdk_pixbuf_unref(status_box->connecting_pixbufs[1]);
539 if (status_box->connecting_pixbufs[2] != NULL)
540 gdk_pixbuf_unref(status_box->connecting_pixbufs[2]);
541 if (status_box->connecting_pixbufs[3] != NULL)
542 gdk_pixbuf_unref(status_box->connecting_pixbufs[3]);
543
544 status_box->connecting_index = 0;
545 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT0,
546 icon_size, "GtkGaimStatusBox");
547 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT1,
548 icon_size, "GtkGaimStatusBox");
549 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT2,
550 icon_size, "GtkGaimStatusBox");
551 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT3,
552 icon_size, "GtkGaimStatusBox");
553
554 if (status_box->typing_pixbufs[0] != NULL)
555 gdk_pixbuf_unref(status_box->typing_pixbufs[0]);
556 if (status_box->typing_pixbufs[1] != NULL)
557 gdk_pixbuf_unref(status_box->typing_pixbufs[1]);
558 if (status_box->typing_pixbufs[2] != NULL)
559 gdk_pixbuf_unref(status_box->typing_pixbufs[2]);
560 if (status_box->typing_pixbufs[3] != NULL)
561 gdk_pixbuf_unref(status_box->typing_pixbufs[3]);
562
563 status_box->typing_index = 0;
564 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING0,
565 icon_size, "GtkGaimStatusBox");
566 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING1,
567 icon_size, "GtkGaimStatusBox");
568 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING2,
569 icon_size, "GtkGaimStatusBox");
570 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING3,
571 icon_size, "GtkGaimStatusBox");
572 }
573
574 static void
514 current_status_pref_changed_cb(const char *name, GaimPrefType type, 575 current_status_pref_changed_cb(const char *name, GaimPrefType type,
515 gpointer val, gpointer data) 576 gpointer val, gpointer data)
516 { 577 {
517 GtkGaimStatusBox *box = data; 578 GtkGaimStatusBox *box = data;
518 if (box->account) 579 if (box->account)
519 update_to_reflect_account_status(box, box->account, 580 update_to_reflect_account_status(box, box->account,
520 gaim_account_get_active_status(box->account)); 581 gaim_account_get_active_status(box->account));
521 else 582 else
522 update_to_reflect_current_status(box); 583 update_to_reflect_current_status(box);
584 }
585
586 static void
587 buddy_list_details_pref_changed_cb(const char *name, GaimPrefType type,
588 gpointer val, gpointer data)
589 {
590 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data;
591
592 cache_pixbufs(status_box);
593 gtk_gaim_status_box_regenerate(status_box);
523 } 594 }
524 595
525 #if 0 596 #if 0
526 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) 597 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box)
527 { 598 {
559 GtkWidget *vbox; 630 GtkWidget *vbox;
560 GtkCellRenderer *text_rend; 631 GtkCellRenderer *text_rend;
561 GtkCellRenderer *icon_rend; 632 GtkCellRenderer *icon_rend;
562 GtkTextBuffer *buffer; 633 GtkTextBuffer *buffer;
563 GtkTreePath *path; 634 GtkTreePath *path;
564 GtkIconSize icon_size;
565 635
566 text_rend = gtk_cell_renderer_text_new(); 636 text_rend = gtk_cell_renderer_text_new();
567 icon_rend = gtk_cell_renderer_pixbuf_new(); 637 icon_rend = gtk_cell_renderer_pixbuf_new();
568 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
569 638
570 status_box->imhtml_visible = FALSE; 639 status_box->imhtml_visible = FALSE;
571 status_box->connecting = FALSE; 640 status_box->connecting = FALSE;
572 status_box->typing = FALSE; 641 status_box->typing = FALSE;
573 status_box->title = NULL; 642 status_box->title = NULL;
650 719
651 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", 720 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event",
652 G_CALLBACK(scroll_event_cb), status_box->imhtml); 721 G_CALLBACK(scroll_event_cb), status_box->imhtml);
653 722
654 #if GTK_CHECK_VERSION(2,6,0) 723 #if GTK_CHECK_VERSION(2,6,0)
655 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); 724 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL);
656 #endif 725 #endif
657 726
658 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, 727 cache_pixbufs(status_box);
659 icon_size, "GtkGaimStatusBox");
660 status_box->connecting_index = 0;
661 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT0,
662 icon_size, "GtkGaimStatusBox");
663 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT1,
664 icon_size, "GtkGaimStatusBox");
665 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT2,
666 icon_size, "GtkGaimStatusBox");
667 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT3,
668 icon_size, "GtkGaimStatusBox");
669
670 status_box->typing_index = 0;
671 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING0,
672 icon_size, "GtkGaimStatusBox");
673 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING1,
674 icon_size, "GtkGaimStatusBox");
675 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING2,
676 icon_size, "GtkGaimStatusBox");
677 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING3,
678 icon_size, "GtkGaimStatusBox");
679
680 gtk_gaim_status_box_regenerate(status_box); 728 gtk_gaim_status_box_regenerate(status_box);
681 729
682 /* Monitor changes in the "/core/savedstatus/current" preference */
683 gaim_prefs_connect_callback(status_box, "/core/savedstatus/current", 730 gaim_prefs_connect_callback(status_box, "/core/savedstatus/current",
684 current_status_pref_changed_cb, status_box); 731 current_status_pref_changed_cb, status_box);
732 gaim_prefs_connect_callback(status_box, "/gaim/gtk/blist/show_buddy_icons",
733 buddy_list_details_pref_changed_cb, status_box);
734
685 } 735 }
686 736
687 static void 737 static void
688 gtk_gaim_status_box_size_request(GtkWidget *widget, 738 gtk_gaim_status_box_size_request(GtkWidget *widget,
689 GtkRequisition *requisition) 739 GtkRequisition *requisition)
713 763
714 parent_alc = *allocation; 764 parent_alc = *allocation;
715 box_alc = *allocation; 765 box_alc = *allocation;
716 combo_box_size_request(widget, &req); 766 combo_box_size_request(widget, &req);
717 767
718 box_alc.height = MAX(1, ((allocation->height) - (req.height) - (12))); 768 box_alc.height = MAX(1, (allocation->height - req.height - 12));
719 box_alc.y = box_alc.y + req.height + 9; 769 box_alc.y = box_alc.y + req.height + 9;
720 770
721 box_alc.width -= 6; 771 box_alc.width -= 6;
722 box_alc.x += 3; 772 box_alc.x += 3;
723 773