comparison src/gtkblist.c @ 12656:60cce1861e59

[gaim-migrate @ 14999] Add a Buddies --> Show Idle Times menu option to the blist committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 25 Dec 2005 18:16:29 +0000
parents 773f694e83bf
children b18738b03b35
comparison
equal deleted inserted replaced
12655:2ef70289676c 12656:60cce1861e59
1417 gtk_main_iteration(); 1417 gtk_main_iteration();
1418 gdk_cursor_unref(cursor); 1418 gdk_cursor_unref(cursor);
1419 } 1419 }
1420 1420
1421 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", 1421 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons",
1422 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
1423
1424 if (gtkblist->window->window)
1425 gdk_window_set_cursor(gtkblist->window->window, NULL);
1426 }
1427
1428 static void gaim_gtk_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item)
1429 {
1430 if (gtkblist->window->window)
1431 {
1432 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1433 gdk_window_set_cursor(gtkblist->window->window, cursor);
1434 while (gtk_events_pending())
1435 gtk_main_iteration();
1436 gdk_cursor_unref(cursor);
1437 }
1438
1439 gaim_prefs_set_bool("/gaim/gtk/blist/show_idle_time",
1422 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); 1440 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
1423 1441
1424 if (gtkblist->window->window) 1442 if (gtkblist->window->window)
1425 gdk_window_set_cursor(gtkblist->window->window, NULL); 1443 gdk_window_set_cursor(gtkblist->window->window, NULL);
1426 } 1444 }
2520 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, "<StockItem>", GAIM_STOCK_LOG }, 2538 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, "<StockItem>", GAIM_STOCK_LOG },
2521 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>", NULL }, 2539 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>", NULL },
2522 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>", NULL }, 2540 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>", NULL },
2523 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>", NULL }, 2541 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>", NULL },
2524 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>", NULL }, 2542 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>", NULL },
2543 { N_("/Buddies/Show Idle _Times"), NULL, gaim_gtk_blist_show_idle_time_cb, 1, "<CheckItem>", NULL },
2525 { N_("/Buddies/_Sort Buddies"), NULL, NULL, 0, "<Branch>", NULL }, 2544 { N_("/Buddies/_Sort Buddies"), NULL, NULL, 0, "<Branch>", NULL },
2526 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>", NULL }, 2545 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>", NULL },
2527 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, 2546 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD },
2528 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, 2547 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD },
2529 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD }, 2548 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD },
2619 { 2638 {
2620 GaimContact *c; 2639 GaimContact *c;
2621 GaimBuddy *b; 2640 GaimBuddy *b;
2622 GaimPresence *presence; 2641 GaimPresence *presence;
2623 char *tmp; 2642 char *tmp;
2624 gboolean idle;
2625 time_t idle_secs, signon; 2643 time_t idle_secs, signon;
2626 2644
2627 if (GAIM_BLIST_NODE_IS_CONTACT(node)) 2645 if (GAIM_BLIST_NODE_IS_CONTACT(node))
2628 { 2646 {
2629 c = (GaimContact *)node; 2647 c = (GaimContact *)node;
2687 g_string_append_printf(str, _("\n<b>Logged In:</b> %s"), tmp); 2705 g_string_append_printf(str, _("\n<b>Logged In:</b> %s"), tmp);
2688 g_free(tmp); 2706 g_free(tmp);
2689 } 2707 }
2690 2708
2691 /* Idle */ 2709 /* Idle */
2692 idle = gaim_presence_is_idle(presence); 2710 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") &&
2693 if (idle) 2711 gaim_presence_is_idle(presence))
2694 { 2712 {
2695 idle_secs = gaim_presence_get_idle_time(presence); 2713 idle_secs = gaim_presence_get_idle_time(presence);
2696 if (idle_secs > 0) 2714 if (idle_secs > 0)
2697 { 2715 {
2698 tmp = gaim_str_seconds_to_string(time(NULL) - idle_secs); 2716 tmp = gaim_str_seconds_to_string(time(NULL) - idle_secs);
3021 g_strdelimit(tmp, "\n", ' '); 3039 g_strdelimit(tmp, "\n", ' ');
3022 statustext = tmp; 3040 statustext = tmp;
3023 #endif 3041 #endif
3024 } 3042 }
3025 3043
3026 if (gaim_presence_is_idle(presence)) { 3044 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") &&
3045 gaim_presence_is_idle(presence))
3046 {
3027 time_t idle_secs = gaim_presence_get_idle_time(presence); 3047 time_t idle_secs = gaim_presence_get_idle_time(presence);
3028 3048
3029 if (idle_secs > 0) { 3049 if (idle_secs > 0) {
3030 int ihrs, imin; 3050 int ihrs, imin;
3031 3051
3067 dim_grey(), 3087 dim_grey(),
3068 idletime != NULL ? idletime : "", 3088 idletime != NULL ? idletime : "",
3069 (idletime != NULL && statustext != NULL) ? " - " : "", 3089 (idletime != NULL && statustext != NULL) ? " - " : "",
3070 statustext != NULL ? statustext : ""); 3090 statustext != NULL ? statustext : "");
3071 } 3091 }
3072 if (idletime) 3092
3073 g_free(idletime); 3093 g_free(idletime);
3074 if (statustext) 3094 g_free(statustext);
3075 g_free(statustext); 3095 g_free(esc);
3076 if (esc)
3077 g_free(esc);
3078 3096
3079 return text; 3097 return text;
3080 } 3098 }
3081 3099
3082 static void gaim_gtk_blist_restore_position() 3100 static void gaim_gtk_blist_restore_position()
3361 3379
3362 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { 3380 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) {
3363 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE); 3381 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE);
3364 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE); 3382 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE);
3365 } else { 3383 } else {
3366 gtk_tree_view_column_set_visible(gtkblist->idle_column, TRUE); 3384 gtk_tree_view_column_set_visible(gtkblist->idle_column,
3385 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time"));
3367 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE); 3386 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE);
3368 } 3387 }
3369 } 3388 }
3370 3389
3371 static void 3390 static void
3626 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); 3645 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview);
3627 gaim_gtk_blist_update_columns(); 3646 gaim_gtk_blist_update_columns();
3628 3647
3629 gtkblist->statusbox = gtk_gaim_status_box_new(); 3648 gtkblist->statusbox = gtk_gaim_status_box_new();
3630 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); 3649 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox");
3631 3650
3632 gtk_widget_show(gtkblist->statusbox); 3651 gtk_widget_show(gtkblist->statusbox);
3633 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); 3652 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0);
3634 3653
3635 3654
3636 /* set the Show Offline Buddies option. must be done 3655 /* set the Show Offline Buddies option. must be done
3637 * after the treeview or faceprint gets mad. -Robot101 3656 * after the treeview or faceprint gets mad. -Robot101
3638 */ 3657 */
3639 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), 3658 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))),
3640 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); 3659 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies"));
3660
3641 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), 3661 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))),
3642 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); 3662 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups"));
3663
3643 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), 3664 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))),
3644 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); 3665 gaim_prefs_get_bool("/gaim/gtk/sound/mute"));
3666
3645 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), 3667 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))),
3646 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); 3668 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"));
3669
3670 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Idle Times"))),
3671 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time"));
3672
3647 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) 3673 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none"))
3648 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); 3674 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE);
3649 3675
3650 /* Update some dynamic things */ 3676 /* Update some dynamic things */
3651 update_menu_bar(gtkblist); 3677 update_menu_bar(gtkblist);
3664 handle = gaim_gtk_blist_get_handle(); 3690 handle = gaim_gtk_blist_get_handle();
3665 3691
3666 /* things that affect how buddies are displayed */ 3692 /* things that affect how buddies are displayed */
3667 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", 3693 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons",
3668 _prefs_change_redo_list, NULL); 3694 _prefs_change_redo_list, NULL);
3695 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time",
3696 _prefs_change_redo_list, NULL);
3669 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", 3697 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups",
3670 _prefs_change_redo_list, NULL); 3698 _prefs_change_redo_list, NULL);
3671 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", 3699 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies",
3672 _prefs_change_redo_list, NULL); 3700 _prefs_change_redo_list, NULL);
3673 3701
3675 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", 3703 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type",
3676 _prefs_change_sort_method, NULL); 3704 _prefs_change_sort_method, NULL);
3677 3705
3678 /* things that affect what columns are displayed */ 3706 /* things that affect what columns are displayed */
3679 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", 3707 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons",
3708 show_buddy_icons_pref_cb, NULL);
3709 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time",
3680 show_buddy_icons_pref_cb, NULL); 3710 show_buddy_icons_pref_cb, NULL);
3681 3711
3682 /* menus */ 3712 /* menus */
3683 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", 3713 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute",
3684 gaim_gtk_blist_mute_pref_cb, NULL); 3714 gaim_gtk_blist_mute_pref_cb, NULL);
3967 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); 3997 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL));
3968 3998
3969 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); 3999 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE);
3970 mark = gaim_gtk_blist_get_name_markup(buddy, selected); 4000 mark = gaim_gtk_blist_get_name_markup(buddy, selected);
3971 4001
3972 if (gaim_presence_is_idle(presence)) 4002 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") &&
4003 gaim_presence_is_idle(presence))
3973 { 4004 {
3974 time_t idle_secs = gaim_presence_get_idle_time(presence); 4005 time_t idle_secs = gaim_presence_get_idle_time(presence);
3975 4006
3976 if (idle_secs > 0) 4007 if (idle_secs > 0)
3977 { 4008 {
4005 IDLE_COLUMN, idle, 4036 IDLE_COLUMN, idle,
4006 BUDDY_ICON_COLUMN, avatar, 4037 BUDDY_ICON_COLUMN, avatar,
4007 -1); 4038 -1);
4008 4039
4009 g_free(mark); 4040 g_free(mark);
4010 if(idle) 4041 g_free(idle);
4011 g_free(idle);
4012 if(status) 4042 if(status)
4013 g_object_unref(status); 4043 g_object_unref(status);
4014 if(avatar) 4044 if(avatar)
4015 g_object_unref(avatar); 4045 g_object_unref(avatar);
4016 } 4046 }
4989 5019
4990 /* Initialize prefs */ 5020 /* Initialize prefs */
4991 gaim_prefs_add_none("/gaim/gtk/blist"); 5021 gaim_prefs_add_none("/gaim/gtk/blist");
4992 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); 5022 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE);
4993 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); 5023 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE);
5024 gaim_prefs_add_bool("/gaim/gtk/blist/show_idle_time", TRUE);
4994 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); 5025 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE);
4995 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); 5026 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE);
4996 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE); 5027 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE);
4997 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); 5028 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical");
4998 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); 5029 gaim_prefs_add_int("/gaim/gtk/blist/x", 0);