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