annotate src/gtkstatusselector.c @ 10456:d23802800eeb

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