Mercurial > pidgin
changeset 1058:4927ce25d8cc
[gaim-migrate @ 1068]
idle times for single connections; deleting an account signs it off if need be
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 03 Nov 2000 20:23:38 +0000 |
parents | d50d3abb9eb7 |
children | 6e60c69d4432 |
files | plugins/SIGNALS src/aim.c src/buddy.c src/gaim.h src/idle.c src/multi.c src/plugins.c |
diffstat | 7 files changed, 79 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/SIGNALS Fri Nov 03 10:46:58 2000 +0000 +++ b/plugins/SIGNALS Fri Nov 03 20:23:38 2000 +0000 @@ -11,6 +11,7 @@ event_buddy_back, event_buddy_idle, event_buddy_unidle, + event_blist_update, event_chat_invited, event_chat_join, event_chat_leave, @@ -130,6 +131,11 @@ 'who' is who is no longer idle. +event_blist_update: + (none) + + called when the idle times are updated in the buddy list + event_chat_invited: struct gaim_connection *gc, char *who, char *room, char *message
--- a/src/aim.c Fri Nov 03 10:46:58 2000 +0000 +++ b/src/aim.c Fri Nov 03 20:23:38 2000 +0000 @@ -576,8 +576,6 @@ if (general_options & OPT_GEN_DEBUG) show_debug(NULL); - gdk_threads_enter(); - #ifdef USE_PERL perl_init(); perl_autoload(); @@ -627,7 +625,6 @@ gtk_main(); #endif /* USE_APPLET */ - gdk_threads_leave(); return 0;
--- a/src/buddy.c Fri Nov 03 10:46:58 2000 +0000 +++ b/src/buddy.c Fri Nov 03 20:23:38 2000 +0000 @@ -1353,6 +1353,10 @@ gtk_box_pack_start(GTK_BOX(box), b->label, TRUE, TRUE, 1); gtk_widget_show(b->label); + b->idle = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(box), b->idle, FALSE, FALSE, 1); + gtk_widget_show(b->idle); + gs->members = g_slist_insert(gs->members, b, pos); return b; } @@ -1416,6 +1420,58 @@ return FALSE; } +static void update_idle_time(struct buddy_show *bs) { + char idlet[16]; + time_t t; + int ihrs, imin; + struct buddy *b; + GSList *c; + + time(&t); + if (g_slist_length(bs->connlist) == 1) { + b = find_buddy(bs->connlist->data, bs->name); + if (!b) return; + ihrs = (t - b->idle) / 3600; imin = ((t - b->idle) / 60) % 60; + + if (ihrs) + g_snprintf(idlet, sizeof idlet, "(%d:%02d)", ihrs, imin); + else + g_snprintf(idlet, sizeof idlet, "(%d)", imin); + + gtk_widget_hide(bs->idle); + if (b->idle) + gtk_label_set(GTK_LABEL(bs->idle), idlet); + else + gtk_label_set(GTK_LABEL(bs->idle), ""); + if (display_options & OPT_DISP_SHOW_IDLETIME) + gtk_widget_show(bs->idle); + } else { + /* FIXME */ + } +} + +void update_idle_times() { + GSList *grp = shows; + GSList *mem; + struct buddy_show *b; + struct group_show *g; + struct buddy *bud; + time_t t; + char idlet[16]; + int ihrs, imin; + + while (grp) { + g = (struct group_show *)grp->data; + mem = g->members; + while (mem) { + b = (struct buddy_show *)mem->data; + update_idle_time(b); + mem = mem->next; + } + grp = grp->next; + } +} + void set_buddy(struct gaim_connection *gc, struct buddy *b) { struct group *g = find_group_by_buddy(gc, b->name); @@ -1424,6 +1480,7 @@ GdkPixmap *pm; GdkBitmap *bm; char **xpm = NULL; + if (b->present) { if ((gs = find_group_show(g->name)) == NULL) gs = new_group_show(g->name); @@ -1460,6 +1517,7 @@ gdk_pixmap_unref(pm); gdk_bitmap_unref(bm); } + update_idle_time(bs); } else { play_sound(BUDDY_LEAVE); gs = find_group_show(g->name);
--- a/src/gaim.h Fri Nov 03 10:46:58 2000 +0000 +++ b/src/gaim.h Fri Nov 03 20:23:38 2000 +0000 @@ -183,6 +183,7 @@ event_buddy_back, event_buddy_idle, event_buddy_unidle, + event_blist_update, event_chat_invited, event_chat_join, event_chat_leave, @@ -232,6 +233,7 @@ GtkWidget *item; GtkWidget *pix; GtkWidget *label; + GtkWidget *idle; char *name; char *show; GSList *connlist; @@ -594,6 +596,7 @@ extern void do_quit(); extern void update_chat_button_pix(); extern void update_im_button_pix(); +extern void update_idle_times(); /* Functions in html.c */ extern char *fix_url(char *);
--- a/src/idle.c Fri Nov 03 10:46:58 2000 +0000 +++ b/src/idle.c Fri Nov 03 20:23:38 2000 +0000 @@ -46,6 +46,9 @@ #endif /* Not idle, really... :) */ + update_idle_times(); + + plugin_event(event_blist_update, 0, 0, 0, 0); time(&t);
--- a/src/multi.c Fri Nov 03 10:46:58 2000 +0000 +++ b/src/multi.c Fri Nov 03 20:23:38 2000 +0000 @@ -535,6 +535,8 @@ if (row != -1) { u = g_list_nth_data(aim_users, row); if (u) { + if (u->gc) + signoff(u->gc); aim_users = g_list_remove(aim_users, u); save_prefs(); }
--- a/src/plugins.c Fri Nov 03 10:46:58 2000 +0000 +++ b/src/plugins.c Fri Nov 03 20:23:38 2000 +0000 @@ -576,6 +576,9 @@ case event_buddy_unidle: sprintf(buf, "event_buddy_unidle"); break; + case event_blist_update: + sprintf(buf, "event_blist_update"); + break; case event_chat_invited: sprintf(buf, "event_chat_invited"); break; @@ -642,6 +645,7 @@ /* no args */ case event_away: case event_back: + case event_blist_update: case event_quit: { void (*function)(void *) = g->function; @@ -775,6 +779,9 @@ case event_buddy_unidle: g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); break; + case event_blist_update: + buf[0] = 0; + break; case event_chat_invited: g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, (char *)arg4); break;