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