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