Mercurial > pidgin.yaz
changeset 4944:5fe846b7603f
[gaim-migrate @ 5278]
Fixes by Rob "Robot101" McQueen:
Buddies who sign off within 10 seconds of signing on won't get stuck "online"
forever
Idle times refresh every minute
Show icons/text on the buddy list buttons works now
URL tooltips in gtkimhtml won't linger around for no good reason.
Thanks, Rob.
And Rob Flynn is a spoil sport ;)
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Tue, 01 Apr 2003 07:57:13 +0000 |
parents | f0c7d092948d |
children | f5efec4603ef |
files | src/buddy.c src/gaim.h src/gaimrc.c src/gtkimhtml.c src/gtklist.h src/prefs.c |
diffstat | 6 files changed, 109 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Tue Apr 01 07:48:28 2003 +0000 +++ b/src/buddy.c Tue Apr 01 07:57:13 2003 +0000 @@ -377,17 +377,7 @@ #endif } -/* This is called 10 seconds after the buddy logs in. It removes the "logged in" icon and replaces it with - * the normal status icon */ - -static gboolean gaim_reset_present_icon(GaimBlistNode *b) -{ - ((struct buddy*)b)->present = 1; - gaim_gtk_blist_update(NULL, b); - return FALSE; -} - -static void edit_mode_cb(gpointer callback_data, guint callback_action, +static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, GtkWidget *checkitem) { GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); gdk_window_set_cursor(gtkblist->window->window, cursor); @@ -405,16 +395,17 @@ gaim_gtk_blist_refresh(gaim_get_blist()); } +/* This is called 10 seconds after the buddy logs in. It removes the "logged in" icon and replaces it with + * the normal status icon. Make sure they didn't sign off in the mean-time though. */ -static void gaim_gtk_blist_update_toolbar_icons (GtkWidget *widget, gpointer data) { - if (GTK_IS_IMAGE(widget)) { - if (blist_options & OPT_BLIST_SHOW_BUTTON_XPM) - gtk_widget_show(widget); - else - gtk_widget_hide(widget); - } else if (GTK_IS_CONTAINER(widget)) { - gtk_container_foreach(GTK_CONTAINER(widget), gaim_gtk_blist_update_toolbar_icons, NULL); +static gboolean gaim_reset_present_icon (GaimBlistNode *b) +{ + if (((struct buddy *)b)->present == 2) { + ((struct buddy *)b)->present = 1; + gaim_gtk_blist_update(NULL, b); } + + return FALSE; } static void gaim_gtk_blist_drag_data_get_cb (GtkWidget *widget, @@ -657,7 +648,7 @@ /* Edit menu */ { N_("/_Edit"), NULL, NULL, 0, "<Branch>" }, - { N_("/Edit/_Show Offline Buddies"), NULL, edit_mode_cb, 1, "<CheckItem>"}, + { N_("/Edit/_Show Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, { N_("/Edit/_Add a Buddy..."), NULL, gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, { N_("/Edit/Add a _Group..."), NULL, show_add_group, 0, NULL}, { "/Edit/sep", NULL, NULL, 0, "<Separator>" }, @@ -665,7 +656,6 @@ { N_("/Edit/Preferences"), "<CTL>P", show_prefs, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, { N_("/Edit/Pr_ivacy"), NULL, show_privacy_options, 0, NULL }, - /* Tools */ { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, @@ -1073,6 +1063,24 @@ } } +static gboolean gaim_gtk_blist_refresh_timer(struct gaim_buddy_list *list) +{ + GaimBlistNode *group = list->root; + GaimBlistNode *buddy; + + while (group) { + buddy = group->child; + while (buddy) { + if (((struct buddy *)buddy)->idle) + gaim_gtk_blist_update(list, buddy); + buddy = buddy->next; + } + group = group->next; + } + + /* keep on going */ + return TRUE; +} /********************************************************************************** * Public API Functions * @@ -1221,15 +1229,6 @@ gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); gaim_gtk_blist_update_columns(); - /* OK... let's show this bad boy. */ - gaim_gtk_blist_refresh(list); - gaim_gtk_blist_restore_position(); - gtk_widget_show_all(gtkblist->window); - - /* the button box below is first added now, the reason is that if we - * show() it immediately, the buddy list width will be dependent of - * the button box even if the user turned the button box off. */ - /**************************** Button Box **************************************/ sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); @@ -1261,16 +1260,18 @@ gtk_size_group_add_widget(sg, button); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_away_cb), NULL); + gaim_gtk_blist_update_toolbar(); + /* set the Show Offline Buddies option */ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Edit/Show Offline Buddies"))), blist_options & OPT_BLIST_SHOW_OFFLINE); /* OK... let's show this bad boy. */ - gaim_gtk_blist_refresh(list); gaim_gtk_blist_restore_position(); gtk_widget_show_all(gtkblist->window); - gaim_gtk_blist_update_toolbar(); + gaim_gtk_blist_refresh(list); + gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); } void gaim_gtk_blist_refresh(struct gaim_buddy_list *list) @@ -1322,16 +1323,42 @@ return get_iter_from_node_helper(node, iter, &root); } +/* + * These state assignments suck. I'm sorry. They're for historical reasons. + * Roll on new prefs. -Robot101 + * + * NO_BUTTON_TEXT && SHOW_BUTTON_XPM - image + * !NO_BUTTON_TEXT && !SHOW_BUTTON_XPM - text + * !NO_BUTTON_TEXT && SHOW_BUTTON_XPM - text & images + * NO_BUTTON_TEXT && !SHOW_BUTTON_XPM - none + */ + +static void gaim_gtk_blist_update_toolbar_icons (GtkWidget *widget, gpointer data) { + if (GTK_IS_IMAGE(widget)) { + if (blist_options & OPT_BLIST_SHOW_BUTTON_XPM) + gtk_widget_show(widget); + else + gtk_widget_hide(widget); + } else if (GTK_IS_LABEL(widget)) { + if (blist_options & OPT_BLIST_NO_BUTTON_TEXT) + gtk_widget_hide(widget); + else + gtk_widget_show(widget); + } else if (GTK_IS_CONTAINER(widget)) { + gtk_container_foreach(GTK_CONTAINER(widget), gaim_gtk_blist_update_toolbar_icons, NULL); + } +} + void gaim_gtk_blist_update_toolbar() { if (!gtkblist) return; - gtk_container_foreach(GTK_CONTAINER(gtkblist->bbox), gaim_gtk_blist_update_toolbar_icons, NULL); - - if (blist_options & OPT_BLIST_NO_BUTTONS) + if (blist_options & OPT_BLIST_NO_BUTTON_TEXT && !(blist_options & OPT_BLIST_SHOW_BUTTON_XPM)) gtk_widget_hide(gtkblist->bbox); - else + else { gtk_widget_show_all(gtkblist->bbox); + gtk_container_foreach(GTK_CONTAINER(gtkblist->bbox), gaim_gtk_blist_update_toolbar_icons, NULL); + } } static void gaim_gtk_blist_remove(struct gaim_buddy_list *list, GaimBlistNode *node) @@ -1572,8 +1599,16 @@ { if (!gtkblist) return; + gtk_widget_destroy(gtkblist->window); + if (gtkblist->refresh_timer) + g_source_remove(gtkblist->refresh_timer); + if (gtkblist->timeout) + g_source_remove(gtkblist->timeout); + + gtkblist->refresh_timer = 0; + gtkblist->timeout = 0; gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; gtkblist->treemodel = NULL; gtkblist->idle_column = NULL; @@ -1582,8 +1617,6 @@ protomenu = NULL; awaymenu = NULL; bpmenu = NULL; - - gtkblist->timeout = 0; } static void gaim_gtk_blist_set_visible(struct gaim_buddy_list *list, gboolean show) @@ -1655,13 +1688,12 @@ { docklet_count--; if (!docklet_count) { - if (connections) { + if (connections) gaim_blist_set_visible(TRUE); - } else if (mainwindow) { + else if (mainwindow) gtk_window_present(GTK_WINDOW(mainwindow)); - } else { + else show_login(); - } } }
--- a/src/gaim.h Tue Apr 01 07:48:28 2003 +0000 +++ b/src/gaim.h Tue Apr 01 07:57:13 2003 +0000 @@ -157,14 +157,9 @@ /*#define OPT_ACCT_KEEPALV 0x00000002 this shouldn't be optional */ #define OPT_ACCT_REM_PASS 0x00000004 #define OPT_ACCT_MAIL_CHECK 0x00000008 -/*do not use OPT_ACCT 0x00000010 talk to robot101 about automatic - name stuff with this option - */ #define DEFAULT_INFO "Visit the Gaim website at <A HREF=\"http://gaim.sourceforge.net/\">http://gaim.sourceforge.net/</A>." - - enum log_event { log_signon = 0, log_signoff, @@ -232,7 +227,7 @@ #define OPT_BLIST_SHOW_PIXMAPS 0x00000010 #define OPT_BLIST_SHOW_IDLETIME 0x00000020 #define OPT_BLIST_SHOW_BUTTON_XPM 0x00000040 -#define OPT_BLIST_NO_BUTTONS 0x00000080 +#define OPT_BLIST_NO_BUTTON_TEXT 0x00000080 #define OPT_BLIST_NO_MT_GRP 0x00000100 #define OPT_BLIST_SHOW_WARN 0x00000200 #define OPT_BLIST_GREY_IDLERS 0x00000400
--- a/src/gaimrc.c Tue Apr 01 07:48:28 2003 +0000 +++ b/src/gaimrc.c Tue Apr 01 07:57:13 2003 +0000 @@ -729,7 +729,7 @@ { /* OPT_DISP_SHOW_SMILEY */ 0x00000100, &convo_options, OPT_CONVO_SHOW_SMILEY }, { /* OPT_DISP_COOL_LOOK */ 0x00000400, &misc_options, 0}, { /* OPT_DISP_CHAT_LOGON */ 0x00000800, &chat_options, OPT_CHAT_LOGON }, -{ /* OPT_DISP_NO_BUTTONS */ 0x00002000, &blist_options, OPT_BLIST_NO_BUTTONS }, +{ /* OPT_DISP_NO_BUTTONS */ 0x00002000, &blist_options, OPT_BLIST_NO_BUTTON_TEXT }, { /* OPT_DISP_CONV_BUTTON_TEXT */ 0x00004000, &im_options, OPT_IM_BUTTON_TEXT }, { /* OPT_DISP_CHAT_BUTTON_TEXT */ 0x00008000, &chat_options, OPT_CHAT_BUTTON_TEXT }, { /* OPT_DISP_NO_MT_GRP */ 0x00040000, &blist_options, OPT_BLIST_NO_MT_GRP },
--- a/src/gtkimhtml.c Tue Apr 01 07:48:28 2003 +0000 +++ b/src/gtkimhtml.c Tue Apr 01 07:57:13 2003 +0000 @@ -54,6 +54,7 @@ #define TOOLTIP_TIMEOUT 500 static gboolean gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer user_data); +static gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer user_data); static gboolean gtk_size_allocate_cb(GtkWidget *widget, GtkAllocation *alloc, gpointer user_data); static gint gtk_imhtml_tip (gpointer data); @@ -230,8 +231,10 @@ g_free, (GDestroyNotify)gtk_smiley_tree_destroy); imhtml->default_smilies = gtk_smiley_tree_new(); + g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); - g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); + g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); + gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK); imhtml->tip = NULL; imhtml->tip_timer = 0; @@ -393,6 +396,23 @@ return FALSE; } +gboolean gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) +{ + /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ + if (GTK_IMHTML(imhtml)->tip_window) { + gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); + GTK_IMHTML(imhtml)->tip_window = NULL; + } + if (GTK_IMHTML(imhtml)->tip_timer) { + g_source_remove(GTK_IMHTML(imhtml)->tip_timer); + GTK_IMHTML(imhtml)->tip_timer = 0; + } + gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->arrow_cursor); + + /* propogate the event normally */ + return FALSE; +} + /* this isn't used yet static void gtk_smiley_tree_remove (GtkSmileyTree *tree,
--- a/src/gtklist.h Tue Apr 01 07:48:28 2003 +0000 +++ b/src/gtklist.h Tue Apr 01 07:57:13 2003 +0000 @@ -51,13 +51,14 @@ GtkWidget *treeview; /**< It's a treeview... d'uh. */ GtkTreeStore *treemodel; /**< This is the treemodel. */ - GtkTreeViewColumn *idle_column, *warning_column, *buddy_icon_column; - + GtkWidget *bbox; /**< A Button Box. */ + guint refresh_timer; /**< The timer for refreshing every 30 seconds */ + guint timeout; /**< The timeout for the tooltip. */ GdkRectangle rect; /**< This is the bounding rectangle of the cell we're currently hovering over. This is
--- a/src/prefs.c Tue Apr 01 07:48:28 2003 +0000 +++ b/src/prefs.c Tue Apr 01 07:57:13 2003 +0000 @@ -541,8 +541,11 @@ gtk_container_set_border_width (GTK_CONTAINER (ret), 12); vbox = make_frame (ret, _("Buttons")); - gaim_button(_("_Hide IM/Info/Chat buttons"), &blist_options, OPT_BLIST_NO_BUTTONS, vbox); - gaim_button(_("Show _pictures on buttons"), &blist_options, OPT_BLIST_SHOW_BUTTON_XPM, vbox); + gaim_dropdown(vbox, _("Show _buttons as:"), &blist_options, OPT_BLIST_SHOW_BUTTON_XPM | OPT_BLIST_NO_BUTTON_TEXT, + _("Pictures"), OPT_BLIST_SHOW_BUTTON_XPM | OPT_BLIST_NO_BUTTON_TEXT, + _("Text"), 0, + _("Pictures and text"), OPT_BLIST_SHOW_BUTTON_XPM, + _("None"), OPT_BLIST_NO_BUTTON_TEXT, NULL); vbox = make_frame (ret, _("Buddy List Window")); gaim_button(_("_Save window size/position"), &blist_options, OPT_BLIST_SAVED_WINDOWS, vbox); @@ -557,7 +560,7 @@ /* gaim_button(_("Show buddy t_ype icons"), &blist_options, OPT_BLIST_SHOW_PIXMAPS, vbox); */ gaim_button(_("Show _warning levels"), &blist_options, OPT_BLIST_SHOW_WARN, vbox); gaim_button(_("Show idle _times"), &blist_options, OPT_BLIST_SHOW_IDLETIME, vbox); - gaim_button(_("Grey i_dle buddies"), &blist_options, OPT_BLIST_GREY_IDLERS, vbox); + gaim_button(_("Dim i_dle buddies"), &blist_options, OPT_BLIST_GREY_IDLERS, vbox); gtk_widget_show_all(ret); return ret; @@ -1975,9 +1978,7 @@ if (!gtkblist) return; - if (option == OPT_BLIST_NO_BUTTONS || option == OPT_BLIST_NO_BUTTONS) - gaim_gtk_blist_update_toolbar(); - else if (option == OPT_BLIST_SHOW_WARN || + if (option == OPT_BLIST_SHOW_WARN || option == OPT_BLIST_SHOW_IDLETIME) gaim_gtk_blist_update_columns(); else if (option == OPT_BLIST_SHOW_ICONS) { @@ -1985,9 +1986,6 @@ gaim_gtk_blist_update_columns(); } else gaim_gtk_blist_refresh(gaim_get_blist()); - - - } static void set_convo_option(GtkWidget *w, int option) @@ -2303,6 +2301,8 @@ else gtk_widget_set_sensitive(sndcmd, FALSE); gaim_sound_change_output_method(); + } else if (option == (int*)&blist_options) { + gaim_gtk_blist_update_toolbar(); } else if (option == (int*)&im_options) { if (clear == (OPT_IM_SIDE_TAB | OPT_IM_BR_TAB)) gaim_gtkconv_update_tabs();