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