comparison src/away.c @ 1773:6d1d9e988fd4

[gaim-migrate @ 1783] Away message queueue thingy. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Mon, 30 Apr 2001 06:02:06 +0000
parents 9aae465eeb6e
children 9d0c91c705b7
comparison
equal deleted inserted replaced
1772:896432d66303 1773:6d1d9e988fd4
38 #include "pixmaps/join.xpm" 38 #include "pixmaps/join.xpm"
39 39
40 GtkWidget *imaway = NULL; 40 GtkWidget *imaway = NULL;
41 41
42 GtkWidget *awaymenu = NULL; 42 GtkWidget *awaymenu = NULL;
43 GtkWidget *clistqueue = NULL;
44 GtkWidget *clistqueuesw;
45
43 struct away_message *awaymessage = NULL; 46 struct away_message *awaymessage = NULL;
44 struct away_message *default_away; 47 struct away_message *default_away;
45 int auto_away; 48 int auto_away;
46 49
47 static void destroy_im_away() 50 static void destroy_im_away()
49 if (imaway) 52 if (imaway)
50 gtk_widget_destroy(imaway); 53 gtk_widget_destroy(imaway);
51 imaway = NULL; 54 imaway = NULL;
52 } 55 }
53 56
57 void purge_away_queue()
58 {
59 struct conversation *cnv;
60 GSList *templist = message_queue;
61
62 gtk_clist_freeze(GTK_CLIST(clistqueue));
63
64 gtk_clist_clear(GTK_CLIST(clistqueue));
65
66 while (templist)
67 {
68 struct queued_message *qm = (struct queued_message *)templist->data;
69
70 cnv = find_conversation(qm->name);
71
72 if (!cnv)
73 cnv = new_conversation(qm->name);
74
75 cnv->gc = qm->gc;
76
77 write_to_conv(cnv, qm->message, WFLAG_RECV, NULL, qm->tm);
78
79 free(qm->message);
80
81 templist = g_slist_remove(templist, qm);
82
83 free(qm);
84 }
85
86 gtk_clist_thaw(GTK_CLIST(clistqueue));
87
88 message_queue = NULL;
89 }
90
91 void toggle_away_queue()
92 {
93 if (!clistqueue || !clistqueuesw)
94 return;
95
96 if (general_options & OPT_GEN_QUEUE_WHEN_AWAY)
97 {
98 gtk_widget_show(clistqueue);
99 gtk_widget_show(clistqueuesw);
100 }
101 else
102 {
103 gtk_widget_hide(clistqueue);
104 gtk_widget_hide(clistqueuesw);
105 purge_away_queue();
106 }
107
108 }
109
54 void do_im_back(GtkWidget *w, GtkWidget *x) 110 void do_im_back(GtkWidget *w, GtkWidget *x)
55 { 111 {
56 if (imaway) { 112 if (imaway) {
57 GtkWidget *tmp = imaway; 113 GtkWidget *tmp = imaway;
58 /*GSList *templist = message_queue; 114
59 115 purge_away_queue();
60 while (templist) 116
61 {
62 struct queued_message *qm = (struct queued_message *)templist->data;
63
64 free(qm->message);
65
66 message_queue = g_slist_remove(message_queue, qm);
67
68 free(qm);
69 }
70 */
71
72 imaway = NULL; 117 imaway = NULL;
73 gtk_widget_destroy(tmp); 118 gtk_widget_destroy(tmp);
74 if (w != tmp) 119 if (w != tmp)
75 return; 120 return;
76 } 121 }
118 */ 163 */
119 strncpy_nohtml(buf, a->message, sizeof(buf)); 164 strncpy_nohtml(buf, a->message, sizeof(buf));
120 165
121 vscrollbar = gtk_vscrollbar_new(GTK_TEXT(awaytext)->vadj); 166 vscrollbar = gtk_vscrollbar_new(GTK_TEXT(awaytext)->vadj);
122 gtk_widget_show(vscrollbar); 167 gtk_widget_show(vscrollbar);
123 gtk_widget_set_usize(awaytext, 225, 100); 168 gtk_widget_set_usize(awaytext, 245, 120);
124 gtk_text_set_word_wrap(GTK_TEXT(awaytext), TRUE); 169 gtk_text_set_word_wrap(GTK_TEXT(awaytext), TRUE);
125 gtk_widget_show(awaytext); 170 gtk_widget_show(awaytext);
126 gtk_text_freeze(GTK_TEXT(awaytext)); 171 gtk_text_freeze(GTK_TEXT(awaytext));
127 gtk_text_insert(GTK_TEXT(awaytext), NULL, NULL, NULL, buf, -1); 172 gtk_text_insert(GTK_TEXT(awaytext), NULL, NULL, NULL, buf, -1);
128 gtk_widget_show(awaytext); 173 gtk_widget_show(awaytext);
129 174
130 if (display_options & OPT_DISP_COOL_LOOK) 175 if (display_options & OPT_DISP_COOL_LOOK)
131 gtk_button_set_relief(GTK_BUTTON(back), GTK_RELIEF_NONE); 176 gtk_button_set_relief(GTK_BUTTON(back), GTK_RELIEF_NONE);
132 177
178 clistqueuesw = gtk_scrolled_window_new(NULL, NULL);
179 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clistqueuesw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
180
181 clistqueue = gtk_clist_new(2);
182 gtk_clist_set_column_width(GTK_CLIST(clistqueue), 0, 100);
183 gtk_widget_set_usize(GTK_WIDGET(clistqueue), -1, 50);
184 gtk_container_add(GTK_CONTAINER(clistqueuesw), clistqueue);
185
133 /* Put the buttons in the box */ 186 /* Put the buttons in the box */
134 gtk_box_pack_start(GTK_BOX(vbox), awaytext, TRUE, TRUE, 0); 187 gtk_box_pack_start(GTK_BOX(vbox), awaytext, TRUE, TRUE, 0);
188
189 gtk_box_pack_start(GTK_BOX(vbox), clistqueuesw, TRUE, TRUE, 0);
190
135 gtk_box_pack_start(GTK_BOX(vbox), back, FALSE, FALSE, 0); 191 gtk_box_pack_start(GTK_BOX(vbox), back, FALSE, FALSE, 0);
136 192
137 /* Handle closes right */ 193 /* Handle closes right */
138 gtk_signal_connect(GTK_OBJECT(imaway), "destroy", GTK_SIGNAL_FUNC(do_im_back), imaway); 194 gtk_signal_connect(GTK_OBJECT(imaway), "destroy", GTK_SIGNAL_FUNC(do_im_back), imaway);
139 gtk_signal_connect(GTK_OBJECT(back), "clicked", GTK_SIGNAL_FUNC(do_im_back), imaway); 195 gtk_signal_connect(GTK_OBJECT(back), "clicked", GTK_SIGNAL_FUNC(do_im_back), imaway);
140 196
141 /* Finish up */ 197 /* Finish up */
198 if (general_options & OPT_GEN_QUEUE_WHEN_AWAY)
199 {
200 gtk_widget_show(clistqueuesw);
201 gtk_widget_show(clistqueue);
202 }
203
142 gtk_widget_show(back); 204 gtk_widget_show(back);
143 gtk_widget_show(vbox); 205 gtk_widget_show(vbox);
144 if (strlen(a->name)) 206 if (strlen(a->name))
145 gtk_window_set_title(GTK_WINDOW(imaway), a->name); 207 gtk_window_set_title(GTK_WINDOW(imaway), a->name);
146 else 208 else