Mercurial > pidgin
annotate src/gtkstatusbox.c @ 11983:39f2aa4350d8
[gaim-migrate @ 14276]
Finally turning this on, after sticking in a vpane so you can get it
out of your way. I also changed the icons.
Still todo is making it show and hide based on if they match the global status,
and misc stuff like adding and removing the selectors based on account
enable/disable and add/delete.
Anyway, now that they're enabled, y'all can tell me what you think,
and if I'm really going in the right direction.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sat, 05 Nov 2005 19:22:26 +0000 |
parents | 053bb5ad040b |
children | f08a5365e2c9 |
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; | |
288 const char *proto_name, *type_name; | |
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); | |
297 } | |
298 | |
11732 | 299 g_snprintf(basename2, sizeof(basename2), "%s.png", |
11983 | 300 proto_name); |
301 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
11732 | 302 basename2, NULL); |
303 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
304 g_free(filename); | |
305 | |
306 if (pixbuf != NULL) { | |
11983 | 307 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32, |
11732 | 308 GDK_INTERP_BILINEAR); |
309 g_object_unref(G_OBJECT(pixbuf)); | |
310 } | |
311 | |
11983 | 312 |
313 /* TODO: let the prpl pick the emblem on a per status bases, and only | |
314 * use the primitive as a fallback */ | |
315 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type)); | |
316 if (!strcmp(type_name, "hidden")) | |
317 type_name = "invisible"; | |
318 if (!strcmp(type_name, "unavailable")) | |
319 type_name = "na"; | |
320 g_snprintf(basename2, sizeof(basename2), "%s.png", | |
321 type_name); | |
322 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
323 basename2, NULL); | |
324 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
325 g_free(filename); | |
326 | |
327 if (emblem) { | |
328 gdk_pixbuf_composite(emblem, | |
329 scale, 32-15, 32-15, | |
330 15, 15, | |
331 32-15, 32-15, | |
332 1, 1, | |
333 GDK_INTERP_BILINEAR, | |
334 255); | |
335 | |
336 g_object_unref(emblem); | |
337 } | |
11732 | 338 return scale; |
339 } | |
340 | |
11870 | 341 /** |
342 * This updates the GtkTreeView so that it correctly shows the state | |
343 * we are currently using. It is used when the current state is | |
344 * updated from somewhere other than the GtkStatusBox (from a plugin, | |
345 * or when signing on with the "-n" option, for example). It is | |
346 * also used when the user selects the "Custom..." option. | |
347 * | |
348 * Maybe we could accomplish this by triggering off the mouse and | |
349 * keyboard signals instead of the changed signal? | |
350 */ | |
351 static void | |
352 update_to_reflect_current_status(GtkGaimStatusBox *status_box) | |
353 { | |
354 const char *current_savedstatus_name; | |
355 GaimSavedStatus *saved_status; | |
356 | |
11983 | 357 /* this function is inappropriate for ones with accounts */ |
358 if (status_box->account) | |
359 return; | |
360 | |
11870 | 361 current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); |
362 saved_status = gaim_savedstatus_find(current_savedstatus_name); | |
11951 | 363 |
364 /* | |
365 * Suppress the "changed" signal because the status | |
366 * was changed programmatically. | |
367 */ | |
368 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
369 | |
11870 | 370 if (saved_status == NULL) |
371 { | |
372 /* Default to "available" */ | |
373 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | |
374 } | |
375 else | |
376 { | |
377 GaimStatusPrimitive primitive; | |
378 const char *message; | |
379 | |
380 primitive = gaim_savedstatus_get_type(saved_status); | |
381 if (gaim_savedstatus_has_substatuses(saved_status) || | |
382 ((primitive != GAIM_STATUS_AVAILABLE) && | |
383 (primitive != GAIM_STATUS_OFFLINE) && | |
384 (primitive != GAIM_STATUS_AWAY) && | |
385 (primitive != GAIM_STATUS_HIDDEN))) | |
386 { | |
387 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4); | |
388 } | |
389 else | |
390 { | |
391 if (primitive == GAIM_STATUS_AVAILABLE) | |
392 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | |
393 if (primitive == GAIM_STATUS_OFFLINE) | |
394 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); | |
395 else if (primitive == GAIM_STATUS_AWAY) | |
396 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); | |
397 else if (primitive == GAIM_STATUS_HIDDEN) | |
398 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); | |
399 } | |
400 | |
401 message = gaim_savedstatus_get_message(saved_status); | |
11954 | 402 if (message == NULL) |
11951 | 403 { |
11954 | 404 status_box->imhtml_visible = FALSE; |
405 } | |
406 else | |
407 { | |
408 status_box->imhtml_visible = TRUE; | |
409 | |
11951 | 410 /* |
411 * Suppress the "changed" signal because the status | |
412 * was changed programmatically. | |
413 */ | |
414 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); | |
11954 | 415 |
416 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
11870 | 417 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
11951 | 418 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); |
419 } | |
11870 | 420 } |
11951 | 421 |
422 /* Stop suppressing the "changed" signal. */ | |
423 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | |
11870 | 424 } |
425 | |
11732 | 426 static void |
427 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) | |
428 { | |
11739 | 429 GaimAccount *account; |
11732 | 430 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; |
431 GtkIconSize icon_size; | |
432 | |
433 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
434 | |
435 gtk_list_store_clear(status_box->dropdown_store); | |
436 | |
11739 | 437 account = GTK_GAIM_STATUS_BOX(status_box)->account; |
438 if (account == NULL) | |
439 { | |
11756 | 440 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_ONLINE, |
11732 | 441 icon_size, "GtkGaimStatusBox"); |
11756 | 442 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_AWAY, |
11732 | 443 icon_size, "GtkGaimStatusBox"); |
11756 | 444 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
11732 | 445 icon_size, "GtkGaimStatusBox"); |
11756 | 446 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE, |
11732 | 447 icon_size, "GtkGaimStatusBox"); |
448 /* hacks */ | |
11739 | 449 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AVAILABLE, pixbuf, _("Available"), NULL); |
450 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AWAY, pixbuf2, _("Away"), NULL); | |
451 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_HIDDEN, pixbuf4, _("Invisible"), NULL); | |
452 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_OFFLINE, pixbuf3, _("Offline"), NULL); | |
11738 | 453 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
11739 | 454 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("Custom..."), NULL); |
455 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL); | |
11732 | 456 |
11870 | 457 update_to_reflect_current_status(status_box); |
11732 | 458 |
459 } else { | |
460 const GList *l; | |
11739 | 461 |
462 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
463 { | |
11732 | 464 GaimStatusType *status_type = (GaimStatusType *)l->data; |
465 | |
466 if (!gaim_status_type_is_user_settable(status_type)) | |
467 continue; | |
468 | |
11739 | 469 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
470 gaim_status_type_get_primitive(status_type), | |
11983 | 471 load_icon(account, status_type), |
11739 | 472 gaim_status_type_get_name(status_type), |
473 NULL); | |
11732 | 474 } |
11967 | 475 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); |
11732 | 476 } |
477 | |
478 } | |
479 | |
11753 | 480 #if GTK_CHECK_VERSION(2,6,0) |
11738 | 481 static gboolean |
482 dropdown_store_row_separator_func(GtkTreeModel *model, | |
483 GtkTreeIter *iter, gpointer data) | |
484 { | |
11739 | 485 GtkGaimStatusBoxItemType type; |
11738 | 486 |
11885 | 487 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
11738 | 488 |
11739 | 489 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR) |
11738 | 490 return TRUE; |
491 | |
492 return FALSE; | |
493 } | |
11753 | 494 #endif |
11738 | 495 |
10643 | 496 static void |
11954 | 497 current_status_pref_changed_cb(const char *name, GaimPrefType type, |
498 gpointer val, gpointer data) | |
499 { | |
500 update_to_reflect_current_status(data); | |
501 } | |
502 | |
503 static void | |
10643 | 504 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) |
505 { | |
11400 | 506 GtkCellRenderer *text_rend; |
507 GtkCellRenderer *icon_rend; | |
10643 | 508 GtkTextBuffer *buffer; |
11732 | 509 GtkTreePath *path; |
11400 | 510 GtkIconSize icon_size; |
511 | |
512 text_rend = gtk_cell_renderer_text_new(); | |
513 icon_rend = gtk_cell_renderer_pixbuf_new(); | |
514 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
10643 | 515 |
516 status_box->imhtml_visible = FALSE; | |
517 status_box->connecting = FALSE; | |
518 status_box->typing = FALSE; | |
519 status_box->title = NULL; | |
10861 | 520 status_box->pixbuf = NULL; |
10643 | 521 status_box->cell_view = gtk_cell_view_new(); |
522 gtk_widget_show (status_box->cell_view); | |
10861 | 523 |
11739 | 524 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
525 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 | 526 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
527 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
528 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
529 gtk_list_store_append(status_box->store, &(status_box->iter)); | |
530 gtk_gaim_status_box_refresh(status_box); | |
11593
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
531 path = gtk_tree_path_new_from_string("0"); |
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
532 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
|
533 gtk_tree_path_free(path); |
10643 | 534 gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view); |
10861 | 535 |
10643 | 536 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
537 status_box->text_rend = gtk_cell_renderer_text_new(); | |
538 | |
539 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); | |
10861 | 540 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
10643 | 541 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
542 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
543 | |
544 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | |
11499 | 545 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
10643 | 546 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
547 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
548 | |
549 status_box->vbox = gtk_vbox_new(0, FALSE); | |
550 status_box->imhtml = gtk_imhtml_new(NULL, NULL); | |
551 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); | |
552 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); | |
11562 | 553 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
10643 | 554 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
555 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); | |
556 status_box->sw = gtk_scrolled_window_new(NULL, NULL); | |
557 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
558 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); | |
559 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); | |
560 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); | |
11654 | 561 |
11850 | 562 |
563 #if GTK_CHECK_VERSION(2,6,0) | |
564 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); | |
565 #endif | |
566 | |
11756 | 567 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
568 icon_size, "GtkGaimStatusBox"); | |
569 status_box->connecting_index = 0; | |
570 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT0, | |
571 icon_size, "GtkGaimStatusBox"); | |
572 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT1, | |
573 icon_size, "GtkGaimStatusBox"); | |
574 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT2, | |
575 icon_size, "GtkGaimStatusBox"); | |
576 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT3, | |
577 icon_size, "GtkGaimStatusBox"); | |
578 | |
579 status_box->typing_index = 0; | |
580 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING0, | |
581 icon_size, "GtkGaimStatusBox"); | |
582 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING1, | |
583 icon_size, "GtkGaimStatusBox"); | |
584 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING2, | |
585 icon_size, "GtkGaimStatusBox"); | |
586 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING3, | |
587 icon_size, "GtkGaimStatusBox"); | |
588 | |
11732 | 589 gtk_gaim_status_box_regenerate(status_box); |
11954 | 590 |
591 /* Monitor changes in the "/core/status/current" preference */ | |
592 gaim_prefs_connect_callback(status_box, "/core/status/current", | |
593 current_status_pref_changed_cb, status_box); | |
594 | |
595 /* TODO: Need to override the destroy method for this object and put the following line in it */ | |
596 /* gaim_prefs_disconnect_by_handle(status_box); */ | |
10643 | 597 } |
598 | |
599 static void | |
10861 | 600 gtk_gaim_status_box_size_request(GtkWidget *widget, |
601 GtkRequisition *requisition) | |
10643 | 602 { |
603 GtkRequisition box_req; | |
604 combo_box_size_request(widget, requisition); | |
10861 | 605 |
10643 | 606 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
607 if (box_req.height > 1) | |
608 requisition->height = requisition->height + box_req.height + 6; | |
10861 | 609 |
10643 | 610 requisition->width = 1; |
611 | |
612 } | |
613 | |
614 static void | |
10861 | 615 gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
616 GtkAllocation *allocation) | |
10643 | 617 { |
618 GtkRequisition req = {0,0}; | |
11400 | 619 GtkAllocation parent_alc, box_alc; |
620 | |
621 parent_alc = *allocation; | |
622 box_alc = *allocation; | |
10643 | 623 combo_box_size_request(widget, &req); |
10861 | 624 |
10643 | 625 /* EVIL XXX */ |
10861 | 626 box_alc.height = 80; |
627 /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */ | |
628 | |
10643 | 629 box_alc.y = box_alc.y + req.height + 6; |
630 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); | |
10861 | 631 |
10643 | 632 parent_alc.height = MAX(1,req.height); |
633 combo_box_size_allocate(widget, &parent_alc); | |
634 widget->allocation = *allocation; | |
635 } | |
636 | |
637 | |
638 static gboolean | |
10861 | 639 gtk_gaim_status_box_expose_event(GtkWidget *widget, |
640 GdkEventExpose *event) | |
10643 | 641 { |
10861 | 642 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
643 combo_box_expose_event(widget, event); | |
10643 | 644 |
10861 | 645 gtk_container_propagate_expose(GTK_CONTAINER(widget), |
646 status_box->vbox, event); | |
647 return FALSE; | |
10643 | 648 } |
649 | |
650 static void | |
10861 | 651 gtk_gaim_status_box_forall(GtkContainer *container, |
652 gboolean include_internals, | |
653 GtkCallback callback, | |
654 gpointer callback_data) | |
10643 | 655 { |
10861 | 656 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
10643 | 657 |
10861 | 658 if (include_internals) |
659 { | |
660 (* callback) (status_box->vbox, callback_data); | |
661 } | |
10643 | 662 |
10861 | 663 combo_box_forall(container, include_internals, callback, callback_data); |
10643 | 664 } |
665 | |
666 GtkWidget * | |
667 gtk_gaim_status_box_new() | |
668 { | |
669 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | |
670 } | |
671 | |
11499 | 672 GtkWidget * |
673 gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
674 { | |
675 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
676 } | |
10643 | 677 |
678 void | |
11739 | 679 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GtkGaimStatusBoxItemType type, GdkPixbuf *pixbuf, const char *text, const char *sec_text) |
10643 | 680 { |
681 GtkTreeIter iter; | |
682 char *t; | |
10861 | 683 |
10643 | 684 if (sec_text) { |
685 char aa_color[8]; | |
686 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
687 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
688 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
689 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
10861 | 690 style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
10643 | 691 t = g_strdup_printf("%s\n<span color=\"%s\">%s</span>", text, aa_color, sec_text); |
692 } else { | |
693 t = g_strdup(text); | |
694 } | |
10861 | 695 |
10643 | 696 gtk_list_store_append(status_box->dropdown_store, &iter); |
697 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 698 TYPE_COLUMN, type, |
10643 | 699 ICON_COLUMN, pixbuf, |
10861 | 700 TEXT_COLUMN, t, |
10643 | 701 TITLE_COLUMN, text, |
10861 | 702 DESC_COLUMN, sec_text, |
11739 | 703 -1); |
11638 | 704 g_free(t); |
10643 | 705 } |
706 | |
707 void | |
11738 | 708 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box) |
709 { | |
11756 | 710 /* Don't do anything unless GTK actually supports |
711 * gtk_combo_box_set_row_separator_func */ | |
712 #if GTK_CHECK_VERSION(2,6,0) | |
11738 | 713 GtkTreeIter iter; |
714 | |
715 gtk_list_store_append(status_box->dropdown_store, &iter); | |
716 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 717 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR, |
718 -1); | |
11756 | 719 #endif |
11738 | 720 } |
721 | |
722 void | |
10643 | 723 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) |
724 { | |
11523 | 725 if (status_box->error) |
726 g_free(status_box->error); | |
11891 | 727 status_box->error = NULL; |
728 if (error != NULL) | |
729 status_box->error = g_strdup(error); | |
10643 | 730 gtk_gaim_status_box_refresh(status_box); |
731 } | |
732 | |
733 void | |
734 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) | |
735 { | |
736 if (!status_box) | |
737 return; | |
738 status_box->connecting = connecting; | |
739 gtk_gaim_status_box_refresh(status_box); | |
740 } | |
741 | |
742 void | |
743 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) | |
744 { | |
745 if (!status_box) | |
746 return; | |
747 if (status_box->connecting_index == 3) | |
748 status_box->connecting_index = 0; | |
10861 | 749 else |
10643 | 750 status_box->connecting_index++; |
751 gtk_gaim_status_box_refresh(status_box); | |
752 } | |
753 | |
754 void | |
755 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) | |
756 { | |
757 if (status_box->typing_index == 3) | |
758 status_box->typing_index = 0; | |
10861 | 759 else |
10643 | 760 status_box->typing_index++; |
761 gtk_gaim_status_box_refresh(status_box); | |
762 } | |
763 | |
11654 | 764 static void |
765 activate_currently_selected_status(GtkGaimStatusBox *status_box) | |
10643 | 766 { |
11739 | 767 GtkGaimStatusBoxItemType type; |
768 gchar *title; | |
10643 | 769 GtkTreeIter iter; |
11654 | 770 char *message; |
771 GaimSavedStatus *saved_status; | |
10643 | 772 |
11951 | 773 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter)) |
774 return; | |
11654 | 775 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
11739 | 776 TYPE_COLUMN, &type, |
11638 | 777 TITLE_COLUMN, &title, -1); |
11654 | 778 message = gtk_gaim_status_box_get_message(status_box); |
11739 | 779 |
780 /* | |
781 * If the currently selected status is "Custom..." or | |
11954 | 782 * "Saved..." then do nothing. Custom statuses are |
783 * activated elsewhere, and we update the status_box | |
784 * accordingly by monitoring the preference | |
785 * "/core/status/current" and then calling | |
786 * update_to_reflect_current_status() | |
11739 | 787 */ |
788 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES)) | |
789 return; | |
11654 | 790 |
791 /* TODO: Should save the previous status as a transient status? */ | |
792 | |
11981 | 793 if (status_box->account) { |
794 const GList *l = gaim_account_get_status_types(status_box->account); | |
795 gint active; | |
796 GaimStatusType *status_type; | |
797 | |
798 g_object_get(G_OBJECT(status_box), "active", &active, NULL); | |
11654 | 799 |
11981 | 800 status_type = g_list_nth_data((GList *)l, active); |
801 if (message) | |
802 gaim_account_set_status(status_box->account, gaim_status_type_get_id(status_type), | |
803 TRUE, "message", message, NULL); | |
804 else | |
805 gaim_account_set_status(status_box->account, gaim_status_type_get_id(status_type), | |
806 TRUE, NULL); | |
807 | |
808 } else { | |
809 /* Save the newly selected status to prefs.xml and status.xml */ | |
810 /* TODO: This should be saved as transient. */ | |
811 saved_status = gaim_savedstatus_find(_("Default")); | |
812 if (saved_status == NULL) | |
813 saved_status = gaim_savedstatus_new(_("Default"), type); | |
814 gaim_savedstatus_set_type(saved_status, type); | |
815 gaim_savedstatus_set_message(saved_status, message); | |
816 gaim_prefs_set_string("/core/status/current", _("Default")); | |
817 | |
818 /* Set the status for each account */ | |
819 gaim_savedstatus_activate(saved_status); | |
820 } | |
11627 | 821 |
11638 | 822 g_free(title); |
11654 | 823 g_free(message); |
824 } | |
825 | |
826 static void remove_typing_cb(GtkGaimStatusBox *status_box) | |
827 { | |
828 activate_currently_selected_status(status_box); | |
829 | |
830 g_source_remove(status_box->typing); | |
831 status_box->typing = 0; | |
832 gtk_gaim_status_box_refresh(status_box); | |
10643 | 833 } |
834 | |
835 static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
836 { | |
11400 | 837 GtkGaimStatusBox *status_box; |
10643 | 838 GtkTreeIter iter; |
11739 | 839 GtkGaimStatusBoxItemType type; |
10643 | 840 char *text, *sec_text; |
841 GdkPixbuf *pixbuf; | |
11960 | 842 GList *accounts = NULL, *node; |
10643 | 843 |
11400 | 844 status_box = GTK_GAIM_STATUS_BOX(box); |
845 | |
10643 | 846 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
11739 | 847 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
848 TYPE_COLUMN, &type, | |
849 TITLE_COLUMN, &text, | |
10861 | 850 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf, |
11739 | 851 -1); |
10643 | 852 if (status_box->title) |
853 g_free(status_box->title); | |
11638 | 854 status_box->title = text; |
10643 | 855 if (status_box->desc && sec_text) |
11638 | 856 g_free(status_box->desc); |
857 status_box->desc = sec_text; | |
10643 | 858 if (status_box->pixbuf) |
859 g_object_unref(status_box->pixbuf); | |
860 status_box->pixbuf = pixbuf; | |
11638 | 861 if (status_box->typing) |
862 g_source_remove(status_box->typing); | |
863 status_box->typing = 0; | |
10861 | 864 |
11951 | 865 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11729 | 866 { |
11951 | 867 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
868 { | |
869 gaim_gtk_status_editor_show(NULL); | |
870 update_to_reflect_current_status(status_box); | |
871 return; | |
872 } | |
11729 | 873 |
11951 | 874 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
875 { | |
876 gaim_gtk_status_window_show(); | |
877 update_to_reflect_current_status(status_box); | |
878 return; | |
879 } | |
11729 | 880 } |
881 | |
11654 | 882 /* |
11755 | 883 * Show the message box whenever 'type' allows for a |
11960 | 884 * message attribute on any protocol that is enabled, |
885 * or our protocol, if we have account set | |
11654 | 886 */ |
11960 | 887 if (status_box->account) |
888 accounts = g_list_prepend(accounts, status_box->account); | |
889 else | |
890 accounts = gaim_accounts_get_all_active(); | |
11755 | 891 status_box->imhtml_visible = FALSE; |
892 for (node = accounts; node != NULL; node = node->next) | |
893 { | |
894 GaimAccount *account; | |
895 GaimStatusType *status_type; | |
896 | |
897 account = node->data; | |
898 status_type = gaim_account_get_status_type_with_primitive(account, type); | |
899 if ((status_type != NULL) && | |
900 (gaim_status_type_get_attr(status_type, "message") != NULL)) | |
901 { | |
902 status_box->imhtml_visible = TRUE; | |
903 break; | |
904 } | |
905 } | |
906 g_list_free(accounts); | |
11654 | 907 |
908 if (status_box->imhtml_visible) | |
909 { | |
10643 | 910 gtk_widget_show_all(status_box->vbox); |
11951 | 911 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
912 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); | |
10643 | 913 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
914 gtk_widget_grab_focus(status_box->imhtml); | |
11654 | 915 } |
916 else | |
917 { | |
10643 | 918 gtk_widget_hide_all(status_box->vbox); |
11951 | 919 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11981 | 920 activate_currently_selected_status(status_box); /* This is where we actually set the status */ |
10643 | 921 } |
922 gtk_gaim_status_box_refresh(status_box); | |
923 } | |
924 | |
925 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) | |
926 { | |
927 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; | |
11951 | 928 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(box))) |
929 { | |
930 if (box->typing) { | |
931 gtk_gaim_status_box_pulse_typing(box); | |
932 g_source_remove(box->typing); | |
933 } | |
934 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); | |
10861 | 935 } |
10643 | 936 gtk_gaim_status_box_refresh(box); |
937 } | |
10649 | 938 |
11739 | 939 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) |
10649 | 940 { |
941 GtkTreeIter iter; | |
11739 | 942 GtkGaimStatusBoxItemType type; |
10649 | 943 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
10861 | 944 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
10649 | 945 TYPE_COLUMN, &type, -1); |
946 return type; | |
947 } | |
948 | |
11638 | 949 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) |
10649 | 950 { |
951 if (status_box->imhtml_visible) | |
952 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
953 else | |
954 return NULL; | |
955 } |