annotate src/away.c @ 9860:65b3156f9f48

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