Mercurial > pidgin
annotate src/gtkstatusbox.c @ 11997:9d451c9cc3d9
[gaim-migrate @ 14290]
hopefully fix a warning i'm not getting
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 06 Nov 2005 23:20:21 +0000 |
parents | aa77da6c7f21 |
children | 191cbb614925 |
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 | |
11627 | 26 #include "account.h" |
10643 | 27 #include "internal.h" |
11627 | 28 #include "savedstatuses.h" |
10643 | 29 #include "status.h" |
11732 | 30 #include "debug.h" |
11627 | 31 |
10643 | 32 #include "gtkgaim.h" |
11729 | 33 #include "gtksavedstatuses.h" |
10643 | 34 #include "gtkstock.h" |
35 #include "gtkstatusbox.h" | |
36 | |
37 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); | |
11562 | 38 static void remove_typing_cb(GtkGaimStatusBox *box); |
10643 | 39 |
11967 | 40 static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); |
11732 | 41 static void gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box); |
10643 | 42 static void gtk_gaim_status_box_changed(GtkComboBox *box); |
43 static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
44 static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
45 static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); | |
46 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
47 | |
48 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); | |
49 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); | |
50 static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event); | |
51 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
11739 | 52 |
10643 | 53 enum { |
11739 | 54 TYPE_COLUMN, /* A GtkGaimStatusBoxItemType */ |
11738 | 55 ICON_COLUMN, /* This is a GdkPixbuf (the other columns are strings) */ |
56 TEXT_COLUMN, /* A string */ | |
57 TITLE_COLUMN, /* The plain-English title of this item */ | |
58 DESC_COLUMN, /* A plain-English description of this item */ | |
10643 | 59 NUM_COLUMNS |
60 }; | |
61 | |
11499 | 62 enum { |
63 PROP_0, | |
64 PROP_ACCOUNT | |
65 }; | |
66 | |
10643 | 67 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); |
68 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); | |
69 | |
70 GType | |
71 gtk_gaim_status_box_get_type (void) | |
72 { | |
10861 | 73 static GType status_box_type = 0; |
10643 | 74 |
10861 | 75 if (!status_box_type) |
76 { | |
77 static const GTypeInfo status_box_info = | |
78 { | |
79 sizeof (GtkGaimStatusBoxClass), | |
80 NULL, /* base_init */ | |
81 NULL, /* base_finalize */ | |
82 (GClassInitFunc) gtk_gaim_status_box_class_init, | |
83 NULL, /* class_finalize */ | |
84 NULL, /* class_data */ | |
85 sizeof (GtkGaimStatusBox), | |
86 0, | |
87 (GInstanceInitFunc) gtk_gaim_status_box_init | |
88 }; | |
10643 | 89 |
10861 | 90 status_box_type = g_type_register_static(GTK_TYPE_COMBO_BOX, |
91 "GtkGaimStatusBox", | |
92 &status_box_info, | |
93 0); | |
94 } | |
10643 | 95 |
10861 | 96 return status_box_type; |
10643 | 97 } |
98 | |
99 static void | |
11499 | 100 gtk_gaim_status_box_get_property(GObject *object, guint param_id, |
101 GValue *value, GParamSpec *psec) | |
102 { | |
103 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
104 | |
105 switch (param_id) { | |
106 case PROP_ACCOUNT: | |
107 g_value_set_pointer(value, statusbox->account); | |
108 break; | |
109 default: | |
110 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec); | |
111 break; | |
112 } | |
113 } | |
114 | |
115 static void | |
11967 | 116 update_to_reflect_account_status(GtkGaimStatusBox *status_box, GaimAccount *account, GaimStatus *newstatus) |
11960 | 117 { |
11967 | 118 const GList *l; |
119 int status_no = -1; | |
120 const GaimStatusType *statustype = NULL; | |
121 | |
122 statustype = gaim_status_type_find_with_id((GList *)gaim_account_get_status_types(account), | |
123 (char *)gaim_status_type_get_id(gaim_status_get_type(newstatus))); | |
124 | |
125 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) { | |
126 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
127 | |
128 if (!gaim_status_type_is_user_settable(status_type)) | |
129 continue; | |
130 status_no++; | |
131 if (statustype == status_type) | |
132 break; | |
133 } | |
134 | |
135 if (status_no != -1) { | |
136 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
137 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), status_no); | |
138 gtk_gaim_status_box_refresh(status_box); | |
139 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | |
140 } | |
141 | |
142 } | |
143 | |
144 static void | |
145 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus, GtkGaimStatusBox *status_box) | |
146 { | |
147 if (status_box->account == account) | |
148 update_to_reflect_account_status(status_box, account, newstatus); | |
11960 | 149 } |
150 | |
151 static void | |
11499 | 152 gtk_gaim_status_box_set_property(GObject *object, guint param_id, |
153 const GValue *value, GParamSpec *pspec) | |
154 { | |
155 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
156 | |
157 switch (param_id) { | |
158 case PROP_ACCOUNT: | |
159 statusbox->account = g_value_get_pointer(value); | |
11960 | 160 |
161 /* FIXME: call this in the destroy function too, if we had one */ | |
11967 | 162 if (statusbox->status_changed_signal) { |
163 gaim_signal_disconnect(gaim_accounts_get_handle(), "account-status-changed", | |
164 statusbox, GAIM_CALLBACK(account_status_changed_cb)); | |
165 statusbox->status_changed_signal = 0; | |
166 } | |
11960 | 167 if (statusbox->account) |
11967 | 168 statusbox->status_changed_signal = gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
11960 | 169 statusbox, GAIM_CALLBACK(account_status_changed_cb), |
170 statusbox); | |
11732 | 171 gtk_gaim_status_box_regenerate(statusbox); |
11499 | 172 break; |
173 default: | |
174 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
175 break; | |
176 } | |
177 } | |
178 | |
179 | |
180 static void | |
10643 | 181 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
182 { | |
10861 | 183 GObjectClass *object_class; |
184 GtkWidgetClass *widget_class; | |
185 GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; | |
186 GtkContainerClass *container_class = (GtkContainerClass*)klass; | |
10643 | 187 |
10861 | 188 parent_class->changed = gtk_gaim_status_box_changed; |
189 widget_class = (GtkWidgetClass*)klass; | |
190 combo_box_size_request = widget_class->size_request; | |
191 widget_class->size_request = gtk_gaim_status_box_size_request; | |
192 combo_box_size_allocate = widget_class->size_allocate; | |
193 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; | |
194 combo_box_expose_event = widget_class->expose_event; | |
195 widget_class->expose_event = gtk_gaim_status_box_expose_event; | |
10643 | 196 |
10861 | 197 combo_box_forall = container_class->forall; |
198 container_class->forall = gtk_gaim_status_box_forall; | |
199 | |
200 object_class = (GObjectClass *)klass; | |
11499 | 201 |
202 object_class->get_property = gtk_gaim_status_box_get_property; | |
203 object_class->set_property = gtk_gaim_status_box_set_property; | |
204 | |
205 g_object_class_install_property(object_class, | |
206 PROP_ACCOUNT, | |
207 g_param_spec_pointer("account", | |
208 "Account", | |
209 "The account, or NULL for all accounts", | |
210 G_PARAM_READWRITE | |
211 ) | |
212 ); | |
10643 | 213 } |
214 | |
215 static void | |
216 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | |
217 { | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
218 char *text, *title; |
10643 | 219 char aa_color[8]; |
220 GdkPixbuf *pixbuf; | |
10702 | 221 GtkTreePath *path; |
11870 | 222 GtkStyle *style; |
10643 | 223 |
11870 | 224 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
10643 | 225 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
226 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
227 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
228 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
229 |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
230 title = status_box->title; |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
231 if (!title) |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
232 title = ""; |
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
233 |
11960 | 234 |
10643 | 235 if (status_box->error) { |
11499 | 236 text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", |
10861 | 237 title, status_box->error); |
10643 | 238 } else if (status_box->typing) { |
10861 | 239 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
240 title, aa_color, _("Typing")); | |
10643 | 241 } else if (status_box->connecting) { |
10861 | 242 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
243 title, aa_color, _("Connecting")); | |
244 } else if (status_box->desc) { | |
245 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", | |
246 title, aa_color, status_box->desc); | |
10643 | 247 } else { |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
248 text = g_strdup_printf("%s", title); |
10643 | 249 } |
10861 | 250 |
11960 | 251 if (status_box->account) { |
252 char *text2 = g_strdup_printf("%s\n<span size=\"smaller\">%s</span>", gaim_account_get_username(status_box->account), text); | |
253 g_free(text); | |
254 text = text2; | |
255 } | |
256 | |
257 | |
11523 | 258 if (status_box->connecting) |
259 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | |
260 else if (status_box->error) | |
10643 | 261 pixbuf = status_box->error_pixbuf; |
262 else if (status_box->typing) | |
263 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | |
264 else | |
265 pixbuf = status_box->pixbuf; | |
266 | |
267 gtk_list_store_set(status_box->store, &(status_box->iter), | |
11755 | 268 TYPE_COLUMN, -1, /* This field is not used in this list store */ |
10643 | 269 ICON_COLUMN, pixbuf, |
10861 | 270 TEXT_COLUMN, text, |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
271 TITLE_COLUMN, title, |
10861 | 272 DESC_COLUMN, status_box->desc, |
11739 | 273 -1); |
10702 | 274 path = gtk_tree_path_new_from_string("0"); |
275 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); | |
276 gtk_tree_path_free(path); | |
10643 | 277 |
278 g_free(text); | |
279 } | |
280 | |
11732 | 281 static GdkPixbuf * |
11983 | 282 load_icon(GaimAccount *account, GaimStatusType *status_type) |
11732 | 283 { |
284 char basename2[BUFSIZ]; | |
285 char *filename; | |
11983 | 286 GaimPluginProtocolInfo *prpl_info = NULL; |
287 GaimPlugin *plugin; | |
11997 | 288 const char *proto_name = NULL, *type_name; |
11983 | 289 GdkPixbuf *pixbuf, *scale = NULL, *emblem; |
11732 | 290 |
11983 | 291 |
292 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
11732 | 293 |
11983 | 294 if (plugin != NULL) { |
295 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
296 proto_name = prpl_info->list_icon(account, NULL); | |
11997 | 297 } else { |
298 return NULL; | |
11983 | 299 } |
300 | |
11732 | 301 g_snprintf(basename2, sizeof(basename2), "%s.png", |
11983 | 302 proto_name); |
303 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
11732 | 304 basename2, NULL); |
305 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
306 g_free(filename); | |
307 | |
308 if (pixbuf != NULL) { | |
11983 | 309 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32, |
11732 | 310 GDK_INTERP_BILINEAR); |
311 g_object_unref(G_OBJECT(pixbuf)); | |
312 } | |
313 | |
11983 | 314 |
315 /* TODO: let the prpl pick the emblem on a per status bases, and only | |
316 * use the primitive as a fallback */ | |
317 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type)); | |
318 if (!strcmp(type_name, "hidden")) | |
319 type_name = "invisible"; | |
320 if (!strcmp(type_name, "unavailable")) | |
321 type_name = "na"; | |
322 g_snprintf(basename2, sizeof(basename2), "%s.png", | |
323 type_name); | |
324 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
325 basename2, NULL); | |
326 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
327 g_free(filename); | |
328 | |
329 if (emblem) { | |
330 gdk_pixbuf_composite(emblem, | |
331 scale, 32-15, 32-15, | |
332 15, 15, | |
333 32-15, 32-15, | |
334 1, 1, | |
335 GDK_INTERP_BILINEAR, | |
336 255); | |
337 | |
338 g_object_unref(emblem); | |
339 } | |
11732 | 340 return scale; |
341 } | |
342 | |
11870 | 343 /** |
344 * This updates the GtkTreeView so that it correctly shows the state | |
345 * we are currently using. It is used when the current state is | |
346 * updated from somewhere other than the GtkStatusBox (from a plugin, | |
347 * or when signing on with the "-n" option, for example). It is | |
348 * also used when the user selects the "Custom..." option. | |
349 * | |
350 * Maybe we could accomplish this by triggering off the mouse and | |
351 * keyboard signals instead of the changed signal? | |
352 */ | |
353 static void | |
354 update_to_reflect_current_status(GtkGaimStatusBox *status_box) | |
355 { | |
356 const char *current_savedstatus_name; | |
357 GaimSavedStatus *saved_status; | |
358 | |
11983 | 359 /* this function is inappropriate for ones with accounts */ |
360 if (status_box->account) | |
361 return; | |
362 | |
11870 | 363 current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); |
364 saved_status = gaim_savedstatus_find(current_savedstatus_name); | |
11951 | 365 |
366 /* | |
367 * Suppress the "changed" signal because the status | |
368 * was changed programmatically. | |
369 */ | |
370 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
371 | |
11870 | 372 if (saved_status == NULL) |
373 { | |
374 /* Default to "available" */ | |
375 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | |
376 } | |
377 else | |
378 { | |
379 GaimStatusPrimitive primitive; | |
380 const char *message; | |
381 | |
382 primitive = gaim_savedstatus_get_type(saved_status); | |
383 if (gaim_savedstatus_has_substatuses(saved_status) || | |
384 ((primitive != GAIM_STATUS_AVAILABLE) && | |
385 (primitive != GAIM_STATUS_OFFLINE) && | |
386 (primitive != GAIM_STATUS_AWAY) && | |
387 (primitive != GAIM_STATUS_HIDDEN))) | |
388 { | |
389 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4); | |
390 } | |
391 else | |
392 { | |
393 if (primitive == GAIM_STATUS_AVAILABLE) | |
394 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | |
395 if (primitive == GAIM_STATUS_OFFLINE) | |
396 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); | |
397 else if (primitive == GAIM_STATUS_AWAY) | |
398 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); | |
399 else if (primitive == GAIM_STATUS_HIDDEN) | |
400 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); | |
401 } | |
402 | |
403 message = gaim_savedstatus_get_message(saved_status); | |
11954 | 404 if (message == NULL) |
11951 | 405 { |
11954 | 406 status_box->imhtml_visible = FALSE; |
407 } | |
408 else | |
409 { | |
410 status_box->imhtml_visible = TRUE; | |
411 | |
11951 | 412 /* |
413 * Suppress the "changed" signal because the status | |
414 * was changed programmatically. | |
415 */ | |
416 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); | |
11954 | 417 |
418 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
11870 | 419 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
11951 | 420 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); |
421 } | |
11870 | 422 } |
11951 | 423 |
424 /* Stop suppressing the "changed" signal. */ | |
425 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | |
11870 | 426 } |
427 | |
11732 | 428 static void |
429 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) | |
430 { | |
11739 | 431 GaimAccount *account; |
11732 | 432 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; |
433 GtkIconSize icon_size; | |
434 | |
435 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
436 | |
437 gtk_list_store_clear(status_box->dropdown_store); | |
438 | |
11739 | 439 account = GTK_GAIM_STATUS_BOX(status_box)->account; |
440 if (account == NULL) | |
441 { | |
11756 | 442 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_ONLINE, |
11732 | 443 icon_size, "GtkGaimStatusBox"); |
11756 | 444 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_AWAY, |
11732 | 445 icon_size, "GtkGaimStatusBox"); |
11756 | 446 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
11732 | 447 icon_size, "GtkGaimStatusBox"); |
11756 | 448 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE, |
11732 | 449 icon_size, "GtkGaimStatusBox"); |
450 /* hacks */ | |
11739 | 451 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AVAILABLE, pixbuf, _("Available"), NULL); |
452 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AWAY, pixbuf2, _("Away"), NULL); | |
453 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_HIDDEN, pixbuf4, _("Invisible"), NULL); | |
454 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_OFFLINE, pixbuf3, _("Offline"), NULL); | |
11738 | 455 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
11739 | 456 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("Custom..."), NULL); |
457 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL); | |
11732 | 458 |
11870 | 459 update_to_reflect_current_status(status_box); |
11732 | 460 |
461 } else { | |
462 const GList *l; | |
11739 | 463 |
464 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
465 { | |
11732 | 466 GaimStatusType *status_type = (GaimStatusType *)l->data; |
467 | |
468 if (!gaim_status_type_is_user_settable(status_type)) | |
469 continue; | |
470 | |
11739 | 471 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
472 gaim_status_type_get_primitive(status_type), | |
11983 | 473 load_icon(account, status_type), |
11739 | 474 gaim_status_type_get_name(status_type), |
475 NULL); | |
11732 | 476 } |
11967 | 477 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); |
11732 | 478 } |
479 | |
480 } | |
481 | |
11753 | 482 #if GTK_CHECK_VERSION(2,6,0) |
11738 | 483 static gboolean |
484 dropdown_store_row_separator_func(GtkTreeModel *model, | |
485 GtkTreeIter *iter, gpointer data) | |
486 { | |
11739 | 487 GtkGaimStatusBoxItemType type; |
11738 | 488 |
11885 | 489 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
11738 | 490 |
11739 | 491 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR) |
11738 | 492 return TRUE; |
493 | |
494 return FALSE; | |
495 } | |
11753 | 496 #endif |
11738 | 497 |
10643 | 498 static void |
11954 | 499 current_status_pref_changed_cb(const char *name, GaimPrefType type, |
500 gpointer val, gpointer data) | |
501 { | |
502 update_to_reflect_current_status(data); | |
503 } | |
504 | |
505 static void | |
10643 | 506 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) |
507 { | |
11400 | 508 GtkCellRenderer *text_rend; |
509 GtkCellRenderer *icon_rend; | |
10643 | 510 GtkTextBuffer *buffer; |
11732 | 511 GtkTreePath *path; |
11400 | 512 GtkIconSize icon_size; |
513 | |
514 text_rend = gtk_cell_renderer_text_new(); | |
515 icon_rend = gtk_cell_renderer_pixbuf_new(); | |
516 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
10643 | 517 |
518 status_box->imhtml_visible = FALSE; | |
519 status_box->connecting = FALSE; | |
520 status_box->typing = FALSE; | |
521 status_box->title = NULL; | |
10861 | 522 status_box->pixbuf = NULL; |
10643 | 523 status_box->cell_view = gtk_cell_view_new(); |
524 gtk_widget_show (status_box->cell_view); | |
10861 | 525 |
11739 | 526 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
527 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
10643 | 528 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
529 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
530 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
531 gtk_list_store_append(status_box->store, &(status_box->iter)); | |
532 gtk_gaim_status_box_refresh(status_box); | |
11593
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
533 path = gtk_tree_path_new_from_string("0"); |
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
534 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); |
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
535 gtk_tree_path_free(path); |
10643 | 536 gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view); |
10861 | 537 |
10643 | 538 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
539 status_box->text_rend = gtk_cell_renderer_text_new(); | |
540 | |
541 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); | |
10861 | 542 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
10643 | 543 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
544 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
545 | |
546 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | |
11499 | 547 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
10643 | 548 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
549 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
550 | |
551 status_box->vbox = gtk_vbox_new(0, FALSE); | |
552 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | |
553 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); | |
554 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); | |
11562 | 555 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
10643 | 556 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
557 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); | |
558 status_box->sw = gtk_scrolled_window_new(NULL, NULL); | |
559 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
560 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); | |
561 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); | |
562 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); | |
11654 | 563 |
11850 | 564 |
565 #if GTK_CHECK_VERSION(2,6,0) | |
566 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); | |
567 #endif | |
568 | |
11756 | 569 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
570 icon_size, "GtkGaimStatusBox"); | |
571 status_box->connecting_index = 0; | |
572 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT0, | |
573 icon_size, "GtkGaimStatusBox"); | |
574 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT1, | |
575 icon_size, "GtkGaimStatusBox"); | |
576 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT2, | |
577 icon_size, "GtkGaimStatusBox"); | |
578 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT3, | |
579 icon_size, "GtkGaimStatusBox"); | |
580 | |
581 status_box->typing_index = 0; | |
582 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING0, | |
583 icon_size, "GtkGaimStatusBox"); | |
584 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING1, | |
585 icon_size, "GtkGaimStatusBox"); | |
586 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING2, | |
587 icon_size, "GtkGaimStatusBox"); | |
588 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING3, | |
589 icon_size, "GtkGaimStatusBox"); | |
590 | |
11732 | 591 gtk_gaim_status_box_regenerate(status_box); |
11954 | 592 |
593 /* Monitor changes in the "/core/status/current" preference */ | |
594 gaim_prefs_connect_callback(status_box, "/core/status/current", | |
595 current_status_pref_changed_cb, status_box); | |
596 | |
597 /* TODO: Need to override the destroy method for this object and put the following line in it */ | |
598 /* gaim_prefs_disconnect_by_handle(status_box); */ | |
10643 | 599 } |
600 | |
601 static void | |
10861 | 602 gtk_gaim_status_box_size_request(GtkWidget *widget, |
603 GtkRequisition *requisition) | |
10643 | 604 { |
605 GtkRequisition box_req; | |
606 combo_box_size_request(widget, requisition); | |
10861 | 607 |
10643 | 608 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
609 if (box_req.height > 1) | |
610 requisition->height = requisition->height + box_req.height + 6; | |
10861 | 611 |
10643 | 612 requisition->width = 1; |
613 | |
614 } | |
615 | |
616 static void | |
10861 | 617 gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
618 GtkAllocation *allocation) | |
10643 | 619 { |
620 GtkRequisition req = {0,0}; | |
11400 | 621 GtkAllocation parent_alc, box_alc; |
622 | |
623 parent_alc = *allocation; | |
624 box_alc = *allocation; | |
10643 | 625 combo_box_size_request(widget, &req); |
10861 | 626 |
11991 | 627 box_alc.height = allocation->height - req.height - 6; |
10861 | 628 /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */ |
629 | |
10643 | 630 box_alc.y = box_alc.y + req.height + 6; |
631 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); | |
10861 | 632 |
10643 | 633 parent_alc.height = MAX(1,req.height); |
634 combo_box_size_allocate(widget, &parent_alc); | |
635 widget->allocation = *allocation; | |
636 } | |
637 | |
638 | |
639 static gboolean | |
10861 | 640 gtk_gaim_status_box_expose_event(GtkWidget *widget, |
641 GdkEventExpose *event) | |
10643 | 642 { |
10861 | 643 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
644 combo_box_expose_event(widget, event); | |
10643 | 645 |
10861 | 646 gtk_container_propagate_expose(GTK_CONTAINER(widget), |
647 status_box->vbox, event); | |
648 return FALSE; | |
10643 | 649 } |
650 | |
651 static void | |
10861 | 652 gtk_gaim_status_box_forall(GtkContainer *container, |
653 gboolean include_internals, | |
654 GtkCallback callback, | |
655 gpointer callback_data) | |
10643 | 656 { |
10861 | 657 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
10643 | 658 |
10861 | 659 if (include_internals) |
660 { | |
661 (* callback) (status_box->vbox, callback_data); | |
662 } | |
10643 | 663 |
10861 | 664 combo_box_forall(container, include_internals, callback, callback_data); |
10643 | 665 } |
666 | |
667 GtkWidget * | |
668 gtk_gaim_status_box_new() | |
669 { | |
670 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | |
671 } | |
672 | |
11499 | 673 GtkWidget * |
674 gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
675 { | |
676 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
677 } | |
10643 | 678 |
679 void | |
11739 | 680 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GtkGaimStatusBoxItemType type, GdkPixbuf *pixbuf, const char *text, const char *sec_text) |
10643 | 681 { |
682 GtkTreeIter iter; | |
683 char *t; | |
10861 | 684 |
10643 | 685 if (sec_text) { |
686 char aa_color[8]; | |
687 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
688 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
689 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
690 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
10861 | 691 style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
10643 | 692 t = g_strdup_printf("%s\n<span color=\"%s\">%s</span>", text, aa_color, sec_text); |
693 } else { | |
694 t = g_strdup(text); | |
695 } | |
10861 | 696 |
10643 | 697 gtk_list_store_append(status_box->dropdown_store, &iter); |
698 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 699 TYPE_COLUMN, type, |
10643 | 700 ICON_COLUMN, pixbuf, |
10861 | 701 TEXT_COLUMN, t, |
10643 | 702 TITLE_COLUMN, text, |
10861 | 703 DESC_COLUMN, sec_text, |
11739 | 704 -1); |
11638 | 705 g_free(t); |
10643 | 706 } |
707 | |
708 void | |
11738 | 709 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box) |
710 { | |
11756 | 711 /* Don't do anything unless GTK actually supports |
712 * gtk_combo_box_set_row_separator_func */ | |
713 #if GTK_CHECK_VERSION(2,6,0) | |
11738 | 714 GtkTreeIter iter; |
715 | |
716 gtk_list_store_append(status_box->dropdown_store, &iter); | |
717 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 718 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR, |
719 -1); | |
11756 | 720 #endif |
11738 | 721 } |
722 | |
723 void | |
10643 | 724 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) |
725 { | |
11523 | 726 if (status_box->error) |
727 g_free(status_box->error); | |
11891 | 728 status_box->error = NULL; |
729 if (error != NULL) | |
730 status_box->error = g_strdup(error); | |
10643 | 731 gtk_gaim_status_box_refresh(status_box); |
732 } | |
733 | |
734 void | |
735 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) | |
736 { | |
737 if (!status_box) | |
738 return; | |
739 status_box->connecting = connecting; | |
740 gtk_gaim_status_box_refresh(status_box); | |
741 } | |
742 | |
743 void | |
744 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) | |
745 { | |
746 if (!status_box) | |
747 return; | |
748 if (status_box->connecting_index == 3) | |
749 status_box->connecting_index = 0; | |
10861 | 750 else |
10643 | 751 status_box->connecting_index++; |
752 gtk_gaim_status_box_refresh(status_box); | |
753 } | |
754 | |
755 void | |
756 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) | |
757 { | |
758 if (status_box->typing_index == 3) | |
759 status_box->typing_index = 0; | |
10861 | 760 else |
10643 | 761 status_box->typing_index++; |
762 gtk_gaim_status_box_refresh(status_box); | |
763 } | |
764 | |
11993 | 765 static GaimStatusType |
766 *find_status_type_by_index(const GaimAccount *account, gint active) | |
767 { | |
768 const GList *l = gaim_account_get_status_types(account); | |
769 gint i; | |
770 | |
771 for (i = 0; l; l = l->next) { | |
772 GaimStatusType *status_type = l->data; | |
773 if (!gaim_status_type_is_user_settable(status_type)) | |
774 continue; | |
775 | |
776 if (active == i) | |
777 return status_type; | |
778 i++; | |
779 } | |
780 | |
781 return NULL; | |
782 } | |
783 | |
11654 | 784 static void |
785 activate_currently_selected_status(GtkGaimStatusBox *status_box) | |
10643 | 786 { |
11739 | 787 GtkGaimStatusBoxItemType type; |
788 gchar *title; | |
10643 | 789 GtkTreeIter iter; |
11654 | 790 char *message; |
791 GaimSavedStatus *saved_status; | |
10643 | 792 |
11951 | 793 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter)) |
794 return; | |
11654 | 795 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
11739 | 796 TYPE_COLUMN, &type, |
11638 | 797 TITLE_COLUMN, &title, -1); |
11654 | 798 message = gtk_gaim_status_box_get_message(status_box); |
11739 | 799 |
800 /* | |
801 * If the currently selected status is "Custom..." or | |
11954 | 802 * "Saved..." then do nothing. Custom statuses are |
803 * activated elsewhere, and we update the status_box | |
804 * accordingly by monitoring the preference | |
805 * "/core/status/current" and then calling | |
806 * update_to_reflect_current_status() | |
11739 | 807 */ |
808 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES)) | |
809 return; | |
11654 | 810 |
811 /* TODO: Should save the previous status as a transient status? */ | |
812 | |
11981 | 813 if (status_box->account) { |
814 gint active; | |
815 GaimStatusType *status_type; | |
816 | |
817 g_object_get(G_OBJECT(status_box), "active", &active, NULL); | |
11654 | 818 |
11993 | 819 status_type = find_status_type_by_index(status_box->account, active); |
11981 | 820 if (message) |
821 gaim_account_set_status(status_box->account, gaim_status_type_get_id(status_type), | |
822 TRUE, "message", message, NULL); | |
823 else | |
824 gaim_account_set_status(status_box->account, gaim_status_type_get_id(status_type), | |
825 TRUE, NULL); | |
826 | |
827 } else { | |
828 /* Save the newly selected status to prefs.xml and status.xml */ | |
829 /* TODO: This should be saved as transient. */ | |
830 saved_status = gaim_savedstatus_find(_("Default")); | |
831 if (saved_status == NULL) | |
832 saved_status = gaim_savedstatus_new(_("Default"), type); | |
833 gaim_savedstatus_set_type(saved_status, type); | |
834 gaim_savedstatus_set_message(saved_status, message); | |
835 gaim_prefs_set_string("/core/status/current", _("Default")); | |
836 | |
837 /* Set the status for each account */ | |
838 gaim_savedstatus_activate(saved_status); | |
839 } | |
11627 | 840 |
11638 | 841 g_free(title); |
11654 | 842 g_free(message); |
843 } | |
844 | |
845 static void remove_typing_cb(GtkGaimStatusBox *status_box) | |
846 { | |
847 activate_currently_selected_status(status_box); | |
848 | |
849 g_source_remove(status_box->typing); | |
850 status_box->typing = 0; | |
851 gtk_gaim_status_box_refresh(status_box); | |
10643 | 852 } |
853 | |
854 static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
855 { | |
11400 | 856 GtkGaimStatusBox *status_box; |
10643 | 857 GtkTreeIter iter; |
11739 | 858 GtkGaimStatusBoxItemType type; |
10643 | 859 char *text, *sec_text; |
860 GdkPixbuf *pixbuf; | |
11960 | 861 GList *accounts = NULL, *node; |
10643 | 862 |
11400 | 863 status_box = GTK_GAIM_STATUS_BOX(box); |
864 | |
10643 | 865 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
11739 | 866 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
867 TYPE_COLUMN, &type, | |
868 TITLE_COLUMN, &text, | |
10861 | 869 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf, |
11739 | 870 -1); |
10643 | 871 if (status_box->title) |
872 g_free(status_box->title); | |
11638 | 873 status_box->title = text; |
10643 | 874 if (status_box->desc && sec_text) |
11638 | 875 g_free(status_box->desc); |
876 status_box->desc = sec_text; | |
10643 | 877 if (status_box->pixbuf) |
878 g_object_unref(status_box->pixbuf); | |
879 status_box->pixbuf = pixbuf; | |
11638 | 880 if (status_box->typing) |
881 g_source_remove(status_box->typing); | |
882 status_box->typing = 0; | |
10861 | 883 |
11951 | 884 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11729 | 885 { |
11951 | 886 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
887 { | |
888 gaim_gtk_status_editor_show(NULL); | |
889 update_to_reflect_current_status(status_box); | |
890 return; | |
891 } | |
11729 | 892 |
11951 | 893 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
894 { | |
895 gaim_gtk_status_window_show(); | |
896 update_to_reflect_current_status(status_box); | |
897 return; | |
898 } | |
11729 | 899 } |
900 | |
11654 | 901 /* |
11755 | 902 * Show the message box whenever 'type' allows for a |
11960 | 903 * message attribute on any protocol that is enabled, |
904 * or our protocol, if we have account set | |
11654 | 905 */ |
11960 | 906 if (status_box->account) |
907 accounts = g_list_prepend(accounts, status_box->account); | |
908 else | |
909 accounts = gaim_accounts_get_all_active(); | |
11755 | 910 status_box->imhtml_visible = FALSE; |
911 for (node = accounts; node != NULL; node = node->next) | |
912 { | |
913 GaimAccount *account; | |
914 GaimStatusType *status_type; | |
915 | |
916 account = node->data; | |
917 status_type = gaim_account_get_status_type_with_primitive(account, type); | |
918 if ((status_type != NULL) && | |
919 (gaim_status_type_get_attr(status_type, "message") != NULL)) | |
920 { | |
921 status_box->imhtml_visible = TRUE; | |
922 break; | |
923 } | |
924 } | |
925 g_list_free(accounts); | |
11654 | 926 |
927 if (status_box->imhtml_visible) | |
928 { | |
10643 | 929 gtk_widget_show_all(status_box->vbox); |
11951 | 930 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
931 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); | |
10643 | 932 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
933 gtk_widget_grab_focus(status_box->imhtml); | |
11654 | 934 } |
935 else | |
936 { | |
10643 | 937 gtk_widget_hide_all(status_box->vbox); |
11951 | 938 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11981 | 939 activate_currently_selected_status(status_box); /* This is where we actually set the status */ |
10643 | 940 } |
941 gtk_gaim_status_box_refresh(status_box); | |
942 } | |
943 | |
944 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) | |
945 { | |
946 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; | |
11951 | 947 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(box))) |
948 { | |
949 if (box->typing) { | |
950 gtk_gaim_status_box_pulse_typing(box); | |
951 g_source_remove(box->typing); | |
952 } | |
953 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); | |
10861 | 954 } |
10643 | 955 gtk_gaim_status_box_refresh(box); |
956 } | |
10649 | 957 |
11739 | 958 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) |
10649 | 959 { |
960 GtkTreeIter iter; | |
11739 | 961 GtkGaimStatusBoxItemType type; |
10649 | 962 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
10861 | 963 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
10649 | 964 TYPE_COLUMN, &type, -1); |
965 return type; | |
966 } | |
967 | |
11638 | 968 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) |
10649 | 969 { |
970 if (status_box->imhtml_visible) | |
971 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
972 else | |
973 return NULL; | |
974 } |