Mercurial > pidgin.yaz
annotate src/away.c @ 9988:d770673338f4
[gaim-migrate @ 10901]
(15:20:15) grim elite: ok.. i just got to make a big #if 0 because the
custom away messages aren't setup yet :/
(15:30:01) grim elite: ok i've got it compiling.. couple of warnings yet..
(15:34:24) grim elite:
www.reaperworld.com/code/gaim/gaim-2.0.0cvs-oscar_compiles.diff
Mark should look this over, but it seems fairly straight forward
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 08 Sep 2004 19:36:04 +0000 |
parents | f4ff7d2b9b2c |
children | cc4b2125d05d |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
1 | 7 * |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
21 * |
1 | 22 */ |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
23 #include "internal.h" |
9791 | 24 #include "gtkgaim.h" |
1 | 25 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
26 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
27 #include "debug.h" |
9730 | 28 #include "notify.h" |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
29 #include "plugin.h" |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
30 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
31 #include "prpl.h" |
6727 | 32 #include "status.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
33 #include "util.h" |
8807 | 34 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
35 |
9944 | 36 #if 0 |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6284
diff
changeset
|
37 /* XXX CORE/UI: Until we can get rid of the message queue stuff... */ |
9730 | 38 #include "away.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
39 #include "gaim.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
40 #include "gtkblist.h" |
9709 | 41 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
42 #include "gtkimhtml.h" |
9730 | 43 #include "gtkimhtmltoolbar.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
44 #include "gtkprefs.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
45 #include "gtkutils.h" |
1 | 46 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
47 GtkWidget *imaway = NULL; |
652
4d3285caa191
[gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
621
diff
changeset
|
48 GtkWidget *awaymenu = NULL; |
4412 | 49 GtkWidget *awayqueue = NULL; |
50 GtkListStore *awayqueuestore = NULL; | |
51 GtkWidget *awayqueuesw; | |
1773 | 52 |
6479 | 53 GSList *message_queue = NULL; |
54 GSList *unread_message_queue = NULL; | |
55 | |
56 GSList *away_messages = NULL; | |
1 | 57 struct away_message *awaymessage = NULL; |
58 | |
4412 | 59 static void dequeue_message(GtkTreeIter *iter) |
60 { | |
61 gchar *name; | |
62 GSList *templist; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
63 GaimConversation *cnv; |
9550 | 64 gboolean orig_while_away; |
65 | |
66 orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); | |
67 if (orig_while_away) | |
68 gaim_prefs_set_bool("/core/sound/while_away", FALSE); | |
4412 | 69 |
70 gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), iter, 0, &name, -1); | |
4491 | 71 |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8413
diff
changeset
|
72 gaim_debug(GAIM_DEBUG_INFO, "away", "Dequeueing messages from %s.\n", |
5213
1cf4eb75e3ee
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
73 name); |
4491 | 74 |
4412 | 75 templist = message_queue; |
4491 | 76 |
4412 | 77 while (templist) { |
78 struct queued_message *qm = templist->data; | |
79 if (templist->data) { | |
4793 | 80 if (!gaim_utf8_strcasecmp(qm->name, name)) { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
81 GaimAccount *account = NULL; |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
82 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
83 if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) |
4608 | 84 account = qm->account; |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
85 |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
86 cnv = gaim_find_conversation_with_account(name, account); |
4412 | 87 |
88 if (!cnv) | |
4491 | 89 cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
90 else |
4491 | 91 gaim_conversation_set_account(cnv, account); |
4412 | 92 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
93 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, |
4412 | 94 qm->flags, qm->tm); |
95 g_free(qm->message); | |
96 g_free(qm); | |
97 templist = message_queue = g_slist_remove(message_queue, qm); | |
4491 | 98 |
4412 | 99 } else { |
100 templist = templist->next; | |
101 } | |
102 } | |
103 } | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
104 |
4412 | 105 g_free(name); |
106 /* In GTK 2.2, _store_remove actually returns whether iter is valid or not | |
107 * after the remove, but in GTK 2.0 it is a void function. */ | |
108 gtk_list_store_remove(awayqueuestore, iter); | |
9550 | 109 |
110 if (orig_while_away) | |
111 gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); | |
4412 | 112 } |
113 | |
4274 | 114 void purge_away_queue(GSList **queue) |
1773 | 115 { |
4274 | 116 GSList *q = *queue; |
117 struct queued_message *qm; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
118 GaimConversation *cnv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
119 GaimAccount *account; |
9550 | 120 gboolean orig_while_away; |
121 | |
122 orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); | |
123 if (orig_while_away) | |
124 gaim_prefs_set_bool("/core/sound/while_away", FALSE); | |
1773 | 125 |
4274 | 126 while (q) { |
127 qm = q->data; | |
4167 | 128 |
4491 | 129 account = NULL; |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
130 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5573
diff
changeset
|
131 if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) |
4608 | 132 account = qm->account; |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
133 |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
134 cnv = gaim_find_conversation_with_account(qm->name, account); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4274
diff
changeset
|
135 |
4167 | 136 if (!cnv) |
4491 | 137 cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4412
diff
changeset
|
138 else |
4491 | 139 gaim_conversation_set_account(cnv, account); |
4274 | 140 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
141 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, qm->flags, qm->tm); |
4167 | 142 |
143 g_free(qm->message); | |
144 g_free(qm); | |
4274 | 145 |
146 q->data = NULL; | |
147 q = q->next; | |
4167 | 148 } |
149 | |
4274 | 150 g_slist_free(*queue); |
151 *queue = NULL; | |
9550 | 152 |
153 if (orig_while_away) | |
154 gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); | |
4167 | 155 } |
156 | |
4412 | 157 gint dequeue_cb(GtkWidget *treeview, GdkEventButton *event, gpointer data) { |
158 GtkTreeIter iter; | |
159 GtkTreeSelection *select; | |
4491 | 160 |
4167 | 161 if(!(event->type == GDK_2BUTTON_PRESS && event->button == 1)) |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8413
diff
changeset
|
162 return FALSE; /* Double clicking on the list will dequeue that user's messages. */ |
4491 | 163 |
4412 | 164 select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
165 if(gtk_tree_selection_get_selected(select, NULL, &iter)) | |
166 dequeue_message(&iter); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4274
diff
changeset
|
167 |
4412 | 168 return FALSE; |
4167 | 169 } |
4491 | 170 |
2573 | 171 |
172 | |
1773 | 173 void toggle_away_queue() |
174 { | |
4412 | 175 if (!awayqueue || !awayqueuesw) |
1773 | 176 return; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
177 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
178 if (gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
4412 | 179 gtk_widget_show(awayqueue); |
180 gtk_widget_show(awayqueuesw); | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
181 } else { |
4412 | 182 gtk_widget_hide(awayqueue); |
183 gtk_widget_hide(awayqueuesw); | |
4274 | 184 purge_away_queue(&message_queue); |
1773 | 185 } |
186 } | |
187 | |
1 | 188 void do_im_back(GtkWidget *w, GtkWidget *x) |
189 { | |
190 if (imaway) { | |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
191 GtkWidget *tmp = imaway; |
1768 | 192 |
4274 | 193 purge_away_queue(&message_queue); |
194 | |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
195 imaway = NULL; |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
196 gtk_widget_destroy(tmp); |
1614
3d3362903e1d
[gaim-migrate @ 1624]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1607
diff
changeset
|
197 if (w != tmp) |
3d3362903e1d
[gaim-migrate @ 1624]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1607
diff
changeset
|
198 return; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
199 } |
1 | 200 |
201 awaymessage = NULL; | |
4412 | 202 awayqueue = NULL; |
203 awayqueuesw = NULL; | |
9674 | 204 if (awayqueuestore != NULL) |
205 g_object_unref(G_OBJECT(awayqueuestore)); | |
4412 | 206 awayqueuestore = NULL; |
3514 | 207 serv_set_away_all(NULL); |
1 | 208 } |
209 | |
1044 | 210 |
1 | 211 void do_away_message(GtkWidget *w, struct away_message *a) |
212 { | |
213 GtkWidget *back; | |
9827 | 214 GtkWidget *edit; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
215 GtkWidget *awaytext; |
1888
dedcd9e6f3e8
[gaim-migrate @ 1898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
216 GtkWidget *sw; |
1 | 217 GtkWidget *vbox; |
9827 | 218 GtkWidget *hbox; |
4412 | 219 GtkTreeViewColumn *column; |
220 GtkCellRenderer *renderer; | |
1888
dedcd9e6f3e8
[gaim-migrate @ 1898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
221 char *buf; |
1 | 222 |
1254
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
223 if (!a) |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
224 return; |
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
225 |
6284 | 226 if(imaway) |
227 gtk_widget_destroy(imaway); | |
228 | |
229 GAIM_DIALOG(imaway); | |
230 gtk_window_set_role(GTK_WINDOW(imaway), "imaway"); | |
231 if (strlen(a->name)) | |
232 gtk_window_set_title(GTK_WINDOW(imaway), a->name); | |
233 else | |
7859 | 234 gtk_window_set_title(GTK_WINDOW(imaway), _("Away!")); |
6284 | 235 g_signal_connect(G_OBJECT(imaway), "destroy", |
236 G_CALLBACK(do_im_back), imaway); | |
1888
dedcd9e6f3e8
[gaim-migrate @ 1898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
237 |
6284 | 238 vbox = gtk_vbox_new(FALSE, 5); |
239 gtk_container_add(GTK_CONTAINER(imaway), vbox); | |
240 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | |
241 gtk_widget_show(vbox); | |
1044 | 242 |
9827 | 243 hbox = gtk_hbox_new(FALSE, 5); |
244 gtk_container_set_border_width(GTK_CONTAINER(hbox), 0); | |
245 gtk_widget_show(hbox); | |
246 | |
6284 | 247 sw = gtk_scrolled_window_new(NULL, NULL); |
248 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, | |
8973 | 249 GTK_POLICY_AUTOMATIC); |
6284 | 250 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
251 gtk_widget_set_size_request(sw, 245, 120); | |
252 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
253 gtk_widget_show(sw); | |
1888
dedcd9e6f3e8
[gaim-migrate @ 1898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
254 |
6284 | 255 awaytext = gtk_imhtml_new(NULL, NULL); |
256 gtk_container_add(GTK_CONTAINER(sw), awaytext); | |
257 gaim_setup_imhtml(awaytext); | |
258 gtk_widget_show(awaytext); | |
259 buf = stylize(a->message, BUF_LONG); | |
6982 | 260 gtk_imhtml_append_text(GTK_IMHTML(awaytext), buf, GTK_IMHTML_NO_TITLE | |
6284 | 261 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL); |
262 g_free(buf); | |
6982 | 263 gtk_imhtml_append_text(GTK_IMHTML(awaytext), "<BR>", |
6284 | 264 GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_COMMENTS | |
265 GTK_IMHTML_NO_SCROLL); | |
1773 | 266 |
6284 | 267 awayqueuesw = gtk_scrolled_window_new(NULL, NULL); |
268 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(awayqueuesw), | |
269 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
270 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(awayqueuesw), | |
271 GTK_SHADOW_IN); | |
272 gtk_box_pack_start(GTK_BOX(vbox), awayqueuesw, TRUE, TRUE, 0); | |
273 | |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8235
diff
changeset
|
274 awayqueuestore = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
6284 | 275 awayqueue = gtk_tree_view_new_with_model(GTK_TREE_MODEL(awayqueuestore)); |
276 renderer = gtk_cell_renderer_text_new(); | |
277 | |
278 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(awayqueue), FALSE); | |
279 column = gtk_tree_view_column_new_with_attributes (NULL, renderer, | |
280 "text", 0, | |
281 NULL); | |
282 gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); | |
283 column = gtk_tree_view_column_new_with_attributes(NULL, renderer, | |
284 "text", 1, | |
285 NULL); | |
286 gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); | |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8235
diff
changeset
|
287 column = gtk_tree_view_column_new_with_attributes(NULL, renderer, |
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8235
diff
changeset
|
288 "text", 2, |
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8235
diff
changeset
|
289 NULL); |
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8235
diff
changeset
|
290 gtk_tree_view_append_column(GTK_TREE_VIEW(awayqueue), column); |
6284 | 291 |
292 gtk_container_add(GTK_CONTAINER(awayqueuesw), awayqueue); | |
293 | |
294 g_signal_connect(G_OBJECT(awayqueue), "button_press_event", G_CALLBACK(dequeue_cb), NULL); | |
2573 | 295 |
1773 | 296 |
6284 | 297 if (gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
298 gtk_widget_show(awayqueuesw); | |
299 gtk_widget_show(awayqueue); | |
300 } | |
1773 | 301 |
9827 | 302 awaymessage = a; |
303 | |
304 edit = gaim_pixbuf_button_from_stock(_("Edit This Message"), GTK_STOCK_CONVERT, GAIM_BUTTON_HORIZONTAL); | |
305 gtk_box_pack_start(GTK_BOX(hbox), edit, TRUE, TRUE, 0); | |
306 g_signal_connect(G_OBJECT(edit), "clicked", G_CALLBACK(create_away_mess), awaymessage); | |
307 gtk_widget_show(edit); | |
308 | |
6284 | 309 back = gaim_pixbuf_button_from_stock(_("I'm Back!"), GTK_STOCK_JUMP_TO, GAIM_BUTTON_HORIZONTAL); |
9827 | 310 gtk_box_pack_start(GTK_BOX(hbox), back, TRUE, TRUE, 0); |
6284 | 311 g_signal_connect(G_OBJECT(back), "clicked", G_CALLBACK(do_im_back), imaway); |
312 gtk_window_set_focus(GTK_WINDOW(imaway), back); | |
313 gtk_widget_show(back); | |
1888
dedcd9e6f3e8
[gaim-migrate @ 1898]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
314 |
9827 | 315 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
1 | 316 |
1779
0da2a831c0ae
[gaim-migrate @ 1789]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1775
diff
changeset
|
317 gtk_widget_show(imaway); |
6019 | 318 serv_set_away_all(awaymessage->message); |
1 | 319 } |
320 | |
8807 | 321 void do_rem_away_mess(gchar *name) |
1 | 322 { |
8820 | 323 struct away_message *a = NULL; |
6216 | 324 struct away_message *default_away = NULL; |
325 const char *default_away_name; | |
326 GSList *l; | |
327 | |
8807 | 328 /* Lookup the away message based on the title */ |
329 for (l = away_messages; l != NULL; l = l->next) { | |
330 a = l->data; | |
331 if (!strcmp(a->name, name)) | |
332 break; | |
333 } | |
334 g_free(name); | |
335 | |
8820 | 336 if (l == NULL || a == NULL) { |
8807 | 337 /* Could not find away message! */ |
338 return; | |
339 } | |
340 | |
6216 | 341 default_away_name = gaim_prefs_get_string("/core/away/default_message"); |
342 | |
343 for(l = away_messages; l; l = l->next) { | |
344 if(!strcmp(default_away_name, ((struct away_message *)l->data)->name)) { | |
345 default_away = l->data; | |
346 break; | |
347 } | |
1254
9da444224f0e
[gaim-migrate @ 1264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
348 } |
6216 | 349 |
350 if(!default_away && away_messages) | |
351 default_away = away_messages->data; | |
352 | |
1306
868f9c98db13
[gaim-migrate @ 1316]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1292
diff
changeset
|
353 away_messages = g_slist_remove(away_messages, a); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
354 g_free(a); |
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
355 do_away_menu(); |
6727 | 356 gaim_status_sync(); |
1 | 357 } |
358 | |
8807 | 359 void rem_away_mess(GtkWidget *w, struct away_message *a) |
360 { | |
361 gchar *text; | |
362 | |
363 text = g_strdup_printf(_("Are you sure you want to remove the away message \"%s\"?"), a->name); | |
364 | |
9976 | 365 gaim_request_action(NULL, NULL, _("Remove Away Message"), text, |
366 0, g_strdup(a->name), 2, | |
8807 | 367 _("Remove"), G_CALLBACK(do_rem_away_mess), |
368 _("Cancel"), G_CALLBACK(g_free)); | |
369 | |
370 g_free(text); | |
371 } | |
372 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
373 static void set_gc_away(GObject *obj, GaimConnection *gc) |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
374 { |
4635 | 375 struct away_message *awy = g_object_get_data(obj, "away_message"); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
376 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
377 if (awy) |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
378 serv_set_away(gc, GAIM_AWAY_CUSTOM, awy->message); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
379 else |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
380 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
381 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
382 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
383 static void set_gc_state(GObject *obj, GaimConnection *gc) |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
384 { |
4635 | 385 char *awy = g_object_get_data(obj, "away_state"); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
386 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
387 serv_set_away(gc, awy, NULL); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
388 } |
1 | 389 |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
390 /* XXX This needs to be fixed, NOW! */ |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
391 extern GtkListStore *prefs_away_store; |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
392 extern GtkWidget *prefs_away_menu; |
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
393 |
1 | 394 void do_away_menu() |
395 { | |
396 GtkWidget *menuitem; | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
397 GtkWidget *remmenu; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
398 GtkWidget *submenu, *submenu2; |
1 | 399 GtkWidget *remitem; |
5160 | 400 GtkWidget *image; |
401 GdkPixbuf *pixbuf, *scale; | |
1 | 402 GList *l; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
403 GSList *awy = away_messages; |
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
404 struct away_message *a; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
405 GList *con; |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
406 GaimConnection *gc = NULL; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
407 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
408 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
409 int count = 0; |
1 | 410 |
4635 | 411 if (prefs_away_store != NULL) { |
412 gtk_list_store_clear(prefs_away_store); | |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
413 while (awy) { |
4635 | 414 GtkTreeIter iter; |
1 | 415 a = (struct away_message *)awy->data; |
4635 | 416 gtk_list_store_append(prefs_away_store, &iter); |
417 gtk_list_store_set(prefs_away_store, &iter, | |
418 0, a->name, | |
419 1, a, | |
420 -1); | |
940 | 421 awy = g_slist_next(awy); |
1 | 422 } |
423 } | |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
424 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
425 if (awaymenu) { |
4635 | 426 l = gtk_container_get_children(GTK_CONTAINER(awaymenu)); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
427 |
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
428 while (l) { |
1530
0b6e4d52de63
[gaim-migrate @ 1540]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
429 gtk_container_remove(GTK_CONTAINER(awaymenu), GTK_WIDGET(l->data)); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
430 l = l->next; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
431 } |
1 | 432 |
8235 | 433 g_list_free(l); |
1 | 434 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
435 remmenu = gtk_menu_new(); |
1 | 436 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
437 menuitem = gtk_menu_item_new_with_label(_("New Away Message")); |
4635 | 438 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
439 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
440 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(create_away_mess), |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
441 NULL); |
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
442 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
443 awy = away_messages; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
444 while (awy) { |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
445 a = (struct away_message *)awy->data; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
446 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
447 remitem = gtk_menu_item_new_with_label(a->name); |
4635 | 448 gtk_menu_shell_append(GTK_MENU_SHELL(remmenu), remitem); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
449 gtk_widget_show(remitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
450 g_signal_connect(G_OBJECT(remitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
451 G_CALLBACK(rem_away_mess), a); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
452 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
453 awy = g_slist_next(awy); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
454 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
455 } |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
456 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
457 menuitem = gtk_menu_item_new_with_label(_("Remove Away Message")); |
4635 | 458 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); |
1 | 459 gtk_widget_show(menuitem); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
460 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
461 gtk_widget_show(remmenu); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
462 |
5160 | 463 gaim_separator(awaymenu); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
464 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
465 for (con = gaim_connections_get_all(); con != NULL; con = con->next) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
466 gc = con->data; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
467 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
468 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
469 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
470 if (prpl_info->away_states != NULL && prpl_info->set_away != NULL) |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
471 count++; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
472 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
473 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
474 if (count == 0) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
475 } else if (count == 1) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
476 GList *msgs, *tmp; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
477 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
478 for (con = gaim_connections_get_all(); con != NULL; con = con->next) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
479 gc = con->data; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
480 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
481 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
482 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
483 if (prpl_info->away_states && prpl_info->set_away) |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
484 break; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
485 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
486 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
487 tmp = msgs = prpl_info->away_states(gc); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
488 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
489 if ((g_list_length(msgs) == 1) && !strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
490 awy = away_messages; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
491 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
492 while (awy) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
493 a = (struct away_message *)awy->data; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
494 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
495 menuitem = gtk_menu_item_new_with_label(a->name); |
4635 | 496 g_object_set_data(G_OBJECT(menuitem), "away_message", a); |
497 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
498 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
499 g_signal_connect(G_OBJECT(menuitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
500 G_CALLBACK(do_away_message), a); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
501 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
502 awy = g_slist_next(awy); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
503 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
504 } else |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
505 while (msgs) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
506 awy = away_messages; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
507 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
508 menuitem = gtk_menu_item_new_with_label(msgs->data); |
4635 | 509 g_object_set_data(G_OBJECT(menuitem), "away_state", msgs->data); |
510 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
511 gtk_widget_show(menuitem); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
512 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
513 if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
514 g_signal_connect(G_OBJECT(menuitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
515 G_CALLBACK(set_gc_state), gc); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
516 } else { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
517 submenu = gtk_menu_new(); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
518 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
519 submenu); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
520 gtk_widget_show(submenu); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
521 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
522 while (awy) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
523 a = (struct away_message *)awy->data; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
524 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
525 menuitem = gtk_menu_item_new_with_label(a->name); |
4635 | 526 g_object_set_data(G_OBJECT(menuitem), "away_message", |
527 a); | |
528 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), | |
529 menuitem); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
530 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
531 g_signal_connect(G_OBJECT(menuitem), |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
532 "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
533 G_CALLBACK |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
534 (do_away_message), a); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
535 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
536 awy = g_slist_next(awy); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
537 } |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
538 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
539 msgs = g_list_next(msgs); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
540 } |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
541 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1456
diff
changeset
|
542 g_list_free(tmp); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
543 } |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
544 else { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
545 for (con = gaim_connections_get_all(); con != NULL; con = con->next) { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
546 GaimAccount *account; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
547 char buf[256]; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
548 GList *msgs, *tmp; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
549 gc = con->data; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
550 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
551 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
552 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
553 if (!prpl_info->away_states || !prpl_info->set_away) |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
554 continue; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
555 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
556 account = gaim_connection_get_account(gc); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
557 |
5161 | 558 g_snprintf(buf, sizeof(buf), "%s (%s)", |
9699 | 559 gaim_account_get_username(account), |
560 gaim_account_get_protocol_name(account)); | |
5161 | 561 menuitem = gtk_image_menu_item_new_with_label(buf); |
562 | |
5160 | 563 pixbuf = create_prpl_icon(gc->account); |
564 if (pixbuf) { | |
565 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); | |
566 image = gtk_image_new_from_pixbuf(scale); | |
567 g_object_unref(G_OBJECT(pixbuf)); | |
568 g_object_unref(G_OBJECT(scale)); | |
5161 | 569 gtk_widget_show(image); |
570 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), | |
571 image); | |
5160 | 572 } |
573 | |
4635 | 574 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
575 gtk_widget_show(menuitem); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
576 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
577 submenu = gtk_menu_new(); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
578 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
579 gtk_widget_show(submenu); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
580 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
581 tmp = msgs = prpl_info->away_states(gc); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
582 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
583 if ((g_list_length(msgs) == 1) && |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
584 (!strcmp(msgs->data, GAIM_AWAY_CUSTOM))) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
585 menuitem = gtk_menu_item_new_with_label(_("Back")); |
4635 | 586 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
587 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
588 g_signal_connect(G_OBJECT(menuitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
589 G_CALLBACK(set_gc_away), gc); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
590 |
5160 | 591 gaim_separator(submenu); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
592 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
593 awy = away_messages; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
594 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
595 while (awy) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
596 a = (struct away_message *)awy->data; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
597 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
598 menuitem = gtk_menu_item_new_with_label(a->name); |
4635 | 599 g_object_set_data(G_OBJECT(menuitem), "away_message", a); |
600 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
601 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
602 g_signal_connect(G_OBJECT(menuitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
603 G_CALLBACK(set_gc_away), gc); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
604 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
605 awy = g_slist_next(awy); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
606 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
607 } else |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
608 while (msgs) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
609 awy = away_messages; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
610 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
611 menuitem = gtk_menu_item_new_with_label(msgs->data); |
4635 | 612 g_object_set_data(G_OBJECT(menuitem), "away_state", |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
613 msgs->data); |
4635 | 614 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
615 gtk_widget_show(menuitem); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
616 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
617 if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
618 g_signal_connect(G_OBJECT(menuitem), |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
619 "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
620 G_CALLBACK(set_gc_state), |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
621 gc); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
622 } else { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
623 submenu2 = gtk_menu_new(); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
624 gtk_menu_item_set_submenu(GTK_MENU_ITEM |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
625 (menuitem), submenu2); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
626 gtk_widget_show(submenu2); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
627 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
628 while (awy) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
629 a = (struct away_message *)awy->data; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
630 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
631 menuitem = |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
632 gtk_menu_item_new_with_label(a-> |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
633 name); |
4635 | 634 g_object_set_data(G_OBJECT(menuitem), |
635 "away_message", a); | |
636 gtk_menu_shell_append(GTK_MENU_SHELL(submenu2), | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
637 menuitem); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
638 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
639 g_signal_connect(G_OBJECT(menuitem), |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
640 "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
641 G_CALLBACK |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
642 (set_gc_away), gc); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
643 |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
644 awy = g_slist_next(awy); |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
645 } |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
646 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
647 msgs = g_list_next(msgs); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
648 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
649 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
650 g_list_free(tmp); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
651 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
652 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
653 menuitem = gtk_menu_item_new_with_label(_("Set All Away")); |
4635 | 654 gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem); |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
655 gtk_widget_show(menuitem); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
656 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
657 submenu = gtk_menu_new(); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
658 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
659 gtk_widget_show(submenu); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
660 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
661 awy = away_messages; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
662 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
663 while (awy) { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
664 a = (struct away_message *)awy->data; |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
665 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
666 menuitem = gtk_menu_item_new_with_label(a->name); |
4635 | 667 g_object_set_data(G_OBJECT(menuitem), "away_message", a); |
668 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
669 gtk_widget_show(menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
670 g_signal_connect(G_OBJECT(menuitem), "activate", |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
671 G_CALLBACK(do_away_message), a); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
672 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
673 awy = g_slist_next(awy); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1306
diff
changeset
|
674 } |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
675 } |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
676 } |
5560
b7319c094153
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
677 |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
678 if (prefs_away_menu) { |
4635 | 679 l = gtk_container_get_children(GTK_CONTAINER(prefs_away_menu)); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1191
diff
changeset
|
680 while (l) { |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
681 gtk_widget_destroy(GTK_WIDGET(l->data)); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
682 l = l->next; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
683 } |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
684 gtk_widget_hide(GTK_WIDGET(prefs_away_menu)); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
685 default_away_menu_init(GTK_WIDGET(prefs_away_menu)); |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1044
diff
changeset
|
686 gtk_widget_show(prefs_away_menu); |
1 | 687 } |
688 } | |
9730 | 689 |
690 /*------------------------------------------------------------------------*/ | |
691 /* The dialog for new away messages (from dialogs.c) */ | |
692 /*------------------------------------------------------------------------*/ | |
693 struct create_away { | |
694 GtkWidget *window; | |
695 GtkWidget *toolbar; | |
696 GtkWidget *entry; | |
697 GtkWidget *text; | |
698 struct away_message *mess; | |
699 }; | |
700 | |
701 static void | |
702 away_mess_destroy(GtkWidget *widget, struct create_away *ca) | |
703 { | |
704 gtk_widget_destroy(ca->window); | |
705 g_free(ca); | |
706 } | |
707 | |
708 static void | |
709 away_mess_destroy_ca(GtkWidget *widget, GdkEvent *event, struct create_away *ca) | |
710 { | |
711 away_mess_destroy(NULL, ca); | |
712 } | |
713 | |
714 static gint | |
715 sort_awaymsg_list(gconstpointer a, gconstpointer b) | |
716 { | |
717 struct away_message *msg_a; | |
718 struct away_message *msg_b; | |
719 | |
720 msg_a = (struct away_message *)a; | |
721 msg_b = (struct away_message *)b; | |
722 | |
723 return (strcmp(msg_a->name, msg_b->name)); | |
724 } | |
725 | |
726 static struct | |
727 away_message *save_away_message(struct create_away *ca) | |
728 { | |
729 struct away_message *am; | |
730 gchar *away_message; | |
731 | |
732 if (!ca->mess) | |
733 am = g_new0(struct away_message, 1); | |
734 else { | |
735 am = ca->mess; | |
736 } | |
737 | |
738 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | |
739 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); | |
740 | |
741 g_snprintf(am->message, sizeof(am->message), "%s", away_message); | |
742 g_free(away_message); | |
743 | |
744 if (!ca->mess) | |
745 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list); | |
746 | |
747 do_away_menu(NULL); | |
748 gaim_status_sync(); | |
749 | |
750 return am; | |
751 } | |
752 | |
753 int | |
754 check_away_mess(struct create_away *ca, int type) | |
755 { | |
756 gchar *msg; | |
757 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) { | |
758 /* We shouldn't allow a blank title */ | |
759 gaim_notify_error(NULL, NULL, | |
760 _("You cannot save an away message with a " | |
761 "blank title"), | |
762 _("Please give the message a title, or choose " | |
763 "\"Use\" to use without saving.")); | |
764 return 0; | |
765 } | |
766 | |
767 msg = gtk_imhtml_get_text(GTK_IMHTML(ca->text), NULL, NULL); | |
768 | |
769 if ((type <= 1) && ((msg == NULL) || (*msg == '\0'))) { | |
770 /* We shouldn't allow a blank message */ | |
771 gaim_notify_error(NULL, NULL, | |
772 _("You cannot create an empty away message"), NULL); | |
773 return 0; | |
774 } | |
775 | |
776 g_free(msg); | |
777 | |
778 return 1; | |
779 } | |
780 | |
781 void | |
782 save_away_mess(GtkWidget *widget, struct create_away *ca) | |
783 { | |
784 if (!check_away_mess(ca, 1)) | |
785 return; | |
786 | |
787 save_away_message(ca); | |
788 | |
789 away_mess_destroy(NULL, ca); | |
790 } | |
791 | |
792 void | |
793 use_away_mess(GtkWidget *widget, struct create_away *ca) | |
794 { | |
795 static struct away_message am; | |
796 gchar *away_message; | |
797 | |
798 if (!check_away_mess(ca, 0)) | |
799 return; | |
800 | |
801 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | |
802 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text)); | |
803 | |
804 g_snprintf(am.message, sizeof(am.message), "%s", away_message); | |
805 g_free(away_message); | |
806 | |
807 do_away_message(NULL, &am); | |
808 | |
809 away_mess_destroy(NULL, ca); | |
810 } | |
811 | |
812 void | |
813 su_away_mess(GtkWidget *widget, struct create_away *ca) | |
814 { | |
815 if (!check_away_mess(ca, 1)) | |
816 return; | |
817 | |
818 do_away_message(NULL, save_away_message(ca)); | |
819 | |
820 away_mess_destroy(NULL, ca); | |
821 } | |
822 | |
823 void | |
824 create_away_mess(GtkWidget *widget, void *dummy) | |
825 { | |
826 GtkWidget *vbox, *hbox; | |
827 GtkWidget *label; | |
828 GtkWidget *sw; | |
829 GtkWidget *button; | |
830 GList *focus_chain = NULL; | |
831 struct create_away *ca = g_new0(struct create_away, 1); | |
832 | |
833 /* Set up window */ | |
834 GAIM_DIALOG(ca->window); | |
835 gtk_widget_set_size_request(ca->window, -1, 250); | |
836 gtk_window_set_role(GTK_WINDOW(ca->window), "away_mess"); | |
837 gtk_window_set_title(GTK_WINDOW(ca->window), _("New away message")); | |
838 g_signal_connect(G_OBJECT(ca->window), "delete_event", | |
839 G_CALLBACK(away_mess_destroy_ca), ca); | |
840 | |
841 hbox = gtk_hbox_new(FALSE, 12); | |
842 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12); | |
843 gtk_container_add(GTK_CONTAINER(ca->window), hbox); | |
844 | |
845 vbox = gtk_vbox_new(FALSE, 12); | |
846 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
847 | |
848 /* Away message title */ | |
849 hbox = gtk_hbox_new(FALSE, 0); | |
850 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
851 | |
852 label = gtk_label_new(_("Away title: ")); | |
853 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
854 | |
855 ca->entry = gtk_entry_new(); | |
856 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0); | |
857 gaim_set_accessible_label (ca->entry, label); | |
858 focus_chain = g_list_append(focus_chain, hbox); | |
859 | |
860 /* Toolbar */ | |
861 ca->toolbar = gtk_imhtmltoolbar_new(); | |
862 gtk_box_pack_start(GTK_BOX(vbox), ca->toolbar, FALSE, FALSE, 0); | |
863 | |
864 /* Away message text */ | |
865 sw = gtk_scrolled_window_new(NULL, NULL); | |
866 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
867 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
868 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | |
869 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
870 | |
871 ca->text = gtk_imhtml_new(NULL, NULL); | |
872 gtk_imhtml_set_editable(GTK_IMHTML(ca->text), TRUE); | |
873 gtk_imhtml_set_format_functions(GTK_IMHTML(ca->text), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); | |
874 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR); | |
875 | |
876 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(ca->text), | |
877 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")); | |
878 gtk_imhtml_html_shortcuts(GTK_IMHTML(ca->text), | |
879 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")); | |
880 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
881 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text)); | |
882 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(ca->toolbar), ca->text); | |
883 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(ca->toolbar), "default"); | |
884 gaim_setup_imhtml(ca->text); | |
885 | |
886 gtk_container_add(GTK_CONTAINER(sw), ca->text); | |
887 focus_chain = g_list_append(focus_chain, sw); | |
888 | |
889 if (dummy) { | |
9827 | 890 /* If anything is passed here, it is an away_message pointer */ |
891 struct away_message *amt = (struct away_message *) dummy ; | |
9730 | 892 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name); |
893 gtk_imhtml_append_text_with_images(GTK_IMHTML(ca->text), amt->message, 0, NULL); | |
894 ca->mess = amt; | |
895 } | |
896 | |
897 hbox = gtk_hbox_new(FALSE, 5); | |
898 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
899 | |
900 button = gaim_pixbuf_button_from_stock(_("_Save"), GTK_STOCK_SAVE, GAIM_BUTTON_HORIZONTAL); | |
901 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_away_mess), ca); | |
902 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
903 | |
904 button = gaim_pixbuf_button_from_stock(_("Sa_ve & Use"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL); | |
905 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(su_away_mess), ca); | |
906 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
907 | |
908 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE, GAIM_BUTTON_HORIZONTAL); | |
909 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(use_away_mess), ca); | |
910 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
911 | |
912 button = gaim_pixbuf_button_from_stock(_("_Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); | |
913 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(away_mess_destroy), ca); | |
914 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
915 focus_chain = g_list_prepend(focus_chain, hbox); | |
916 | |
917 gtk_widget_show_all(ca->window); | |
918 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); | |
919 } | |
9944 | 920 #endif /* 0 */ |