Mercurial > pidgin
annotate src/gtkstatusbox.c @ 14161:694aae55ab6d
[gaim-migrate @ 16809]
gaim_ssl_connect's are now cancelable (without crashing, anyway)
This was relatively easy, because the PRPLs already keep a reference
to the GaimSslConnection. I just needed to update the core ssl code
to keep track of the GaimProxyConnectInfo, and to call
gaim_proxy_connect_cancel() when gaim_ssl_close() is called
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 17 Aug 2006 05:47:58 +0000 |
parents | 47292c1f7e9f |
children | 06a2658aa96e |
rev | line source |
---|---|
10643 | 1 /* |
2 * @file gtkstatusbox.c GTK+ Status Selection Widget | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 | |
13044 | 26 /* |
27 * The status box is made up of two main pieces: | |
28 * - The box that displays the current status, which is made | |
29 * of a GtkListStore ("status_box->store") and GtkCellView | |
30 * ("status_box->cell_view"). There is always exactly 1 row | |
31 * in this list store. Only the TYPE_ICON and TYPE_TEXT | |
32 * columns are used in this list store. | |
33 * - The dropdown menu that lets users select a status, which | |
34 * is made of a GtkComboBox ("status_box") and GtkListStore | |
35 * ("status_box->dropdown_store"). This dropdown is shown | |
36 * when the user clicks on the box that displays the current | |
37 * status. This list store contains one row for Available, | |
38 * one row for Away, etc., a few rows for popular statuses, | |
39 * and the "New..." and "Saved..." options. | |
40 */ | |
41 | |
12274 | 42 #include <gdk/gdkkeysyms.h> |
43 | |
11627 | 44 #include "account.h" |
10643 | 45 #include "internal.h" |
11627 | 46 #include "savedstatuses.h" |
10643 | 47 #include "status.h" |
11732 | 48 #include "debug.h" |
11627 | 49 |
10643 | 50 #include "gtkgaim.h" |
11729 | 51 #include "gtksavedstatuses.h" |
10643 | 52 #include "gtkstock.h" |
53 #include "gtkstatusbox.h" | |
12080 | 54 #include "gtkutils.h" |
10643 | 55 |
12651 | 56 #ifdef USE_GTKSPELL |
57 # include <gtkspell/gtkspell.h> | |
58 # ifdef _WIN32 | |
59 # include "wspell.h" | |
60 # endif | |
61 #endif | |
62 | |
12309 | 63 #define TYPING_TIMEOUT 4000 |
64 | |
10643 | 65 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); |
12460
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
66 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data); |
11562 | 67 static void remove_typing_cb(GtkGaimStatusBox *box); |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
68 static void update_size (GtkGaimStatusBox *box); |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
69 static gint get_statusbox_index(GtkGaimStatusBox *box, GaimSavedStatus *saved_status); |
10643 | 70 |
12274 | 71 static void gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box); |
11967 | 72 static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); |
11732 | 73 static void gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box); |
10643 | 74 static void gtk_gaim_status_box_changed(GtkComboBox *box); |
75 static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
76 static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
77 static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); | |
78 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
79 | |
14133 | 80 static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
81 static void icon_choose_cb(const char *filename, gpointer data); |
14133 | 82 |
10643 | 83 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); |
84 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); | |
85 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
11739 | 86 |
10643 | 87 enum { |
13044 | 88 /** A GtkGaimStatusBoxItemType */ |
89 TYPE_COLUMN, | |
90 | |
91 /** | |
92 * This is a GdkPixbuf (the other columns are strings). | |
93 * This column is visible. | |
94 */ | |
95 ICON_COLUMN, | |
96 | |
97 /** The text displayed on the status box. This column is visible. */ | |
98 TEXT_COLUMN, | |
99 | |
100 /** The plain-English title of this item */ | |
101 TITLE_COLUMN, | |
102 | |
103 /** A plain-English description of this item */ | |
104 DESC_COLUMN, | |
105 | |
106 /* | |
107 * This value depends on TYPE_COLUMN. For POPULAR types, | |
108 * this is the creation time. For PRIMITIVE types, | |
109 * this is the GaimStatusPrimitive. | |
110 */ | |
111 DATA_COLUMN, | |
112 | |
10643 | 113 NUM_COLUMNS |
114 }; | |
115 | |
11499 | 116 enum { |
117 PROP_0, | |
118 PROP_ACCOUNT | |
119 }; | |
120 | |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
121 GtkComboBoxClass *parent_class = NULL; |
12651 | 122 |
10643 | 123 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); |
124 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); | |
125 | |
126 GType | |
127 gtk_gaim_status_box_get_type (void) | |
128 { | |
10861 | 129 static GType status_box_type = 0; |
10643 | 130 |
10861 | 131 if (!status_box_type) |
132 { | |
133 static const GTypeInfo status_box_info = | |
134 { | |
135 sizeof (GtkGaimStatusBoxClass), | |
136 NULL, /* base_init */ | |
137 NULL, /* base_finalize */ | |
138 (GClassInitFunc) gtk_gaim_status_box_class_init, | |
139 NULL, /* class_finalize */ | |
140 NULL, /* class_data */ | |
141 sizeof (GtkGaimStatusBox), | |
142 0, | |
12221
152748df85cf
[gaim-migrate @ 14523]
Richard Laager <rlaager@wiktel.com>
parents:
12125
diff
changeset
|
143 (GInstanceInitFunc) gtk_gaim_status_box_init, |
152748df85cf
[gaim-migrate @ 14523]
Richard Laager <rlaager@wiktel.com>
parents:
12125
diff
changeset
|
144 NULL /* value_table */ |
10861 | 145 }; |
10643 | 146 |
10861 | 147 status_box_type = g_type_register_static(GTK_TYPE_COMBO_BOX, |
148 "GtkGaimStatusBox", | |
149 &status_box_info, | |
150 0); | |
151 } | |
10643 | 152 |
10861 | 153 return status_box_type; |
10643 | 154 } |
155 | |
156 static void | |
11499 | 157 gtk_gaim_status_box_get_property(GObject *object, guint param_id, |
158 GValue *value, GParamSpec *psec) | |
159 { | |
160 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
161 | |
162 switch (param_id) { | |
163 case PROP_ACCOUNT: | |
164 g_value_set_pointer(value, statusbox->account); | |
165 break; | |
166 default: | |
167 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec); | |
168 break; | |
169 } | |
170 } | |
171 | |
172 static void | |
11967 | 173 update_to_reflect_account_status(GtkGaimStatusBox *status_box, GaimAccount *account, GaimStatus *newstatus) |
11960 | 174 { |
11967 | 175 const GList *l; |
176 int status_no = -1; | |
177 const GaimStatusType *statustype = NULL; | |
12060 | 178 const char *message; |
11967 | 179 |
180 statustype = gaim_status_type_find_with_id((GList *)gaim_account_get_status_types(account), | |
181 (char *)gaim_status_type_get_id(gaim_status_get_type(newstatus))); | |
182 | |
183 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) { | |
184 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
185 | |
186 if (!gaim_status_type_is_user_settable(status_type)) | |
187 continue; | |
188 status_no++; | |
189 if (statustype == status_type) | |
190 break; | |
191 } | |
192 | |
193 if (status_no != -1) { | |
194 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
195 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
|
196 |
12060 | 197 message = gaim_status_get_attr_string(newstatus, "message"); |
198 | |
199 if (!message || !*message) | |
200 { | |
201 gtk_widget_hide_all(status_box->vbox); | |
202 status_box->imhtml_visible = FALSE; | |
203 } | |
204 else | |
205 { | |
206 gtk_widget_show_all(status_box->vbox); | |
207 status_box->imhtml_visible = TRUE; | |
208 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
12274 | 209 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); |
12060 | 210 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
211 } | |
11967 | 212 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); |
12274 | 213 gtk_gaim_status_box_refresh(status_box); |
11967 | 214 } |
215 } | |
216 | |
217 static void | |
218 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus, GtkGaimStatusBox *status_box) | |
219 { | |
220 if (status_box->account == account) | |
221 update_to_reflect_account_status(status_box, account, newstatus); | |
11960 | 222 } |
223 | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
224 static gboolean |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
225 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
226 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
227 if (box->buddy_icon_sel) { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
228 gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
229 return FALSE; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
230 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
231 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
232 box->buddy_icon_sel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
233 gtk_widget_show_all(box->buddy_icon_sel); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
234 return FALSE; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
235 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
236 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
237 static gboolean |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
238 icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
239 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
240 gdk_window_set_cursor(widget->window, box->hand_cursor); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
241 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon_hover); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
242 return FALSE; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
243 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
244 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
245 static gboolean |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
246 icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
247 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
248 gdk_window_set_cursor(widget->window, box->arrow_cursor); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
249 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon) ; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
250 return FALSE; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
251 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
252 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
253 static void |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
254 setup_icon_box(GtkGaimStatusBox *status_box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
255 { |
14154
c55e46e26781
[gaim-migrate @ 16799]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14153
diff
changeset
|
256 if (status_box->account && |
c55e46e26781
[gaim-migrate @ 16799]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14153
diff
changeset
|
257 !gaim_account_get_ui_bool(status_box->account, GAIM_GTK_UI, "use-global-buddyicon", TRUE)) |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
258 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
259 char *string = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(status_box->account)); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
260 gtk_gaim_status_box_set_buddy_icon(status_box, string); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
261 g_free(string); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
262 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
263 else |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
264 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
265 gtk_gaim_status_box_set_buddy_icon(status_box, gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon")); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
266 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
267 status_box->icon = gtk_image_new_from_pixbuf(status_box->buddy_icon); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
268 status_box->icon_box = gtk_event_box_new(); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
269 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
270 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
271 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
272 g_signal_connect(G_OBJECT(status_box->icon_box), "enter-notify-event", G_CALLBACK(icon_box_enter_cb), status_box); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
273 g_signal_connect(G_OBJECT(status_box->icon_box), "leave-notify-event", G_CALLBACK(icon_box_leave_cb), status_box); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
274 g_signal_connect(G_OBJECT(status_box->icon_box), "button-press-event", G_CALLBACK(icon_box_press_cb), status_box); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
275 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
276 gtk_container_add(GTK_CONTAINER(status_box->icon_box), status_box->icon); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
277 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
278 gtk_widget_show_all(status_box->icon_box); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
279 gtk_widget_set_parent(status_box->icon_box, GTK_WIDGET(status_box)); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
280 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
281 |
11960 | 282 static void |
11499 | 283 gtk_gaim_status_box_set_property(GObject *object, guint param_id, |
284 const GValue *value, GParamSpec *pspec) | |
285 { | |
286 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
287 | |
288 switch (param_id) { | |
289 case PROP_ACCOUNT: | |
290 statusbox->account = g_value_get_pointer(value); | |
11960 | 291 |
11967 | 292 if (statusbox->status_changed_signal) { |
293 gaim_signal_disconnect(gaim_accounts_get_handle(), "account-status-changed", | |
294 statusbox, GAIM_CALLBACK(account_status_changed_cb)); | |
295 statusbox->status_changed_signal = 0; | |
296 } | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
297 |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
298 if (statusbox->account) { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
299 GaimPlugin *plug = gaim_plugins_find_with_id(gaim_account_get_protocol_id(statusbox->account)); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
300 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
301 if (prplinfo && prplinfo->icon_spec.format != NULL) { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
302 setup_icon_box(statusbox); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
303 } |
11967 | 304 statusbox->status_changed_signal = gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
11960 | 305 statusbox, GAIM_CALLBACK(account_status_changed_cb), |
306 statusbox); | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
307 } else { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
308 setup_icon_box(statusbox); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
309 } |
11732 | 310 gtk_gaim_status_box_regenerate(statusbox); |
12256 | 311 |
11499 | 312 break; |
313 default: | |
314 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
315 break; | |
316 } | |
317 } | |
318 | |
319 static void | |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
320 gtk_gaim_status_box_finalize(GObject *obj) |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
321 { |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
322 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(obj); |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
323 |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
324 if (statusbox->status_changed_signal) { |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
325 gaim_signal_disconnect(gaim_accounts_get_handle(), "account-status-changed", |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
326 statusbox, GAIM_CALLBACK(account_status_changed_cb)); |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
327 statusbox->status_changed_signal = 0; |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
328 } |
14128 | 329 gaim_signals_disconnect_by_handle(statusbox); |
12651 | 330 gaim_prefs_disconnect_by_handle(statusbox); |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
331 |
14133 | 332 gdk_cursor_unref(statusbox->hand_cursor); |
333 gdk_cursor_unref(statusbox->arrow_cursor); | |
334 | |
335 g_object_unref(G_OBJECT(statusbox->buddy_icon)); | |
336 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); | |
14141 | 337 |
14133 | 338 if (statusbox->buddy_icon_sel) |
339 gtk_widget_destroy(statusbox->buddy_icon_sel); | |
14141 | 340 |
14133 | 341 g_free(statusbox->buddy_icon_path); |
342 | |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
343 G_OBJECT_CLASS(parent_class)->finalize(obj); |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
344 } |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
345 |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
346 static void |
10643 | 347 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
348 { | |
10861 | 349 GObjectClass *object_class; |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
350 GtkComboBoxClass *combo_class; |
10861 | 351 GtkWidgetClass *widget_class; |
352 GtkContainerClass *container_class = (GtkContainerClass*)klass; | |
10643 | 353 |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
354 parent_class = g_type_class_peek_parent(klass); |
12651 | 355 |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
356 combo_class = (GtkComboBoxClass*)klass; |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
357 combo_class->changed = gtk_gaim_status_box_changed; |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
358 |
10861 | 359 widget_class = (GtkWidgetClass*)klass; |
360 combo_box_size_request = widget_class->size_request; | |
361 widget_class->size_request = gtk_gaim_status_box_size_request; | |
362 combo_box_size_allocate = widget_class->size_allocate; | |
363 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; | |
364 widget_class->expose_event = gtk_gaim_status_box_expose_event; | |
10643 | 365 |
10861 | 366 combo_box_forall = container_class->forall; |
367 container_class->forall = gtk_gaim_status_box_forall; | |
368 | |
369 object_class = (GObjectClass *)klass; | |
11499 | 370 |
12379
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
371 object_class->finalize = gtk_gaim_status_box_finalize; |
24c5fbfca306
[gaim-migrate @ 14683]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12320
diff
changeset
|
372 |
11499 | 373 object_class->get_property = gtk_gaim_status_box_get_property; |
374 object_class->set_property = gtk_gaim_status_box_set_property; | |
375 | |
376 g_object_class_install_property(object_class, | |
377 PROP_ACCOUNT, | |
378 g_param_spec_pointer("account", | |
379 "Account", | |
380 "The account, or NULL for all accounts", | |
381 G_PARAM_READWRITE | |
382 ) | |
383 ); | |
10643 | 384 } |
385 | |
13044 | 386 /** |
387 * This updates the text displayed on the status box so that it shows | |
13123 | 388 * the current status. This is the only function in this file that |
389 * should modify status_box->store | |
13044 | 390 */ |
10643 | 391 static void |
392 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | |
393 { | |
13124 | 394 gboolean show_buddy_icons; |
395 GtkIconSize icon_size; | |
396 GtkStyle *style; | |
397 char aa_color[8]; | |
398 GaimSavedStatus *saved_status; | |
13123 | 399 char *primary, *secondary, *text; |
10643 | 400 GdkPixbuf *pixbuf; |
10702 | 401 GtkTreePath *path; |
10643 | 402 |
13121 | 403 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
13124 | 404 if (show_buddy_icons) |
405 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
406 else | |
407 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); | |
408 | |
11870 | 409 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
10643 | 410 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
411 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
412 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
413 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
10672
0925c898b73c
[gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10661
diff
changeset
|
414 |
13121 | 415 saved_status = gaim_savedstatus_get_current(); |
416 | |
13124 | 417 /* Primary */ |
13123 | 418 if (status_box->typing != 0) |
419 { | |
420 GtkTreeIter iter; | |
421 GtkGaimStatusBoxItemType type; | |
422 gpointer data; | |
423 | |
424 /* Primary (get the status selected in the dropdown) */ | |
425 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
426 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | |
427 TYPE_COLUMN, &type, | |
428 DATA_COLUMN, &data, | |
429 -1); | |
430 if (type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) | |
13124 | 431 primary = g_strdup(gaim_primitive_get_name_from_type(GPOINTER_TO_INT(data))); |
13123 | 432 else |
13124 | 433 /* This should never happen, but just in case... */ |
434 primary = g_strdup("New status"); | |
435 } | |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
436 else if (status_box->account != NULL) |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
437 { |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
438 primary = g_strdup(gaim_status_get_name(gaim_account_get_active_status(status_box->account))); |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
439 } |
13124 | 440 else if (gaim_savedstatus_is_transient(saved_status)) |
441 primary = g_strdup(gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status))); | |
442 else | |
443 primary = g_markup_escape_text(gaim_savedstatus_get_title(saved_status), -1); | |
13123 | 444 |
13124 | 445 /* Secondary */ |
446 if (status_box->typing != 0) | |
13123 | 447 secondary = g_strdup(_("Typing")); |
448 else if (status_box->connecting) | |
449 secondary = g_strdup(_("Connecting")); | |
13124 | 450 else if (gaim_savedstatus_is_transient(saved_status)) |
451 secondary = NULL; | |
13123 | 452 else |
453 { | |
13124 | 454 const char *message; |
455 char *tmp; | |
456 message = gaim_savedstatus_get_message(saved_status); | |
457 if (message != NULL) | |
13123 | 458 { |
13124 | 459 tmp = gaim_markup_strip_html(message); |
460 gaim_util_chrreplace(tmp, '\n', ' '); | |
461 secondary = g_markup_escape_text(tmp, -1); | |
462 g_free(tmp); | |
13123 | 463 } |
464 else | |
13124 | 465 secondary = NULL; |
466 } | |
13123 | 467 |
13124 | 468 /* Pixbuf */ |
469 if (status_box->typing != 0) | |
470 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | |
471 else if (status_box->connecting) | |
472 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | |
473 else | |
474 { | |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
475 if (status_box->account != NULL) |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
476 pixbuf = gaim_gtk_create_prpl_icon_with_status(status_box->account, |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
477 gaim_status_get_type(gaim_account_get_active_status(status_box->account)), |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
478 show_buddy_icons ? 1.0 : 0.5); |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
479 else |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
480 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
481 gaim_savedstatus_get_type(saved_status), |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
482 show_buddy_icons ? 1.0 : 0.5); |
13124 | 483 |
484 if (!gaim_savedstatus_is_transient(saved_status)) | |
485 { | |
486 GdkPixbuf *emblem; | |
487 | |
488 /* Overlay a disk in the bottom left corner */ | |
489 emblem = gtk_widget_render_icon(GTK_WIDGET(status_box->vbox), | |
490 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); | |
491 if (emblem != NULL) | |
492 { | |
493 int width, height; | |
494 width = gdk_pixbuf_get_width(pixbuf) / 2; | |
495 height = gdk_pixbuf_get_height(pixbuf) / 2; | |
496 gdk_pixbuf_composite(emblem, pixbuf, 0, height, | |
497 width, height, 0, height, | |
498 0.5, 0.5, GDK_INTERP_BILINEAR, 255); | |
499 g_object_unref(G_OBJECT(emblem)); | |
500 } | |
501 } | |
10643 | 502 } |
10861 | 503 |
13121 | 504 if (status_box->account != NULL) { |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
505 text = g_strdup_printf("%s%s<span size=\"smaller\" color=\"%s\">%s</span>", |
12228 | 506 gaim_account_get_username(status_box->account), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
507 show_buddy_icons ? "\n" : " - ", aa_color, |
13123 | 508 secondary ? secondary : primary); |
509 } else if (secondary != NULL) { | |
13121 | 510 char *separator; |
511 separator = show_buddy_icons ? "\n" : " - "; | |
13123 | 512 text = g_strdup_printf("%s<span size=\"smaller\" color=\"%s\">%s%s</span>", |
513 primary, aa_color, separator, secondary); | |
12228 | 514 } else { |
13123 | 515 text = g_strdup(primary); |
11960 | 516 } |
13123 | 517 g_free(primary); |
518 g_free(secondary); | |
10643 | 519 |
13044 | 520 /* |
521 * Only two columns are used in this list store (does it | |
522 * really need to be a list store?) | |
523 */ | |
10643 | 524 gtk_list_store_set(status_box->store, &(status_box->iter), |
525 ICON_COLUMN, pixbuf, | |
10861 | 526 TEXT_COLUMN, text, |
11739 | 527 -1); |
13124 | 528 if ((status_box->typing == 0) && (!status_box->connecting)) |
529 g_object_unref(pixbuf); | |
13123 | 530 g_free(text); |
531 | |
532 /* Make sure to activate the only row in the tree view */ | |
10702 | 533 path = gtk_tree_path_new_from_string("0"); |
534 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); | |
535 gtk_tree_path_free(path); | |
10643 | 536 |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
537 update_size(status_box); |
10643 | 538 } |
539 | |
11870 | 540 /** |
541 * This updates the GtkTreeView so that it correctly shows the state | |
542 * we are currently using. It is used when the current state is | |
543 * updated from somewhere other than the GtkStatusBox (from a plugin, | |
544 * or when signing on with the "-n" option, for example). It is | |
13025 | 545 * also used when the user selects the "New..." option. |
11870 | 546 * |
547 * Maybe we could accomplish this by triggering off the mouse and | |
548 * keyboard signals instead of the changed signal? | |
549 */ | |
550 static void | |
13124 | 551 status_menu_refresh_iter(GtkGaimStatusBox *status_box) |
11870 | 552 { |
553 GaimSavedStatus *saved_status; | |
13050 | 554 GaimStatusPrimitive primitive; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
555 gint index; |
12125 | 556 const char *message; |
11870 | 557 |
11983 | 558 /* this function is inappropriate for ones with accounts */ |
559 if (status_box->account) | |
560 return; | |
561 | |
12125 | 562 saved_status = gaim_savedstatus_get_current(); |
11951 | 563 |
564 /* | |
565 * Suppress the "changed" signal because the status | |
566 * was changed programmatically. | |
567 */ | |
568 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | |
569 | |
13050 | 570 /* |
571 * If the saved_status is transient, is Available, Away, Invisible | |
572 * or Offline, and it does not have an substatuses, then select | |
573 * the primitive in the dropdown menu. Otherwise select the | |
574 * popular status in the dropdown menu. | |
575 */ | |
576 primitive = gaim_savedstatus_get_type(saved_status); | |
577 if (gaim_savedstatus_is_transient(saved_status) && | |
578 ((primitive == GAIM_STATUS_AVAILABLE) || (primitive == GAIM_STATUS_AWAY) || | |
579 (primitive == GAIM_STATUS_INVISIBLE) || (primitive == GAIM_STATUS_OFFLINE)) && | |
580 (!gaim_savedstatus_has_substatuses(saved_status))) | |
581 { | |
582 index = get_statusbox_index(status_box, saved_status); | |
13066 | 583 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); |
13050 | 584 } |
11870 | 585 else |
586 { | |
13066 | 587 GtkTreeIter iter; |
13111 | 588 GtkGaimStatusBoxItemType type; |
589 gpointer data; | |
13066 | 590 |
591 /* Unset the active item */ | |
592 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), -1); | |
593 | |
594 /* If this saved status is in the list store, then set it as the active item */ | |
595 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(status_box->dropdown_store), &iter)) | |
596 { | |
597 do | |
598 { | |
599 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, | |
13111 | 600 TYPE_COLUMN, &type, |
13066 | 601 DATA_COLUMN, &data, |
602 -1); | |
13111 | 603 if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && |
604 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) | |
13066 | 605 { |
606 /* Found! */ | |
607 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
608 break; | |
609 } | |
610 } | |
611 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); | |
612 } | |
12125 | 613 } |
13050 | 614 |
12125 | 615 message = gaim_savedstatus_get_message(saved_status); |
13050 | 616 if (!gaim_savedstatus_is_transient(saved_status) || !message || !*message) |
12125 | 617 { |
618 status_box->imhtml_visible = FALSE; | |
619 gtk_widget_hide_all(status_box->vbox); | |
620 } | |
621 else | |
622 { | |
623 status_box->imhtml_visible = TRUE; | |
624 gtk_widget_show_all(status_box->vbox); | |
11870 | 625 |
12125 | 626 /* |
627 * Suppress the "changed" signal because the status | |
628 * was changed programmatically. | |
629 */ | |
630 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); | |
11954 | 631 |
12125 | 632 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
12274 | 633 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); |
12125 | 634 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
635 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); | |
11870 | 636 } |
11951 | 637 |
12634
8512c990967b
[gaim-migrate @ 14970]
Richard Laager <rlaager@wiktel.com>
parents:
12619
diff
changeset
|
638 update_size(status_box); |
8512c990967b
[gaim-migrate @ 14970]
Richard Laager <rlaager@wiktel.com>
parents:
12619
diff
changeset
|
639 |
11951 | 640 /* Stop suppressing the "changed" signal. */ |
641 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | |
11870 | 642 } |
643 | |
11732 | 644 static void |
12778 | 645 add_popular_statuses(GtkGaimStatusBox *statusbox) |
646 { | |
13090 | 647 gboolean show_buddy_icons; |
13124 | 648 GtkIconSize icon_size; |
12778 | 649 GList *list, *cur; |
13062 | 650 GdkPixbuf *pixbuf, *emblem; |
651 int width, height; | |
12778 | 652 |
653 list = gaim_savedstatuses_get_popular(6); | |
654 if (list == NULL) | |
655 /* Odd... oh well, nothing we can do about it. */ | |
656 return; | |
657 | |
13090 | 658 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
659 if (show_buddy_icons) | |
12778 | 660 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
661 else | |
662 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); | |
663 | |
12779 | 664 gtk_gaim_status_box_add_separator(statusbox); |
665 | |
12778 | 666 for (cur = list; cur != NULL; cur = cur->next) |
667 { | |
668 GaimSavedStatus *saved = cur->data; | |
13050 | 669 const gchar *message; |
13098
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
670 gchar *stripped = NULL; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
671 |
13090 | 672 /* Get an appropriate status icon */ |
13121 | 673 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
674 gaim_savedstatus_get_type(saved), | |
13090 | 675 show_buddy_icons ? 1.0 : 0.5); |
13050 | 676 |
677 if (gaim_savedstatus_is_transient(saved)) | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
678 { |
13050 | 679 /* |
680 * Transient statuses do not have a title, so the savedstatus | |
681 * API returns the message when gaim_savedstatus_get_title() is | |
682 * called, so we don't need to get the message a second time. | |
683 */ | |
684 } | |
685 else | |
686 { | |
687 message = gaim_savedstatus_get_message(saved); | |
13098
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
688 if (message != NULL) |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
689 { |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
690 stripped = gaim_markup_strip_html(message); |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
691 gaim_util_chrreplace(stripped, '\n', ' '); |
44a4bd35cc97
[gaim-migrate @ 15460]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
692 } |
13090 | 693 |
694 /* Overlay a disk in the bottom left corner */ | |
695 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), | |
696 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); | |
697 if (emblem != NULL) | |
698 { | |
699 width = gdk_pixbuf_get_width(pixbuf) / 2; | |
700 height = gdk_pixbuf_get_height(pixbuf) / 2; | |
701 gdk_pixbuf_composite(emblem, pixbuf, 0, height, | |
702 width, height, 0, height, | |
703 0.5, 0.5, GDK_INTERP_BILINEAR, 255); | |
704 g_object_unref(G_OBJECT(emblem)); | |
705 } | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
706 } |
13090 | 707 |
12778 | 708 gtk_gaim_status_box_add(statusbox, GTK_GAIM_STATUS_BOX_TYPE_POPULAR, |
13079 | 709 pixbuf, gaim_savedstatus_get_title(saved), stripped, |
12778 | 710 GINT_TO_POINTER(gaim_savedstatus_get_creation_time(saved))); |
13050 | 711 g_free(stripped); |
13090 | 712 if (pixbuf != NULL) |
713 g_object_unref(G_OBJECT(pixbuf)); | |
12778 | 714 } |
715 | |
716 g_list_free(list); | |
717 } | |
718 | |
719 static void | |
11732 | 720 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) |
721 { | |
13090 | 722 gboolean show_buddy_icons; |
11739 | 723 GaimAccount *account; |
13090 | 724 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4, *tmp; |
11732 | 725 GtkIconSize icon_size; |
726 | |
13090 | 727 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
728 if (show_buddy_icons) | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
729 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
730 else |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
731 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); |
11732 | 732 |
12256 | 733 /* Unset the model while clearing it */ |
734 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL); | |
11732 | 735 gtk_list_store_clear(status_box->dropdown_store); |
13241 | 736 /* Don't set the model until the new statuses have been added to the box. |
737 * What is presumably a bug in Gtk < 2.4 causes things to get all confused | |
738 * if we do this here. */ | |
739 /* 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
|
740 |
11739 | 741 account = GTK_GAIM_STATUS_BOX(status_box)->account; |
742 if (account == NULL) | |
743 { | |
12779 | 744 /* Global */ |
11756 | 745 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_ONLINE, |
11732 | 746 icon_size, "GtkGaimStatusBox"); |
11756 | 747 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_AWAY, |
11732 | 748 icon_size, "GtkGaimStatusBox"); |
11756 | 749 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE, |
11732 | 750 icon_size, "GtkGaimStatusBox"); |
11756 | 751 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE, |
11732 | 752 icon_size, "GtkGaimStatusBox"); |
12779 | 753 |
754 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)); | |
755 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)); | |
756 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)); | |
757 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)); | |
758 | |
759 add_popular_statuses(status_box); | |
760 | |
11738 | 761 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
13025 | 762 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
12778 | 763 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
764 | |
13241 | 765 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
13124 | 766 status_menu_refresh_iter(status_box); |
11732 | 767 |
768 } else { | |
12779 | 769 /* Per-account */ |
11732 | 770 const GList *l; |
11739 | 771 |
772 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
773 { | |
11732 | 774 GaimStatusType *status_type = (GaimStatusType *)l->data; |
775 | |
776 if (!gaim_status_type_is_user_settable(status_type)) | |
777 continue; | |
778 | |
13090 | 779 tmp = gaim_gtk_create_prpl_icon_with_status(account, status_type, |
780 show_buddy_icons ? 1.0 : 0.5); | |
11739 | 781 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
782 GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, tmp, |
11739 | 783 gaim_status_type_get_name(status_type), |
13316
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
784 NULL, |
41c4b4aa523a
[gaim-migrate @ 15682]
Richard Laager <rlaager@wiktel.com>
parents:
13283
diff
changeset
|
785 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
13090 | 786 if (tmp != NULL) |
787 g_object_unref(tmp); | |
11732 | 788 } |
13241 | 789 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
11967 | 790 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); |
11732 | 791 } |
792 } | |
793 | |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
794 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
|
795 { |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
796 gtk_combo_box_popup(GTK_COMBO_BOX(w)); |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
797 return TRUE; |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
798 } |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
799 |
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
800 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
|
801 { |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
802 if (event->direction == GDK_SCROLL_UP) |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
803 gtk_imhtml_page_up(imhtml); |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
804 else if (event->direction == GDK_SCROLL_DOWN) |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
805 gtk_imhtml_page_down(imhtml); |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
806 return TRUE; |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
807 } |
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
808 |
13123 | 809 static int imhtml_remove_focus(GtkWidget *w, GdkEventKey *event, GtkGaimStatusBox *status_box) |
12274 | 810 { |
811 if (event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab) | |
812 { | |
813 /* If last inserted character is a tab, then remove the focus from here */ | |
814 GtkWidget *top = gtk_widget_get_toplevel(w); | |
815 g_signal_emit_by_name(G_OBJECT(top), "move_focus", | |
816 (event->state & GDK_SHIFT_MASK) ? | |
817 GTK_DIR_TAB_BACKWARD: GTK_DIR_TAB_FORWARD); | |
818 return TRUE; | |
819 } | |
13123 | 820 if (!status_box->typing != 0) |
12274 | 821 return FALSE; |
13803
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
822 |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
823 /* Reset the status if Escape was pressed */ |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
824 if (event->keyval == GDK_Escape) |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
825 { |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
826 g_source_remove(status_box->typing); |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
827 status_box->typing = 0; |
13830
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
828 if (status_box->account != NULL) |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
829 update_to_reflect_account_status(status_box, status_box->account, |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
830 gaim_account_get_active_status(status_box->account)); |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
831 else |
0a1132e6eac4
[gaim-migrate @ 16279]
Richard Laager <rlaager@wiktel.com>
parents:
13803
diff
changeset
|
832 status_menu_refresh_iter(status_box); |
13803
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
833 return TRUE; |
25a09aff5dde
[gaim-migrate @ 16217]
Richard Laager <rlaager@wiktel.com>
parents:
13802
diff
changeset
|
834 } |
14035 | 835 |
13123 | 836 gtk_gaim_status_box_pulse_typing(status_box); |
837 g_source_remove(status_box->typing); | |
838 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); | |
12460
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
839 |
12274 | 840 return FALSE; |
841 } | |
842 | |
11753 | 843 #if GTK_CHECK_VERSION(2,6,0) |
11738 | 844 static gboolean |
845 dropdown_store_row_separator_func(GtkTreeModel *model, | |
846 GtkTreeIter *iter, gpointer data) | |
847 { | |
11739 | 848 GtkGaimStatusBoxItemType type; |
11738 | 849 |
11885 | 850 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
11738 | 851 |
11739 | 852 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR) |
11738 | 853 return TRUE; |
854 | |
855 return FALSE; | |
856 } | |
11753 | 857 #endif |
11738 | 858 |
10643 | 859 static void |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
860 cache_pixbufs(GtkGaimStatusBox *status_box) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
861 { |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
862 GtkIconSize icon_size; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
863 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
864 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) |
13065 | 865 { |
866 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 6, NULL); | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
867 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_TWO_LINE); |
13065 | 868 } else { |
869 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 3, NULL); | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
870 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL_TWO_LINE); |
13065 | 871 } |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
872 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
873 if (status_box->connecting_pixbufs[0] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
874 gdk_pixbuf_unref(status_box->connecting_pixbufs[0]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
875 if (status_box->connecting_pixbufs[1] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
876 gdk_pixbuf_unref(status_box->connecting_pixbufs[1]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
877 if (status_box->connecting_pixbufs[2] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
878 gdk_pixbuf_unref(status_box->connecting_pixbufs[2]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
879 if (status_box->connecting_pixbufs[3] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
880 gdk_pixbuf_unref(status_box->connecting_pixbufs[3]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
881 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
882 status_box->connecting_index = 0; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
883 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
|
884 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
885 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
|
886 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
887 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
|
888 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
889 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
|
890 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
891 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
892 if (status_box->typing_pixbufs[0] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
893 gdk_pixbuf_unref(status_box->typing_pixbufs[0]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
894 if (status_box->typing_pixbufs[1] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
895 gdk_pixbuf_unref(status_box->typing_pixbufs[1]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
896 if (status_box->typing_pixbufs[2] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
897 gdk_pixbuf_unref(status_box->typing_pixbufs[2]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
898 if (status_box->typing_pixbufs[3] != NULL) |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
899 gdk_pixbuf_unref(status_box->typing_pixbufs[3]); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
900 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
901 status_box->typing_index = 0; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
902 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
|
903 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
904 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
|
905 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
906 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
|
907 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
908 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
|
909 icon_size, "GtkGaimStatusBox"); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
910 } |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
911 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
912 static void |
14128 | 913 current_savedstatus_changed_cb(GaimSavedStatus *now, GaimSavedStatus *old, gpointer data) |
11954 | 914 { |
13121 | 915 GtkGaimStatusBox *status_box = data; |
12778 | 916 |
917 /* Make sure our current status is added to the list of popular statuses */ | |
13121 | 918 gtk_gaim_status_box_regenerate(status_box); |
12778 | 919 |
13121 | 920 if (status_box->account != NULL) |
921 update_to_reflect_account_status(status_box, status_box->account, | |
922 gaim_account_get_active_status(status_box->account)); | |
12244 | 923 else |
13124 | 924 status_menu_refresh_iter(status_box); |
13121 | 925 |
926 gtk_gaim_status_box_refresh(status_box); | |
11954 | 927 } |
928 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
929 static void |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
930 buddy_list_details_pref_changed_cb(const char *name, GaimPrefType type, |
12816 | 931 gconstpointer val, gpointer data) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
932 { |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
933 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
934 |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
935 cache_pixbufs(status_box); |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
936 gtk_gaim_status_box_regenerate(status_box); |
13121 | 937 gtk_gaim_status_box_refresh(status_box); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
938 } |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
939 |
12651 | 940 static void |
941 spellcheck_prefs_cb(const char *name, GaimPrefType type, | |
12816 | 942 gconstpointer value, gpointer data) |
12651 | 943 { |
944 #ifdef USE_GTKSPELL | |
945 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; | |
946 | |
947 if (value) | |
948 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); | |
949 else | |
950 { | |
951 GtkSpell *spell; | |
952 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(status_box->imhtml)); | |
953 gtkspell_detach(spell); | |
954 } | |
955 #endif | |
956 } | |
957 | |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
958 #if 0 |
12262 | 959 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
|
960 { |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
961 |
12274 | 962 if (event->button != 1) |
963 return FALSE; | |
12262 | 964 gtk_combo_box_popdown(GTK_COMBO_BOX(box)); |
965 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), FALSE); | |
966 if (!box->imhtml_visible) | |
967 g_signal_emit_by_name(G_OBJECT(box), "changed", NULL, NULL); | |
968 return TRUE; | |
969 } | |
970 | |
971 static gboolean button_pressed_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) | |
972 { | |
12274 | 973 if (event->button != 1) |
974 return FALSE; | |
12262 | 975 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
12274 | 976 // Disabled until button_released_cb works |
977 // gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), TRUE); | |
12262 | 978 return TRUE; |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
979 } |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
980 #endif |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
981 |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
982 static void |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
983 toggled_cb(GtkWidget *widget, GtkGaimStatusBox *box) |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
984 { |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
985 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
986 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
|
987 } |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
988 |
11954 | 989 static void |
14141 | 990 icon_choose_cb(const char *filename, gpointer data) |
14133 | 991 { |
14141 | 992 GtkGaimStatusBox *box; |
993 | |
994 box = data; | |
995 | |
14133 | 996 if (filename) { |
997 GList *accounts; | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
998 |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
999 if (box->account) { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1000 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(box->account)); |
14155 | 1001 if (plug) { |
1002 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); | |
1003 if (prplinfo && prplinfo->icon_spec.format) { | |
1004 char *icon = gaim_gtk_convert_buddy_icon(plug, filename); | |
1005 gaim_account_set_buddy_icon(box->account, icon); | |
1006 g_free(icon); | |
1007 gaim_account_set_ui_bool(box->account, GAIM_GTK_UI, "use-global-buddyicon", FALSE); | |
1008 } | |
14133 | 1009 } |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1010 } else { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1011 for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1012 GaimAccount *account = accounts->data; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1013 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
14155 | 1014 if (plug) { |
1015 GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); | |
1016 if (prplinfo != NULL && | |
1017 gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", TRUE) && | |
1018 prplinfo->icon_spec.format) { | |
1019 char *icon = gaim_gtk_convert_buddy_icon(plug, filename); | |
1020 gaim_account_set_buddy_icon(account, icon); | |
1021 g_free(icon); | |
1022 } | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1023 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1024 } |
14133 | 1025 } |
1026 gtk_gaim_status_box_set_buddy_icon(box, filename); | |
1027 } | |
14141 | 1028 |
14133 | 1029 box->buddy_icon_sel = NULL; |
1030 } | |
1031 | |
1032 static void | |
10643 | 1033 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) |
1034 { | |
11400 | 1035 GtkCellRenderer *text_rend; |
1036 GtkCellRenderer *icon_rend; | |
10643 | 1037 GtkTextBuffer *buffer; |
1038 | |
1039 status_box->imhtml_visible = FALSE; | |
1040 status_box->connecting = FALSE; | |
13123 | 1041 status_box->typing = 0; |
12262 | 1042 status_box->toggle_button = gtk_toggle_button_new(); |
1043 status_box->hbox = gtk_hbox_new(FALSE, 6); | |
10643 | 1044 status_box->cell_view = gtk_cell_view_new(); |
12262 | 1045 status_box->vsep = gtk_vseparator_new(); |
1046 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
|
1047 |
12778 | 1048 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); |
1049 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 | 1050 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
1051 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
1052 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
1053 gtk_list_store_append(status_box->store, &(status_box->iter)); | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
1054 |
12262 | 1055 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox); |
1056 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0); | |
12274 | 1057 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); |
1058 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); | |
12262 | 1059 gtk_widget_show_all(status_box->toggle_button); |
1060 #if GTK_CHECK_VERSION(2,4,0) | |
1061 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); | |
1062 #endif | |
10643 | 1063 |
13044 | 1064 text_rend = gtk_cell_renderer_text_new(); |
1065 icon_rend = gtk_cell_renderer_pixbuf_new(); | |
10643 | 1066 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); |
10861 | 1067 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
10643 | 1068 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
1069 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
13045 | 1070 #if GTK_CHECK_VERSION(2, 6, 0) |
1071 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
1072 #endif | |
10643 | 1073 |
13044 | 1074 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
1075 status_box->text_rend = gtk_cell_renderer_text_new(); | |
10643 | 1076 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
11499 | 1077 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
10643 | 1078 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
1079 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
13045 | 1080 #if GTK_CHECK_VERSION(2, 6, 0) |
1081 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
1082 #endif | |
10643 | 1083 |
1084 status_box->vbox = gtk_vbox_new(0, FALSE); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13244
diff
changeset
|
1085 status_box->sw = gaim_gtk_create_imhtml(FALSE, &status_box->imhtml, NULL, NULL); |
12879
f8748df5c17a
[gaim-migrate @ 15231]
Gary Kramlich <grim@reaperworld.com>
parents:
12827
diff
changeset
|
1086 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
1087 |
10643 | 1088 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
|
1089 #if 0 |
12274 | 1090 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event", |
1091 G_CALLBACK(button_pressed_cb), status_box); | |
1092 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event", | |
1093 G_CALLBACK(button_released_cb), status_box); | |
12294
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
1094 #endif |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
1095 g_signal_connect(G_OBJECT(status_box->toggle_button), "toggled", |
d6b5373948f9
[gaim-migrate @ 14598]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12286
diff
changeset
|
1096 G_CALLBACK(toggled_cb), status_box); |
10643 | 1097 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
|
1098 g_signal_connect(G_OBJECT(status_box->imhtml), "format_function_toggle", |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1099 G_CALLBACK(imhtml_format_changed_cb), status_box); |
12274 | 1100 g_signal_connect(G_OBJECT(status_box->imhtml), "key_press_event", |
1101 G_CALLBACK(imhtml_remove_focus), status_box); | |
11562 | 1102 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
10643 | 1103 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
12651 | 1104 #ifdef USE_GTKSPELL |
1105 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
1106 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); | |
1107 #endif | |
10643 | 1108 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); |
12262 | 1109 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); |
12275 | 1110 GTK_BIN(status_box)->child = status_box->toggle_button; |
12269 | 1111 |
10643 | 1112 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); |
11654 | 1113 |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
1114 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
|
1115 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", |
12827
0f40c44348f4
[gaim-migrate @ 15175]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
1116 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml); |
12075
f62022e07351
[gaim-migrate @ 14372]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12074
diff
changeset
|
1117 |
11850 | 1118 #if GTK_CHECK_VERSION(2,6,0) |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
1119 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); |
11850 | 1120 #endif |
1121 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
1122 cache_pixbufs(status_box); |
11732 | 1123 gtk_gaim_status_box_regenerate(status_box); |
13737 | 1124 gtk_gaim_status_box_refresh(status_box); |
11954 | 1125 |
14128 | 1126 gaim_signal_connect(gaim_savedstatuses_get_handle(), "savedstatus-changed", |
1127 status_box, | |
1128 GAIM_CALLBACK(current_savedstatus_changed_cb), | |
1129 status_box); | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12585
diff
changeset
|
1130 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
|
1131 buddy_list_details_pref_changed_cb, status_box); |
12651 | 1132 gaim_prefs_connect_callback(status_box, "/gaim/gtk/conversations/spellcheck", |
1133 spellcheck_prefs_cb, status_box); | |
10643 | 1134 } |
1135 | |
1136 static void | |
10861 | 1137 gtk_gaim_status_box_size_request(GtkWidget *widget, |
1138 GtkRequisition *requisition) | |
10643 | 1139 { |
1140 GtkRequisition box_req; | |
1141 combo_box_size_request(widget, requisition); | |
12596
037a673ba862
[gaim-migrate @ 14926]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1142 requisition->height += 3; |
10861 | 1143 |
13065 | 1144 /* If the gtkimhtml is visible, then add some additional padding */ |
10643 | 1145 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
1146 if (box_req.height > 1) | |
13065 | 1147 requisition->height += box_req.height + 3; |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12275
diff
changeset
|
1148 |
10643 | 1149 requisition->width = 1; |
14133 | 1150 |
1151 | |
1152 } | |
1153 | |
1154 /* From gnome-panel */ | |
1155 static void | |
1156 do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift) | |
1157 { | |
1158 gint i, j; | |
1159 gint width, height, has_alpha, srcrowstride, destrowstride; | |
1160 guchar *target_pixels; | |
1161 guchar *original_pixels; | |
1162 guchar *pixsrc; | |
1163 guchar *pixdest; | |
1164 int val; | |
1165 guchar r,g,b; | |
1166 | |
1167 has_alpha = gdk_pixbuf_get_has_alpha (src); | |
1168 width = gdk_pixbuf_get_width (src); | |
1169 height = gdk_pixbuf_get_height (src); | |
1170 srcrowstride = gdk_pixbuf_get_rowstride (src); | |
1171 destrowstride = gdk_pixbuf_get_rowstride (dest); | |
1172 target_pixels = gdk_pixbuf_get_pixels (dest); | |
1173 original_pixels = gdk_pixbuf_get_pixels (src); | |
1174 | |
1175 for (i = 0; i < height; i++) { | |
1176 pixdest = target_pixels + i*destrowstride; | |
1177 pixsrc = original_pixels + i*srcrowstride; | |
1178 for (j = 0; j < width; j++) { | |
1179 r = *(pixsrc++); | |
1180 g = *(pixsrc++); | |
1181 b = *(pixsrc++); | |
1182 val = r + shift; | |
1183 *(pixdest++) = CLAMP(val, 0, 255); | |
1184 val = g + shift; | |
1185 *(pixdest++) = CLAMP(val, 0, 255); | |
1186 val = b + shift; | |
1187 *(pixdest++) = CLAMP(val, 0, 255); | |
1188 if (has_alpha) | |
1189 *(pixdest++) = *(pixsrc++); | |
1190 } | |
1191 } | |
10643 | 1192 } |
1193 | |
1194 static void | |
10861 | 1195 gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
14133 | 1196 GtkAllocation *allocation) |
10643 | 1197 { |
14133 | 1198 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
10643 | 1199 GtkRequisition req = {0,0}; |
14133 | 1200 GtkAllocation parent_alc, box_alc, icon_alc; |
1201 GdkPixbuf *scaled; | |
11400 | 1202 |
10643 | 1203 combo_box_size_request(widget, &req); |
10861 | 1204 |
13065 | 1205 box_alc = *allocation; |
12596
037a673ba862
[gaim-migrate @ 14926]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1206 box_alc.height = MAX(1, (allocation->height - req.height - 6)); |
13065 | 1207 box_alc.y += req.height + 6; |
10643 | 1208 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); |
10861 | 1209 |
13065 | 1210 parent_alc = *allocation; |
10643 | 1211 parent_alc.height = MAX(1,req.height); |
12102
8df87db79bad
[gaim-migrate @ 14399]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12100
diff
changeset
|
1212 parent_alc.y += 3; |
14133 | 1213 |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1214 if (status_box->icon_box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1215 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1216 parent_alc.width -= (parent_alc.height + 3); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1217 icon_alc = *allocation; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1218 icon_alc.height = MAX(1,req.height); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1219 icon_alc.width = icon_alc.height; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1220 icon_alc.x = allocation->width - icon_alc.width; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1221 icon_alc.y += 3; |
14141 | 1222 |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1223 if (status_box->icon_size != icon_alc.height) |
14144 | 1224 { |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1225 if ((status_box->buddy_icon_path != NULL) && |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1226 (*status_box->buddy_icon_path != '\0')) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1227 { |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1228 scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1229 icon_alc.height, icon_alc.width, FALSE, NULL); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1230 g_object_unref(status_box->buddy_icon_hover); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1231 status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1232 do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1233 g_object_unref(status_box->buddy_icon); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1234 status_box->buddy_icon = scaled; |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1235 gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1236 } |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1237 status_box->icon_size = icon_alc.height; |
14144 | 1238 } |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1239 gtk_widget_size_allocate(status_box->icon_box, &icon_alc); |
14133 | 1240 } |
1241 | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1242 combo_box_size_allocate(widget, &parent_alc); |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1243 gtk_widget_size_allocate(status_box->toggle_button, &parent_alc); |
10643 | 1244 widget->allocation = *allocation; |
1245 } | |
1246 | |
1247 static gboolean | |
10861 | 1248 gtk_gaim_status_box_expose_event(GtkWidget *widget, |
12262 | 1249 GdkEventExpose *event) |
10643 | 1250 { |
10861 | 1251 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
12262 | 1252 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
12275 | 1253 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
14133 | 1254 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); |
10861 | 1255 return FALSE; |
10643 | 1256 } |
1257 | |
1258 static void | |
10861 | 1259 gtk_gaim_status_box_forall(GtkContainer *container, |
1260 gboolean include_internals, | |
1261 GtkCallback callback, | |
1262 gpointer callback_data) | |
10643 | 1263 { |
10861 | 1264 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
10643 | 1265 |
10861 | 1266 if (include_internals) |
1267 { | |
1268 (* callback) (status_box->vbox, callback_data); | |
12275 | 1269 (* callback) (status_box->toggle_button, callback_data); |
1270 (* callback) (status_box->arrow, callback_data); | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1271 if (status_box->icon_box) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1272 (* callback) (status_box->icon_box, callback_data); |
10861 | 1273 } |
10643 | 1274 |
10861 | 1275 combo_box_forall(container, include_internals, callback, callback_data); |
10643 | 1276 } |
1277 | |
1278 GtkWidget * | |
1279 gtk_gaim_status_box_new() | |
1280 { | |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1281 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", NULL, NULL); |
10643 | 1282 } |
1283 | |
11499 | 1284 GtkWidget * |
1285 gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
1286 { | |
1287 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
1288 } | |
10643 | 1289 |
13050 | 1290 /** |
1291 * Add a row to the dropdown menu. | |
1292 * | |
1293 * @param status_box The status box itself. | |
1294 * @param type A GtkGaimStatusBoxItemType. | |
1295 * @param pixbuf The icon to associate with this row in the menu. | |
1296 * @param title The title of this item. For the primitive entries, | |
1297 * this is something like "Available" or "Away." For | |
1298 * the saved statuses, this is something like | |
1299 * "My favorite away message!" This should be | |
1300 * plaintext (non-markedup) (this function escapes it). | |
1301 * @param desc The secondary text for this item. This will be | |
1302 * placed on the row below the title, in a dimmer | |
1303 * font (generally gray). This text should be plaintext | |
1304 * (non-markedup) (this function escapes it). | |
1305 * @param data Data to be associated with this row in the dropdown | |
1306 * menu. For primitives this is the value of the | |
1307 * GaimStatusPrimitive. For saved statuses this is the | |
1308 * creation timestamp. | |
1309 */ | |
10643 | 1310 void |
13050 | 1311 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GtkGaimStatusBoxItemType type, GdkPixbuf *pixbuf, const char *title, const char *desc, gpointer data) |
10643 | 1312 { |
1313 GtkTreeIter iter; | |
13050 | 1314 char *text; |
10861 | 1315 |
13050 | 1316 if (desc == NULL) |
1317 { | |
1318 text = g_markup_escape_text(title, -1); | |
1319 } | |
1320 else | |
1321 { | |
13385 | 1322 gboolean show_buddy_icons; |
1323 GtkStyle *style; | |
10643 | 1324 char aa_color[8]; |
13050 | 1325 gchar *escaped_title, *escaped_desc; |
1326 | |
13385 | 1327 show_buddy_icons = gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"); |
13050 | 1328 style = gtk_widget_get_style(GTK_WIDGET(status_box)); |
10643 | 1329 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", |
1330 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
1331 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
10861 | 1332 style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
13050 | 1333 |
1334 escaped_title = g_markup_escape_text(title, -1); | |
1335 escaped_desc = g_markup_escape_text(desc, -1); | |
13385 | 1336 text = g_strdup_printf("%s%s<span color=\"%s\" size=\"smaller\">%s</span>", |
1337 escaped_title, | |
1338 show_buddy_icons ? "\n" : " - ", | |
1339 aa_color, escaped_desc); | |
13050 | 1340 g_free(escaped_title); |
1341 g_free(escaped_desc); | |
10643 | 1342 } |
10861 | 1343 |
10643 | 1344 gtk_list_store_append(status_box->dropdown_store, &iter); |
1345 gtk_list_store_set(status_box->dropdown_store, &iter, | |
13050 | 1346 TYPE_COLUMN, type, |
1347 ICON_COLUMN, pixbuf, | |
1348 TEXT_COLUMN, text, | |
1349 TITLE_COLUMN, title, | |
1350 DESC_COLUMN, desc, | |
1351 DATA_COLUMN, data, | |
1352 -1); | |
1353 g_free(text); | |
10643 | 1354 } |
1355 | |
1356 void | |
11738 | 1357 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box) |
1358 { | |
11756 | 1359 /* Don't do anything unless GTK actually supports |
1360 * gtk_combo_box_set_row_separator_func */ | |
1361 #if GTK_CHECK_VERSION(2,6,0) | |
11738 | 1362 GtkTreeIter iter; |
1363 | |
1364 gtk_list_store_append(status_box->dropdown_store, &iter); | |
1365 gtk_list_store_set(status_box->dropdown_store, &iter, | |
11739 | 1366 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR, |
1367 -1); | |
11756 | 1368 #endif |
11738 | 1369 } |
1370 | |
1371 void | |
10643 | 1372 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) |
1373 { | |
1374 if (!status_box) | |
1375 return; | |
1376 status_box->connecting = connecting; | |
1377 gtk_gaim_status_box_refresh(status_box); | |
1378 } | |
1379 | |
1380 void | |
14133 | 1381 gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *box, const char *filename) |
1382 { | |
1383 GdkPixbuf *scaled; | |
1384 g_free(box->buddy_icon_path); | |
1385 box->buddy_icon_path = g_strdup(filename); | |
1386 | |
14144 | 1387 if ((filename != NULL) && (*filename != '\0')) |
14143 | 1388 { |
14144 | 1389 if (box->buddy_icon != NULL) |
1390 g_object_unref(box->buddy_icon); | |
14143 | 1391 scaled = gdk_pixbuf_new_from_file_at_scale(filename, |
1392 box->icon_size, box->icon_size, FALSE, NULL); | |
14144 | 1393 if (scaled != NULL) |
1394 { | |
1395 box->buddy_icon_hover = gdk_pixbuf_copy(scaled); | |
1396 do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); | |
1397 box->buddy_icon = scaled; | |
1398 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); | |
1399 } | |
14143 | 1400 } |
14141 | 1401 |
14153
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1402 if (box->account == NULL) |
f96ff06f6dcc
[gaim-migrate @ 16798]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14152
diff
changeset
|
1403 gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); |
14133 | 1404 } |
1405 | |
1406 const char* | |
1407 gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *box) | |
1408 { | |
1409 return box->buddy_icon_path; | |
1410 } | |
1411 | |
1412 void | |
10643 | 1413 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) |
1414 { | |
1415 if (!status_box) | |
1416 return; | |
1417 if (status_box->connecting_index == 3) | |
1418 status_box->connecting_index = 0; | |
10861 | 1419 else |
10643 | 1420 status_box->connecting_index++; |
1421 gtk_gaim_status_box_refresh(status_box); | |
1422 } | |
1423 | |
12274 | 1424 static void |
10643 | 1425 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) |
1426 { | |
1427 if (status_box->typing_index == 3) | |
1428 status_box->typing_index = 0; | |
10861 | 1429 else |
10643 | 1430 status_box->typing_index++; |
1431 gtk_gaim_status_box_refresh(status_box); | |
1432 } | |
1433 | |
13050 | 1434 static GaimStatusType * |
1435 find_status_type_by_index(const GaimAccount *account, gint active) | |
11993 | 1436 { |
1437 const GList *l = gaim_account_get_status_types(account); | |
1438 gint i; | |
1439 | |
1440 for (i = 0; l; l = l->next) { | |
1441 GaimStatusType *status_type = l->data; | |
1442 if (!gaim_status_type_is_user_settable(status_type)) | |
1443 continue; | |
1444 | |
1445 if (active == i) | |
1446 return status_type; | |
1447 i++; | |
1448 } | |
1449 | |
1450 return NULL; | |
1451 } | |
1452 | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1453 static gboolean |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1454 message_changed(const char *one, const char *two) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1455 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1456 if (one == NULL && two == NULL) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1457 return FALSE; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1458 |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1459 if (one == NULL || two == NULL) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1460 return TRUE; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1461 |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1462 return (g_utf8_collate(one, two) != 0); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1463 } |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1464 |
11654 | 1465 static void |
1466 activate_currently_selected_status(GtkGaimStatusBox *status_box) | |
10643 | 1467 { |
11739 | 1468 GtkGaimStatusBoxItemType type; |
12779 | 1469 gpointer data; |
11739 | 1470 gchar *title; |
10643 | 1471 GtkTreeIter iter; |
11654 | 1472 char *message; |
1473 GaimSavedStatus *saved_status; | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1474 gboolean changed = TRUE; |
10643 | 1475 |
11951 | 1476 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter)) |
1477 return; | |
12659 | 1478 |
11654 | 1479 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
12779 | 1480 TYPE_COLUMN, &type, |
1481 DATA_COLUMN, &data, | |
1482 -1); | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
1483 |
11739 | 1484 /* |
13025 | 1485 * If the currently selected status is "New..." or |
12779 | 1486 * "Saved..." or a popular status then do nothing. |
13124 | 1487 * Popular statuses are |
11954 | 1488 * activated elsewhere, and we update the status_box |
14128 | 1489 * accordingly by connecting to the savedstatus-changed |
1490 * signal and then calling status_menu_refresh_iter() | |
11739 | 1491 */ |
12779 | 1492 if (type != GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) |
11739 | 1493 return; |
11654 | 1494 |
12659 | 1495 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
1496 TITLE_COLUMN, &title, -1); | |
1497 | |
1498 message = gtk_gaim_status_box_get_message(status_box); | |
1499 if (!message || !*message) | |
1500 { | |
1501 gtk_widget_hide_all(status_box->vbox); | |
1502 status_box->imhtml_visible = FALSE; | |
13230 | 1503 if (message != NULL) |
1504 { | |
1505 g_free(message); | |
1506 message = NULL; | |
1507 } | |
12659 | 1508 } |
1509 | |
12779 | 1510 if (status_box->account == NULL) { |
1511 /* Global */ | |
1512 /* Save the newly selected status to prefs.xml and status.xml */ | |
1513 | |
13111 | 1514 /* Has the status really been changed? */ |
12779 | 1515 saved_status = gaim_savedstatus_get_current(); |
13801
3f23b55a2cc4
[gaim-migrate @ 16215]
Richard Laager <rlaager@wiktel.com>
parents:
13739
diff
changeset
|
1516 if (gaim_savedstatus_get_type(saved_status) == GPOINTER_TO_INT(data) && |
3f23b55a2cc4
[gaim-migrate @ 16215]
Richard Laager <rlaager@wiktel.com>
parents:
13739
diff
changeset
|
1517 !gaim_savedstatus_has_substatuses(saved_status)) |
12779 | 1518 { |
1519 if (!message_changed(gaim_savedstatus_get_message(saved_status), message)) | |
1520 changed = FALSE; | |
1521 } | |
1522 | |
1523 if (changed) | |
1524 { | |
13012 | 1525 /* If we've used this type+message before, lookup the transient status */ |
13244 | 1526 saved_status = gaim_savedstatus_find_transient_by_type_and_message( |
13012 | 1527 GPOINTER_TO_INT(data), message); |
1528 | |
1529 /* If this type+message is unique then create a new transient saved status */ | |
1530 if (saved_status == NULL) | |
1531 { | |
1532 saved_status = gaim_savedstatus_new(NULL, GPOINTER_TO_INT(data)); | |
1533 gaim_savedstatus_set_message(saved_status, message); | |
1534 } | |
12779 | 1535 |
1536 /* Set the status for each account */ | |
1537 gaim_savedstatus_activate(saved_status); | |
1538 } | |
1539 } else { | |
1540 /* Per-account */ | |
11981 | 1541 gint active; |
1542 GaimStatusType *status_type; | |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1543 GaimStatus *status; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1544 const char *id = NULL; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1545 |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1546 status = gaim_account_get_active_status(status_box->account); |
11981 | 1547 |
1548 g_object_get(G_OBJECT(status_box), "active", &active, NULL); | |
11654 | 1549 |
11993 | 1550 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
|
1551 id = gaim_status_type_get_id(status_type); |
11981 | 1552 |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1553 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
|
1554 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1555 /* Selected status and previous status is the same */ |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1556 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
|
1557 changed = FALSE; |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1558 } |
12123 | 1559 |
12076
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1560 if (changed) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1561 { |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1562 if (message) |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1563 gaim_account_set_status(status_box->account, id, |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1564 TRUE, "message", message, NULL); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1565 else |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1566 gaim_account_set_status(status_box->account, id, |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1567 TRUE, NULL); |
4fb1edd43f45
[gaim-migrate @ 14373]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12075
diff
changeset
|
1568 } |
11981 | 1569 } |
11627 | 1570 |
11638 | 1571 g_free(title); |
11654 | 1572 g_free(message); |
1573 } | |
1574 | |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1575 static void update_size(GtkGaimStatusBox *status_box) |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1576 { |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1577 GtkTextBuffer *buffer; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1578 GtkTextIter iter; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1579 int wrapped_lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1580 int lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1581 GdkRectangle oneline; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1582 int height; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1583 int pad_top, pad_inside, pad_bottom; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1584 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1585 if (!status_box->imhtml_visible) |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1586 { |
12598
1c122dbc8e9e
[gaim-migrate @ 14928]
Richard Laager <rlaager@wiktel.com>
parents:
12597
diff
changeset
|
1587 if (status_box->vbox != NULL) |
1c122dbc8e9e
[gaim-migrate @ 14928]
Richard Laager <rlaager@wiktel.com>
parents:
12597
diff
changeset
|
1588 gtk_widget_set_size_request(status_box->vbox, -1, -1); |
12597
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1589 return; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1590 } |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1591 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1592 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
|
1593 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1594 wrapped_lines = 1; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1595 gtk_text_buffer_get_start_iter(buffer, &iter); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1596 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
|
1597 wrapped_lines++; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1598 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1599 lines = gtk_text_buffer_get_line_count(buffer); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1600 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1601 /* Show a maximum of 4 lines */ |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1602 lines = MIN(lines, 4); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1603 wrapped_lines = MIN(wrapped_lines, 4); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1604 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1605 gtk_text_buffer_get_start_iter(buffer, &iter); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1606 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
|
1607 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1608 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
|
1609 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
|
1610 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
|
1611 |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1612 height = (oneline.height + pad_top + pad_bottom) * lines; |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1613 height += (oneline.height + pad_inside) * (wrapped_lines - lines); |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1614 |
12905
ee0c8c446eef
[gaim-migrate @ 15258]
Richard Laager <rlaager@wiktel.com>
parents:
12879
diff
changeset
|
1615 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
|
1616 } |
842b3b897cde
[gaim-migrate @ 14927]
Richard Laager <rlaager@wiktel.com>
parents:
12596
diff
changeset
|
1617 |
11654 | 1618 static void remove_typing_cb(GtkGaimStatusBox *status_box) |
1619 { | |
12782 | 1620 if (status_box->typing == 0) |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1621 { |
12782 | 1622 /* Nothing has changed, so we don't need to do anything */ |
13124 | 1623 status_menu_refresh_iter(status_box); |
12782 | 1624 return; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1625 } |
12782 | 1626 |
11654 | 1627 g_source_remove(status_box->typing); |
1628 status_box->typing = 0; | |
13739 | 1629 |
1630 activate_currently_selected_status(status_box); | |
11654 | 1631 gtk_gaim_status_box_refresh(status_box); |
10643 | 1632 } |
1633 | |
1634 static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
1635 { | |
11400 | 1636 GtkGaimStatusBox *status_box; |
10643 | 1637 GtkTreeIter iter; |
11739 | 1638 GtkGaimStatusBoxItemType type; |
12778 | 1639 gpointer data; |
11960 | 1640 GList *accounts = NULL, *node; |
10643 | 1641 |
11400 | 1642 status_box = GTK_GAIM_STATUS_BOX(box); |
1643 | |
12074
950acb2bc835
[gaim-migrate @ 14370]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12060
diff
changeset
|
1644 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
|
1645 return; |
11739 | 1646 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
1647 TYPE_COLUMN, &type, | |
12778 | 1648 DATA_COLUMN, &data, |
11739 | 1649 -1); |
13123 | 1650 if (status_box->typing != 0) |
11638 | 1651 g_source_remove(status_box->typing); |
1652 status_box->typing = 0; | |
10861 | 1653 |
11951 | 1654 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11729 | 1655 { |
12778 | 1656 if (type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) |
1657 { | |
1658 GaimSavedStatus *saved; | |
1659 saved = gaim_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); | |
1660 g_return_if_fail(saved != NULL); | |
1661 gaim_savedstatus_activate(saved); | |
1662 return; | |
1663 } | |
1664 | |
11951 | 1665 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
1666 { | |
13175 | 1667 GaimSavedStatus *saved_status; |
1668 saved_status = gaim_savedstatus_get_current(); | |
1669 gaim_gtk_status_editor_show(FALSE, | |
1670 gaim_savedstatus_is_transient(saved_status) | |
1671 ? saved_status : NULL); | |
13124 | 1672 status_menu_refresh_iter(status_box); |
11951 | 1673 return; |
1674 } | |
11729 | 1675 |
11951 | 1676 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
1677 { | |
1678 gaim_gtk_status_window_show(); | |
13124 | 1679 status_menu_refresh_iter(status_box); |
11951 | 1680 return; |
1681 } | |
11729 | 1682 } |
1683 | |
11654 | 1684 /* |
12779 | 1685 * Show the message box whenever the primitive allows for a |
11960 | 1686 * message attribute on any protocol that is enabled, |
1687 * or our protocol, if we have account set | |
11654 | 1688 */ |
11960 | 1689 if (status_box->account) |
1690 accounts = g_list_prepend(accounts, status_box->account); | |
1691 else | |
1692 accounts = gaim_accounts_get_all_active(); | |
11755 | 1693 status_box->imhtml_visible = FALSE; |
1694 for (node = accounts; node != NULL; node = node->next) | |
1695 { | |
1696 GaimAccount *account; | |
1697 GaimStatusType *status_type; | |
1698 | |
1699 account = node->data; | |
12779 | 1700 status_type = gaim_account_get_status_type_with_primitive(account, GPOINTER_TO_INT(data)); |
11755 | 1701 if ((status_type != NULL) && |
1702 (gaim_status_type_get_attr(status_type, "message") != NULL)) | |
1703 { | |
1704 status_box->imhtml_visible = TRUE; | |
1705 break; | |
1706 } | |
1707 } | |
1708 g_list_free(accounts); | |
11654 | 1709 |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1710 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
11654 | 1711 { |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1712 if (status_box->imhtml_visible) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1713 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1714 gtk_widget_show_all(status_box->vbox); |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1715 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1716 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
|
1717 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1718 gtk_widget_grab_focus(status_box->imhtml); |
13802
a93eeef163a9
[gaim-migrate @ 16216]
Richard Laager <rlaager@wiktel.com>
parents:
13801
diff
changeset
|
1719 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
12274 | 1720 } |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1721 else |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1722 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1723 gtk_widget_hide_all(status_box->vbox); |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1724 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1725 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
|
1726 } |
10643 | 1727 } |
1728 gtk_gaim_status_box_refresh(status_box); | |
1729 } | |
1730 | |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1731 static gint |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1732 get_statusbox_index(GtkGaimStatusBox *box, GaimSavedStatus *saved_status) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1733 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1734 gint index; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1735 |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1736 switch (gaim_savedstatus_get_type(saved_status)) |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1737 { |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1738 case GAIM_STATUS_AVAILABLE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1739 index = 0; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1740 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1741 case GAIM_STATUS_AWAY: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1742 index = 1; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1743 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1744 case GAIM_STATUS_INVISIBLE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1745 index = 2; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1746 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1747 case GAIM_STATUS_OFFLINE: |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1748 index = 3; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1749 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1750 default: |
13079 | 1751 index = -1; |
12932
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1752 break; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1753 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1754 |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1755 return index; |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1756 } |
d7b9fa3b7baf
[gaim-migrate @ 15285]
Luke Schierer <lschiere@pidgin.im>
parents:
12905
diff
changeset
|
1757 |
10643 | 1758 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) |
1759 { | |
13123 | 1760 GtkGaimStatusBox *status_box = (GtkGaimStatusBox*)data; |
1761 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) | |
11951 | 1762 { |
13123 | 1763 if (status_box->typing != 0) { |
1764 gtk_gaim_status_box_pulse_typing(status_box); | |
1765 g_source_remove(status_box->typing); | |
11951 | 1766 } |
13123 | 1767 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
10861 | 1768 } |
13123 | 1769 gtk_gaim_status_box_refresh(status_box); |
10643 | 1770 } |
10649 | 1771 |
12460
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1772 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
|
1773 { |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1774 imhtml_changed_cb(NULL, data); |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1775 } |
3d999a4d4892
[gaim-migrate @ 14770]
Richard Laager <rlaager@wiktel.com>
parents:
12379
diff
changeset
|
1776 |
11638 | 1777 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) |
10649 | 1778 { |
1779 if (status_box->imhtml_visible) | |
1780 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
1781 else | |
1782 return NULL; | |
1783 } |