Mercurial > pidgin
annotate src/gtkstatusbox.c @ 10688:7818a5e9e3a2
[gaim-migrate @ 12237]
Fixed a problem which would make gaim unable to use GTK installations that it should be able to use. The DllPath registry entry was never being read because the target buffer size was being incorrectly specified. Unless you had the Installer registry key specified and set to NSIS, it would point to the wrong directory for GTK dlls. The error messages from failed registry lookups are now better. I also removed some code that was intended to support alternate GTK installations (dropline?) that use the \lib directory instead of the \bin for the gtk+ dlls, it really isn't an issue anymore.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 12 Mar 2005 19:35:37 +0000 |
parents | 0925c898b73c |
children | f51e040affc6 |
rev | line source |
---|---|
10643 | 1 /* |
2 * @file gtkstatusbox.c GTK+ Status Selection Widget | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 | |
26 #include "internal.h" | |
27 #include "account.h" | |
28 #include "status.h" | |
29 #include "gtkgaim.h" | |
30 #include "gtkstock.h" | |
31 #include "gtkstatusbox.h" | |
32 | |
33 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); | |
34 | |
35 static void gtk_gaim_status_box_changed(GtkComboBox *box); | |
36 static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
37 static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
38 static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); | |
39 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
40 | |
41 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); | |
42 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); | |
43 static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event); | |
44 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
45 enum { | |
46 ICON_COLUMN, | |
47 TEXT_COLUMN, | |
48 TITLE_COLUMN, | |
49 DESC_COLUMN, | |
50 TYPE_COLUMN, | |
51 NUM_COLUMNS | |
52 }; | |
53 | |
54 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); | |
55 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); | |
56 | |
57 GType | |
58 gtk_gaim_status_box_get_type (void) | |
59 { | |
60 static GType status_box_type = 0; | |
61 | |
62 if (!status_box_type) | |
63 { | |
64 static const GTypeInfo status_box_info = | |
65 { | |
66 sizeof (GtkGaimStatusBoxClass), | |
67 NULL, /* base_init */ | |
68 NULL, /* base_finalize */ | |
69 (GClassInitFunc) gtk_gaim_status_box_class_init, | |
70 NULL, /* class_finalize */ | |
71 NULL, /* class_data */ | |
72 sizeof (GtkGaimStatusBox), | |
73 0, | |
74 (GInstanceInitFunc) gtk_gaim_status_box_init | |
75 }; | |
76 | |
77 status_box_type = g_type_register_static (GTK_TYPE_COMBO_BOX, | |
78 "GtkGaimStatusBox", | |
79 &status_box_info, | |
80 0); | |
81 } | |
82 | |
83 return status_box_type; | |
84 } | |
85 | |
86 static void | |
87 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) | |
88 { | |
89 GObjectClass *object_class; | |
90 GtkWidgetClass *widget_class; | |
91 GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; | |
92 GtkContainerClass *container_class = (GtkContainerClass*)klass; | |
93 | |
94 parent_class->changed = gtk_gaim_status_box_changed; | |
95 widget_class = (GtkWidgetClass*)klass; | |
96 combo_box_size_request = widget_class->size_request; | |
97 widget_class->size_request = gtk_gaim_status_box_size_request; | |
98 combo_box_size_allocate = widget_class->size_allocate; | |
99 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; | |
100 combo_box_expose_event = widget_class->expose_event; | |
101 widget_class->expose_event = gtk_gaim_status_box_expose_event; | |
102 | |
103 combo_box_forall = container_class->forall; | |
104 container_class->forall = gtk_gaim_status_box_forall; | |
105 | |
106 object_class = (GObjectClass *)klass; | |
107 } | |
108 | |
109 static void | |
110 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | |
111 { | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
112 char *text, *title; |
10643 | 113 char aa_color[8]; |
114 GdkPixbuf *pixbuf; | |
115 | |
116 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
117 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
118 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
119 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
120 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
121 |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
122 title = status_box->title; |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
123 if (!title) |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
124 title = ""; |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
125 |
10643 | 126 if (status_box->error) { |
127 text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
128 title, status_box->error); |
10643 | 129 } else if (status_box->typing) { |
10661
f02873d475dc
[gaim-migrate @ 12198]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10649
diff
changeset
|
130 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
131 title, |
10643 | 132 aa_color, |
133 _("Typing")); | |
134 } else if (status_box->connecting) { | |
135 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
136 title, |
10643 | 137 aa_color, |
138 _("Connecting")); | |
139 } else if (status_box->desc) { | |
140 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
141 title, aa_color, status_box->desc); |
10643 | 142 } else { |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
143 text = g_strdup_printf("%s", title); |
10643 | 144 } |
145 | |
146 if (status_box->error) | |
147 pixbuf = status_box->error_pixbuf; | |
148 else if (status_box->typing) | |
149 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | |
150 else if (status_box->connecting) | |
151 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | |
152 else | |
153 pixbuf = status_box->pixbuf; | |
154 | |
155 gtk_list_store_set(status_box->store, &(status_box->iter), | |
156 ICON_COLUMN, pixbuf, | |
157 TEXT_COLUMN, text, | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
158 TITLE_COLUMN, title, |
10643 | 159 DESC_COLUMN, status_box->desc, |
160 TYPE_COLUMN, NULL, -1); | |
161 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), gtk_tree_path_new_from_string("0")); | |
162 | |
163 g_free(text); | |
164 } | |
165 | |
166 static void | |
167 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) | |
168 { | |
169 GtkCellRenderer *text_rend = gtk_cell_renderer_text_new(); | |
170 GtkCellRenderer *icon_rend = gtk_cell_renderer_pixbuf_new(); | |
171 GtkTextBuffer *buffer; | |
172 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; | |
173 GtkIconSize icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
174 | |
175 status_box->imhtml_visible = FALSE; | |
176 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, | |
177 icon_size, "GtkGaimStatusBox"); | |
178 status_box->connecting_index = 0; | |
179 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT0, | |
180 icon_size, "GtkGaimStatusBox"); | |
181 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT1, | |
182 icon_size, "GtkGaimStatusBox"); | |
183 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT2, | |
184 icon_size, "GtkGaimStatusBox"); | |
185 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT3, | |
186 icon_size, "GtkGaimStatusBox"); | |
187 | |
188 status_box->typing_index = 0; | |
189 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING0, | |
190 icon_size, "GtkGaimStatusBox"); | |
191 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING1, | |
192 icon_size, "GtkGaimStatusBox"); | |
193 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING2, | |
194 icon_size, "GtkGaimStatusBox"); | |
195 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING3, | |
196 icon_size, "GtkGaimStatusBox"); | |
197 status_box->connecting = FALSE; | |
198 status_box->typing = FALSE; | |
199 status_box->title = NULL; | |
200 status_box->pixbuf = NULL; | |
201 status_box->cell_view = gtk_cell_view_new(); | |
202 gtk_widget_show (status_box->cell_view); | |
203 | |
204 status_box->store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
205 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
206 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); | |
207 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
208 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
209 gtk_list_store_append(status_box->store, &(status_box->iter)); | |
210 gtk_gaim_status_box_refresh(status_box); | |
211 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), gtk_tree_path_new_from_string("0")); | |
212 gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view); | |
213 | |
214 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); | |
215 status_box->text_rend = gtk_cell_renderer_text_new(); | |
216 | |
217 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); | |
218 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); | |
219 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); | |
220 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
221 | |
222 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | |
223 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); | |
224 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); | |
225 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
226 | |
227 status_box->vbox = gtk_vbox_new(0, FALSE); | |
228 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | |
229 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); | |
230 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); | |
231 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); | |
232 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); | |
233 status_box->sw = gtk_scrolled_window_new(NULL, NULL); | |
234 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
235 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); | |
236 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); | |
237 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); | |
238 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_ONLINE, | |
239 icon_size, "GtkGaimStatusBox"); | |
240 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AWAY, | |
241 icon_size, "GtkGaimStatusBox"); | |
242 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, | |
243 icon_size, "GtkGaimStatusBox"); | |
244 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_INVISIBLE, | |
245 icon_size, "GtkGaimStatusBox"); | |
246 /* hacks */ | |
247 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Available"), NULL, "available"); | |
248 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf2, _("Away"), NULL, "away"); | |
249 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf4, _("Invisible"), NULL, "invisible"); | |
250 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf3, _("Offline"), NULL, "offline"); | |
251 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | |
252 | |
253 } | |
254 | |
255 | |
256 static void | |
257 gtk_gaim_status_box_size_request (GtkWidget *widget, | |
258 GtkRequisition *requisition) | |
259 { | |
260 GtkRequisition box_req; | |
261 combo_box_size_request(widget, requisition); | |
262 | |
263 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); | |
264 if (box_req.height > 1) | |
265 requisition->height = requisition->height + box_req.height + 6; | |
266 | |
267 requisition->width = 1; | |
268 | |
269 } | |
270 | |
271 static void | |
272 gtk_gaim_status_box_size_allocate (GtkWidget *widget, | |
273 GtkAllocation *allocation) | |
274 { | |
275 GtkRequisition req = {0,0}; | |
276 GtkAllocation parent_alc = *allocation, box_alc = *allocation ; | |
277 combo_box_size_request(widget, &req); | |
278 | |
279 /* EVIL XXX */ | |
280 box_alc.height = 80;//MAX(1,box_alc.height - req.height - 6); | |
281 | |
282 box_alc.y = box_alc.y + req.height + 6; | |
283 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); | |
284 | |
285 parent_alc.height = MAX(1,req.height); | |
286 combo_box_size_allocate(widget, &parent_alc); | |
287 widget->allocation = *allocation; | |
288 } | |
289 | |
290 | |
291 static gboolean | |
292 gtk_gaim_status_box_expose_event (GtkWidget *widget, | |
293 GdkEventExpose *event) | |
294 { | |
295 | |
296 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (widget); | |
297 combo_box_expose_event(widget, event); | |
298 | |
299 gtk_container_propagate_expose (GTK_CONTAINER (widget), | |
300 status_box->vbox, event); | |
301 return FALSE; | |
302 } | |
303 | |
304 static void | |
305 gtk_gaim_status_box_forall (GtkContainer *container, | |
306 gboolean include_internals, | |
307 GtkCallback callback, | |
308 gpointer callback_data) | |
309 { | |
310 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); | |
311 | |
312 if (include_internals) | |
313 { | |
314 (* callback) (status_box->vbox, callback_data); | |
315 } | |
316 | |
317 combo_box_forall(container, include_internals, callback, callback_data); | |
318 } | |
319 | |
320 GtkWidget * | |
321 gtk_gaim_status_box_new() | |
322 { | |
323 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | |
324 } | |
325 | |
326 | |
327 void | |
328 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) | |
329 { | |
330 GtkTreeIter iter; | |
331 char *t; | |
332 | |
333 if (sec_text) { | |
334 char aa_color[8]; | |
335 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
336 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
337 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
338 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
339 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
340 t = g_strdup_printf("%s\n<span color=\"%s\">%s</span>", text, aa_color, sec_text); | |
341 } else { | |
342 t = g_strdup(text); | |
343 } | |
344 | |
345 gtk_list_store_append(status_box->dropdown_store, &iter); | |
346 gtk_list_store_set(status_box->dropdown_store, &iter, | |
347 ICON_COLUMN, pixbuf, | |
348 TEXT_COLUMN, t, | |
349 TITLE_COLUMN, text, | |
350 DESC_COLUMN, sec_text, | |
351 TYPE_COLUMN, edit, -1); | |
352 } | |
353 | |
354 void | |
355 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) | |
356 { | |
357 status_box->error = g_strdup(error); | |
358 gtk_gaim_status_box_refresh(status_box); | |
359 } | |
360 | |
361 void | |
362 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) | |
363 { | |
364 if (!status_box) | |
365 return; | |
366 status_box->connecting = connecting; | |
367 gtk_gaim_status_box_refresh(status_box); | |
368 } | |
369 | |
370 void | |
371 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) | |
372 { | |
373 if (!status_box) | |
374 return; | |
375 if (status_box->connecting_index == 3) | |
376 status_box->connecting_index = 0; | |
377 else | |
378 status_box->connecting_index++; | |
379 gtk_gaim_status_box_refresh(status_box); | |
380 } | |
381 | |
382 void | |
383 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) | |
384 { | |
385 if (status_box->typing_index == 3) | |
386 status_box->typing_index = 0; | |
387 else | |
388 status_box->typing_index++; | |
389 gtk_gaim_status_box_refresh(status_box); | |
390 } | |
391 | |
392 static void remove_typing_cb(GtkGaimStatusBox *box) | |
393 { | |
394 gchar *status_type_id; | |
395 GList *l; | |
396 GtkTreeIter iter; | |
397 | |
398 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(box), &iter); | |
399 gtk_tree_model_get(GTK_TREE_MODEL(box->dropdown_store), &iter, TYPE_COLUMN, &status_type_id, -1); | |
400 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | |
401 GaimAccount *account = (GaimAccount*)l->data; | |
402 GaimStatusType *status_type; | |
403 | |
404 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) | |
405 continue; | |
406 | |
407 status_type = gaim_account_get_status_type(account, status_type_id); | |
408 | |
409 if (status_type == NULL) | |
410 continue; | |
411 gaim_account_set_status(account, status_type_id, TRUE, | |
412 "message",gtk_imhtml_get_markup(GTK_IMHTML(box->imhtml)), NULL); | |
413 } | |
414 g_source_remove(box->typing); | |
415 box->typing = 0; | |
416 gtk_gaim_status_box_refresh(box); | |
417 } | |
418 | |
419 static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
420 { | |
421 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(box); | |
422 GtkTreeIter iter; | |
423 char *text, *sec_text; | |
424 GdkPixbuf *pixbuf; | |
425 gchar *status_type_id; | |
426 GList *l; | |
427 | |
428 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
429 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, TITLE_COLUMN, &text, | |
430 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf, | |
431 TYPE_COLUMN, &status_type_id, -1); | |
432 if (status_box->title) | |
433 g_free(status_box->title); | |
434 status_box->title = g_strdup(text); | |
435 if (status_box->desc && sec_text) | |
436 g_free(status_box->desc); | |
437 status_box->desc = g_strdup(sec_text); | |
438 if (status_box->pixbuf) | |
439 g_object_unref(status_box->pixbuf); | |
440 status_box->pixbuf = pixbuf; | |
441 | |
442 if (!strcmp(status_type_id, "away")) { | |
443 gtk_widget_show_all(status_box->vbox); | |
444 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); | |
445 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
446 gtk_widget_grab_focus(status_box->imhtml); | |
447 } else { | |
448 if (status_box->typing) { | |
449 g_source_remove(status_box->typing); | |
450 status_box->typing = 0; | |
451 } | |
452 gtk_widget_hide_all(status_box->vbox); | |
453 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | |
454 GaimAccount *account = (GaimAccount*)l->data; | |
455 GaimStatusType *status_type; | |
456 | |
457 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) | |
458 continue; | |
459 | |
460 status_type = gaim_account_get_status_type(account, status_type_id); | |
461 | |
462 if (status_type == NULL) | |
463 continue; | |
464 gaim_account_set_status(account, status_type_id, TRUE, NULL); | |
465 } | |
466 } | |
467 gtk_gaim_status_box_refresh(status_box); | |
468 } | |
469 | |
470 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) | |
471 { | |
472 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; | |
473 if (box->typing) { | |
474 gtk_gaim_status_box_pulse_typing(box); | |
475 g_source_remove(box->typing); | |
476 } | |
477 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); | |
478 gtk_gaim_status_box_refresh(box); | |
479 } | |
10649 | 480 |
481 const char *gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) | |
482 { | |
483 GtkTreeIter iter; | |
484 char *type; | |
485 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
486 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | |
487 TYPE_COLUMN, &type, -1); | |
488 return type; | |
489 } | |
490 | |
491 const char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) | |
492 { | |
493 if (status_box->imhtml_visible) | |
494 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
495 else | |
496 return NULL; | |
497 } |