Mercurial > pidgin.yaz
changeset 4167:7002b6f16bdf
[gaim-migrate @ 4396]
(00:14:20) Robot101: if anyone with CVS would like to choose between the
docklet eating messages if you ask it to queue them, or an occasional crash
when returning from away with queued messages, I have a patch to revert ari's
'fix' at http://people.debian.org/~robot101/silly-ari.diff
(00:15:05) Robot101: Sean and I agreed that keeping the queued messages in a
GSList is better, so if ari could seperate the gtk2ification and the
fixing of the crash, without breaking the generic queueing stuff, that'd be
peachy
(00:15:22) Robot101: in the meantime, the docklet saying it has queued messages,
and not letting you read them, is pretty damn obnoxious.
(00:16:30) LSchiere: i'll do it
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 02 Jan 2003 05:18:16 +0000 |
parents | 481c51159627 |
children | ebfb80bbe1ed |
files | src/away.c src/buddy.c src/server.c src/ui.h |
diffstat | 4 files changed, 84 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/src/away.c Thu Jan 02 01:18:21 2003 +0000 +++ b/src/away.c Thu Jan 02 05:18:16 2003 +0000 @@ -36,9 +36,8 @@ GtkWidget *imaway = NULL; GtkWidget *awaymenu = NULL; -GtkWidget *awayqueue = NULL; -GtkListStore *awayqueuestore; -GtkWidget *awayqueuesw; +GtkWidget *clistqueue = NULL; +GtkWidget *clistqueuesw; struct away_message *awaymessage = NULL; struct away_message *default_away; @@ -49,24 +48,53 @@ if (imaway) gtk_widget_destroy(imaway); - awayqueue = NULL; - awayqueuestore = NULL; - awayqueuesw = NULL; + clistqueue = NULL; + clistqueuesw = NULL; imaway = NULL; } -void dequeue_message(GtkTreeIter *iter) +void purge_away_queue(GSList *queue) { - gchar *name; - GSList *templist; struct conversation *cnv; - gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), iter, 0, &name, -1); + gtk_clist_freeze(GTK_CLIST(clistqueue)); + gtk_clist_clear(GTK_CLIST(clistqueue)); + + while (queue) { + struct queued_message *qm = queue->data; + + cnv = find_conversation(qm->name); + if (!cnv) + cnv = new_conversation(qm->name); + if (g_slist_index(connections, qm->gc) >= 0) + set_convo_gc(cnv, qm->gc); + write_to_conv(cnv, qm->message, qm->flags, NULL, qm->tm, qm->len); + + queue = g_slist_remove(queue, qm); + + g_free(qm->message); + g_free(qm); + } + + gtk_clist_thaw(GTK_CLIST(clistqueue)); +} + +void dequeue_by_buddy(GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data) { + char *temp; + char *name; + GSList *templist; + struct conversation *cnv; + if(!(event->type == GDK_2BUTTON_PRESS && event->button == 1)) + return; /* Double clicking on the clist will unqueue that users messages. */ + + gtk_clist_get_text(GTK_CLIST(clist), row, 0, &temp); + name = g_strdup(temp); + + if (!name) + return; debug_printf("Unqueueing messages from %s.\n", name); - templist = message_queue; - while (templist) { struct queued_message *qm = templist->data; if (templist->data) { @@ -87,55 +115,25 @@ } } } - g_free(name); - /* In GTK 2.2, _store_remove actually returns whether iter is valid or not - * after the remove, but in GTK 2.0 it is a void function. */ - gtk_list_store_remove(awayqueuestore, iter); -} - -void purge_away_queue(GSList *queue) -{ - gboolean valid; - GtkTreeIter iter; + gtk_clist_remove(GTK_CLIST(clist), row); - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter); - while(valid) { - dequeue_message(&iter); - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), - &iter); - } +} - g_object_unref(G_OBJECT(awayqueuestore)); -} - -gint dequeue_cb(GtkWidget *treeview, GdkEventButton *event, gpointer data) { - GtkTreeIter iter; - GtkTreeSelection *select; - - if(!(event->type == GDK_2BUTTON_PRESS && event->button == 1)) - return FALSE; /* Double clicking on the list will unqueue that user's messages. */ - - select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - if(gtk_tree_selection_get_selected(select, NULL, &iter)) - dequeue_message(&iter); - - return FALSE; -} void toggle_away_queue() { - if (!awayqueue || !awayqueuesw) + if (!clistqueue || !clistqueuesw) return; if (away_options & OPT_AWAY_QUEUE) { - gtk_widget_show(awayqueue); - gtk_widget_show(awayqueuesw); + gtk_widget_show(clistqueue); + gtk_widget_show(clistqueuesw); } else { - gtk_widget_hide(awayqueue); - gtk_widget_hide(awayqueuesw); + gtk_widget_hide(clistqueue); + gtk_widget_hide(clistqueuesw); purge_away_queue(message_queue); } } @@ -160,8 +158,8 @@ } awaymessage = NULL; - awayqueue = NULL; - awayqueuesw = NULL; + clistqueue = NULL; + clistqueuesw = NULL; serv_set_away_all(NULL); } @@ -172,8 +170,6 @@ GtkWidget *awaytext; GtkWidget *sw; GtkWidget *vbox; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; char *buf2; char *buf; @@ -218,35 +214,22 @@ gtk_imhtml_append_text(GTK_IMHTML(awaytext), "<BR>", -1, GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL); - awayqueuesw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(awayqueuesw), GTK_POLICY_NEVER, + clistqueuesw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clistqueuesw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(awayqueuesw), - GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(vbox), awayqueuesw, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), clistqueuesw, TRUE, TRUE, 0); - awayqueuestore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); - awayqueue = gtk_tree_view_new_with_model(GTK_TREE_MODEL(awayqueuestore)); - renderer = gtk_cell_renderer_text_new(); - - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(awayqueue), FALSE); - column = gtk_tree_view_column_new_with_attributes (NULL, renderer, - "text", 0, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); - column = gtk_tree_view_column_new_with_attributes(NULL, renderer, - "text", 1, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); - - gtk_container_add(GTK_CONTAINER(awayqueuesw), awayqueue); - - g_signal_connect(G_OBJECT(awayqueue), "button_press_event", G_CALLBACK(dequeue_cb), NULL); + clistqueue = gtk_clist_new(2); + gtk_clist_set_column_width(GTK_CLIST(clistqueue), 0, 100); + gtk_widget_set_usize(GTK_WIDGET(clistqueue), -1, 50); + gtk_container_add(GTK_CONTAINER(clistqueuesw), clistqueue); + gtk_signal_connect(GTK_OBJECT(clistqueue), "select_row", GTK_SIGNAL_FUNC(dequeue_by_buddy), NULL); + if (away_options & OPT_AWAY_QUEUE) { - gtk_widget_show(awayqueuesw); - gtk_widget_show(awayqueue); + gtk_widget_show(clistqueuesw); + gtk_widget_show(clistqueue); } back = picture_button(imaway, _("I'm Back!"), join_xpm);
--- a/src/buddy.c Thu Jan 02 01:18:21 2003 +0000 +++ b/src/buddy.c Thu Jan 02 05:18:16 2003 +0000 @@ -2398,7 +2398,7 @@ char tmp[1024]; g_snprintf(tmp, sizeof(tmp), _("%s logged in."), b->show); write_to_conv(c, tmp, WFLAG_SYSTEM, NULL, time(NULL), -1); - } else if (awayqueue && find_queue_total_by_name(b->name)) { + } else if (clistqueue && find_queue_total_by_name(b->name)) { struct queued_message *qm = g_new0(struct queued_message, 1); g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); qm->message = g_strdup_printf(_("%s logged in."), b->show); @@ -2457,7 +2457,7 @@ char tmp[1024]; g_snprintf(tmp, sizeof(tmp), _("%s logged out."), b->show); write_to_conv(c, tmp, WFLAG_SYSTEM, NULL, time(NULL), -1); - } else if (awayqueue && find_queue_total_by_name(b->name)) { + } else if (clistqueue && find_queue_total_by_name(b->name)) { struct queued_message *qm = g_new0(struct queued_message, 1); g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); qm->message = g_strdup_printf(_("%s logged out."), b->show); @@ -2609,7 +2609,7 @@ blist = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_gravity(GTK_WINDOW(blist), GDK_GRAVITY_STATIC); + gtk_window_set_gravity(GTK_WINDOW(blist), GDK_GRAVITY_NORTH_WEST); gtk_window_set_policy(GTK_WINDOW(blist), TRUE, TRUE, TRUE); gtk_window_set_title(GTK_WINDOW(blist), _("Gaim - Buddy List")); gtk_window_set_role(GTK_WINDOW(blist), "buddy_list");
--- a/src/server.c Thu Jan 02 01:18:21 2003 +0000 +++ b/src/server.c Thu Jan 02 05:18:16 2003 +0000 @@ -473,20 +473,17 @@ int find_queue_row_by_name(char *name) { - gchar *temp; - gint i = 0; - gboolean valid; - GtkTreeIter iter; + GSList *templist; + char *temp; + int i; + + templist = message_queue; - valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter); - while(valid) { - gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), &iter, 0, &temp, -1); - if(!strcmp(name, temp)) + for (i = 0; i < GTK_CLIST(clistqueue)->rows; i++) { + gtk_clist_get_text(GTK_CLIST(clistqueue), i, 0, &temp); + + if (!strcmp(name, temp)) return i; - g_free(temp); - - i++; - valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(awayqueuestore), &iter); } return -1; @@ -626,14 +623,13 @@ * imaway dialog being shown. in fact, it's possible for *all* the accounts to be * away without the imaway dialog being shown. so in order for this to be queued * properly, we have to make sure that the imaway dialog actually exists, first. */ - if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { + if (!cnv && clistqueue && (away_options & OPT_AWAY_QUEUE)) { /* alright, so we're going to queue it. neat, eh? :) so first we create * something to store the message, and add it to our queue. Then we update * the away dialog to indicate that we've queued something. */ struct queued_message *qm; - GtkTreeIter iter; - gchar path[10]; - + struct buddy *b; + qm = g_new0(struct queued_message, 1); g_snprintf(qm->name, sizeof(qm->name), "%s", name); qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); @@ -644,25 +640,20 @@ message_queue = g_slist_append(message_queue, qm); row = find_queue_row_by_name(qm->name); + if (row >= 0) { char number[32]; int qtotal; qtotal = find_queue_total_by_name(qm->name); g_snprintf(number, 32, _("(%d messages)"), qtotal); - g_snprintf(path, 10, "%d", row); - gtk_tree_model_get_iter_from_string( - GTK_TREE_MODEL(awayqueuestore), &iter, path); - gtk_list_store_set(awayqueuestore, &iter, - 1, number, -1); + gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); } else { - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), - &iter); - gtk_list_store_append(awayqueuestore, &iter); - gtk_list_store_set(awayqueuestore, &iter, - 0, qm->name, - 1, _("(1 message)"), - -1); + gchar *heh[2]; + + heh[0] = qm->name; + heh[1] = _("(1 message)"); + gtk_clist_append(GTK_CLIST(clistqueue), heh); } } else { /* ok, so we're not queuing it. well then, we'll try to handle it normally. @@ -726,7 +717,7 @@ /* apply default fonts and colors */ tmpmsg = stylize(gc->away, MSG_LEN); serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); - if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { + if (!cnv && clistqueue && (away_options & OPT_AWAY_QUEUE)) { struct queued_message *qm; qm = g_new0(struct queued_message, 1); g_snprintf(qm->name, sizeof(qm->name), "%s", name);
--- a/src/ui.h Thu Jan 02 01:18:21 2003 +0000 +++ b/src/ui.h Thu Jan 02 05:18:16 2003 +0000 @@ -280,8 +280,7 @@ extern struct away_message *default_away; extern int auto_away; extern GtkWidget *awaymenu; -extern GtkWidget *awayqueue; -extern GtkListStore *awayqueuestore; +extern GtkWidget *clistqueue; /* Globals in buddy.c */ extern GtkWidget *buddies;