Mercurial > pidgin.yaz
changeset 124:5f294f7c4f2e
[gaim-migrate @ 134]
Whee
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sun, 16 Apr 2000 02:01:48 +0000 |
parents | f7a5f376f54e |
children | bfe26481cff5 |
files | plugins/Makefile plugins/chkmail.c |
diffstat | 2 files changed, 67 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/Makefile Sun Apr 16 01:59:17 2000 +0000 +++ b/plugins/Makefile Sun Apr 16 02:01:48 2000 +0000 @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -Wall `gnome-config --cflags gtk` -I../src +CFLAGS = -Wall `gnome-config --cflags gtk` -I../src -g LDFLAGS = -ggdb `gnome-config --libs gtk` -shared all: simple.so gaiminc.so autorecon.so spellchk.so chkmail.so filectl.so
--- a/plugins/chkmail.c Sun Apr 16 01:59:17 2000 +0000 +++ b/plugins/chkmail.c Sun Apr 16 02:01:48 2000 +0000 @@ -22,9 +22,7 @@ static void *handle = NULL; extern GtkWidget *blist; -GtkWidget *maily; -GtkWidget *vbox2; -GtkWidget *yo; +extern GtkWidget *buddies; GList *tmp; int lastnum = 0; @@ -77,67 +75,103 @@ return 0; } +void destroy_mail_list() +{ + GList *list; + GtkWidget *w; + + list = GTK_TREE(buddies)->children; + + while (list) { + w = (GtkWidget *)list->data; + if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, "Mail Server")) { + gtk_tree_remove_items(GTK_TREE(buddies), list); + if (!list) + break; + } + list = list->next; + } +} + + +void setup_mail_list() +{ + GList *list; + GtkWidget *w; + GtkWidget *item; + GtkWidget *tree; + gchar *buf; + + list = GTK_TREE(buddies)->children; + + while (list) { + w = (GtkWidget *)list->data; + if (!strcmp(GTK_LABEL(GTK_BIN(w)->child)->label, "Mail Server")) { + gtk_tree_remove_items(GTK_TREE(buddies), list); + if (!list) + break; + } + list = list->next; + } + + item = gtk_tree_item_new_with_label("Mail Server"); + tree = gtk_tree_new(); + gtk_widget_show(item); + gtk_widget_show(tree); + gtk_tree_append(GTK_TREE(buddies), item); + gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree); + gtk_tree_item_expand(GTK_TREE_ITEM(item)); + + buf = g_malloc(BUF_LONG); + + g_snprintf(buf, BUF_LONG, "%s (%d/%d)", mailhost, lastnum - orig, orig); + item = gtk_tree_item_new_with_label(buf); + g_free(buf); + + gtk_tree_append(GTK_TREE(tree), item); + gtk_widget_show(item); +} + void gaim_plugin_init(void *h) { handle = h; tmp = gtk_container_children(GTK_CONTAINER(blist)); - maily = gtk_label_new("You have no new email"); - vbox2 = (GtkWidget *)tmp->data; - - yo = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(yo), GTK_SHADOW_IN ); - gtk_widget_show(yo); - - gtk_box_pack_start(GTK_BOX(vbox2), yo, FALSE, FALSE, 5); - gtk_box_reorder_child(GTK_BOX(vbox2), yo, 2); - gtk_container_add(GTK_CONTAINER(yo), maily); - - gtk_widget_show(maily); - orig = num_msgs(); lastnum = orig; + gaim_signal_connect(handle, event_blist_update, setup_mail_list, NULL); + setup_mail_list(); + mytimer = gtk_timeout_add(30000, (GtkFunction)update_mail, NULL); } void update_mail () { int newnum; - gchar *buf; gtk_timeout_remove(mytimer); newnum = num_msgs(); - buf = g_malloc(BUF_LONG); - if ( (newnum >= lastnum) && (newnum > 0)) { - g_snprintf(buf, BUF_LONG, "You have %d new e-mail(s)", newnum - orig); + newnum = newnum - orig; } else { - g_snprintf(buf, BUF_LONG, "You have no new email"); + newnum = 0; } - gtk_widget_destroy(maily); - maily = gtk_label_new(buf); - g_free(buf); - - gtk_container_add(GTK_CONTAINER(yo), maily); - - gtk_widget_show(maily); - if (newnum < lastnum) { orig = 0; } lastnum = newnum; mytimer = gtk_timeout_add(30000, (GtkFunction)update_mail, NULL); + setup_mail_list(); } void gaim_plugin_remove() { + gtk_timeout_remove(mytimer); + destroy_mail_list(); handle = NULL; - gtk_widget_hide(maily); - gtk_widget_destroy(yo); - gtk_timeout_remove(mytimer); } char *name() {