annotate src/gtkstatusselector.c @ 10437:446f5f28e8d0

[gaim-migrate @ 11694] sf patch #1090744, from Balwinder Singh Dheeman Adds back a thingy to the perl API committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 27 Dec 2004 20:48:41 +0000
parents ce098e226486
children 6feef0a9098a
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
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
41 GtkWidget *optmenu;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
42 GtkWidget *menu;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
43 GtkSizeGroup *sg;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
44
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 GtkListStore *model;
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
46
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
47 guint entry_timer;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 };
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 enum
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 COLUMN_STATUS_TYPE_ID,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 COLUMN_ICON,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 COLUMN_NAME,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 NUM_COLUMNS
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 };
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
58 #define GAIM_SELECTOR_TEXT "gaim-text"
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
59 #define GAIM_SELECTOR_STATUS_TYPE_ID "gaim-status-type-id"
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
60
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 static void gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 static void gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 static void gaim_gtk_status_selector_finalize(GObject *obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 static void gaim_gtk_status_selector_destroy(GtkObject *obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 static void status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
66 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
67 static void signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 static void rebuild_list(GaimGtkStatusSelector *selector);
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 GtkVBox *parent_class = NULL;
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 GType
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 gaim_gtk_status_selector_get_type(void)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 static GType type = 0;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 if (!type)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 static const GTypeInfo info =
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 sizeof(GaimGtkStatusSelectorClass),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 (GClassInitFunc)gaim_gtk_status_selector_class_init,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 NULL,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 sizeof(GaimGtkStatusSelector),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 0,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 (GInstanceInitFunc)gaim_gtk_status_selector_init
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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 type = g_type_register_static(GTK_TYPE_VBOX,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 "GaimGtkStatusSelector", &info, 0);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 return type;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *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 GObjectClass *gobject_class;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 GtkObjectClass *object_class;
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 parent_class = g_type_class_peek_parent(klass);
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 gobject_class = G_OBJECT_CLASS(klass);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 object_class = GTK_OBJECT_CLASS(klass);
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 gobject_class->finalize = gaim_gtk_status_selector_finalize;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 object_class->destroy = gaim_gtk_status_selector_destroy;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 {
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
118 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 GtkWidget *combo;
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
120 GtkCellRenderer *renderer;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
121 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
122 GtkWidget *optmenu;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
123 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 GtkWidget *entry;
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
125 GtkWidget *toolbar;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
126 GtkWidget *frame;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 selector->priv = g_new0(GaimGtkStatusSelectorPrivate, 1);
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 #if GTK_CHECK_VERSION(2,4,0)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 selector->priv->model = gtk_list_store_new(NUM_COLUMNS, G_TYPE_POINTER,
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
132 GDK_TYPE_PIXBUF, G_TYPE_STRING);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 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
135 selector->priv->combo = combo;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 g_object_unref(G_OBJECT(selector->priv->model));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 renderer = gtk_cell_renderer_pixbuf_new();
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 "pixbuf", COLUMN_ICON,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 renderer = gtk_cell_renderer_text_new();
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 "text", COLUMN_NAME,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 g_signal_connect(G_OBJECT(combo), "changed",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 G_CALLBACK(status_switched_cb), selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 /* TODO */
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 gtk_widget_show(combo);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 gtk_box_pack_start(GTK_BOX(selector), combo, FALSE, FALSE, 0);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
160
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
161 #else /* GTK < 2.4.0 */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
162 selector->priv->optmenu = optmenu = gtk_option_menu_new();
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
163 gtk_widget_show(optmenu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
164
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
165 selector->priv->menu = gtk_menu_new();
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
166 gtk_widget_show(selector->priv->menu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
167 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), selector->priv->menu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
168
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
169 selector->priv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
170
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
171 g_signal_connect(G_OBJECT(optmenu), "changed",
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
172 G_CALLBACK(status_switched_cb), selector);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
173
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
174 gtk_box_pack_start(GTK_BOX(selector), optmenu, FALSE, FALSE, 0);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
175 #endif
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
176
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
177 frame = gaim_gtk_create_imhtml(TRUE, &entry, &toolbar);
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
178 selector->priv->entry = entry;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
179 selector->priv->frame = frame;
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
180 gtk_widget_set_name(entry, "gaim_gtkstatusselector_imhtml");
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
181 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0);
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
182 gtk_widget_hide(toolbar);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
184 g_signal_connect(G_OBJECT(entry), "key_press_event",
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
185 G_CALLBACK(key_press_cb), selector);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
187 selector, GAIM_CALLBACK(signed_on_off_cb),
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
188 selector);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
190 selector, GAIM_CALLBACK(signed_on_off_cb),
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
191 selector);
10404
ce098e226486 [gaim-migrate @ 11649]
Mark Doliner <mark@kingant.net>
parents: 10400
diff changeset
192
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 rebuild_list(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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 gaim_gtk_status_selector_finalize(GObject *obj)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 g_return_if_fail(obj != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 selector = GAIM_GTK_STATUS_SELECTOR(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
206 if (selector->priv->sg) {
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
207 g_object_unref(selector->priv->sg);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
208 selector->priv->sg = NULL;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
209 }
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
210
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 g_free(selector->priv);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 if (G_OBJECT_CLASS(parent_class)->finalize)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 G_OBJECT_CLASS(parent_class)->finalize(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 gaim_gtk_status_selector_destroy(GtkObject *obj)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 g_return_if_fail(obj != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 selector = GAIM_GTK_STATUS_SELECTOR(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
10187
5a1fe52036ad [gaim-migrate @ 11302]
Mark Doliner <mark@kingant.net>
parents: 10183
diff changeset
227 gaim_signals_disconnect_by_handle(selector);
10249
a7c8a8735a31 [gaim-migrate @ 11389]
Mark Doliner <mark@kingant.net>
parents: 10248
diff changeset
228 if (selector->priv->entry_timer != 0)
a7c8a8735a31 [gaim-migrate @ 11389]
Mark Doliner <mark@kingant.net>
parents: 10248
diff changeset
229 gaim_timeout_remove(selector->priv->entry_timer);
10187
5a1fe52036ad [gaim-migrate @ 11302]
Mark Doliner <mark@kingant.net>
parents: 10183
diff changeset
230
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 if (GTK_OBJECT_CLASS(parent_class)->destroy)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 GTK_OBJECT_CLASS(parent_class)->destroy(obj);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
235 static gboolean
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
236 get_selected_data(GaimGtkStatusSelector *selector, const char **text, const char **status_type_id)
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
237 {
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10207
diff changeset
238 #if GTK_CHECK_VERSION(2,4,0)
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
239 GtkTreeIter iter;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
240
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
241 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo),
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
242 &iter))
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
243 return FALSE;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
244
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
245 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
246 COLUMN_NAME, text,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
247 COLUMN_STATUS_TYPE_ID, status_type_id,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
248 -1);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
249 return TRUE;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
250 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
251 GtkWidget *item;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
252 int i;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
253 GList *l;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
254
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
255 i = gtk_option_menu_get_history(GTK_OPTION_MENU(selector->priv->optmenu));
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
256 l = GTK_MENU_SHELL(selector->priv->menu)->children;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
257 item = g_list_nth_data(l, i);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
258 *text = g_object_get_data(G_OBJECT(item), GAIM_SELECTOR_TEXT);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
259 *status_type_id = g_object_get_data(G_OBJECT(item), GAIM_SELECTOR_STATUS_TYPE_ID);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
260 return TRUE;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
261 #endif
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
262 return FALSE;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
263 }
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
264
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 {
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
268 const char *status_type_id = NULL;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
269 const char *text = NULL;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
271 if (!get_selected_data(selector, &text, &status_type_id))
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
272 return;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
274 if (status_type_id == NULL)
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
275 {
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
276 if (!strcmp(text, _("New Status")))
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
277 {
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
278 /* TODO */
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
279 }
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
280 }
10197
7369bf2bf593 [gaim-migrate @ 11314]
Mark Doliner <mark@kingant.net>
parents: 10191
diff changeset
281 else
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
282 {
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
283 /*
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
284 * 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
285 * status immediately. Otherwise just register a timeout and the
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
286 * status will be set whenever the user stops typing the message.
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
287 */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
288 GList *l;
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
289 GtkTextBuffer *buffer;
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
290 gboolean allow_message = FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
292 buffer =
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
293 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry));
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
294
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
295 gtk_text_buffer_set_text(buffer, text, -1);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
296
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
297 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
298 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
299 GaimAccount *account = (GaimAccount*)l->data;
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
300 GaimStatusType *status_type;
10404
ce098e226486 [gaim-migrate @ 11649]
Mark Doliner <mark@kingant.net>
parents: 10400
diff changeset
301
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
302 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
303 continue;
10199
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 status_type = gaim_account_get_status_type(account,
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
306 status_type_id);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
307
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
308 if (status_type == NULL)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
309 continue;
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 if (gaim_status_type_get_attr(status_type, "message") != NULL)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
312 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
313 allow_message = TRUE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
314 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
315 else
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 gaim_account_set_status(account,
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
318 status_type_id, TRUE,
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
319 NULL);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
320 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
321 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
322
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
323 if (allow_message)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
324 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
325 gtk_widget_show(selector->priv->frame);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
326 key_press_cb(NULL, NULL, selector);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
327 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
328 else
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
329 gtk_widget_hide(selector->priv->frame);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
330 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
331 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
332
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
333 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
334 insert_text_timeout_cb(gpointer data)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
335 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
336 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
337 const char *status_type_id;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
338 const char *text;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
339
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
340 if (!get_selected_data(selector, &text, &status_type_id))
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
341 return FALSE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
342
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
343 if (status_type_id == NULL)
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 if (!strcmp(text, _("New Status")))
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
346 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
347 /* TODO */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
348 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
349 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
350 else
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
351 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
352 gchar *message;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
353 GList *l;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
354
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
355 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry));
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
356
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
357 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
359 GaimAccount *account = (GaimAccount*)l->data;
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
360 GaimStatusType *status_type;
10404
ce098e226486 [gaim-migrate @ 11649]
Mark Doliner <mark@kingant.net>
parents: 10400
diff changeset
361
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
362 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
363 continue;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
365 status_type = gaim_account_get_status_type(account,
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
366 status_type_id);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
368 if (status_type == NULL)
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
369 continue;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
371 if (gaim_status_type_get_attr(status_type, "message") != NULL)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 {
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
373 gaim_account_set_status(account,
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
374 status_type_id, TRUE,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
375 "message", message,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
376 NULL);
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
377 }
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
378 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
379 }
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
381 return FALSE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
382 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
383
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
384 /**
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
385 * 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
386 * 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
387 * 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
388 * status message.
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
389 */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
390 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
391 key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
392 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
393 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)user_data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
394
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
395 if (selector->priv->entry_timer != 0) {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
396 gaim_timeout_remove(selector->priv->entry_timer);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
398
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
399 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
400 selector);
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
401
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
402 return FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 }
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 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 rebuild_list(selector);
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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 static GdkPixbuf *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 load_icon(const char *basename)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 char *filename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 GdkPixbuf *pixbuf, *scale = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 if (!strcmp(basename, "available.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 basename = "online.png";
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 else if (!strcmp(basename, "hidden.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 basename = "invisible.png";
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 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 g_free(filename);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 if (pixbuf != NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 GDK_INTERP_BILINEAR);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 g_object_unref(G_OBJECT(pixbuf));
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 else
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 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 "default", basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 scale = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 g_free(filename);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 }
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 return scale;
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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 add_item(GaimGtkStatusSelector *selector, const char *status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 const char *text, GdkPixbuf *pixbuf)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 {
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
449 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 GtkTreeIter iter;
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 gtk_list_store_append(selector->priv->model, &iter);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 gtk_list_store_set(selector->priv->model, &iter,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 COLUMN_STATUS_TYPE_ID, status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 COLUMN_ICON, pixbuf,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 COLUMN_NAME, text,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 -1);
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
458 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
459 GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
460 GtkWidget *item, *hbox, *label;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
461
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
462 /* Create the item. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
463 item = gtk_menu_item_new();
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
464
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
465 /* Create the hbox. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
466 hbox = gtk_hbox_new(FALSE, 4);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
467 gtk_container_add(GTK_CONTAINER(item), hbox);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
468 gtk_widget_show(hbox);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
469
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
470 gtk_size_group_add_widget(selector->priv->sg, image);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
471
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
472 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
473 gtk_widget_show(image);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
474
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
475 /* Create the label. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
476 label = gtk_label_new(text);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
477 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
478 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
479 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
480 gtk_widget_show(label);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
481
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
482 g_object_set_data_full(G_OBJECT(item), GAIM_SELECTOR_TEXT, g_strdup(text), g_free);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
483 g_object_set_data_full(G_OBJECT(item), GAIM_SELECTOR_STATUS_TYPE_ID, g_strdup(status_type_id), g_free);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
484
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
485 gtk_menu_shell_append(GTK_MENU_SHELL(selector->priv->menu), item);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
486 gtk_widget_show(item);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
487 gaim_set_accessible_label(item, label);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
488 #endif
10178
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 if (pixbuf != NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 g_object_unref(G_OBJECT(pixbuf));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
494
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 rebuild_list(GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498 gboolean single_prpl = TRUE;
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
499 GList *accounts;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
500 gboolean enabled = FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 GaimAccount *first_account = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 const char *first_prpl_type = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 GList *l;
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 g_return_if_fail(selector != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
508 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 gtk_list_store_clear(selector->priv->model);
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
510 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
511 gtk_option_menu_remove_menu(GTK_OPTION_MENU(selector->priv->optmenu));
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
512 /* XXX this automaticly destroys the menu, right? */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
513 selector->priv->menu = gtk_menu_new();
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
514 gtk_widget_show(selector->priv->menu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
515 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517 /*
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
518 * If no accounts are enabled then gray ourself out and get
10352
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
519 * outta hee.
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
520 */
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
521 for(accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) {
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
522 GaimAccount *a = accounts->data;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
523 if (gaim_account_get_enabled(a, GAIM_GTK_UI)) {
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
524 enabled = TRUE;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
525 break;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
526 }
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
527 }
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
528
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
529 if (enabled == FALSE)
10352
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
530 {
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
531 gtk_widget_set_sensitive(GTK_WIDGET(selector), FALSE);
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
532 return;
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
533 }
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
534 gtk_widget_set_sensitive(GTK_WIDGET(selector), TRUE);
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
535
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
536 /*
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
537 * 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
538 * connected, they'll see all their statuses. This is ideal for those
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539 * who use only one account, or one single protocol. Everyone else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540 * gets Available and Away and a list of saved statuses.
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
541 */
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
542 for (l = gaim_accounts_get_all(); l != NULL && single_prpl; l = l->next)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
543 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
544 GaimAccount *account = l->data;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 GaimPluginProtocolInfo *prpl_info;
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
546 GaimPlugin *plugin;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
547 const char *basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
549 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
550 continue;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
551
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
552 plugin = gaim_find_prpl(account->protocol_id);
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
553 if (!plugin)
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
554 continue;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
555
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
556 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 basename = prpl_info->list_icon(account, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 if (first_prpl_type == NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
561 first_prpl_type = basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562 first_account = account;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 }
10179
97ee3bf7bcf7 [gaim-migrate @ 11294]
Christian Hammond <chipx86@chipx86.com>
parents: 10178
diff changeset
564 else if (strcmp(first_prpl_type, basename))
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 single_prpl = FALSE;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
566 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
568 if (single_prpl)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
570 const GList *l;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572 for (l = gaim_account_get_status_types(first_account);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
573 l != NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574 l = l->next)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576 GaimStatusType *status_type = (GaimStatusType *)l->data;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577 char filename[BUFSIZ];
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
578
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
579 if (!gaim_status_type_is_user_settable(status_type))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580 continue;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
581
10207
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
582 /*
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
583 * TODO Find a way to fallback to the GaimStatusPrimitive
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
584 * if an icon for this id does not exist.
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
585 */
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 g_snprintf(filename, sizeof(filename), "%s.png",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587 gaim_status_type_get_id(status_type));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 add_item(selector,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 gaim_status_type_get_id(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 gaim_status_type_get_name(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 load_icon(filename));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
594 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595 else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 add_item(selector, "available", _("Available"),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598 load_icon("online.png"));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599 add_item(selector, "away", _("Away"), load_icon("away.png"));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
600 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
601
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
602 /* TODO: Add saved statuses here? */
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
603
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604 add_item(selector, NULL, _("New Status"),
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
605 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
606 GTK_ICON_SIZE_MENU, NULL));
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
607 #if !GTK_CHECK_VERSION(2,4,0)
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
608 gtk_option_menu_set_menu(GTK_OPTION_MENU(selector->priv->optmenu), selector->priv->menu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
609 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
610 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
611
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612 GtkWidget *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 gaim_gtk_status_selector_new(void)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
614 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
615 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
617 selector = g_object_new(GAIM_GTK_TYPE_STATUS_SELECTOR, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619 return GTK_WIDGET(selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 }