Mercurial > pidgin
annotate src/gtkstatusbox.c @ 13952:841a5ffbfee4
[gaim-migrate @ 16500]
uiops for GaimConnections. This only shows an error message for a disconnect.
uiops for GaimNotify. I have not done the notifications for searchresults
yet. That will require multi-column GntTree's, which will also allow for
improved email-notifications. I hope to complete it by next week.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 17 Jul 2006 03:45:24 +0000 |
parents | 0a1132e6eac4 |
children | 8bda65b88e49 |
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 | |
13123 | 307 * the current status. This is the only function in this file that |
308 * should modify status_box->store | |
13044 | 309 */ |
10643 | 310 static void |
311 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | |
312 { | |
13124 | 313 gboolean show_buddy_icons; |
314 GtkIconSize icon_size; | |
315 GtkStyle *style; | |
316 char aa_color[8]; | |
317 GaimSavedStatus *saved_status; | |
13123 | 318 char *primary, *secondary, *text; |
10643 | 319 GdkPixbuf *pixbuf; |
10702 | 320 GtkTreePath *path; |
10643 | 321 |
13121 | 322 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
13124 | 323 if (show_buddy_icons) |
324 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
325 else | |
326 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); | |
327 | |
11870 | 328 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
10643 | 329 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
330 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
331 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
332 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
333 |
13121 | 334 saved_status = gaim_savedstatus_get_current(); |
335 | |
13124 | 336 /* Primary */ |
13123 | 337 if (status_box->typing != 0) |
338 { | |
339 GtkTreeIter iter; | |
340 GtkGaimStatusBoxItemType type; | |
341 gpointer data; | |
342 | |
343 /* Primary (get the status selected in the dropdown) */ | |
344 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
345 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | |
346 TYPE_COLUMN, &type, | |
347 DATA_COLUMN, &data, | |
348 -1); | |
349 if (type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) | |
13124 | 350 primary = g_strdup(gaim_primitive_get_name_from_type(GPOINTER_TO_INT(data))); |
13123 | 351 else |
13124 | 352 /* This should never happen, but just in case... */ |
353 primary = g_strdup("New status"); | |
354 } | |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
355 else if (status_box->account != NULL) |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
356 { |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
357 primary = g_strdup(gaim_status_get_name(gaim_account_get_active_status(status_box->account))); |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
358 } |
13124 | 359 else if (gaim_savedstatus_is_transient(saved_status)) |
360 primary = g_strdup(gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status))); | |
361 else | |
362 primary = g_markup_escape_text(gaim_savedstatus_get_title(saved_status), -1); | |
13123 | 363 |
13124 | 364 /* Secondary */ |
365 if (status_box->typing != 0) | |
13123 | 366 secondary = g_strdup(_("Typing")); |
367 else if (status_box->connecting) | |
368 secondary = g_strdup(_("Connecting")); | |
13124 | 369 else if (gaim_savedstatus_is_transient(saved_status)) |
370 secondary = NULL; | |
13123 | 371 else |
372 { | |
13124 | 373 const char *message; |
374 char *tmp; | |
375 message = gaim_savedstatus_get_message(saved_status); | |
376 if (message != NULL) | |
13123 | 377 { |
13124 | 378 tmp = gaim_markup_strip_html(message); |
379 gaim_util_chrreplace(tmp, '\n', ' '); | |
380 secondary = g_markup_escape_text(tmp, -1); | |
381 g_free(tmp); | |
13123 | 382 } |
383 else | |
13124 | 384 secondary = NULL; |
385 } | |
13123 | 386 |
13124 | 387 /* Pixbuf */ |
388 if (status_box->typing != 0) | |
389 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | |
390 else if (status_box->connecting) | |
391 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | |
392 else | |
393 { | |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
394 if (status_box->account != NULL) |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
395 pixbuf = gaim_gtk_create_prpl_icon_with_status(status_box->account, |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
396 gaim_status_get_type(gaim_account_get_active_status(status_box->account)), |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
397 show_buddy_icons ? 1.0 : 0.5); |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
398 else |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
399 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
400 gaim_savedstatus_get_type(saved_status), |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
401 show_buddy_icons ? 1.0 : 0.5); |
13124 | 402 |
403 if (!gaim_savedstatus_is_transient(saved_status)) | |
404 { | |
405 GdkPixbuf *emblem; | |
406 | |
407 /* Overlay a disk in the bottom left corner */ | |
408 emblem = gtk_widget_render_icon(GTK_WIDGET(status_box->vbox), | |
409 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); | |
410 if (emblem != NULL) | |
411 { | |
412 int width, height; | |
413 width = gdk_pixbuf_get_width(pixbuf) / 2; | |
414 height = gdk_pixbuf_get_height(pixbuf) / 2; | |
415 gdk_pixbuf_composite(emblem, pixbuf, 0, height, | |
416 width, height, 0, height, | |
417 0.5, 0.5, GDK_INTERP_BILINEAR, 255); | |
418 g_object_unref(G_OBJECT(emblem)); | |
419 } | |
420 } | |
10643 | 421 } |
10861 | 422 |
13121 | 423 if (status_box->account != NULL) { |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
424 text = g_strdup_printf("%s%s<span size=\"smaller\" color=\"%s\">%s</span>", |
12228 | 425 gaim_account_get_username(status_box->account), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
426 show_buddy_icons ? "\n" : " - ", aa_color, |
13123 | 427 secondary ? secondary : primary); |
428 } else if (secondary != NULL) { | |
13121 | 429 char *separator; |
430 separator = show_buddy_icons ? "\n" : " - "; | |
13123 | 431 text = g_strdup_printf("%s<span size=\"smaller\" color=\"%s\">%s%s</span>", |
432 primary, aa_color, separator, secondary); | |
12228 | 433 } else { |
13123 | 434 text = g_strdup(primary); |
11960 | 435 } |
13123 | 436 g_free(primary); |
437 g_free(secondary); | |
10643 | 438 |
13044 | 439 /* |
440 * Only two columns are used in this list store (does it | |
441 * really need to be a list store?) | |
442 */ | |
10643 | 443 gtk_list_store_set(status_box->store, &(status_box->iter), |
444 ICON_COLUMN, pixbuf, | |
10861 | 445 TEXT_COLUMN, text, |
11739 | 446 -1); |
13124 | 447 if ((status_box->typing == 0) && (!status_box->connecting)) |
448 g_object_unref(pixbuf); | |
13123 | 449 g_free(text); |
450 | |
451 /* Make sure to activate the only row in the tree view */ | |
10702 | 452 path = gtk_tree_path_new_from_string("0"); |
453 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); | |
454 gtk_tree_path_free(path); | |
10643 | 455 |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
456 update_size(status_box); |
10643 | 457 } |
458 | |
11870 | 459 /** |
460 * This updates the GtkTreeView so that it correctly shows the state | |
461 * we are currently using. It is used when the current state is | |
462 * updated from somewhere other than the GtkStatusBox (from a plugin, | |
463 * or when signing on with the "-n" option, for example). It is | |
13025 | 464 * also used when the user selects the "New..." option. |
11870 | 465 * |
466 * Maybe we could accomplish this by triggering off the mouse and | |
467 * keyboard signals instead of the changed signal? | |
468 */ | |
469 static void | |
13124 | 470 status_menu_refresh_iter(GtkGaimStatusBox *status_box) |
11870 | 471 { |
472 GaimSavedStatus *saved_status; | |
13050 | 473 GaimStatusPrimitive primitive; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
474 gint index; |
12125 | 475 const char *message; |
11870 | 476 |
11983 | 477 /* this function is inappropriate for ones with accounts */ |
478 if (status_box->account) | |
479 return; | |
480 | |
12125 | 481 saved_status = gaim_savedstatus_get_current(); |
11951 | 482 |
483 /* | |
484 * Suppress the "changed" signal because the status | |
485 * was changed programmatically. | |
486 */ | |
487 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
488 | |
13050 | 489 /* |
490 * If the saved_status is transient, is Available, Away, Invisible | |
491 * or Offline, and it does not have an substatuses, then select | |
492 * the primitive in the dropdown menu. Otherwise select the | |
493 * popular status in the dropdown menu. | |
494 */ | |
495 primitive = gaim_savedstatus_get_type(saved_status); | |
496 if (gaim_savedstatus_is_transient(saved_status) && | |
497 ((primitive == GAIM_STATUS_AVAILABLE) || (primitive == GAIM_STATUS_AWAY) || | |
498 (primitive == GAIM_STATUS_INVISIBLE) || (primitive == GAIM_STATUS_OFFLINE)) && | |
499 (!gaim_savedstatus_has_substatuses(saved_status))) | |
500 { | |
501 index = get_statusbox_index(status_box, saved_status); | |
13066 | 502 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); |
13050 | 503 } |
11870 | 504 else |
505 { | |
13066 | 506 GtkTreeIter iter; |
13111 | 507 GtkGaimStatusBoxItemType type; |
508 gpointer data; | |
13066 | 509 |
510 /* Unset the active item */ | |
511 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), -1); | |
512 | |
513 /* If this saved status is in the list store, then set it as the active item */ | |
514 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(status_box->dropdown_store), &iter)) | |
515 { | |
516 do | |
517 { | |
518 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | |
13111 | 519 TYPE_COLUMN, &type, |
13066 | 520 DATA_COLUMN, &data, |
521 -1); | |
13111 | 522 if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && |
523 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) | |
13066 | 524 { |
525 /* Found! */ | |
526 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
527 break; | |
528 } | |
529 } | |
530 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); | |
531 } | |
12125 | 532 } |
13050 | 533 |
12125 | 534 message = gaim_savedstatus_get_message(saved_status); |
13050 | 535 if (!gaim_savedstatus_is_transient(saved_status) || !message || !*message) |
12125 | 536 { |
537 status_box->imhtml_visible = FALSE; | |
538 gtk_widget_hide_all(status_box->vbox); | |
539 } | |
540 else | |
541 { | |
542 status_box->imhtml_visible = TRUE; | |
543 gtk_widget_show_all(status_box->vbox); | |
11870 | 544 |
12125 | 545 /* |
546 * Suppress the "changed" signal because the status | |
547 * was changed programmatically. | |
548 */ | |
549 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); | |
11954 | 550 |
12125 | 551 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
12274 | 552 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); |
12125 | 553 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
554 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); | |
11870 | 555 } |
11951 | 556 |
12634
8512c990967b
[gaim-migrate @ 14970]
Richard Laager <rlaager@wiktel.com>
parents:
12619
diff
changeset
|
557 update_size(status_box); |
8512c990967b
[gaim-migrate @ 14970]
Richard Laager <rlaager@wiktel.com>
parents:
12619
diff
changeset
|
558 |
11951 | 559 /* Stop suppressing the "changed" signal. */ |
560 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | |
11870 | 561 } |
562 | |
11732 | 563 static void |
12778 | 564 add_popular_statuses(GtkGaimStatusBox *statusbox) |
565 { | |
13090 | 566 gboolean show_buddy_icons; |
13124 | 567 GtkIconSize icon_size; |
12778 | 568 GList *list, *cur; |
13062 | 569 GdkPixbuf *pixbuf, *emblem; |
570 int width, height; | |
12778 | 571 |
572 list = gaim_savedstatuses_get_popular(6); | |
573 if (list == NULL) | |
574 /* Odd... oh well, nothing we can do about it. */ | |
575 return; | |
576 | |
13090 | 577 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
578 if (show_buddy_icons) | |
12778 | 579 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
580 else | |
581 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); | |
582 | |
12779 | 583 gtk_gaim_status_box_add_separator(statusbox); |
584 | |
12778 | 585 for (cur = list; cur != NULL; cur = cur->next) |
586 { | |
587 GaimSavedStatus *saved = cur->data; | |
13050 | 588 const gchar *message; |
13098
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
589 gchar *stripped = NULL; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
590 |
13090 | 591 /* Get an appropriate status icon */ |
13121 | 592 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
593 gaim_savedstatus_get_type(saved), | |
13090 | 594 show_buddy_icons ? 1.0 : 0.5); |
13050 | 595 |
596 if (gaim_savedstatus_is_transient(saved)) | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
597 { |
13050 | 598 /* |
599 * Transient statuses do not have a title, so the savedstatus | |
600 * API returns the message when gaim_savedstatus_get_title() is | |
601 * called, so we don't need to get the message a second time. | |
602 */ | |
603 } | |
604 else | |
605 { | |
606 message = gaim_savedstatus_get_message(saved); | |
13098
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
607 if (message != NULL) |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
608 { |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
609 stripped = gaim_markup_strip_html(message); |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
610 gaim_util_chrreplace(stripped, '\n', ' '); |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
611 } |
13090 | 612 |
613 /* Overlay a disk in the bottom left corner */ | |
614 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), | |
615 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); | |
616 if (emblem != NULL) | |
617 { | |
618 width = gdk_pixbuf_get_width(pixbuf) / 2; | |
619 height = gdk_pixbuf_get_height(pixbuf) / 2; | |
620 gdk_pixbuf_composite(emblem, pixbuf, 0, height, | |
621 width, height, 0, height, | |
622 0.5, 0.5, GDK_INTERP_BILINEAR, 255); | |
623 g_object_unref(G_OBJECT(emblem)); | |
624 } | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
625 } |
13090 | 626 |
12778 | 627 gtk_gaim_status_box_add(statusbox, GTK_GAIM_STATUS_BOX_TYPE_POPULAR, |
13079 | 628 pixbuf, gaim_savedstatus_get_title(saved), stripped, |
12778 | 629 GINT_TO_POINTER(gaim_savedstatus_get_creation_time(saved))); |
13050 | 630 g_free(stripped); |
13090 | 631 if (pixbuf != NULL) |
632 g_object_unref(G_OBJECT(pixbuf)); | |
12778 | 633 } |
634 | |
635 g_list_free(list); | |
636 } | |
637 | |
638 static void | |
11732 | 639 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) |
640 { | |
13090 | 641 gboolean show_buddy_icons; |
11739 | 642 GaimAccount *account; |
13090 | 643 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4, *tmp; |
11732 | 644 GtkIconSize icon_size; |
645 | |
13090 | 646 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
647 if (show_buddy_icons) | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
648 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
649 else |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
650 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); |
11732 | 651 |
12256 | 652 /* Unset the model while clearing it */ |
653 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL); | |
11732 | 654 gtk_list_store_clear(status_box->dropdown_store); |
13241 | 655 /* Don't set the model until the new statuses have been added to the box. |
656 * What is presumably a bug in Gtk < 2.4 causes things to get all confused | |
657 * if we do this here. */ | |
658 /* 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
|
659 |
11739 | 660 account = GTK_GAIM_STATUS_BOX(status_box)->account; |
661 if (account == NULL) | |
662 { | |
12779 | 663 /* Global */ |
11756 | 664 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_ONLINE, |
11732 | 665 icon_size, "GtkGaimStatusBox"); |
11756 | 666 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_AWAY, |
11732 | 667 icon_size, "GtkGaimStatusBox"); |
11756 | 668 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
11732 | 669 icon_size, "GtkGaimStatusBox"); |
11756 | 670 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE, |
11732 | 671 icon_size, "GtkGaimStatusBox"); |
12779 | 672 |
673 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)); | |
674 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)); | |
675 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)); | |
676 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)); | |
677 | |
678 add_popular_statuses(status_box); | |
679 | |
11738 | 680 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
13025 | 681 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
12778 | 682 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
683 | |
13241 | 684 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
13124 | 685 status_menu_refresh_iter(status_box); |
11732 | 686 |
687 } else { | |
12779 | 688 /* Per-account */ |
11732 | 689 const GList *l; |
11739 | 690 |
691 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
692 { | |
11732 | 693 GaimStatusType *status_type = (GaimStatusType *)l->data; |
694 | |
695 if (!gaim_status_type_is_user_settable(status_type)) | |
696 continue; | |
697 | |
13090 | 698 tmp = gaim_gtk_create_prpl_icon_with_status(account, status_type, |
699 show_buddy_icons ? 1.0 : 0.5); | |
11739 | 700 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
701 GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, tmp, |
11739 | 702 gaim_status_type_get_name(status_type), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
703 NULL, |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
704 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
13090 | 705 if (tmp != NULL) |
706 g_object_unref(tmp); | |
11732 | 707 } |
13241 | 708 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
11967 | 709 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); |
11732 | 710 } |
711 } | |
712 | |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
713 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
|
714 { |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
715 gtk_combo_box_popup(GTK_COMBO_BOX(w)); |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
716 return TRUE; |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
717 } |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
718 |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
719 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
|
720 { |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
721 if (event->direction == GDK_SCROLL_UP) |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
722 gtk_imhtml_page_up(imhtml); |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
723 else if (event->direction == GDK_SCROLL_DOWN) |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
724 gtk_imhtml_page_down(imhtml); |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
725 return TRUE; |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
726 } |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
727 |
13123 | 728 static int imhtml_remove_focus(GtkWidget *w, GdkEventKey *event, GtkGaimStatusBox *status_box) |
12274 | 729 { |
730 if (event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab) | |
731 { | |
732 /* If last inserted character is a tab, then remove the focus from here */ | |
733 GtkWidget *top = gtk_widget_get_toplevel(w); | |
734 g_signal_emit_by_name(G_OBJECT(top), "move_focus", | |
735 (event->state & GDK_SHIFT_MASK) ? | |
736 GTK_DIR_TAB_BACKWARD: GTK_DIR_TAB_FORWARD); | |
737 return TRUE; | |
738 } | |
13123 | 739 if (!status_box->typing != 0) |
12274 | 740 return FALSE; |
13803
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
741 |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
742 /* Reset the status if Escape was pressed */ |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
743 if (event->keyval == GDK_Escape) |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
744 { |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
745 g_source_remove(status_box->typing); |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
746 status_box->typing = 0; |
13830
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
747 if (status_box->account != NULL) |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
748 update_to_reflect_account_status(status_box, status_box->account, |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
749 gaim_account_get_active_status(status_box->account)); |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
750 else |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
751 status_menu_refresh_iter(status_box); |
13803
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
752 return TRUE; |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
753 } |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
754 |
13123 | 755 gtk_gaim_status_box_pulse_typing(status_box); |
756 g_source_remove(status_box->typing); | |
757 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); | |
12460
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
758 |
12274 | 759 return FALSE; |
760 } | |
761 | |
11753 | 762 #if GTK_CHECK_VERSION(2,6,0) |
11738 | 763 static gboolean |
764 dropdown_store_row_separator_func(GtkTreeModel *model, | |
765 GtkTreeIter *iter, gpointer data) | |
766 { | |
11739 | 767 GtkGaimStatusBoxItemType type; |
11738 | 768 |
11885 | 769 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
11738 | 770 |
11739 | 771 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR) |
11738 | 772 return TRUE; |
773 | |
774 return FALSE; | |
775 } | |
11753 | 776 #endif |
11738 | 777 |
10643 | 778 static void |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
779 cache_pixbufs(GtkGaimStatusBox *status_box) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
780 { |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
781 GtkIconSize icon_size; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
782 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
783 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) |
13065 | 784 { |
785 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
|
786 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_TWO_LINE); |
13065 | 787 } else { |
788 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
|
789 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL_TWO_LINE); |
13065 | 790 } |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
791 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
792 if (status_box->connecting_pixbufs[0] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
793 gdk_pixbuf_unref(status_box->connecting_pixbufs[0]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
794 if (status_box->connecting_pixbufs[1] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
795 gdk_pixbuf_unref(status_box->connecting_pixbufs[1]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
796 if (status_box->connecting_pixbufs[2] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
797 gdk_pixbuf_unref(status_box->connecting_pixbufs[2]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
798 if (status_box->connecting_pixbufs[3] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
799 gdk_pixbuf_unref(status_box->connecting_pixbufs[3]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
800 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
801 status_box->connecting_index = 0; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
802 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
|
803 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
804 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
|
805 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
806 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
|
807 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
808 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
|
809 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
810 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
811 if (status_box->typing_pixbufs[0] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
812 gdk_pixbuf_unref(status_box->typing_pixbufs[0]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
813 if (status_box->typing_pixbufs[1] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
814 gdk_pixbuf_unref(status_box->typing_pixbufs[1]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
815 if (status_box->typing_pixbufs[2] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
816 gdk_pixbuf_unref(status_box->typing_pixbufs[2]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
817 if (status_box->typing_pixbufs[3] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
818 gdk_pixbuf_unref(status_box->typing_pixbufs[3]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
819 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
820 status_box->typing_index = 0; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
821 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
|
822 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
823 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
|
824 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
825 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
|
826 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
827 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
|
828 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
829 } |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
830 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
831 static void |
11954 | 832 current_status_pref_changed_cb(const char *name, GaimPrefType type, |
12816 | 833 gconstpointer val, gpointer data) |
11954 | 834 { |
13121 | 835 GtkGaimStatusBox *status_box = data; |
12778 | 836 |
837 /* Make sure our current status is added to the list of popular statuses */ | |
13121 | 838 gtk_gaim_status_box_regenerate(status_box); |
12778 | 839 |
13121 | 840 if (status_box->account != NULL) |
841 update_to_reflect_account_status(status_box, status_box->account, | |
842 gaim_account_get_active_status(status_box->account)); | |
12244 | 843 else |
13124 | 844 status_menu_refresh_iter(status_box); |
13121 | 845 |
846 gtk_gaim_status_box_refresh(status_box); | |
11954 | 847 } |
848 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
849 static void |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
850 buddy_list_details_pref_changed_cb(const char *name, GaimPrefType type, |
12816 | 851 gconstpointer val, gpointer data) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
852 { |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
853 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
854 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
855 cache_pixbufs(status_box); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
856 gtk_gaim_status_box_regenerate(status_box); |
13121 | 857 gtk_gaim_status_box_refresh(status_box); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
858 } |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
859 |
12651 | 860 static void |
861 spellcheck_prefs_cb(const char *name, GaimPrefType type, | |
12816 | 862 gconstpointer value, gpointer data) |
12651 | 863 { |
864 #ifdef USE_GTKSPELL | |
865 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; | |
866 | |
867 if (value) | |
868 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); | |
869 else | |
870 { | |
871 GtkSpell *spell; | |
872 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(status_box->imhtml)); | |
873 gtkspell_detach(spell); | |
874 } | |
875 #endif | |
876 } | |
877 | |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
878 #if 0 |
12262 | 879 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
|
880 { |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
881 |
12274 | 882 if (event->button != 1) |
883 return FALSE; | |
12262 | 884 gtk_combo_box_popdown(GTK_COMBO_BOX(box)); |
885 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), FALSE); | |
886 if (!box->imhtml_visible) | |
887 g_signal_emit_by_name(G_OBJECT(box), "changed", NULL, NULL); | |
888 return TRUE; | |
889 } | |
890 | |
891 static gboolean button_pressed_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) | |
892 { | |
12274 | 893 if (event->button != 1) |
894 return FALSE; | |
12262 | 895 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
12274 | 896 // Disabled until button_released_cb works |
897 // gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), TRUE); | |
12262 | 898 return TRUE; |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
899 } |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
900 #endif |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
901 |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
902 static void |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
903 toggled_cb(GtkWidget *widget, GtkGaimStatusBox *box) |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
904 { |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
905 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
906 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
|
907 } |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
908 |
11954 | 909 static void |
10643 | 910 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) |
911 { | |
11400 | 912 GtkCellRenderer *text_rend; |
913 GtkCellRenderer *icon_rend; | |
10643 | 914 GtkTextBuffer *buffer; |
915 | |
916 status_box->imhtml_visible = FALSE; | |
917 status_box->connecting = FALSE; | |
13123 | 918 status_box->typing = 0; |
12262 | 919 status_box->toggle_button = gtk_toggle_button_new(); |
920 status_box->hbox = gtk_hbox_new(FALSE, 6); | |
10643 | 921 status_box->cell_view = gtk_cell_view_new(); |
12262 | 922 status_box->vsep = gtk_vseparator_new(); |
923 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
|
924 |
12778 | 925 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); |
926 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 | 927 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
928 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
929 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
930 gtk_list_store_append(status_box->store, &(status_box->iter)); | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
931 |
12262 | 932 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox); |
933 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0); | |
12274 | 934 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); |
935 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); | |
12262 | 936 gtk_widget_show_all(status_box->toggle_button); |
937 #if GTK_CHECK_VERSION(2,4,0) | |
938 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); | |
939 #endif | |
10643 | 940 |
13044 | 941 text_rend = gtk_cell_renderer_text_new(); |
942 icon_rend = gtk_cell_renderer_pixbuf_new(); | |
10643 | 943 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); |
10861 | 944 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
10643 | 945 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
946 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
13045 | 947 #if GTK_CHECK_VERSION(2, 6, 0) |
948 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
949 #endif | |
10643 | 950 |
13044 | 951 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
952 status_box->text_rend = gtk_cell_renderer_text_new(); | |
10643 | 953 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
11499 | 954 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
10643 | 955 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
956 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
13045 | 957 #if GTK_CHECK_VERSION(2, 6, 0) |
958 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
959 #endif | |
10643 | 960 |
961 status_box->vbox = gtk_vbox_new(0, FALSE); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13244
diff
changeset
|
962 status_box->sw = gaim_gtk_create_imhtml(FALSE, &status_box->imhtml, NULL, NULL); |
12879
f8748df5c17a
[gaim-migrate @ 15231]
Gary Kramlich <grim@reaperworld.com>
parents:
12827
diff
changeset
|
963 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
964 |
10643 | 965 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
|
966 #if 0 |
12274 | 967 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event", |
968 G_CALLBACK(button_pressed_cb), status_box); | |
969 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event", | |
970 G_CALLBACK(button_released_cb), status_box); | |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
971 #endif |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
972 g_signal_connect(G_OBJECT(status_box->toggle_button), "toggled", |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
973 G_CALLBACK(toggled_cb), status_box); |
10643 | 974 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
|
975 g_signal_connect(G_OBJECT(status_box->imhtml), "format_function_toggle", |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
976 G_CALLBACK(imhtml_format_changed_cb), status_box); |
12274 | 977 g_signal_connect(G_OBJECT(status_box->imhtml), "key_press_event", |
978 G_CALLBACK(imhtml_remove_focus), status_box); | |
11562 | 979 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
10643 | 980 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
12651 | 981 #ifdef USE_GTKSPELL |
982 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
983 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); | |
984 #endif | |
10643 | 985 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); |
12262 | 986 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); |
12275 | 987 GTK_BIN(status_box)->child = status_box->toggle_button; |
12269 | 988 |
10643 | 989 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); |
11654 | 990 |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
991 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
|
992 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
993 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml); |
12075
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
994 |
11850 | 995 #if GTK_CHECK_VERSION(2,6,0) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
996 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); |
11850 | 997 #endif |
998 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
999 cache_pixbufs(status_box); |
11732 | 1000 gtk_gaim_status_box_regenerate(status_box); |
13737 | 1001 gtk_gaim_status_box_refresh(status_box); |
11954 | 1002 |
12123 | 1003 gaim_prefs_connect_callback(status_box, "/core/savedstatus/current", |
11954 | 1004 current_status_pref_changed_cb, status_box); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
1005 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
|
1006 buddy_list_details_pref_changed_cb, status_box); |
12651 | 1007 gaim_prefs_connect_callback(status_box, "/gaim/gtk/conversations/spellcheck", |
1008 spellcheck_prefs_cb, status_box); | |
10643 | 1009 } |
1010 | |
1011 static void | |
10861 | 1012 gtk_gaim_status_box_size_request(GtkWidget *widget, |
1013 GtkRequisition *requisition) | |
10643 | 1014 { |
1015 GtkRequisition box_req; | |
1016 combo_box_size_request(widget, requisition); | |
12596
037a673ba862
[gaim-migrate @ 14926]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1017 requisition->height += 3; |
10861 | 1018 |
13065 | 1019 /* If the gtkimhtml is visible, then add some additional padding */ |
10643 | 1020 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
1021 if (box_req.height > 1) | |
13065 | 1022 requisition->height += box_req.height + 3; |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
1023 |
10643 | 1024 requisition->width = 1; |
1025 } | |
1026 | |
1027 static void | |
10861 | 1028 gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
1029 GtkAllocation *allocation) | |
10643 | 1030 { |
1031 GtkRequisition req = {0,0}; | |
11400 | 1032 GtkAllocation parent_alc, box_alc; |
1033 | |
10643 | 1034 combo_box_size_request(widget, &req); |
10861 | 1035 |
13065 | 1036 box_alc = *allocation; |
12596
037a673ba862
[gaim-migrate @ 14926]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1037 box_alc.height = MAX(1, (allocation->height - req.height - 6)); |
13065 | 1038 box_alc.y += req.height + 6; |
10643 | 1039 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); |
10861 | 1040 |
13065 | 1041 parent_alc = *allocation; |
10643 | 1042 parent_alc.height = MAX(1,req.height); |
12102
8df87db79bad
[gaim-migrate @ 14399]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12100
diff
changeset
|
1043 parent_alc.y += 3; |
10643 | 1044 combo_box_size_allocate(widget, &parent_alc); |
12262 | 1045 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->toggle_button, &parent_alc); |
10643 | 1046 widget->allocation = *allocation; |
1047 } | |
1048 | |
1049 static gboolean | |
10861 | 1050 gtk_gaim_status_box_expose_event(GtkWidget *widget, |
12262 | 1051 GdkEventExpose *event) |
10643 | 1052 { |
10861 | 1053 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
12262 | 1054 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
12275 | 1055 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
10861 | 1056 return FALSE; |
10643 | 1057 } |
1058 | |
1059 static void | |
10861 | 1060 gtk_gaim_status_box_forall(GtkContainer *container, |
1061 gboolean include_internals, | |
1062 GtkCallback callback, | |
1063 gpointer callback_data) | |
10643 | 1064 { |
10861 | 1065 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
10643 | 1066 |
10861 | 1067 if (include_internals) |
1068 { | |
1069 (* callback) (status_box->vbox, callback_data); | |
12275 | 1070 (* callback) (status_box->toggle_button, callback_data); |
1071 (* callback) (status_box->arrow, callback_data); | |
10861 | 1072 } |
10643 | 1073 |
10861 | 1074 combo_box_forall(container, include_internals, callback, callback_data); |
10643 | 1075 } |
1076 | |
1077 GtkWidget * | |
1078 gtk_gaim_status_box_new() | |
1079 { | |
1080 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | |
1081 } | |
1082 | |
11499 | 1083 GtkWidget * |
1084 gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
1085 { | |
1086 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
1087 } | |
10643 | 1088 |
13050 | 1089 /** |
1090 * Add a row to the dropdown menu. | |
1091 * | |
1092 * @param status_box The status box itself. | |
1093 * @param type A GtkGaimStatusBoxItemType. | |
1094 * @param pixbuf The icon to associate with this row in the menu. | |
1095 * @param title The title of this item. For the primitive entries, | |
1096 * this is something like "Available" or "Away." For | |
1097 * the saved statuses, this is something like | |
1098 * "My favorite away message!" This should be | |
1099 * plaintext (non-markedup) (this function escapes it). | |
1100 * @param desc The secondary text for this item. This will be | |
1101 * placed on the row below the title, in a dimmer | |
1102 * font (generally gray). This text should be plaintext | |
1103 * (non-markedup) (this function escapes it). | |
1104 * @param data Data to be associated with this row in the dropdown | |
1105 * menu. For primitives this is the value of the | |
1106 * GaimStatusPrimitive. For saved statuses this is the | |
1107 * creation timestamp. | |
1108 */ | |
10643 | 1109 void |
13050 | 1110 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GtkGaimStatusBoxItemType type, GdkPixbuf *pixbuf, const char *title, const char *desc, gpointer data) |
10643 | 1111 { |
1112 GtkTreeIter iter; | |
13050 | 1113 char *text; |
10861 | 1114 |
13050 | 1115 if (desc == NULL) |
1116 { | |
1117 text = g_markup_escape_text(title, -1); | |
1118 } | |
1119 else | |
1120 { | |
13385 | 1121 gboolean show_buddy_icons; |
1122 GtkStyle *style; | |
10643 | 1123 char aa_color[8]; |
13050 | 1124 gchar *escaped_title, *escaped_desc; |
1125 | |
13385 | 1126 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
13050 | 1127 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
10643 | 1128 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
1129 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
1130 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
10861 | 1131 style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
13050 | 1132 |
1133 escaped_title = g_markup_escape_text(title, -1); | |
1134 escaped_desc = g_markup_escape_text(desc, -1); | |
13385 | 1135 text = g_strdup_printf("%s%s<span color=\"%s\" size=\"smaller\">%s</span>", |
1136 escaped_title, | |
1137 show_buddy_icons ? "\n" : " - ", | |
1138 aa_color, escaped_desc); | |
13050 | 1139 g_free(escaped_title); |
1140 g_free(escaped_desc); | |
10643 | 1141 } |
10861 | 1142 |
10643 | 1143 gtk_list_store_append(status_box->dropdown_store, &iter); |
1144 gtk_list_store_set(status_box->dropdown_store, &iter, | |
13050 | 1145 TYPE_COLUMN, type, |
1146 ICON_COLUMN, pixbuf, | |
1147 TEXT_COLUMN, text, | |
1148 TITLE_COLUMN, title, | |
1149 DESC_COLUMN, desc, | |
1150 DATA_COLUMN, data, | |
1151 -1); | |
1152 g_free(text); | |
10643 | 1153 } |
1154 | |
1155 void | |
11738 | 1156 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box) |
1157 { | |
11756 | 1158 /* Don't do anything unless GTK actually supports |
1159 * gtk_combo_box_set_row_separator_func */ | |
1160 #if GTK_CHECK_VERSION(2,6,0) | |
11738 | 1161 GtkTreeIter iter; |
1162 | |
1163 gtk_list_store_append(status_box->dropdown_store, &iter); | |
1164 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 1165 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR, |
1166 -1); | |
11756 | 1167 #endif |
11738 | 1168 } |
1169 | |
1170 void | |
10643 | 1171 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) |
1172 { | |
1173 if (!status_box) | |
1174 return; | |
1175 status_box->connecting = connecting; | |
1176 gtk_gaim_status_box_refresh(status_box); | |
1177 } | |
1178 | |
1179 void | |
1180 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) | |
1181 { | |
1182 if (!status_box) | |
1183 return; | |
1184 if (status_box->connecting_index == 3) | |
1185 status_box->connecting_index = 0; | |
10861 | 1186 else |
10643 | 1187 status_box->connecting_index++; |
1188 gtk_gaim_status_box_refresh(status_box); | |
1189 } | |
1190 | |
12274 | 1191 static void |
10643 | 1192 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) |
1193 { | |
1194 if (status_box->typing_index == 3) | |
1195 status_box->typing_index = 0; | |
10861 | 1196 else |
10643 | 1197 status_box->typing_index++; |
1198 gtk_gaim_status_box_refresh(status_box); | |
1199 } | |
1200 | |
13050 | 1201 static GaimStatusType * |
1202 find_status_type_by_index(const GaimAccount *account, gint active) | |
11993 | 1203 { |
1204 const GList *l = gaim_account_get_status_types(account); | |
1205 gint i; | |
1206 | |
1207 for (i = 0; l; l = l->next) { | |
1208 GaimStatusType *status_type = l->data; | |
1209 if (!gaim_status_type_is_user_settable(status_type)) | |
1210 continue; | |
1211 | |
1212 if (active == i) | |
1213 return status_type; | |
1214 i++; | |
1215 } | |
1216 | |
1217 return NULL; | |
1218 } | |
1219 | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1220 static gboolean |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1221 message_changed(const char *one, const char *two) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1222 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1223 if (one == NULL && two == NULL) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1224 return FALSE; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1225 |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1226 if (one == NULL || two == NULL) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1227 return TRUE; |
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 return (g_utf8_collate(one, two) != 0); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1230 } |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1231 |
11654 | 1232 static void |
1233 activate_currently_selected_status(GtkGaimStatusBox *status_box) | |
10643 | 1234 { |
11739 | 1235 GtkGaimStatusBoxItemType type; |
12779 | 1236 gpointer data; |
11739 | 1237 gchar *title; |
10643 | 1238 GtkTreeIter iter; |
11654 | 1239 char *message; |
1240 GaimSavedStatus *saved_status; | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1241 gboolean changed = TRUE; |
10643 | 1242 |
11951 | 1243 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter)) |
1244 return; | |
12659 | 1245 |
11654 | 1246 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
12779 | 1247 TYPE_COLUMN, &type, |
1248 DATA_COLUMN, &data, | |
1249 -1); | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
1250 |
11739 | 1251 /* |
13025 | 1252 * If the currently selected status is "New..." or |
12779 | 1253 * "Saved..." or a popular status then do nothing. |
13124 | 1254 * Popular statuses are |
11954 | 1255 * activated elsewhere, and we update the status_box |
1256 * accordingly by monitoring the preference | |
12123 | 1257 * "/core/savedstatus/current" and then calling |
13124 | 1258 * status_menu_refresh_iter() |
11739 | 1259 */ |
12779 | 1260 if (type != GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) |
11739 | 1261 return; |
11654 | 1262 |
12659 | 1263 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
1264 TITLE_COLUMN, &title, -1); | |
1265 | |
1266 message = gtk_gaim_status_box_get_message(status_box); | |
1267 if (!message || !*message) | |
1268 { | |
1269 gtk_widget_hide_all(status_box->vbox); | |
1270 status_box->imhtml_visible = FALSE; | |
13230 | 1271 if (message != NULL) |
1272 { | |
1273 g_free(message); | |
1274 message = NULL; | |
1275 } | |
12659 | 1276 } |
1277 | |
12779 | 1278 if (status_box->account == NULL) { |
1279 /* Global */ | |
1280 /* Save the newly selected status to prefs.xml and status.xml */ | |
1281 | |
13111 | 1282 /* Has the status really been changed? */ |
12779 | 1283 saved_status = gaim_savedstatus_get_current(); |
13801
3f23b55a2cc4
[gaim-migrate @ 16215]
Richard Laager <rlaager@wiktel.com>
parents:
13739
diff
changeset
|
1284 if (gaim_savedstatus_get_type(saved_status) == GPOINTER_TO_INT(data) && |
3f23b55a2cc4
[gaim-migrate @ 16215]
Richard Laager <rlaager@wiktel.com>
parents:
13739
diff
changeset
|
1285 !gaim_savedstatus_has_substatuses(saved_status)) |
12779 | 1286 { |
1287 if (!message_changed(gaim_savedstatus_get_message(saved_status), message)) | |
1288 changed = FALSE; | |
1289 } | |
1290 | |
1291 if (changed) | |
1292 { | |
13012 | 1293 /* If we've used this type+message before, lookup the transient status */ |
13244 | 1294 saved_status = gaim_savedstatus_find_transient_by_type_and_message( |
13012 | 1295 GPOINTER_TO_INT(data), message); |
1296 | |
1297 /* If this type+message is unique then create a new transient saved status */ | |
1298 if (saved_status == NULL) | |
1299 { | |
1300 saved_status = gaim_savedstatus_new(NULL, GPOINTER_TO_INT(data)); | |
1301 gaim_savedstatus_set_message(saved_status, message); | |
1302 } | |
12779 | 1303 |
1304 /* Set the status for each account */ | |
1305 gaim_savedstatus_activate(saved_status); | |
1306 } | |
1307 } else { | |
1308 /* Per-account */ | |
11981 | 1309 gint active; |
1310 GaimStatusType *status_type; | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1311 GaimStatus *status; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1312 const char *id = NULL; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1313 |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1314 status = gaim_account_get_active_status(status_box->account); |
11981 | 1315 |
1316 g_object_get(G_OBJECT(status_box), "active", &active, NULL); | |
11654 | 1317 |
11993 | 1318 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
|
1319 id = gaim_status_type_get_id(status_type); |
11981 | 1320 |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1321 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
|
1322 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1323 /* Selected status and previous status is the same */ |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1324 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
|
1325 changed = FALSE; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1326 } |
12123 | 1327 |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1328 if (changed) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1329 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1330 if (message) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1331 gaim_account_set_status(status_box->account, id, |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1332 TRUE, "message", message, NULL); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1333 else |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1334 gaim_account_set_status(status_box->account, id, |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1335 TRUE, NULL); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1336 } |
11981 | 1337 } |
11627 | 1338 |
11638 | 1339 g_free(title); |
11654 | 1340 g_free(message); |
1341 } | |
1342 | |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1343 static void update_size(GtkGaimStatusBox *status_box) |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1344 { |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1345 GtkTextBuffer *buffer; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1346 GtkTextIter iter; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1347 int wrapped_lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1348 int lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1349 GdkRectangle oneline; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1350 int height; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1351 int pad_top, pad_inside, pad_bottom; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1352 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1353 if (!status_box->imhtml_visible) |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1354 { |
12598
1c122dbc8e9e
[gaim-migrate @ 14928]
Richard Laager <rlaager@wiktel.com>
parents:
12597
diff
changeset
|
1355 if (status_box->vbox != NULL) |
1c122dbc8e9e
[gaim-migrate @ 14928]
Richard Laager <rlaager@wiktel.com>
parents:
12597
diff
changeset
|
1356 gtk_widget_set_size_request(status_box->vbox, -1, -1); |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1357 return; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1358 } |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1359 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1360 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
|
1361 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1362 wrapped_lines = 1; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1363 gtk_text_buffer_get_start_iter(buffer, &iter); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1364 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
|
1365 wrapped_lines++; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1366 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1367 lines = gtk_text_buffer_get_line_count(buffer); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1368 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1369 /* Show a maximum of 4 lines */ |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1370 lines = MIN(lines, 4); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1371 wrapped_lines = MIN(wrapped_lines, 4); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1372 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1373 gtk_text_buffer_get_start_iter(buffer, &iter); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1374 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
|
1375 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1376 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
|
1377 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
|
1378 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
|
1379 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1380 height = (oneline.height + pad_top + pad_bottom) * lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1381 height += (oneline.height + pad_inside) * (wrapped_lines - lines); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1382 |
12905
ee0c8c446eef
[gaim-migrate @ 15258]
Richard Laager <rlaager@wiktel.com>
parents:
12879
diff
changeset
|
1383 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
|
1384 } |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1385 |
11654 | 1386 static void remove_typing_cb(GtkGaimStatusBox *status_box) |
1387 { | |
12782 | 1388 if (status_box->typing == 0) |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1389 { |
12782 | 1390 /* Nothing has changed, so we don't need to do anything */ |
13124 | 1391 status_menu_refresh_iter(status_box); |
12782 | 1392 return; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1393 } |
12782 | 1394 |
11654 | 1395 g_source_remove(status_box->typing); |
1396 status_box->typing = 0; | |
13739 | 1397 |
1398 activate_currently_selected_status(status_box); | |
11654 | 1399 gtk_gaim_status_box_refresh(status_box); |
10643 | 1400 } |
1401 | |
1402 static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
1403 { | |
11400 | 1404 GtkGaimStatusBox *status_box; |
10643 | 1405 GtkTreeIter iter; |
11739 | 1406 GtkGaimStatusBoxItemType type; |
12778 | 1407 gpointer data; |
11960 | 1408 GList *accounts = NULL, *node; |
10643 | 1409 |
11400 | 1410 status_box = GTK_GAIM_STATUS_BOX(box); |
1411 | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
1412 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
|
1413 return; |
11739 | 1414 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
1415 TYPE_COLUMN, &type, | |
12778 | 1416 DATA_COLUMN, &data, |
11739 | 1417 -1); |
13123 | 1418 if (status_box->typing != 0) |
11638 | 1419 g_source_remove(status_box->typing); |
1420 status_box->typing = 0; | |
10861 | 1421 |
11951 | 1422 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11729 | 1423 { |
12778 | 1424 if (type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) |
1425 { | |
1426 GaimSavedStatus *saved; | |
1427 saved = gaim_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); | |
1428 g_return_if_fail(saved != NULL); | |
1429 gaim_savedstatus_activate(saved); | |
1430 return; | |
1431 } | |
1432 | |
11951 | 1433 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
1434 { | |
13175 | 1435 GaimSavedStatus *saved_status; |
1436 saved_status = gaim_savedstatus_get_current(); | |
1437 gaim_gtk_status_editor_show(FALSE, | |
1438 gaim_savedstatus_is_transient(saved_status) | |
1439 ? saved_status : NULL); | |
13124 | 1440 status_menu_refresh_iter(status_box); |
11951 | 1441 return; |
1442 } | |
11729 | 1443 |
11951 | 1444 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
1445 { | |
1446 gaim_gtk_status_window_show(); | |
13124 | 1447 status_menu_refresh_iter(status_box); |
11951 | 1448 return; |
1449 } | |
11729 | 1450 } |
1451 | |
11654 | 1452 /* |
12779 | 1453 * Show the message box whenever the primitive allows for a |
11960 | 1454 * message attribute on any protocol that is enabled, |
1455 * or our protocol, if we have account set | |
11654 | 1456 */ |
11960 | 1457 if (status_box->account) |
1458 accounts = g_list_prepend(accounts, status_box->account); | |
1459 else | |
1460 accounts = gaim_accounts_get_all_active(); | |
11755 | 1461 status_box->imhtml_visible = FALSE; |
1462 for (node = accounts; node != NULL; node = node->next) | |
1463 { | |
1464 GaimAccount *account; | |
1465 GaimStatusType *status_type; | |
1466 | |
1467 account = node->data; | |
12779 | 1468 status_type = gaim_account_get_status_type_with_primitive(account, GPOINTER_TO_INT(data)); |
11755 | 1469 if ((status_type != NULL) && |
1470 (gaim_status_type_get_attr(status_type, "message") != NULL)) | |
1471 { | |
1472 status_box->imhtml_visible = TRUE; | |
1473 break; | |
1474 } | |
1475 } | |
1476 g_list_free(accounts); | |
11654 | 1477 |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1478 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11654 | 1479 { |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1480 if (status_box->imhtml_visible) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1481 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1482 gtk_widget_show_all(status_box->vbox); |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1483 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1484 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
|
1485 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1486 gtk_widget_grab_focus(status_box->imhtml); |
13802
a93eeef163a9
[gaim-migrate @ 16216]
Richard Laager <rlaager@wiktel.com>
parents:
13801
diff
changeset
|
1487 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
12274 | 1488 } |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1489 else |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1490 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1491 gtk_widget_hide_all(status_box->vbox); |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1492 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1493 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
|
1494 } |
10643 | 1495 } |
1496 gtk_gaim_status_box_refresh(status_box); | |
1497 } | |
1498 | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1499 static gint |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1500 get_statusbox_index(GtkGaimStatusBox *box, GaimSavedStatus *saved_status) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1501 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1502 gint index; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1503 |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1504 switch (gaim_savedstatus_get_type(saved_status)) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1505 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1506 case GAIM_STATUS_AVAILABLE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1507 index = 0; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1508 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1509 case GAIM_STATUS_AWAY: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1510 index = 1; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1511 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1512 case GAIM_STATUS_INVISIBLE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1513 index = 2; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1514 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1515 case GAIM_STATUS_OFFLINE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1516 index = 3; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1517 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1518 default: |
13079 | 1519 index = -1; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1520 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1521 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1522 |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1523 return index; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1524 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1525 |
10643 | 1526 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) |
1527 { | |
13123 | 1528 GtkGaimStatusBox *status_box = (GtkGaimStatusBox*)data; |
1529 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) | |
11951 | 1530 { |
13123 | 1531 if (status_box->typing != 0) { |
1532 gtk_gaim_status_box_pulse_typing(status_box); | |
1533 g_source_remove(status_box->typing); | |
11951 | 1534 } |
13123 | 1535 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
10861 | 1536 } |
13123 | 1537 gtk_gaim_status_box_refresh(status_box); |
10643 | 1538 } |
10649 | 1539 |
12460
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1540 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
|
1541 { |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1542 imhtml_changed_cb(NULL, data); |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1543 } |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1544 |
11638 | 1545 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) |
10649 | 1546 { |
1547 if (status_box->imhtml_visible) | |
1548 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
1549 else | |
1550 return NULL; | |
1551 } |