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