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