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