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