annotate src/gtkstatusselector.c @ 10818:0555ec6f3eaa

[gaim-migrate @ 12475] sf patch #1180355, from Richard Laager Adds the ChangeLog.API entry for the removal of the public function gaim_find_conversation committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 12 Apr 2005 00:54:58 +0000
parents 364a2ef907ae
children
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
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10504
diff changeset
162 #else /* GTK+ < 2.4.0 */
10347
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
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
237 get_selected_data(GaimGtkStatusSelector *selector, char **text, const char **status_type_id)
10347
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);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
259 *text = g_strdup(g_object_get_data(G_OBJECT(item), GAIM_SELECTOR_TEXT));
10347
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;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
273 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 }
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
337 g_free(text);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
338 }
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
339
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
340 /**
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
341 * 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
342 * 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
343 * 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
344 * given online/enabled account requires a message, then it sets
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
345 * that status with the entered message.
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
346 */
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
347 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
348 insert_text_timeout_cb(gpointer data)
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 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
351 const char *status_type_id;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
352 char *text;
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
353 gchar *message;
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
354 GList *l;
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
355
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
356 gtk_widget_set_sensitive(selector->priv->frame, FALSE);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
357
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
358 if (!get_selected_data(selector, &text, &status_type_id))
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
359 return FALSE;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
360
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
361 if (status_type_id == NULL)
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
362 {
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
363 g_free(text);
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
364 return FALSE;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
365 }
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
366
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
367 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry));
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
368
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
369 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
370 {
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
371 GaimAccount *account = (GaimAccount*)l->data;
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
372 GaimStatusType *status_type;
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
373
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
374 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
375 continue;
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
376
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
377 status_type = gaim_account_get_status_type(account,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
378 status_type_id);
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
379
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
380 if (status_type == NULL)
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
381 continue;
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
382
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
383 if (gaim_status_type_get_attr(status_type, "message") != NULL)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 {
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
385 gaim_account_set_status(account,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
386 status_type_id, TRUE,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
387 "message", message,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
388 NULL);
10188
5709800d1dee [gaim-migrate @ 11303]
Mark Doliner <mark@kingant.net>
parents: 10187
diff changeset
389 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
390 }
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
392 g_free(text);
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
393 g_free(message);
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10495
diff changeset
394
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
395 return FALSE;
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
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 * 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
400 * 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
401 * 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
402 * status message.
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
403 */
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
404 static gboolean
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
405 key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data)
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
406 {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
407 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)user_data;
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
408
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
409 if (selector->priv->entry_timer != 0) {
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
410 gaim_timeout_remove(selector->priv->entry_timer);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 }
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
412
10455
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
413 selector->priv->entry_timer = gaim_timeout_add(3000,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
414 insert_text_timeout_cb,
6d4f02da1cef [gaim-migrate @ 11723]
Mark Doliner <mark@kingant.net>
parents: 10447
diff changeset
415 selector);
10199
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
416
76e296e16def [gaim-migrate @ 11316]
Mark Doliner <mark@kingant.net>
parents: 10197
diff changeset
417 return FALSE;
10178
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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 rebuild_list(selector);
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
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 static GdkPixbuf *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 load_icon(const char *basename)
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 char *filename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 GdkPixbuf *pixbuf, *scale = NULL;
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 if (!strcmp(basename, "available.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 basename = "online.png";
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 else if (!strcmp(basename, "hidden.png"))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435 basename = "invisible.png";
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 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 g_free(filename);
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 if (pixbuf != NULL)
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 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 GDK_INTERP_BILINEAR);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 g_object_unref(G_OBJECT(pixbuf));
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 else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 "default", basename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 scale = gdk_pixbuf_new_from_file(filename, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 g_free(filename);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 return scale;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 }
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 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 add_item(GaimGtkStatusSelector *selector, const char *status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 const char *text, GdkPixbuf *pixbuf)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 {
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
464 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 GtkTreeIter iter;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 gtk_list_store_append(selector->priv->model, &iter);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 gtk_list_store_set(selector->priv->model, &iter,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 COLUMN_STATUS_TYPE_ID, status_type_id,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 COLUMN_ICON, pixbuf,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 COLUMN_NAME, text,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 -1);
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
473 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
474 GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
475 GtkWidget *item, *hbox, *label;
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
476
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
477 /* Create the item. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
478 item = gtk_menu_item_new();
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 /* Create the hbox. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
481 hbox = gtk_hbox_new(FALSE, 4);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
482 gtk_container_add(GTK_CONTAINER(item), hbox);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
483 gtk_widget_show(hbox);
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_size_group_add_widget(selector->priv->sg, image);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
486
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
487 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
488 gtk_widget_show(image);
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 /* Create the label. */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
491 label = gtk_label_new(text);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
492 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
493 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
494 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
495 gtk_widget_show(label);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
496
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
497 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
498 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
499
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
500 gtk_menu_shell_append(GTK_MENU_SHELL(selector->priv->menu), item);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
501 gtk_widget_show(item);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
502 gaim_set_accessible_label(item, label);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
503 #endif
10178
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 if (pixbuf != NULL)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 g_object_unref(G_OBJECT(pixbuf));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
509
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 static void
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 rebuild_list(GaimGtkStatusSelector *selector)
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 gboolean single_prpl = TRUE;
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
514 GList *accounts;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
515 gboolean enabled = FALSE;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 GaimAccount *first_account = NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517 const char *first_prpl_type = NULL;
10485
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
518 const GList *l;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 g_return_if_fail(selector != NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
523 #if GTK_CHECK_VERSION(2,4,0)
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524 gtk_list_store_clear(selector->priv->model);
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
525 #else
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
526 gtk_option_menu_remove_menu(GTK_OPTION_MENU(selector->priv->optmenu));
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
527 /* XXX this automaticly destroys the menu, right? */
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
528 selector->priv->menu = gtk_menu_new();
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
529 gtk_widget_show(selector->priv->menu);
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
530 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 /*
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
533 * 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
534 * outta hee.
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
535 */
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
536 for (accounts = gaim_accounts_get_all(); accounts != NULL;
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
537 accounts = accounts->next)
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
538 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
539 GaimAccount *a = accounts->data;
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
540 if (gaim_account_get_enabled(a, GAIM_GTK_UI))
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
541 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
542 enabled = TRUE;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
543 break;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
544 }
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
545 }
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
546
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
547 if (enabled == FALSE)
10352
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
548 {
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
549 gtk_widget_set_sensitive(GTK_WIDGET(selector), FALSE);
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
550 return;
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
551 }
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
552 gtk_widget_set_sensitive(GTK_WIDGET(selector), TRUE);
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
553
5879593a6a10 [gaim-migrate @ 11569]
Mark Doliner <mark@kingant.net>
parents: 10347
diff changeset
554 /*
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555 * 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
556 * connected, they'll see all their statuses. This is ideal for those
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 * who use only one account, or one single protocol. Everyone else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 * gets Available and Away and a list of saved statuses.
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 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
561 {
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
562 GaimAccount *account = l->data;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 GaimPluginProtocolInfo *prpl_info;
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
564 GaimPlugin *plugin;
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 const char *basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
566
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
567 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
568 continue;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
569
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
570 plugin = gaim_find_prpl(account->protocol_id);
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
571 if (!plugin)
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
572 continue;
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
573
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10352
diff changeset
574 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 basename = prpl_info->list_icon(account, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577 if (first_prpl_type == NULL)
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 first_prpl_type = basename;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580 first_account = account;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
581 }
10179
97ee3bf7bcf7 [gaim-migrate @ 11294]
Christian Hammond <chipx86@chipx86.com>
parents: 10178
diff changeset
582 else if (strcmp(first_prpl_type, basename))
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
583 single_prpl = FALSE;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
584 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
585
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 if (single_prpl)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588 for (l = gaim_account_get_status_types(first_account);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 l != NULL;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 l = l->next)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 GaimStatusType *status_type = (GaimStatusType *)l->data;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593 char filename[BUFSIZ];
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 if (!gaim_status_type_is_user_settable(status_type))
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 continue;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597
10207
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
598 /*
10447
6feef0a9098a [gaim-migrate @ 11712]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
599 * TODO: Find a way to fallback to the GaimStatusPrimitive
10207
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
600 * if an icon for this id does not exist.
9d03dd6ccc9a [gaim-migrate @ 11328]
Mark Doliner <mark@kingant.net>
parents: 10199
diff changeset
601 */
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
602 g_snprintf(filename, sizeof(filename), "%s.png",
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 gaim_status_type_get_id(status_type));
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 add_item(selector,
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606 gaim_status_type_get_id(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
607 gaim_status_type_get_name(status_type),
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608 load_icon(filename));
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
609 }
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 else
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612 {
10485
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
613 /* what follows is either really ugly, or brilliant depending on
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
614 * how you look at it, and how much you've had to drink */
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
615 int i;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
616 int num_accounts = 0;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
617 int options[GAIM_STATUS_NUM_PRIMITIVES];
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
618 GaimAccount *acct_options[GAIM_STATUS_NUM_PRIMITIVES];
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
619
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
620 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
621 options[i] = 0;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
622 acct_options[i] = NULL;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
623 }
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
624
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
625 for(accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
626 GaimAccount *account = accounts->data;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
627
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
628 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
629 continue;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
630
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
631 num_accounts++;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
632
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
633 for(l = gaim_account_get_status_types(account); l != NULL; l = l->next) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
634 GaimStatusType *status_type = l->data;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
635
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
636 if (!gaim_status_type_is_user_settable(status_type))
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
637 continue;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
638
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
639 acct_options[gaim_status_type_get_primitive(status_type)] = account;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
640 }
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
641
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
642 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
643 if(acct_options[i] == account)
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
644 options[i]++;
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
645 }
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
646 }
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
647
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
648 for(i=0; i<GAIM_STATUS_NUM_PRIMITIVES; i++) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
649 if(options[i] == num_accounts) {
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
650 char *filename = g_strdup_printf("%s.png", gaim_primitive_get_id_from_type(i));
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
651 add_item(selector, gaim_primitive_get_id_from_type(i), gaim_primitive_get_name_from_type(i), load_icon(filename));
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
652 g_free(filename);
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
653 }
58ab47ed31bf [gaim-migrate @ 11775]
Nathan Walp <nwalp@pidgin.im>
parents: 10455
diff changeset
654 }
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
655 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
656
10191
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
657 /* TODO: Add saved statuses here? */
0f86175b41a4 [gaim-migrate @ 11306]
Mark Doliner <mark@kingant.net>
parents: 10188
diff changeset
658
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
659 add_item(selector, NULL, _("New Status"),
10347
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
660 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW,
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
661 GTK_ICON_SIZE_MENU, NULL));
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
662 #if !GTK_CHECK_VERSION(2,4,0)
4d2ecbb139a0 [gaim-migrate @ 11561]
Tim Ringenbach <marv@pidgin.im>
parents: 10297
diff changeset
663 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
664 #endif
10178
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665 }
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
666
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
667 GtkWidget *
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
668 gaim_gtk_status_selector_new(void)
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
669 {
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670 GaimGtkStatusSelector *selector;
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
672 selector = g_object_new(GAIM_GTK_TYPE_STATUS_SELECTOR, NULL);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
673
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
674 return GTK_WIDGET(selector);
96a850ab30c8 [gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
675 }