annotate src/gtkstatusselector.c @ 10318:fcadde998ba9

[gaim-migrate @ 11520] Hopefully decode non-ascii direct IM messages. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 04 Dec 2004 21:41:25 +0000
parents ec140184437b
children 4d2ecbb139a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10249
diff changeset
2 * @file gtkstatusselector.c GTK+ Status selector widget
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * @ingroup gtkui
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * source distribution.
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * (at your option) any later version.
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * GNU General Public License for more details.
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 */
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "internal.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "gtkgaim.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include "gtkimhtml.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "gtkstatusselector.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 #include "gtkutils.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 #include "account.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #include "debug.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #include "prefs.h"
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 struct _GaimGtkStatusSelectorPrivate
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 GtkWidget *combo;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 GtkWidget *entry;
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
39 GtkWidget *frame;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 GtkListStore *model;
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
42
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
43 guint entry_timer;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 };
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 enum
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 COLUMN_STATUS_TYPE_ID,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 COLUMN_ICON,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 COLUMN_NAME,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 NUM_COLUMNS
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 };
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 static void gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 static void gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 static void gaim_gtk_status_selector_finalize(GObject *obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 static void gaim_gtk_status_selector_destroy(GtkObject *obj);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
58 #if GTK_CHECK_VERSION (2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 static void status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
60 static gboolean key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 static void signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
62 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 static void rebuild_list(GaimGtkStatusSelector *selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 static GtkVBox *parent_class = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 GType
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 gaim_gtk_status_selector_get_type(void)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 static GType type = 0;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 if (!type)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 static const GTypeInfo info =
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 sizeof(GaimGtkStatusSelectorClass),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 (GClassInitFunc)gaim_gtk_status_selector_class_init,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 sizeof(GaimGtkStatusSelector),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 0,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 (GInstanceInitFunc)gaim_gtk_status_selector_init
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 };
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 type = g_type_register_static(GTK_TYPE_VBOX,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 "GaimGtkStatusSelector", &info, 0);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 return type;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *klass)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 GObjectClass *gobject_class;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 GtkObjectClass *object_class;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 parent_class = g_type_class_peek_parent(klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 gobject_class = G_OBJECT_CLASS(klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 object_class = GTK_OBJECT_CLASS(klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 gobject_class->finalize = gaim_gtk_status_selector_finalize;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 object_class->destroy = gaim_gtk_status_selector_destroy;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 {
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
113 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 GtkWidget *combo;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 GtkWidget *entry;
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
116 GtkWidget *toolbar;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
117 GtkWidget *frame;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 GtkCellRenderer *renderer;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 #endif
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 selector->priv = g_new0(GaimGtkStatusSelectorPrivate, 1);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 #if GTK_CHECK_VERSION(2,4,0)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 selector->priv->model = gtk_list_store_new(NUM_COLUMNS, G_TYPE_POINTER,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 GDK_TYPE_PIXBUF, G_TYPE_STRING);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(selector->priv->model));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 selector->priv->combo = combo;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 g_object_unref(G_OBJECT(selector->priv->model));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 renderer = gtk_cell_renderer_pixbuf_new();
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 "pixbuf", COLUMN_ICON,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 renderer = gtk_cell_renderer_text_new();
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 "text", COLUMN_NAME,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 g_signal_connect(G_OBJECT(combo), "changed",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 G_CALLBACK(status_switched_cb), selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 /* TODO */
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 gtk_widget_show(combo);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 gtk_box_pack_start(GTK_BOX(selector), combo, FALSE, FALSE, 0);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
153 frame = gaim_gtk_create_imhtml(TRUE, &entry, &toolbar);
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
154 selector->priv->entry = entry;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
155 selector->priv->frame = frame;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
156 gtk_widget_set_name(entry, "gaim_gtkstatusselector_imhtml");
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
157 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0);
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
158 gtk_widget_hide(toolbar);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
160 g_signal_connect(G_OBJECT(entry), "key_press_event",
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
161 G_CALLBACK(key_press_cb), selector);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
162
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 selector, GAIM_CALLBACK(signed_on_off_cb),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 selector, GAIM_CALLBACK(signed_on_off_cb),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 rebuild_list(selector);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
171 #endif /* GTK < 2.4.0 */
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 gaim_gtk_status_selector_finalize(GObject *obj)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 g_return_if_fail(obj != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 selector = GAIM_GTK_STATUS_SELECTOR(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 g_free(selector->priv);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 if (G_OBJECT_CLASS(parent_class)->finalize)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 G_OBJECT_CLASS(parent_class)->finalize(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 gaim_gtk_status_selector_destroy(GtkObject *obj)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 g_return_if_fail(obj != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 selector = GAIM_GTK_STATUS_SELECTOR(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199
10187
5a1fe52036ad [gaim-migrate @ 11302]
Mark Doliner <mark@kingant.net>
parents: 10183
diff changeset
200 gaim_signals_disconnect_by_handle(selector);
10249
a7c8a8735a31 [gaim-migrate @ 11389]
Mark Doliner <mark@kingant.net>
parents: 10248
diff changeset
201 if (selector->priv->entry_timer != 0)
a7c8a8735a31 [gaim-migrate @ 11389]
Mark Doliner <mark@kingant.net>
parents: 10248
diff changeset
202 gaim_timeout_remove(selector->priv->entry_timer);
10187
5a1fe52036ad [gaim-migrate @ 11302]
Mark Doliner <mark@kingant.net>
parents: 10183
diff changeset
203
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 if (GTK_OBJECT_CLASS(parent_class)->destroy)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 GTK_OBJECT_CLASS(parent_class)->destroy(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
208 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 GtkTreeIter iter;
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
213 const char *status_type_id;
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
214 const char *text;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
216 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo),
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 &iter))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 {
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
219 return;
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
220 }
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
221
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
222 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter,
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
223 COLUMN_NAME, &text,
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
224 COLUMN_STATUS_TYPE_ID, &status_type_id,
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
225 -1);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
227 if (status_type_id == NULL)
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
228 {
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
229 if (!strcmp(text, _("New Status")))
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
230 {
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
231 /* TODO */
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
232 }
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
233 }
10197
7369bf2bf593 [gaim-migrate @ 11314]
Mark Doliner <mark@kingant.net>
parents: 10191
diff changeset
234 else
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
235 {
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
236 /*
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
237 * If the chosen status does not require a message, then set the
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
238 * status immediately. Otherwise just register a timeout and the
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
239 * status will be set whenever the user stops typing the message.
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
240 */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
241 GList *l;
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
242 GtkTextBuffer *buffer;
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
243 gboolean allow_message = FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
245 buffer =
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
246 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry));
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
247
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
248 gtk_text_buffer_set_text(buffer, text, -1);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
249
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
250 for (l = gaim_connections_get_all(); l != NULL; l = l->next)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
251 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
252 GaimConnection *gc = (GaimConnection *)l->data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
253 GaimAccount *account = gaim_connection_get_account(gc);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
254 GaimStatusType *status_type;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
255
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
256 status_type = gaim_account_get_status_type(account,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
257 status_type_id);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
258
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
259 if (status_type == NULL)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
260 continue;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
261
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
262 if (gaim_status_type_get_attr(status_type, "message") != NULL)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
263 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
264 allow_message = TRUE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
265 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
266 else
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
267 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
268 gaim_account_set_status(account,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
269 status_type_id, TRUE,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
270 NULL);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
271 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
272 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
273
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
274 if (allow_message)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
275 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
276 gtk_widget_show(selector->priv->frame);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
277 key_press_cb(NULL, NULL, selector);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
278 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
279 else
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
280 gtk_widget_hide(selector->priv->frame);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
281 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
282 }
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
283 #endif
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
284
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
285 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
286 insert_text_timeout_cb(gpointer data)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
287 {
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
288 #if GTK_CHECK_VERSION(2,4,0)
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
289 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
290 GtkTreeIter iter;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
291 const char *status_type_id;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
292 const char *text;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
293
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
294 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo),
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
295 &iter))
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
296 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
297 return FALSE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
298 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
299
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
300 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
301 COLUMN_NAME, &text,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
302 COLUMN_STATUS_TYPE_ID, &status_type_id,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
303 -1);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
304
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
305 if (status_type_id == NULL)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
306 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
307 if (!strcmp(text, _("New Status")))
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
308 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
309 /* TODO */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
310 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
311 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
312 else
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
313 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
314 gchar *message;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
315 GList *l;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
316
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
317 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry));
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
318
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
319 for (l = gaim_connections_get_all(); l != NULL; l = l->next)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 {
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
321 GaimConnection *gc = (GaimConnection *)l->data;
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
322 GaimAccount *account = gaim_connection_get_account(gc);
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
323 GaimStatusType *status_type;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
325 status_type = gaim_account_get_status_type(account,
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
326 status_type_id);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
328 if (status_type == NULL)
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
329 continue;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
331 if (gaim_status_type_get_attr(status_type, "message") != NULL)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 {
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
333 gaim_account_set_status(account,
10197
7369bf2bf593 [gaim-migrate @ 11314]
Mark Doliner <mark@kingant.net>
parents: 10191
diff changeset
334 status_type_id, TRUE,
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
335 "message", message,
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
336 NULL);
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
337 }
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
338 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
339 }
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
340 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
342 return FALSE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
343 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
344
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
345 /**
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
346 * The user typed in the IMHTML entry widget. If the user is finished
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
347 * typing then we want to set the appropriate status message. So let's
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
348 * wait 3 seconds, and if they haven't typed anything else then set the
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
349 * status message.
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
350 */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
351 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
352 key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
353 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
354 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)user_data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
355
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
356 if (selector->priv->entry_timer != 0) {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
357 gaim_timeout_remove(selector->priv->entry_timer);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
359
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
360 selector->priv->entry_timer = gaim_timeout_add(3000, insert_text_timeout_cb,
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
361 selector);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
362
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
363 return FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 rebuild_list(selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 static GdkPixbuf *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 load_icon(const char *basename)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 char *filename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 GdkPixbuf *pixbuf, *scale = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 if (!strcmp(basename, "available.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 basename = "online.png";
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 else if (!strcmp(basename, "hidden.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 basename = "invisible.png";
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 g_free(filename);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 if (pixbuf != NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 GDK_INTERP_BILINEAR);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 g_object_unref(G_OBJECT(pixbuf));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 "default", basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 scale = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 g_free(filename);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 return scale;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 add_item(GaimGtkStatusSelector *selector, const char *status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 const char *text, GdkPixbuf *pixbuf)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 GtkTreeIter iter;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 gtk_list_store_append(selector->priv->model, &iter);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 gtk_list_store_set(selector->priv->model, &iter,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 COLUMN_STATUS_TYPE_ID, status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 COLUMN_ICON, pixbuf,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 COLUMN_NAME, text,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 -1);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 if (pixbuf != NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 g_object_unref(G_OBJECT(pixbuf));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 rebuild_list(GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 gboolean single_prpl = TRUE;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 GaimAccount *first_account = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 const char *first_prpl_type = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 GList *l;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 g_return_if_fail(selector != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 gtk_list_store_clear(selector->priv->model);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 /*
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 * If the user only has one IM account or one type of IM account
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 * connected, they'll see all their statuses. This is ideal for those
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 * who use only one account, or one single protocol. Everyone else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 * gets Available and Away and a list of saved statuses.
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 */
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 for (l = gaim_connections_get_all(); l != NULL && single_prpl; l = l->next)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 GaimConnection *gc = (GaimConnection *)l->data;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 GaimAccount *account = gaim_connection_get_account(gc);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 GaimPluginProtocolInfo *prpl_info;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 const char *basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 basename = prpl_info->list_icon(account, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 if (first_prpl_type == NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 first_prpl_type = basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 first_account = account;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 }
10179
97ee3bf7bcf7 [gaim-migrate @ 11294]
Christian Hammond <chipx86@chipx86.com>
parents: 10178
diff changeset
457 else if (strcmp(first_prpl_type, basename))
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 single_prpl = FALSE;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 if (single_prpl)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 const GList *l;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 for (l = gaim_account_get_status_types(first_account);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 l != NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 l = l->next)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 GaimStatusType *status_type = (GaimStatusType *)l->data;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 char filename[BUFSIZ];
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 if (!gaim_status_type_is_user_settable(status_type))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473 continue;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474
10207
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
475 /*
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
476 * TODO Find a way to fallback to the GaimStatusPrimitive
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
477 * if an icon for this id does not exist.
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
478 */
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479 g_snprintf(filename, sizeof(filename), "%s.png",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 gaim_status_type_get_id(status_type));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 add_item(selector,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483 gaim_status_type_get_id(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 gaim_status_type_get_name(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485 load_icon(filename));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
486 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 add_item(selector, "available", _("Available"),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 load_icon("online.png"));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 add_item(selector, "away", _("Away"), load_icon("away.png"));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
495 /* TODO: Add saved statuses here? */
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
496
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 add_item(selector, NULL, _("New Status"),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 GTK_ICON_SIZE_MENU, NULL));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 GtkWidget *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 gaim_gtk_status_selector_new(void)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 selector = g_object_new(GAIM_GTK_TYPE_STATUS_SELECTOR, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 return GTK_WIDGET(selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 }