Mercurial > pidgin.yaz
annotate src/gtkblist.c @ 14094:d0f3eba2717c
[gaim-migrate @ 16723]
Tab-completion should be case-insensitive.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 12 Aug 2006 15:17:14 +0000 |
parents | 7fbca3653056 |
children | 31d33e7bc0e6 |
rev | line source |
---|---|
5228 | 1 /* |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
2 * @file gtkblist.c GTK+ BuddyList API |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
3 * @ingroup gtkui |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
4 * |
5228 | 5 * gaim |
6 * | |
8046 | 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. | |
5228 | 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 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
7620 | 28 |
29 #include "account.h" | |
9015 | 30 #include "connection.h" |
7620 | 31 #include "core.h" |
32 #include "debug.h" | |
33 #include "notify.h" | |
34 #include "prpl.h" | |
35 #include "prefs.h" | |
8986 | 36 #include "plugin.h" |
7620 | 37 #include "request.h" |
38 #include "signals.h" | |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
39 #include "gtkstock.h" |
7620 | 40 #include "util.h" |
41 | |
42 #include "gtkaccount.h" | |
43 #include "gtkblist.h" | |
44 #include "gtkconv.h" | |
45 #include "gtkdebug.h" | |
9709 | 46 #include "gtkdialogs.h" |
7620 | 47 #include "gtkft.h" |
48 #include "gtklog.h" | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
49 #include "gtkmenutray.h" |
7620 | 50 #include "gtkpounce.h" |
11740 | 51 #include "gtkplugin.h" |
7620 | 52 #include "gtkprefs.h" |
53 #include "gtkprivacy.h" | |
8113 | 54 #include "gtkroomlist.h" |
10643 | 55 #include "gtkstatusbox.h" |
7620 | 56 #include "gtkutils.h" |
57 | |
5228 | 58 #include <gdk/gdkkeysyms.h> |
59 #include <gtk/gtk.h> | |
7620 | 60 #include <gdk/gdk.h> |
61 | |
62 typedef struct | |
63 { | |
64 GaimAccount *account; | |
65 | |
66 GtkWidget *window; | |
67 GtkWidget *combo; | |
68 GtkWidget *entry; | |
69 GtkWidget *entry_for_alias; | |
70 GtkWidget *account_box; | |
71 | |
72 } GaimGtkAddBuddyData; | |
73 | |
74 typedef struct | |
75 { | |
9811 | 76 GaimAccount *account; |
9812 | 77 gchar *default_chat_name; |
9811 | 78 |
79 GtkWidget *window; | |
7620 | 80 GtkWidget *account_menu; |
81 GtkWidget *alias_entry; | |
82 GtkWidget *group_combo; | |
83 GtkWidget *entries_box; | |
84 GtkSizeGroup *sg; | |
85 | |
86 GList *entries; | |
87 | |
88 } GaimGtkAddChatData; | |
89 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
90 typedef struct |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
91 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
92 GaimAccount *account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
93 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
94 GtkWidget *window; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
95 GtkWidget *account_menu; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
96 GtkWidget *entries_box; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
97 GtkSizeGroup *sg; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
98 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
99 GList *entries; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
100 } GaimGtkJoinChatData; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
101 |
7620 | 102 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
103 static GtkWidget *accountmenu = NULL; |
5228 | 104 |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
105 static guint visibility_manager_count = 0; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
106 static gboolean gtk_blist_obscured = FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
107 |
11796 | 108 static GList *gaim_gtk_blist_sort_methods = NULL; |
5422 | 109 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
110 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
7620 | 111 |
112 /* The functions we use for sorting aren't available in gtk 2.0.x, and | |
113 * segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */ | |
114 #if GTK_CHECK_VERSION(2,2,1) | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
115 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
116 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
117 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
7620 | 118 #endif |
119 static GaimGtkBuddyList *gtkblist = NULL; | |
5228 | 120 |
13889 | 121 static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
122 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); |
5228 | 123 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); |
7620 | 124 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); |
13889 | 125 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node); |
12530 | 126 static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
127 static const char *item_factory_translate_func (const char *path, gpointer func_data); |
5273 | 128 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); |
7620 | 129 static void redo_buddy_list(GaimBuddyList *list, gboolean remove); |
130 static void gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node); | |
131 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
132 static void gaim_gtk_blist_tooltip_destroy(void); |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
133 |
5256 | 134 struct _gaim_gtk_blist_node { |
135 GtkTreeRowReference *row; | |
7620 | 136 gboolean contact_expanded; |
11910 | 137 gboolean recent_signonoff; |
138 gint recent_signonoff_timer; | |
5256 | 139 }; |
140 | |
10968
e0d5038fbb7e
[gaim-migrate @ 12789]
Christopher O'Brien <siege@pidgin.im>
parents:
10924
diff
changeset
|
141 |
10118 | 142 static char dim_grey_string[8] = ""; |
10144 | 143 static char *dim_grey() |
10118 | 144 { |
145 if (!gtkblist) | |
146 return "dim grey"; | |
147 if (!dim_grey_string[0]) { | |
148 GtkStyle *style = gtk_widget_get_style(gtkblist->treeview); | |
149 snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x", | |
150 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
151 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
152 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
153 } | |
154 return dim_grey_string; | |
155 } | |
10144 | 156 |
5228 | 157 /*************************************************** |
158 * Callbacks * | |
159 ***************************************************/ | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
160 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
161 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
162 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
163 gtk_blist_obscured = TRUE; |
13889 | 164 else if (gtk_blist_obscured) { |
165 gtk_blist_obscured = FALSE; | |
166 gaim_gtk_blist_refresh_timer(gaim_get_blist()); | |
167 } | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
168 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
169 /* continue to handle event normally */ |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
170 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
171 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
172 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
173 static gboolean gtk_blist_window_state_cb(GtkWidget *w, GdkEventWindowState *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
174 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
175 if(event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
176 if(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
177 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", FALSE); |
13889 | 178 else { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
179 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", TRUE); |
13889 | 180 gaim_gtk_blist_refresh_timer(gaim_get_blist()); |
181 } | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
182 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
183 |
12279 | 184 if(event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { |
185 if(event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) | |
186 gaim_prefs_set_bool("/gaim/gtk/blist/list_maximized", TRUE); | |
187 else | |
188 gaim_prefs_set_bool("/gaim/gtk/blist/list_maximized", FALSE); | |
189 } | |
13889 | 190 |
191 /* Refresh gtkblist if un-iconifying */ | |
192 if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED){ | |
193 if (!(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)) | |
194 gaim_gtk_blist_refresh_timer(gaim_get_blist()); | |
195 } | |
196 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
197 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
198 } |
5228 | 199 |
200 static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) | |
201 { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
202 if(visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
203 gaim_blist_set_visible(FALSE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
204 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
205 gaim_core_quit(); |
5228 | 206 |
207 /* we handle everything, event should not propogate further */ | |
208 return TRUE; | |
209 } | |
210 | |
211 static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) | |
212 { | |
213 /* unfortunately GdkEventConfigure ignores the window gravity, but * | |
214 * the only way we have of setting the position doesn't. we have to * | |
7620 | 215 * call get_position because it does pay attention to the gravity. * |
216 * this is inefficient and I agree it sucks, but it's more likely * | |
217 * to work correctly. - Robot101 */ | |
5228 | 218 gint x, y; |
219 | |
220 /* check for visibility because when we aren't visible, this will * | |
221 * give us bogus (0,0) coordinates. - xOr */ | |
7620 | 222 if (GTK_WIDGET_VISIBLE(w)) |
5228 | 223 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
7620 | 224 else |
225 return FALSE; /* carry on normally */ | |
226 | |
13766
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
227 #ifdef _WIN32 |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
228 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
229 * when the window is being maximized */ |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
230 if (gdk_window_get_state(w->window) |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
231 & GDK_WINDOW_STATE_MAXIMIZED) { |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
232 return FALSE; |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
233 } |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
234 #endif |
e55e52d41287
[gaim-migrate @ 16178]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13755
diff
changeset
|
235 |
7620 | 236 /* don't save if nothing changed */ |
237 if (x == gaim_prefs_get_int("/gaim/gtk/blist/x") && | |
238 y == gaim_prefs_get_int("/gaim/gtk/blist/y") && | |
239 event->width == gaim_prefs_get_int("/gaim/gtk/blist/width") && | |
240 event->height == gaim_prefs_get_int("/gaim/gtk/blist/height")) { | |
241 | |
242 return FALSE; /* carry on normally */ | |
5228 | 243 } |
244 | |
7620 | 245 /* don't save off-screen positioning */ |
246 if (x + event->width < 0 || | |
9811 | 247 y + event->height < 0 || |
248 x > gdk_screen_width() || | |
249 y > gdk_screen_height()) { | |
7620 | 250 |
251 return FALSE; /* carry on normally */ | |
252 } | |
253 | |
12279 | 254 /* ignore changes when maximized */ |
255 if(gaim_prefs_get_bool("/gaim/gtk/blist/list_maximized")) | |
256 return FALSE; | |
257 | |
7620 | 258 /* store the position */ |
259 gaim_prefs_set_int("/gaim/gtk/blist/x", x); | |
260 gaim_prefs_set_int("/gaim/gtk/blist/y", y); | |
261 gaim_prefs_set_int("/gaim/gtk/blist/width", event->width); | |
262 gaim_prefs_set_int("/gaim/gtk/blist/height", event->height); | |
263 | |
5228 | 264 /* continue to handle event normally */ |
265 return FALSE; | |
266 } | |
267 | |
7620 | 268 static void gtk_blist_menu_info_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 269 { |
270 serv_get_info(b->account->gc, b->name); | |
271 } | |
272 | |
7620 | 273 static void gtk_blist_menu_im_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 274 { |
9728 | 275 gaim_gtkdialogs_im_with_user(b->account, b->name); |
5228 | 276 } |
277 | |
9466 | 278 static void gtk_blist_menu_send_file_cb(GtkWidget *w, GaimBuddy *b) |
279 { | |
280 serv_send_file(b->account->gc, b->name, NULL); | |
281 } | |
282 | |
7620 | 283 static void gtk_blist_menu_autojoin_cb(GtkWidget *w, GaimChat *chat) |
284 { | |
7693 | 285 gaim_blist_node_set_bool((GaimBlistNode*)chat, "gtk-autojoin", |
286 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))); | |
7620 | 287 } |
288 | |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
289 static void gtk_blist_join_chat(GaimChat *chat) |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
290 { |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
291 GaimConversation *conv; |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
292 |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
293 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
294 gaim_chat_get_name(chat), |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
295 chat->account); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
296 |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
297 if (conv != NULL) |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
298 gaim_gtkconv_present_conversation(conv); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
299 |
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
300 serv_join_chat(chat->account->gc, chat->components); |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
301 } |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
302 |
7620 | 303 static void gtk_blist_menu_join_cb(GtkWidget *w, GaimChat *chat) |
5228 | 304 { |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
305 gtk_blist_join_chat(chat); |
5234 | 306 } |
307 | |
11016 | 308 static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1, |
309 char *arg2, gpointer nada) | |
310 { | |
311 GtkTreeIter iter; | |
312 GtkTreePath *path; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
313 GValue val; |
11016 | 314 GaimBlistNode *node; |
315 | |
316 path = gtk_tree_path_new_from_string (arg1); | |
317 gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
318 gtk_tree_path_free (path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
319 val.g_type = 0; |
11016 | 320 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
321 node = g_value_get_pointer(&val); | |
322 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), TRUE); | |
323 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", FALSE, NULL); | |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
324 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
325 switch (node->type) |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
326 { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
327 case GAIM_BLIST_CONTACT_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
328 { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
329 GaimContact *contact = (GaimContact *)node; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
330 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
331 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
332 if (contact->alias || gtknode->contact_expanded) |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
333 gaim_blist_alias_contact(contact, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
334 else |
12478
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
335 { |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
336 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
337 gaim_blist_alias_buddy(buddy, arg2); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
338 serv_alias_buddy(buddy); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
339 } |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
340 } |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
341 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
342 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
343 case GAIM_BLIST_BUDDY_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
344 gaim_blist_alias_buddy((GaimBuddy*)node, arg2); |
12478
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
345 serv_alias_buddy((GaimBuddy *)node); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
346 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
347 case GAIM_BLIST_GROUP_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
348 gaim_blist_rename_group((GaimGroup*)node, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
349 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
350 case GAIM_BLIST_CHAT_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
351 gaim_blist_alias_chat((GaimChat*)node, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
352 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
353 default: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
354 break; |
11016 | 355 } |
356 } | |
357 | |
5234 | 358 static void gtk_blist_menu_alias_cb(GtkWidget *w, GaimBlistNode *node) |
359 { | |
11016 | 360 GtkTreeIter iter; |
361 GtkTreePath *path; | |
11258 | 362 const char *text = NULL; |
13509
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
363 char *esc; |
11494 | 364 |
11258 | 365 if (!(get_iter_from_node(node, &iter))) { |
11016 | 366 /* This is either a bug, or the buddy is in a collapsed contact */ |
367 node = node->parent; | |
368 if (!get_iter_from_node(node, &iter)) | |
369 /* Now it's definitely a bug */ | |
370 return; | |
371 } | |
11258 | 372 |
373 switch (node->type) { | |
374 case GAIM_BLIST_BUDDY_NODE: | |
375 text = gaim_buddy_get_alias((GaimBuddy *)node); | |
376 break; | |
377 case GAIM_BLIST_CONTACT_NODE: | |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
378 text = gaim_contact_get_alias((GaimContact *)node); |
11258 | 379 break; |
380 case GAIM_BLIST_GROUP_NODE: | |
381 text = ((GaimGroup *)node)->name; | |
382 break; | |
383 case GAIM_BLIST_CHAT_NODE: | |
384 text = gaim_chat_get_name((GaimChat *)node); | |
385 break; | |
386 default: | |
387 g_return_if_reached(); | |
388 } | |
389 | |
13509
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
390 esc = g_markup_escape_text(text, -1); |
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
391 gtk_tree_store_set(gtkblist->treemodel, &iter, NAME_COLUMN, esc, -1); |
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
392 g_free(esc); |
11258 | 393 |
11016 | 394 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
395 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); | |
396 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
397 gtk_widget_grab_focus(gtkblist->treeview); | |
398 gtk_tree_view_set_cursor(GTK_TREE_VIEW(gtkblist->treeview), path, gtkblist->text_column, TRUE); | |
399 gtk_tree_path_free(path); | |
5228 | 400 } |
401 | |
7620 | 402 static void gtk_blist_menu_bp_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 403 { |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
404 gaim_gtk_pounce_editor_show(b->account, b->name, NULL); |
5228 | 405 } |
406 | |
9917 | 407 static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 408 { |
9917 | 409 GaimLogType type; |
410 GaimAccount *account; | |
411 char *name = NULL; | |
10663 | 412 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
413 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
414 |
9917 | 415 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
416 GaimBuddy *b = (GaimBuddy*) node; | |
417 type = GAIM_LOG_IM; | |
418 name = g_strdup(b->name); | |
419 account = b->account; | |
420 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { | |
421 GaimChat *c = (GaimChat*) node; | |
422 GaimPluginProtocolInfo *prpl_info = NULL; | |
423 type = GAIM_LOG_CHAT; | |
424 account = c->account; | |
425 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account))); | |
426 if (prpl_info && prpl_info->get_chat_name) { | |
427 name = prpl_info->get_chat_name(c->components); | |
428 } | |
10663 | 429 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
430 gaim_gtk_log_show_contact((GaimContact *)node); | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
431 gaim_gtk_clear_cursor(gtkblist->window); |
10663 | 432 return; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
433 } else { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
434 gaim_gtk_clear_cursor(gtkblist->window); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
435 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
436 /* This callback should not have been registered for a node |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
437 * that doesn't match the type of one of the blocks above. */ |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
438 g_return_if_reached(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
439 } |
9917 | 440 |
441 if (name && account) { | |
442 gaim_gtk_log_show(type, name, account); | |
443 g_free(name); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
444 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
445 gaim_gtk_clear_cursor(gtkblist->window); |
9917 | 446 } |
7620 | 447 } |
448 | |
5228 | 449 static void gtk_blist_show_systemlog_cb() |
450 { | |
8573 | 451 gaim_gtk_syslog_show(); |
5228 | 452 } |
453 | |
454 static void gtk_blist_show_onlinehelp_cb() | |
455 { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10229
diff
changeset
|
456 gaim_notify_uri(NULL, GAIM_WEBSITE "documentation.php"); |
5228 | 457 } |
458 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
459 static void |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
460 do_join_chat(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
461 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
462 if (data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
463 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
464 GHashTable *components = |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
465 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
466 GList *tmp; |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
467 GaimChat *chat; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
468 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
469 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
470 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
471 if (g_object_get_data(tmp->data, "is_spin")) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
472 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
473 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
474 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
475 g_strdup_printf("%d", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
476 gtk_spin_button_get_value_as_int(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
477 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
478 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
479 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
480 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
481 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
482 g_strdup(gtk_entry_get_text(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
483 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
484 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
485 |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
486 chat = gaim_chat_new(data->account, NULL, components); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
487 gtk_blist_join_chat(chat); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
488 gaim_blist_remove_chat(chat); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
489 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
490 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
491 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
492 static void |
8940 | 493 do_joinchat(GtkWidget *dialog, int id, GaimGtkJoinChatData *info) |
494 { | |
495 switch(id) | |
496 { | |
497 case GTK_RESPONSE_OK: | |
498 do_join_chat(info); | |
499 | |
500 break; | |
501 } | |
502 | |
503 gtk_widget_destroy(GTK_WIDGET(dialog)); | |
504 g_list_free(info->entries); | |
505 g_free(info); | |
506 } | |
507 | |
10475 | 508 /* |
509 * Check the values of all the text entry boxes. If any required input | |
510 * strings are empty then don't allow the user to click on "OK." | |
511 */ | |
512 static void | |
513 joinchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
514 { | |
515 GaimGtkJoinChatData *data; | |
516 GList *tmp; | |
517 const char *text; | |
518 gboolean required; | |
519 gboolean sensitive = TRUE; | |
520 | |
521 data = user_data; | |
522 | |
523 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
524 { | |
525 if (!g_object_get_data(tmp->data, "is_spin")) | |
526 { | |
527 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
528 text = gtk_entry_get_text(tmp->data); | |
529 if (required && (*text == '\0')) | |
530 sensitive = FALSE; | |
531 } | |
532 } | |
533 | |
534 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
535 } | |
536 | |
8940 | 537 static void |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
538 rebuild_joinchat_entries(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
539 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
540 GaimConnection *gc; |
9959 | 541 GList *list = NULL, *tmp = NULL; |
9770 | 542 GHashTable *defaults = NULL; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
543 struct proto_chat_entry *pce; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
544 gboolean focus = TRUE; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
545 |
10127 | 546 g_return_if_fail(data->account != NULL); |
547 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
548 gc = gaim_account_get_connection(data->account); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
549 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
550 while (GTK_BOX(data->entries_box)->children) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
551 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
552 gtk_container_remove(GTK_CONTAINER(data->entries_box), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
553 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
554 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
555 |
14035 | 556 g_list_free(data->entries); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
557 data->entries = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
558 |
9987 | 559 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
9959 | 560 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
561 |
9770 | 562 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
563 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, NULL); | |
564 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
565 for (tmp = list; tmp; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
566 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
567 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
568 GtkWidget *rowbox; |
10475 | 569 GtkWidget *input; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
570 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
571 pce = tmp->data; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
572 |
11243 | 573 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
574 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
575 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
576 label = gtk_label_new_with_mnemonic(pce->label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
577 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
578 gtk_size_group_add_widget(data->sg, label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
579 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
580 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
581 if (pce->is_int) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
582 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
583 GtkObject *adjust; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
584 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
585 1, 10, 10); |
10475 | 586 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
587 gtk_widget_set_size_request(input, 50, -1); | |
588 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
589 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
590 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
591 { |
9770 | 592 char *value; |
10475 | 593 input = gtk_entry_new(); |
594 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9770 | 595 value = g_hash_table_lookup(defaults, pce->identifier); |
596 if (value != NULL) | |
10475 | 597 gtk_entry_set_text(GTK_ENTRY(input), value); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
598 if (pce->secret) |
11986 | 599 { |
10475 | 600 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 601 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
602 } | |
10475 | 603 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
604 g_signal_connect(G_OBJECT(input), "changed", | |
605 G_CALLBACK(joinchat_set_sensitive_if_input_cb), data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
606 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
607 |
10475 | 608 /* Do the following for any type of input widget */ |
609 if (focus) | |
610 { | |
611 gtk_widget_grab_focus(input); | |
612 focus = FALSE; | |
613 } | |
614 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
615 gaim_set_accessible_label(input, label); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
616 g_object_set_data(G_OBJECT(input), "identifier", (gpointer)pce->identifier); |
10475 | 617 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); |
618 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
619 data->entries = g_list_append(data->entries, input); | |
620 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
621 g_free(pce); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
622 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
623 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
624 g_list_free(list); |
10475 | 625 g_hash_table_destroy(defaults); |
626 | |
627 /* Set whether the "OK" button should be clickable initially */ | |
628 joinchat_set_sensitive_if_input_cb(NULL, data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
629 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
630 gtk_widget_show_all(data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
631 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
632 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
633 static void |
8940 | 634 joinchat_select_account_cb(GObject *w, GaimAccount *account, |
13559
bbbde2f5c03b
[gaim-migrate @ 15938]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13545
diff
changeset
|
635 GaimGtkJoinChatData *data) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
636 { |
13559
bbbde2f5c03b
[gaim-migrate @ 15938]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13545
diff
changeset
|
637 data->account = account; |
bbbde2f5c03b
[gaim-migrate @ 15938]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13545
diff
changeset
|
638 rebuild_joinchat_entries(data); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
639 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
640 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
641 static gboolean |
9987 | 642 chat_account_filter_func(GaimAccount *account) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
643 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
644 GaimConnection *gc = gaim_account_get_connection(account); |
8940 | 645 GaimPluginProtocolInfo *prpl_info = NULL; |
646 | |
647 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
648 | |
649 return (prpl_info->chat_info != NULL); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
650 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
651 |
8940 | 652 gboolean |
653 gaim_gtk_blist_joinchat_is_showable() | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
654 { |
8940 | 655 GList *c; |
656 GaimConnection *gc; | |
657 | |
658 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { | |
659 gc = c->data; | |
660 | |
9987 | 661 if (chat_account_filter_func(gaim_connection_get_account(gc))) |
8940 | 662 return TRUE; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
663 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
664 |
8940 | 665 return FALSE; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
666 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
667 |
8305
57bdd25752c1
[gaim-migrate @ 9029]
Christian Hammond <chipx86@chipx86.com>
parents:
8303
diff
changeset
|
668 void |
8940 | 669 gaim_gtk_blist_joinchat_show(void) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
670 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
671 GtkWidget *hbox, *vbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
672 GtkWidget *rowbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
673 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
674 GaimGtkBuddyList *gtkblist; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
675 GtkWidget *img = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
676 GaimGtkJoinChatData *data = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
677 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
678 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
679 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
680 GTK_ICON_SIZE_DIALOG); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
681 data = g_new0(GaimGtkJoinChatData, 1); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
682 |
8975 | 683 data->window = gtk_dialog_new_with_buttons(_("Join a Chat"), |
684 NULL, GTK_DIALOG_NO_SEPARATOR, | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
685 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
8308 | 686 GAIM_STOCK_CHAT, GTK_RESPONSE_OK, NULL); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
687 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); |
11243 | 688 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
689 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 690 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
691 gtk_container_set_border_width( |
11243 | 692 GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); |
8975 | 693 gtk_window_set_role(GTK_WINDOW(data->window), "join_chat"); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
694 |
11243 | 695 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
696 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
697 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
698 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
699 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
700 vbox = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
701 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
702 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
703 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
704 label = gtk_label_new(_("Please enter the appropriate information " |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
705 "about the chat you would like to join.\n")); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
706 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
707 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
708 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
709 |
11243 | 710 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
711 gtk_box_pack_start(GTK_BOX(vbox), rowbox, TRUE, TRUE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
712 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
713 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
714 |
8940 | 715 label = gtk_label_new_with_mnemonic(_("_Account:")); |
716 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
717 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
718 gtk_size_group_add_widget(data->sg, label); | |
719 | |
720 data->account_menu = gaim_gtk_account_option_menu_new(NULL, FALSE, | |
721 G_CALLBACK(joinchat_select_account_cb), | |
9987 | 722 chat_account_filter_func, data); |
8940 | 723 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
724 gtk_label_set_mnemonic_widget(GTK_LABEL(label), | |
725 GTK_WIDGET(data->account_menu)); | |
726 gaim_set_accessible_label (data->account_menu, label); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
727 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
728 data->entries_box = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
729 gtk_container_add(GTK_CONTAINER(vbox), data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
730 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
731 |
8940 | 732 data->account = gaim_gtk_account_option_menu_get_selected(data->account_menu); |
733 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
734 rebuild_joinchat_entries(data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
735 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
736 g_signal_connect(G_OBJECT(data->window), "response", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
737 G_CALLBACK(do_joinchat), data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
738 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
739 g_object_unref(data->sg); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
740 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
741 gtk_widget_show_all(data->window); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
742 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
743 |
5228 | 744 static void gtk_blist_row_expanded_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { |
745 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
746 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
747 |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
748 val.g_type = 0; |
5228 | 749 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); |
750 | |
751 node = g_value_get_pointer(&val); | |
752 | |
753 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 754 gaim_blist_node_set_bool(node, "collapsed", FALSE); |
5228 | 755 } |
756 } | |
757 | |
758 static void gtk_blist_row_collapsed_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { | |
759 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
760 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
761 |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
762 val.g_type = 0; |
5228 | 763 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); |
764 | |
765 node = g_value_get_pointer(&val); | |
766 | |
767 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 768 gaim_blist_node_set_bool(node, "collapsed", TRUE); |
7620 | 769 } else if(GAIM_BLIST_NODE_IS_CONTACT(node)) { |
770 gaim_gtk_blist_collapse_contact_cb(NULL, node); | |
5228 | 771 } |
772 } | |
773 | |
774 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { | |
775 GaimBlistNode *node; | |
776 GtkTreeIter iter; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
777 GValue val; |
5228 | 778 |
779 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
780 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
781 val.g_type = 0; |
5228 | 782 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
783 node = g_value_get_pointer(&val); | |
784 | |
7620 | 785 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { |
786 GaimBuddy *buddy; | |
787 | |
788 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
789 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
790 else | |
791 buddy = (GaimBuddy*)node; | |
792 | |
9728 | 793 gaim_gtkdialogs_im_with_user(buddy->account, buddy->name); |
5234 | 794 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
795 gtk_blist_join_chat((GaimChat *)node); |
5228 | 796 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
797 if (gtk_tree_view_row_expanded(tv, path)) | |
798 gtk_tree_view_collapse_row(tv, path); | |
799 else | |
800 gtk_tree_view_expand_row(tv,path,FALSE); | |
801 } | |
802 } | |
803 | |
5234 | 804 static void gaim_gtk_blist_add_chat_cb() |
805 { | |
806 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
807 GtkTreeIter iter; | |
808 GaimBlistNode *node; | |
809 | |
810 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
811 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 812 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
9754 | 813 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent->parent, NULL, NULL); |
7620 | 814 if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) |
9754 | 815 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent, NULL, NULL); |
5234 | 816 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
9754 | 817 gaim_blist_request_add_chat(NULL, (GaimGroup*)node, NULL, NULL); |
5234 | 818 } |
819 else { | |
9754 | 820 gaim_blist_request_add_chat(NULL, NULL, NULL, NULL); |
5234 | 821 } |
822 } | |
823 | |
5228 | 824 static void gaim_gtk_blist_add_buddy_cb() |
825 { | |
826 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
827 GtkTreeIter iter; | |
828 GaimBlistNode *node; | |
829 | |
830 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
831 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 832 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
833 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent->parent)->name, | |
834 NULL); | |
835 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) | |
836 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
837 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent)->name, NULL); | |
838 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
839 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node)->name, NULL); | |
840 } | |
5228 | 841 } |
842 else { | |
7620 | 843 gaim_blist_request_add_buddy(NULL, NULL, NULL, NULL); |
844 } | |
845 } | |
846 | |
847 static void | |
848 gaim_gtk_blist_remove_cb (GtkWidget *w, GaimBlistNode *node) | |
849 { | |
850 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
9730 | 851 gaim_gtkdialogs_remove_buddy((GaimBuddy*)node); |
7620 | 852 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
9730 | 853 gaim_gtkdialogs_remove_chat((GaimChat*)node); |
7620 | 854 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
9730 | 855 gaim_gtkdialogs_remove_group((GaimGroup*)node); |
7620 | 856 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
9730 | 857 gaim_gtkdialogs_remove_contact((GaimContact*)node); |
5228 | 858 } |
859 } | |
860 | |
861 static void | |
7620 | 862 gaim_gtk_blist_expand_contact_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 863 { |
7620 | 864 struct _gaim_gtk_blist_node *gtknode; |
9632 | 865 GtkTreeIter iter, parent; |
7620 | 866 GaimBlistNode *bnode; |
10325 | 867 GtkTreePath *path; |
7620 | 868 |
869 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
870 return; | |
871 | |
872 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
873 | |
874 gtknode->contact_expanded = TRUE; | |
875 | |
876 for(bnode = node->child; bnode; bnode = bnode->next) { | |
877 gaim_gtk_blist_update(NULL, bnode); | |
878 } | |
10353 | 879 |
9632 | 880 /* This ensures that the bottom buddy is visible, i.e. not scrolled off the alignment */ |
881 get_iter_from_node(node, &parent); | |
10353 | 882 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(gtkblist->treemodel), &iter, &parent, |
9811 | 883 gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtkblist->treemodel), &parent) -1); |
9632 | 884 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
885 /* Let the treeview draw so it knows where to scroll */ | |
886 while (gtk_events_pending()) | |
887 gtk_main_iteration(); | |
10353 | 888 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); |
889 | |
13889 | 890 gaim_gtk_blist_update_contact(NULL, node->child); |
9632 | 891 gtk_tree_path_free(path); |
7620 | 892 } |
893 | |
894 static void | |
895 gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node) | |
896 { | |
897 GaimBlistNode *bnode; | |
898 struct _gaim_gtk_blist_node *gtknode; | |
899 | |
900 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
901 return; | |
902 | |
903 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
904 | |
905 gtknode->contact_expanded = FALSE; | |
906 | |
907 for(bnode = node->child; bnode; bnode = bnode->next) { | |
908 gaim_gtk_blist_update(NULL, bnode); | |
5228 | 909 } |
910 } | |
911 | |
9051 | 912 void |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
913 gaim_gtk_append_blist_node_proto_menu(GtkWidget *menu, GaimConnection *gc, |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
914 GaimBlistNode *node) |
9030 | 915 { |
916 GList *l, *ll; | |
917 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
918 | |
919 if(!prpl_info || !prpl_info->blist_node_menu) | |
920 return; | |
921 | |
922 for(l = ll = prpl_info->blist_node_menu(node); l; l = l->next) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
923 GaimMenuAction *act = (GaimMenuAction *) l->data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
924 gaim_gtk_append_menu_action(menu, act, node); |
9030 | 925 } |
926 g_list_free(ll); | |
927 } | |
928 | |
9051 | 929 void |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
930 gaim_gtk_append_blist_node_extended_menu(GtkWidget *menu, GaimBlistNode *node) |
9030 | 931 { |
932 GList *l, *ll; | |
933 | |
934 for(l = ll = gaim_blist_node_get_extended_menu(node); l; l = l->next) { | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
935 GaimMenuAction *act = (GaimMenuAction *) l->data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
936 gaim_gtk_append_menu_action(menu, act, node); |
9030 | 937 } |
938 g_list_free(ll); | |
939 } | |
940 | |
9774 | 941 void |
10484 | 942 gaim_gtk_blist_make_buddy_menu(GtkWidget *menu, GaimBuddy *buddy, gboolean sub) { |
9774 | 943 GaimPluginProtocolInfo *prpl_info; |
10663 | 944 GaimContact *contact; |
945 gboolean contact_expanded = FALSE; | |
9774 | 946 |
947 g_return_if_fail(menu); | |
948 g_return_if_fail(buddy); | |
949 | |
950 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); | |
951 | |
10663 | 952 contact = gaim_buddy_get_contact(buddy); |
953 if (contact) { | |
954 contact_expanded = ((struct _gaim_gtk_blist_node *)(((GaimBlistNode*)contact)->ui_data))->contact_expanded; | |
955 } | |
956 | |
7620 | 957 if (prpl_info && prpl_info->get_info) { |
8137 | 958 gaim_new_item_from_stock(menu, _("Get _Info"), GAIM_STOCK_INFO, |
9774 | 959 G_CALLBACK(gtk_blist_menu_info_cb), buddy, 0, 0, NULL); |
7620 | 960 } |
8137 | 961 gaim_new_item_from_stock(menu, _("I_M"), GAIM_STOCK_IM, |
9774 | 962 G_CALLBACK(gtk_blist_menu_im_cb), buddy, 0, 0, NULL); |
9466 | 963 if (prpl_info && prpl_info->send_file) { |
9774 | 964 if (!prpl_info->can_receive_file || |
965 prpl_info->can_receive_file(buddy->account->gc, buddy->name)) | |
966 { | |
967 gaim_new_item_from_stock(menu, _("_Send File"), | |
968 GAIM_STOCK_FILE_TRANSFER, | |
969 G_CALLBACK(gtk_blist_menu_send_file_cb), | |
970 buddy, 0, 0, NULL); | |
9466 | 971 } |
972 } | |
12024 | 973 |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
974 gaim_new_item_from_stock(menu, _("Add Buddy _Pounce"), GAIM_STOCK_POUNCE, |
9774 | 975 G_CALLBACK(gtk_blist_menu_bp_cb), buddy, 0, 0, NULL); |
10663 | 976 |
977 if(((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
978 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 979 G_CALLBACK(gtk_blist_menu_showlog_cb), |
980 contact, 0, 0, NULL); | |
981 } else if (!sub) { | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
982 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 983 G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL); |
984 } | |
9774 | 985 |
986 gaim_gtk_append_blist_node_proto_menu(menu, buddy->account->gc, | |
987 (GaimBlistNode *)buddy); | |
988 gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); | |
7620 | 989 |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
990 if (((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
991 gaim_separator(menu); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
992 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
993 gaim_new_item_from_stock(menu, _("Alias..."), GAIM_STOCK_ALIAS, |
9925 | 994 G_CALLBACK(gtk_blist_menu_alias_cb), |
10663 | 995 contact, 0, 0, NULL); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
996 gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
9925 | 997 G_CALLBACK(gaim_gtk_blist_remove_cb), |
10663 | 998 contact, 0, 0, NULL); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
999 } else if (!sub || contact_expanded) { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
1000 gaim_separator(menu); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
1001 |
9925 | 1002 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
1003 G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); | |
1004 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
1005 G_CALLBACK(gaim_gtk_blist_remove_cb), buddy, | |
1006 0, 0, NULL); | |
1007 } | |
7620 | 1008 } |
1009 | |
9774 | 1010 static gboolean |
1011 gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data) { | |
7620 | 1012 GaimBlistNode *node; |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1013 GValue val; |
7620 | 1014 GtkTreeIter iter; |
1015 GtkTreeSelection *sel; | |
1016 | |
1017 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1018 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1019 return FALSE; | |
1020 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1021 val.g_type = 0; |
7620 | 1022 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, |
1023 NODE_COLUMN, &val); | |
1024 node = g_value_get_pointer(&val); | |
1025 | |
1026 if(event->state & GDK_CONTROL_MASK && | |
1027 (event->keyval == 'o' || event->keyval == 'O')) { | |
1028 GaimBuddy *buddy; | |
1029 | |
1030 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1031 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1032 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1033 buddy = (GaimBuddy*)node; | |
1034 } else { | |
1035 return FALSE; | |
1036 } | |
1037 if(buddy) | |
1038 serv_get_info(buddy->account->gc, buddy->name); | |
1039 } | |
1040 | |
1041 return FALSE; | |
1042 } | |
1043 | |
9013 | 1044 |
8143 | 1045 static GtkWidget * |
8952 | 1046 create_group_menu (GaimBlistNode *node, GaimGroup *g) |
8143 | 1047 { |
1048 GtkWidget *menu; | |
11988 | 1049 GtkWidget *item; |
8143 | 1050 |
1051 menu = gtk_menu_new(); | |
1052 gaim_new_item_from_stock(menu, _("Add a _Buddy"), GTK_STOCK_ADD, | |
1053 G_CALLBACK(gaim_gtk_blist_add_buddy_cb), node, 0, 0, NULL); | |
11988 | 1054 item = gaim_new_item_from_stock(menu, _("Add a C_hat"), GTK_STOCK_ADD, |
8143 | 1055 G_CALLBACK(gaim_gtk_blist_add_chat_cb), node, 0, 0, NULL); |
11988 | 1056 gtk_widget_set_sensitive(item, gaim_gtk_blist_joinchat_is_showable()); |
8143 | 1057 gaim_new_item_from_stock(menu, _("_Delete Group"), GTK_STOCK_REMOVE, |
1058 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1059 gaim_new_item_from_stock(menu, _("_Rename"), NULL, | |
11016 | 1060 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
8952 | 1061 |
9051 | 1062 gaim_gtk_append_blist_node_extended_menu(menu, node); |
8952 | 1063 |
8143 | 1064 return menu; |
1065 } | |
1066 | |
8586 | 1067 |
8143 | 1068 static GtkWidget * |
9774 | 1069 create_chat_menu(GaimBlistNode *node, GaimChat *c) { |
8143 | 1070 GtkWidget *menu; |
9030 | 1071 gboolean autojoin; |
8143 | 1072 |
1073 menu = gtk_menu_new(); | |
9030 | 1074 autojoin = (gaim_blist_node_get_bool(node, "gtk-autojoin") || |
1075 (gaim_blist_node_get_string(node, "gtk-autojoin") != NULL)); | |
1076 | |
8143 | 1077 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, |
9030 | 1078 G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL); |
8143 | 1079 gaim_new_check_item(menu, _("Auto-Join"), |
9030 | 1080 G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin); |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
1081 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
9917 | 1082 G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL); |
9030 | 1083 |
9051 | 1084 gaim_gtk_append_blist_node_proto_menu(menu, c->account->gc, node); |
1085 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
8586 | 1086 |
1087 gaim_separator(menu); | |
9030 | 1088 |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1089 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1090 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
1091 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
1092 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
8586 | 1093 |
8143 | 1094 return menu; |
1095 } | |
1096 | |
1097 static GtkWidget * | |
1098 create_contact_menu (GaimBlistNode *node) | |
1099 { | |
1100 GtkWidget *menu; | |
1101 | |
1102 menu = gtk_menu_new(); | |
10663 | 1103 |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
1104 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 1105 G_CALLBACK(gtk_blist_menu_showlog_cb), |
1106 node, 0, 0, NULL); | |
1107 | |
1108 gaim_separator(menu); | |
1109 | |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1110 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1111 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
10663 | 1112 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, |
1113 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1114 | |
1115 gaim_separator(menu); | |
1116 | |
8143 | 1117 gaim_new_item_from_stock(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT, |
1118 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1119 node, 0, 0, NULL); | |
9051 | 1120 |
1121 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
1122 | |
8143 | 1123 return menu; |
1124 } | |
1125 | |
1126 static GtkWidget * | |
9774 | 1127 create_buddy_menu(GaimBlistNode *node, GaimBuddy *b) { |
8143 | 1128 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1129 GtkWidget *menu; | |
1130 GtkWidget *menuitem; | |
1131 gboolean show_offline = gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies"); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1132 |
8143 | 1133 menu = gtk_menu_new(); |
10484 | 1134 gaim_gtk_blist_make_buddy_menu(menu, b, FALSE); |
8143 | 1135 |
1136 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1137 gaim_separator(menu); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1138 |
8143 | 1139 if(gtknode->contact_expanded) { |
1140 gaim_new_item_from_stock(menu, _("_Collapse"), | |
1141 GTK_STOCK_ZOOM_OUT, | |
1142 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1143 node, 0, 0, NULL); | |
1144 } else { | |
1145 gaim_new_item_from_stock(menu, _("_Expand"), | |
1146 GTK_STOCK_ZOOM_IN, | |
1147 G_CALLBACK(gaim_gtk_blist_expand_contact_cb), node, | |
1148 0, 0, NULL); | |
1149 } | |
1150 if(node->child->next) { | |
1151 GaimBlistNode *bnode; | |
1152 | |
1153 for(bnode = node->child; bnode; bnode = bnode->next) { | |
1154 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
9340 | 1155 GdkPixbuf *buf; |
8143 | 1156 GtkWidget *submenu; |
1157 GtkWidget *image; | |
1158 | |
1159 if(buddy == b) | |
1160 continue; | |
1161 if(!buddy->account->gc) | |
1162 continue; | |
1163 if(!show_offline && !GAIM_BUDDY_IS_ONLINE(buddy)) | |
1164 continue; | |
1165 | |
1166 menuitem = gtk_image_menu_item_new_with_label(buddy->name); | |
9340 | 1167 buf = gaim_gtk_blist_get_status_icon(bnode, |
1168 GAIM_STATUS_ICON_SMALL); | |
1169 image = gtk_image_new_from_pixbuf(buf); | |
1170 g_object_unref(G_OBJECT(buf)); | |
8143 | 1171 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), |
9811 | 1172 image); |
8143 | 1173 gtk_widget_show(image); |
1174 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
1175 gtk_widget_show(menuitem); | |
1176 | |
1177 submenu = gtk_menu_new(); | |
1178 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1179 gtk_widget_show(submenu); | |
1180 | |
10484 | 1181 gaim_gtk_blist_make_buddy_menu(submenu, buddy, TRUE); |
8143 | 1182 } |
1183 } | |
1184 } | |
1185 return menu; | |
1186 } | |
1187 | |
1188 static gboolean | |
1189 gaim_gtk_blist_show_context_menu(GaimBlistNode *node, | |
1190 GtkMenuPositionFunc func, | |
1191 GtkWidget *tv, | |
1192 guint button, | |
1193 guint32 time) | |
1194 { | |
1195 struct _gaim_gtk_blist_node *gtknode; | |
1196 GtkWidget *menu = NULL; | |
1197 gboolean handled = FALSE; | |
1198 | |
1199 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
1200 | |
1201 /* Create a menu based on the thing we right-clicked on */ | |
1202 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
8952 | 1203 GaimGroup *g = (GaimGroup *)node; |
9774 | 1204 |
8952 | 1205 menu = create_group_menu(node, g); |
8143 | 1206 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
8586 | 1207 GaimChat *c = (GaimChat *)node; |
9774 | 1208 |
1209 menu = create_chat_menu(node, c); | |
8143 | 1210 } else if ((GAIM_BLIST_NODE_IS_CONTACT(node)) && (gtknode->contact_expanded)) { |
1211 menu = create_contact_menu(node); | |
1212 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1213 GaimBuddy *b; | |
1214 | |
1215 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1216 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1217 else | |
1218 b = (GaimBuddy *)node; | |
1219 | |
9774 | 1220 menu = create_buddy_menu(node, b); |
8143 | 1221 } |
1222 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1223 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1224 /* Unhook the tooltip-timeout since we don't want a tooltip |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1225 * to appear and obscure the context menu we are about to show |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1226 This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1227 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1228 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1229 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1230 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1231 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1232 |
8143 | 1233 /* Now display the menu */ |
1234 if (menu != NULL) { | |
1235 gtk_widget_show_all(menu); | |
1236 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, func, tv, button, time); | |
1237 handled = TRUE; | |
1238 } | |
1239 | |
1240 return handled; | |
1241 } | |
1242 | |
1243 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer user_data) | |
5228 | 1244 { |
1245 GtkTreePath *path; | |
1246 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1247 GValue val; |
5228 | 1248 GtkTreeIter iter; |
1249 GtkTreeSelection *sel; | |
1250 GaimPlugin *prpl = NULL; | |
1251 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 1252 struct _gaim_gtk_blist_node *gtknode; |
1253 gboolean handled = FALSE; | |
5228 | 1254 |
1255 /* Here we figure out which node was clicked */ | |
1256 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
1257 return FALSE; | |
1258 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1259 val.g_type = 0; |
8143 | 1260 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
5228 | 1261 node = g_value_get_pointer(&val); |
7620 | 1262 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1263 | |
8143 | 1264 /* Right click draws a context menu */ |
1265 if ((event->button == 3) && (event->type == GDK_BUTTON_PRESS)) { | |
1266 handled = gaim_gtk_blist_show_context_menu(node, NULL, tv, 3, event->time); | |
1267 | |
1268 /* CTRL+middle click expands or collapse a contact */ | |
1269 } else if ((event->button == 2) && (event->type == GDK_BUTTON_PRESS) && | |
1270 (event->state & GDK_CONTROL_MASK) && (GAIM_BLIST_NODE_IS_CONTACT(node))) { | |
1271 if (gtknode->contact_expanded) | |
7620 | 1272 gaim_gtk_blist_collapse_contact_cb(NULL, node); |
1273 else | |
1274 gaim_gtk_blist_expand_contact_cb(NULL, node); | |
1275 handled = TRUE; | |
8143 | 1276 |
1277 /* Double middle click gets info */ | |
1278 } else if ((event->button == 2) && (event->type == GDK_2BUTTON_PRESS) && | |
1279 ((GAIM_BLIST_NODE_IS_CONTACT(node)) || (GAIM_BLIST_NODE_IS_BUDDY(node)))) { | |
7620 | 1280 GaimBuddy *b; |
1281 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1282 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1283 else | |
1284 b = (GaimBuddy *)node; | |
1285 | |
7956 | 1286 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5228 | 1287 if (prpl != NULL) |
1288 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
1289 | |
8143 | 1290 if (prpl && prpl_info->get_info) |
1291 serv_get_info(b->account->gc, b->name); | |
1292 handled = TRUE; | |
5228 | 1293 } |
1294 | |
8143 | 1295 #if (1) |
1296 /* | |
10814
364a2ef907ae
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10780
diff
changeset
|
1297 * This code only exists because GTK+ doesn't work. If we return |
8143 | 1298 * FALSE here, as would be normal the event propoagates down and |
1299 * somehow gets interpreted as the start of a drag event. | |
1300 * | |
1301 * Um, isn't it _normal_ to return TRUE here? Since the event | |
1302 * was handled? --Mark | |
1303 */ | |
7620 | 1304 if(handled) { |
1305 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1306 gtk_tree_selection_select_path(sel, path); | |
1307 gtk_tree_path_free(path); | |
1308 return TRUE; | |
1309 } | |
5228 | 1310 #endif |
7753 | 1311 gtk_tree_path_free(path); |
8143 | 1312 |
7620 | 1313 return FALSE; |
5228 | 1314 } |
1315 | |
8143 | 1316 static gboolean |
1317 gaim_gtk_blist_popup_menu_cb(GtkWidget *tv, void *user_data) | |
1318 { | |
1319 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1320 GValue val; |
8143 | 1321 GtkTreeIter iter; |
1322 GtkTreeSelection *sel; | |
1323 gboolean handled = FALSE; | |
1324 | |
1325 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1326 if (!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1327 return FALSE; | |
1328 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1329 val.g_type = 0; |
8143 | 1330 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), |
1331 &iter, NODE_COLUMN, &val); | |
1332 node = g_value_get_pointer(&val); | |
1333 | |
1334 /* Shift+F10 draws a context menu */ | |
1335 handled = gaim_gtk_blist_show_context_menu(node, gaim_gtk_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME); | |
1336 | |
1337 return handled; | |
1338 } | |
1339 | |
11796 | 1340 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item) |
1341 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1342 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1343 |
11796 | 1344 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", |
1345 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1346 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1347 gaim_gtk_clear_cursor(gtkblist->window); |
11796 | 1348 } |
1349 | |
12656 | 1350 static void gaim_gtk_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item) |
1351 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1352 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12656 | 1353 |
1354 gaim_prefs_set_bool("/gaim/gtk/blist/show_idle_time", | |
1355 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
1356 | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1357 gaim_gtk_clear_cursor(gtkblist->window); |
12656 | 1358 } |
1359 | |
5228 | 1360 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) |
1361 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1362 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1363 |
7620 | 1364 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", |
1365 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1366 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1367 gaim_gtk_clear_cursor(gtkblist->window); |
5228 | 1368 } |
1369 | |
1370 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, | |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1371 GtkWidget *checkitem) |
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1372 { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1373 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
5228 | 1374 |
7620 | 1375 gaim_prefs_set_bool("/gaim/gtk/blist/show_offline_buddies", |
1376 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem))); | |
5228 | 1377 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1378 gaim_gtk_clear_cursor(gtkblist->window); |
5228 | 1379 } |
1380 | |
10074 | 1381 static void gaim_gtk_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item) |
1382 { | |
1383 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(item)->active); | |
1384 } | |
1385 | |
12816 | 1386 static void |
1387 gaim_gtk_blist_mute_pref_cb(const char *name, GaimPrefType type, | |
1388 gconstpointer value, gpointer data) | |
10074 | 1389 { |
1390 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(gtkblist->ift, | |
1391 N_("/Tools/Mute Sounds"))), (gboolean)GPOINTER_TO_INT(value)); | |
1392 } | |
1393 | |
12816 | 1394 static void |
1395 gaim_gtk_blist_sound_method_pref_cb(const char *name, GaimPrefType type, | |
1396 gconstpointer value, gpointer data) | |
10074 | 1397 { |
1398 gboolean sensitive = TRUE; | |
1399 | |
1400 if(!strcmp(value, "none")) | |
1401 sensitive = FALSE; | |
1402 | |
1403 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), sensitive); | |
1404 } | |
1405 | |
8089 | 1406 static void |
1407 add_buddies_from_vcard(const char *prpl_id, GaimGroup *group, GList *list, | |
1408 const char *alias) | |
1409 { | |
1410 GList *l; | |
1411 GaimAccount *account = NULL; | |
1412 GaimConnection *gc; | |
1413 | |
1414 if (list == NULL) | |
1415 return; | |
1416 | |
1417 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
1418 { | |
1419 gc = (GaimConnection *)l->data; | |
1420 account = gaim_connection_get_account(gc); | |
1421 | |
1422 if (!strcmp(gaim_account_get_protocol_id(account), prpl_id)) | |
1423 break; | |
1424 | |
1425 account = NULL; | |
1426 } | |
1427 | |
1428 if (account != NULL) | |
1429 { | |
1430 for (l = list; l != NULL; l = l->next) | |
1431 { | |
1432 gaim_blist_request_add_buddy(account, l->data, | |
1433 (group ? group->name : NULL), | |
1434 alias); | |
1435 } | |
1436 } | |
1437 | |
1438 g_list_foreach(list, (GFunc)g_free, NULL); | |
1439 g_list_free(list); | |
1440 } | |
1441 | |
1442 static gboolean | |
1443 parse_vcard(const char *vcard, GaimGroup *group) | |
1444 { | |
1445 char *temp_vcard; | |
1446 char *s, *c; | |
1447 char *alias = NULL; | |
1448 GList *aims = NULL; | |
1449 GList *icqs = NULL; | |
1450 GList *yahoos = NULL; | |
1451 GList *msns = NULL; | |
1452 GList *jabbers = NULL; | |
1453 | |
1454 s = temp_vcard = g_strdup(vcard); | |
1455 | |
1456 while (*s != '\0' && strncmp(s, "END:vCard", strlen("END:vCard"))) | |
1457 { | |
1458 char *field, *value; | |
1459 | |
1460 field = s; | |
1461 | |
1462 /* Grab the field */ | |
1463 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ':') | |
1464 s++; | |
1465 | |
1466 if (*s == '\r') s++; | |
1467 if (*s == '\n') | |
1468 { | |
1469 s++; | |
1470 continue; | |
1471 } | |
1472 | |
1473 if (*s != '\0') *s++ = '\0'; | |
1474 | |
1475 if ((c = strchr(field, ';')) != NULL) | |
1476 *c = '\0'; | |
1477 | |
1478 /* Proceed to the end of the line */ | |
1479 value = s; | |
1480 | |
1481 while (*s != '\r' && *s != '\n' && *s != '\0') | |
1482 s++; | |
1483 | |
1484 if (*s == '\r') *s++ = '\0'; | |
1485 if (*s == '\n') *s++ = '\0'; | |
1486 | |
1487 /* We only want to worry about a few fields here. */ | |
1488 if (!strcmp(field, "FN")) | |
1489 alias = g_strdup(value); | |
1490 else if (!strcmp(field, "X-AIM") || !strcmp(field, "X-ICQ") || | |
1491 !strcmp(field, "X-YAHOO") || !strcmp(field, "X-MSN") || | |
1492 !strcmp(field, "X-JABBER")) | |
1493 { | |
1494 char **values = g_strsplit(value, ":", 0); | |
1495 char **im; | |
1496 | |
1497 for (im = values; *im != NULL; im++) | |
1498 { | |
1499 if (!strcmp(field, "X-AIM")) | |
1500 aims = g_list_append(aims, g_strdup(*im)); | |
1501 else if (!strcmp(field, "X-ICQ")) | |
1502 icqs = g_list_append(icqs, g_strdup(*im)); | |
1503 else if (!strcmp(field, "X-YAHOO")) | |
1504 yahoos = g_list_append(yahoos, g_strdup(*im)); | |
1505 else if (!strcmp(field, "X-MSN")) | |
1506 msns = g_list_append(msns, g_strdup(*im)); | |
1507 else if (!strcmp(field, "X-JABBER")) | |
1508 jabbers = g_list_append(jabbers, g_strdup(*im)); | |
1509 } | |
1510 | |
1511 g_strfreev(values); | |
1512 } | |
1513 } | |
1514 | |
1515 g_free(temp_vcard); | |
1516 | |
1517 if (aims == NULL && icqs == NULL && yahoos == NULL && | |
1518 msns == NULL && jabbers == NULL) | |
1519 { | |
14035 | 1520 g_free(alias); |
8089 | 1521 |
1522 return FALSE; | |
1523 } | |
1524 | |
1525 add_buddies_from_vcard("prpl-oscar", group, aims, alias); | |
1526 add_buddies_from_vcard("prpl-oscar", group, icqs, alias); | |
1527 add_buddies_from_vcard("prpl-yahoo", group, yahoos, alias); | |
1528 add_buddies_from_vcard("prpl-msn", group, msns, alias); | |
1529 add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); | |
1530 | |
14035 | 1531 g_free(alias); |
8089 | 1532 |
1533 return TRUE; | |
1534 } | |
1535 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1536 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1537 static void gaim_gtk_blist_drag_begin(GtkWidget *widget, |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1538 GdkDragContext *drag_context, gpointer user_data) |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1539 { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1540 gaim_gtk_blist_tooltip_destroy(); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1541 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1542 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1543 /* Unhook the tooltip-timeout since we don't want a tooltip |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1544 * to appear and obscure the dragging operation. |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1545 * This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1546 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1547 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1548 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1549 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1550 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1551 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1552 |
9811 | 1553 static void gaim_gtk_blist_drag_data_get_cb(GtkWidget *widget, |
1554 GdkDragContext *dc, | |
1555 GtkSelectionData *data, | |
1556 guint info, | |
1557 guint time, | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1558 gpointer null) |
5228 | 1559 { |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1560 |
8089 | 1561 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
1562 { | |
5228 | 1563 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); |
1564 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); | |
1565 GtkTreeIter iter; | |
1566 GaimBlistNode *node = NULL; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1567 GValue val; |
5273 | 1568 if(!sourcerow) |
1569 return; | |
5228 | 1570 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow); |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1571 val.g_type = 0; |
5228 | 1572 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
1573 node = g_value_get_pointer(&val); | |
1574 gtk_selection_data_set (data, | |
1575 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE), | |
1576 8, /* bits */ | |
1577 (void*)&node, | |
1578 sizeof (node)); | |
5273 | 1579 |
5228 | 1580 gtk_tree_path_free(sourcerow); |
1581 } | |
8089 | 1582 else if (data->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
1583 { | |
7706 | 1584 GtkTreeRowReference *ref; |
1585 GtkTreePath *sourcerow; | |
1586 GtkTreeIter iter; | |
1587 GaimBlistNode *node = NULL; | |
1588 GaimBuddy *buddy; | |
1589 GaimConnection *gc; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1590 GValue val; |
7706 | 1591 GString *str; |
1592 const char *protocol; | |
1593 | |
1594 ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); | |
1595 sourcerow = gtk_tree_row_reference_get_path(ref); | |
1596 | |
1597 if (!sourcerow) | |
1598 return; | |
1599 | |
1600 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1601 sourcerow); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1602 val.g_type = 0; |
7706 | 1603 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, |
1604 NODE_COLUMN, &val); | |
1605 | |
1606 node = g_value_get_pointer(&val); | |
1607 | |
1608 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1609 { | |
1610 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
1611 } | |
1612 else if (!GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1613 { | |
1614 gtk_tree_path_free(sourcerow); | |
1615 return; | |
1616 } | |
1617 else | |
1618 { | |
1619 buddy = (GaimBuddy *)node; | |
1620 } | |
1621 | |
1622 gc = gaim_account_get_connection(buddy->account); | |
1623 | |
1624 if (gc == NULL) | |
1625 { | |
1626 gtk_tree_path_free(sourcerow); | |
1627 return; | |
1628 } | |
1629 | |
1630 protocol = | |
1631 GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(buddy->account, | |
1632 buddy); | |
1633 | |
1634 str = g_string_new(NULL); | |
1635 g_string_printf(str, | |
1636 "MIME-Version: 1.0\r\n" | |
1637 "Content-Type: application/x-im-contact\r\n" | |
1638 "X-IM-Protocol: %s\r\n" | |
1639 "X-IM-Username: %s\r\n", | |
1640 protocol, | |
1641 buddy->name); | |
1642 | |
1643 if (buddy->alias != NULL) | |
1644 { | |
1645 g_string_append_printf(str, | |
1646 "X-IM-Alias: %s\r\n", | |
1647 buddy->alias); | |
1648 } | |
1649 | |
1650 str = g_string_append(str, "\r\n"); | |
1651 | |
1652 gtk_selection_data_set(data, | |
1653 gdk_atom_intern("application/x-im-contact", FALSE), | |
1654 8, /* bits */ | |
14035 | 1655 (const guchar *)str->str, |
1656 strlen(str->str) + 1); | |
1657 | |
1658 g_string_free(str, TRUE); | |
7706 | 1659 gtk_tree_path_free(sourcerow); |
1660 } | |
5228 | 1661 } |
1662 | |
1663 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
1664 GtkSelectionData *sd, guint info, guint t) | |
7620 | 1665 { |
13832
d1fdde7cfc0a
[gaim-migrate @ 16281]
Richard Laager <rlaager@wiktel.com>
parents:
13819
diff
changeset
|
1666 if (gtkblist->drag_timeout) { |
d1fdde7cfc0a
[gaim-migrate @ 16281]
Richard Laager <rlaager@wiktel.com>
parents:
13819
diff
changeset
|
1667 g_source_remove(gtkblist->drag_timeout); |
d1fdde7cfc0a
[gaim-migrate @ 16281]
Richard Laager <rlaager@wiktel.com>
parents:
13819
diff
changeset
|
1668 gtkblist->drag_timeout = 0; |
d1fdde7cfc0a
[gaim-migrate @ 16281]
Richard Laager <rlaager@wiktel.com>
parents:
13819
diff
changeset
|
1669 } |
d1fdde7cfc0a
[gaim-migrate @ 16281]
Richard Laager <rlaager@wiktel.com>
parents:
13819
diff
changeset
|
1670 |
5228 | 1671 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) { |
1672 GaimBlistNode *n = NULL; | |
1673 GtkTreePath *path = NULL; | |
1674 GtkTreeViewDropPosition position; | |
1675 memcpy(&n, sd->data, sizeof(n)); | |
1676 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) { | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1677 /* if we're here, I think it means the drop is ok */ |
7642 | 1678 GtkTreeIter iter; |
5228 | 1679 GaimBlistNode *node; |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1680 GValue val; |
7620 | 1681 struct _gaim_gtk_blist_node *gtknode; |
1682 | |
1683 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1684 &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1685 val.g_type = 0; |
7620 | 1686 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), |
1687 &iter, NODE_COLUMN, &val); | |
5228 | 1688 node = g_value_get_pointer(&val); |
7620 | 1689 gtknode = node->ui_data; |
1690 | |
1691 if (GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
1692 GaimContact *c = (GaimContact*)n; | |
1693 if (GAIM_BLIST_NODE_IS_CONTACT(node) && gtknode->contact_expanded) { | |
1694 gaim_blist_merge_contact(c, node); | |
1695 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1696 GAIM_BLIST_NODE_IS_CHAT(node)) { |
5228 | 1697 switch(position) { |
1698 case GTK_TREE_VIEW_DROP_AFTER: | |
1699 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
7620 | 1700 gaim_blist_add_contact(c, (GaimGroup*)node->parent, |
1701 node); | |
1702 break; | |
1703 case GTK_TREE_VIEW_DROP_BEFORE: | |
1704 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1705 gaim_blist_add_contact(c, (GaimGroup*)node->parent, | |
1706 node->prev); | |
1707 break; | |
1708 } | |
1709 } else if(GAIM_BLIST_NODE_IS_GROUP(node)) { | |
1710 gaim_blist_add_contact(c, (GaimGroup*)node, NULL); | |
1711 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1712 gaim_blist_merge_contact(c, node); | |
1713 } | |
1714 } else if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
1715 GaimBuddy *b = (GaimBuddy*)n; | |
1716 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1717 switch(position) { | |
1718 case GTK_TREE_VIEW_DROP_AFTER: | |
1719 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1720 gaim_blist_add_buddy(b, (GaimContact*)node->parent, | |
1721 (GaimGroup*)node->parent->parent, node); | |
5228 | 1722 break; |
1723 case GTK_TREE_VIEW_DROP_BEFORE: | |
1724 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
7620 | 1725 gaim_blist_add_buddy(b, (GaimContact*)node->parent, |
1726 (GaimGroup*)node->parent->parent, | |
1727 node->prev); | |
5228 | 1728 break; |
1729 } | |
7620 | 1730 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
1731 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node->parent, | |
1732 NULL); | |
5228 | 1733 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
7620 | 1734 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node, NULL); |
1735 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1736 if(gtknode->contact_expanded) { | |
1737 switch(position) { | |
1738 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1739 case GTK_TREE_VIEW_DROP_AFTER: | |
1740 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1741 gaim_blist_add_buddy(b, (GaimContact*)node, | |
1742 (GaimGroup*)node->parent, NULL); | |
1743 break; | |
1744 case GTK_TREE_VIEW_DROP_BEFORE: | |
1745 gaim_blist_add_buddy(b, NULL, | |
1746 (GaimGroup*)node->parent, node->prev); | |
1747 break; | |
1748 } | |
1749 } else { | |
1750 switch(position) { | |
1751 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1752 case GTK_TREE_VIEW_DROP_AFTER: | |
1753 gaim_blist_add_buddy(b, NULL, | |
1754 (GaimGroup*)node->parent, NULL); | |
1755 break; | |
1756 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1757 case GTK_TREE_VIEW_DROP_BEFORE: | |
1758 gaim_blist_add_buddy(b, NULL, | |
1759 (GaimGroup*)node->parent, node->prev); | |
1760 break; | |
1761 } | |
1762 } | |
5228 | 1763 } |
5234 | 1764 } else if (GAIM_BLIST_NODE_IS_CHAT(n)) { |
7620 | 1765 GaimChat *chat = (GaimChat *)n; |
1766 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1767 switch(position) { | |
1768 case GTK_TREE_VIEW_DROP_AFTER: | |
1769 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1770 case GTK_TREE_VIEW_DROP_BEFORE: | |
1771 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1772 gaim_blist_add_chat(chat, | |
1773 (GaimGroup*)node->parent->parent, | |
13542
2235ada6c746
[gaim-migrate @ 15919]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13540
diff
changeset
|
1774 node->parent); |
7620 | 1775 break; |
1776 } | |
1777 } else if(GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1778 GAIM_BLIST_NODE_IS_CHAT(node)) { |
1779 switch(position) { | |
1780 case GTK_TREE_VIEW_DROP_AFTER: | |
1781 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
7620 | 1782 gaim_blist_add_chat(chat, (GaimGroup*)node->parent, node); |
5234 | 1783 break; |
1784 case GTK_TREE_VIEW_DROP_BEFORE: | |
1785 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
7620 | 1786 gaim_blist_add_chat(chat, (GaimGroup*)node->parent, node->prev); |
5234 | 1787 break; |
1788 } | |
1789 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7620 | 1790 gaim_blist_add_chat(chat, (GaimGroup*)node, NULL); |
5234 | 1791 } |
5228 | 1792 } else if (GAIM_BLIST_NODE_IS_GROUP(n)) { |
7620 | 1793 GaimGroup *g = (GaimGroup*)n; |
5228 | 1794 if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
1795 switch (position) { | |
1796 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1797 case GTK_TREE_VIEW_DROP_AFTER: | |
1798 gaim_blist_add_group(g, node); | |
1799 break; | |
1800 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1801 case GTK_TREE_VIEW_DROP_BEFORE: | |
1802 gaim_blist_add_group(g, node->prev); | |
1803 break; | |
1804 } | |
7620 | 1805 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
1806 gaim_blist_add_group(g, node->parent->parent); | |
1807 } else if(GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1808 GAIM_BLIST_NODE_IS_CHAT(node)) { |
5228 | 1809 gaim_blist_add_group(g, node->parent); |
1810 } | |
1811 } | |
1812 | |
1813 gtk_tree_path_free(path); | |
7620 | 1814 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5228 | 1815 } |
1816 } | |
7706 | 1817 else if (sd->target == gdk_atom_intern("application/x-im-contact", |
1818 FALSE) && sd->data) | |
1819 { | |
1820 GaimGroup *group = NULL; | |
1821 GtkTreePath *path = NULL; | |
1822 GtkTreeViewDropPosition position; | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7706
diff
changeset
|
1823 GaimAccount *account; |
7706 | 1824 char *protocol = NULL; |
1825 char *username = NULL; | |
1826 char *alias = NULL; | |
1827 | |
1828 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
1829 x, y, &path, &position)) | |
1830 { | |
1831 GtkTreeIter iter; | |
1832 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1833 GValue val; |
7706 | 1834 |
1835 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1836 &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1837 val.g_type = 0; |
7706 | 1838 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), |
1839 &iter, NODE_COLUMN, &val); | |
1840 node = g_value_get_pointer(&val); | |
1841 | |
1842 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1843 { | |
1844 group = (GaimGroup *)node->parent->parent; | |
1845 } | |
1846 else if (GAIM_BLIST_NODE_IS_CHAT(node) || | |
1847 GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1848 { | |
1849 group = (GaimGroup *)node->parent; | |
1850 } | |
1851 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
1852 { | |
1853 group = (GaimGroup *)node; | |
1854 } | |
1855 } | |
1856 | |
11137 | 1857 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7706
diff
changeset
|
1858 &protocol, &username, &alias)) |
7706 | 1859 { |
1860 if (account == NULL) | |
1861 { | |
1862 gaim_notify_error(NULL, NULL, | |
1863 _("You are not currently signed on with an account that " | |
1864 "can add that buddy."), NULL); | |
1865 } | |
1866 else | |
1867 { | |
1868 gaim_blist_request_add_buddy(account, username, | |
1869 (group ? group->name : NULL), | |
1870 alias); | |
1871 } | |
1872 } | |
1873 | |
14035 | 1874 g_free(username); |
1875 g_free(protocol); | |
1876 g_free(alias); | |
7706 | 1877 |
1878 if (path != NULL) | |
1879 gtk_tree_path_free(path); | |
1880 | |
1881 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
1882 } | |
8089 | 1883 else if (sd->target == gdk_atom_intern("text/x-vcard", FALSE) && sd->data) |
1884 { | |
1885 gboolean result; | |
1886 GaimGroup *group = NULL; | |
1887 GtkTreePath *path = NULL; | |
1888 GtkTreeViewDropPosition position; | |
1889 | |
1890 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
1891 x, y, &path, &position)) | |
1892 { | |
1893 GtkTreeIter iter; | |
1894 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1895 GValue val; |
8089 | 1896 |
1897 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1898 &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1899 val.g_type = 0; |
8089 | 1900 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), |
1901 &iter, NODE_COLUMN, &val); | |
1902 node = g_value_get_pointer(&val); | |
1903 | |
1904 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1905 { | |
1906 group = (GaimGroup *)node->parent->parent; | |
1907 } | |
1908 else if (GAIM_BLIST_NODE_IS_CHAT(node) || | |
1909 GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1910 { | |
1911 group = (GaimGroup *)node->parent; | |
1912 } | |
1913 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
1914 { | |
1915 group = (GaimGroup *)node; | |
1916 } | |
1917 } | |
1918 | |
11137 | 1919 result = parse_vcard((const gchar *)sd->data, group); |
8089 | 1920 |
1921 gtk_drag_finish(dc, result, (dc->action == GDK_ACTION_MOVE), t); | |
9525 | 1922 } else if (sd->target == gdk_atom_intern("text/uri-list", FALSE) && sd->data) { |
9495 | 1923 GtkTreePath *path = NULL; |
1924 GtkTreeViewDropPosition position; | |
1925 | |
1926 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
9811 | 1927 x, y, &path, &position)) |
9495 | 1928 { |
1929 GtkTreeIter iter; | |
1930 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1931 GValue val; |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1932 |
9495 | 1933 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), |
1934 &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1935 val.g_type = 0; |
9495 | 1936 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), |
1937 &iter, NODE_COLUMN, &val); | |
1938 node = g_value_get_pointer(&val); | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1939 |
9495 | 1940 if (GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CONTACT(node)) { |
1941 GaimBuddy *b = GAIM_BLIST_NODE_IS_BUDDY(node) ? (GaimBuddy*)node : gaim_contact_get_priority_buddy((GaimContact*)node); | |
10229 | 1942 gaim_dnd_file_manage(sd, b->account, b->name); |
1943 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
1944 } else { | |
1945 gtk_drag_finish(dc, FALSE, FALSE, t); | |
9495 | 1946 } |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1947 } |
8089 | 1948 } |
5228 | 1949 } |
1950 | |
10482 | 1951 static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(GaimBlistNode *node, |
1952 gboolean scaled, gboolean greyed) | |
1953 { | |
10483 | 1954 GdkPixbuf *buf, *ret = NULL; |
10482 | 1955 GdkPixbufLoader *loader; |
1956 GaimBuddyIcon *icon; | |
11137 | 1957 const guchar *data; |
1958 gsize len; | |
10482 | 1959 GaimBuddy *buddy = (GaimBuddy *)node; |
1960 | |
1961 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1962 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1963 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1964 buddy = (GaimBuddy*)node; | |
1965 } else { | |
1966 return NULL; | |
1967 } | |
1968 | |
1969 #if 0 | |
1970 if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) | |
1971 return NULL; | |
1972 #endif | |
1973 | |
1974 if (!(icon = gaim_buddy_get_icon(buddy))) | |
1975 if (!(icon = gaim_buddy_icons_find(buddy->account, buddy->name))) /* Not sure I like this...*/ | |
1976 return NULL; | |
1977 | |
1978 loader = gdk_pixbuf_loader_new(); | |
1979 data = gaim_buddy_icon_get_data(icon, &len); | |
1980 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1981 gdk_pixbuf_loader_close(loader, NULL); |
10482 | 1982 buf = gdk_pixbuf_loader_get_pixbuf(loader); |
1983 if (buf) | |
1984 g_object_ref(G_OBJECT(buf)); | |
1985 g_object_unref(G_OBJECT(loader)); | |
1986 | |
1987 if (buf) { | |
10544 | 1988 GaimAccount *account = gaim_buddy_get_account(buddy); |
1989 GaimPluginProtocolInfo *prpl_info = NULL; | |
1990 int orig_width, orig_height; | |
1991 int scale_width, scale_height; | |
1992 | |
1993 if(account && account->gc) | |
1994 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
1995 | |
10482 | 1996 if (greyed) { |
1997 GaimPresence *presence = gaim_buddy_get_presence(buddy); | |
1998 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | |
1999 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.0, FALSE); | |
2000 if (gaim_presence_is_idle(presence)) | |
2001 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.25, FALSE); | |
2002 } | |
2003 | |
10544 | 2004 /* i'd use the gaim_gtk_buddy_icon_get_scale_size() thing, |
2005 * but it won't tell me the original size, which I need for scaling | |
2006 * purposes */ | |
2007 scale_width = orig_width = gdk_pixbuf_get_width(buf); | |
2008 scale_height = orig_height = gdk_pixbuf_get_height(buf); | |
2009 | |
2010 gaim_buddy_icon_get_scale_size(prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); | |
2011 | |
10482 | 2012 if (scaled) { |
10544 | 2013 if(scale_height > scale_width) { |
2014 scale_width = 30.0 * (double)scale_width / (double)scale_height; | |
2015 scale_height = 30; | |
2016 } else { | |
2017 scale_height = 30.0 * (double)scale_height / (double)scale_width; | |
2018 scale_width = 30; | |
2019 } | |
2020 | |
2021 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 30, 30); | |
2022 gdk_pixbuf_fill(ret, 0x00000000); | |
2023 gdk_pixbuf_scale(buf, ret, (30-scale_width)/2, (30-scale_height)/2, scale_width, scale_height, (30-scale_width)/2, (30-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); | |
10483 | 2024 } else { |
2025 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); | |
2026 } | |
10544 | 2027 g_object_unref(G_OBJECT(buf)); |
10482 | 2028 } |
2029 | |
10483 | 2030 return ret; |
10482 | 2031 } |
2032 | |
11890 | 2033 struct tooltip_data { |
2034 PangoLayout *layout; | |
2035 GdkPixbuf *status_icon; | |
2036 GdkPixbuf *avatar; | |
11892 | 2037 int avatar_width; |
2038 int width; | |
2039 int height; | |
11890 | 2040 }; |
2041 | |
12530 | 2042 static struct tooltip_data * create_tip_for_node(GaimBlistNode *node, gboolean full) |
11890 | 2043 { |
12519 | 2044 char *tooltip_text = NULL; |
11890 | 2045 struct tooltip_data *td = g_new0(struct tooltip_data, 1); |
12519 | 2046 |
12530 | 2047 td->status_icon = gaim_gtk_blist_get_status_icon(node, GAIM_STATUS_ICON_LARGE); |
12971
7bd4dbf26c00
[gaim-migrate @ 15324]
Richard Laager <rlaager@wiktel.com>
parents:
12970
diff
changeset
|
2048 td->avatar = gaim_gtk_blist_get_buddy_icon(node, !full, FALSE); |
12530 | 2049 tooltip_text = gaim_get_tooltip_text(node, full); |
11890 | 2050 td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); |
12940
b25f48c9f6d7
[gaim-migrate @ 15293]
Richard Laager <rlaager@wiktel.com>
parents:
12919
diff
changeset
|
2051 pango_layout_set_markup(td->layout, tooltip_text, -1); |
11890 | 2052 pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD); |
2053 pango_layout_set_width(td->layout, 300000); | |
11983 | 2054 |
11892 | 2055 pango_layout_get_size (td->layout, &td->width, &td->height); |
2056 td->width = PANGO_PIXELS(td->width) + 38 + 8; | |
12530 | 2057 td->height = MAX(PANGO_PIXELS(td->height + 4) + 8, 38); |
11892 | 2058 |
2059 if(td->avatar) { | |
2060 td->avatar_width = gdk_pixbuf_get_width(td->avatar); | |
2061 td->width += td->avatar_width + 8; | |
2062 td->height = MAX(td->height, gdk_pixbuf_get_height(td->avatar) + 8); | |
2063 } | |
11890 | 2064 |
12649
773f694e83bf
[gaim-migrate @ 14987]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12601
diff
changeset
|
2065 g_free(tooltip_text); |
11890 | 2066 return td; |
2067 } | |
2068 | |
5234 | 2069 static void gaim_gtk_blist_paint_tip(GtkWidget *widget, GdkEventExpose *event, GaimBlistNode *node) |
5228 | 2070 { |
2071 GtkStyle *style; | |
11892 | 2072 int current_height, max_width; |
11890 | 2073 GList *l; |
2074 | |
2075 if(gtkblist->tooltipdata == NULL) | |
7620 | 2076 return; |
2077 | |
11890 | 2078 style = gtkblist->tipwindow->style; |
2079 gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, | |
2080 NULL, gtkblist->tipwindow, "tooltip", 0, 0, -1, -1); | |
2081 | |
11892 | 2082 max_width = 0; |
2083 for(l = gtkblist->tooltipdata; l; l = l->next) | |
2084 { | |
2085 struct tooltip_data *td = l->data; | |
2086 max_width = MAX(max_width, td->width); | |
2087 } | |
2088 | |
12519 | 2089 current_height = 4; |
11890 | 2090 for(l = gtkblist->tooltipdata; l; l = l->next) |
10482 | 2091 { |
11890 | 2092 struct tooltip_data *td = l->data; |
5228 | 2093 |
2094 #if GTK_CHECK_VERSION(2,2,0) | |
11890 | 2095 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
12530 | 2096 0, 0, 4, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
11890 | 2097 if(td->avatar) |
2098 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, | |
12519 | 2099 td->avatar, 0, 0, max_width - (td->avatar_width + 4), current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
5228 | 2100 #else |
12519 | 2101 gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
11890 | 2102 if(td->avatar) |
2103 gdk_pixbuf_render_to_drawable(td->avatar, | |
11983 | 2104 GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, |
12530 | 2105 max_width - (td->avatar_width + 4), |
12519 | 2106 current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
5228 | 2107 #endif |
2108 | |
11890 | 2109 gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
12519 | 2110 NULL, gtkblist->tipwindow, "tooltip", 38 + 4, current_height, td->layout); |
11890 | 2111 |
11895 | 2112 current_height += td->height; |
2113 | |
12530 | 2114 if(l->next) |
2115 gtk_paint_hline(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, NULL, NULL, NULL, 4, max_width - 4, current_height-6); | |
2116 | |
11890 | 2117 } |
5228 | 2118 } |
2119 | |
8254 | 2120 static void gaim_gtk_blist_tooltip_destroy() |
2121 { | |
11890 | 2122 while(gtkblist->tooltipdata) { |
2123 struct tooltip_data *td = gtkblist->tooltipdata->data; | |
2124 | |
2125 if(td->avatar) | |
2126 g_object_unref(td->avatar); | |
2127 if(td->status_icon) | |
2128 g_object_unref(td->status_icon); | |
2129 g_object_unref(td->layout); | |
2130 g_free(td); | |
2131 gtkblist->tooltipdata = g_list_delete_link(gtkblist->tooltipdata, gtkblist->tooltipdata); | |
2132 } | |
11636 | 2133 |
8254 | 2134 if (gtkblist->tipwindow == NULL) |
2135 return; | |
2136 | |
2137 gtk_widget_destroy(gtkblist->tipwindow); | |
2138 gtkblist->tipwindow = NULL; | |
2139 } | |
2140 | |
10354 | 2141 static gboolean gaim_gtk_blist_expand_timeout(GtkWidget *tv) |
2142 { | |
2143 GtkTreePath *path; | |
2144 GtkTreeIter iter; | |
2145 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2146 GValue val; |
10354 | 2147 struct _gaim_gtk_blist_node *gtknode; |
2148 | |
2149 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y, &path, NULL, NULL, NULL)) | |
2150 return FALSE; | |
2151 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2152 val.g_type = 0; |
10354 | 2153 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
2154 node = g_value_get_pointer(&val); | |
2155 | |
10504 | 2156 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) { |
2157 gtk_tree_path_free(path); | |
10354 | 2158 return FALSE; |
10504 | 2159 } |
10354 | 2160 |
2161 gtknode = node->ui_data; | |
2162 | |
2163 if (!gtknode->contact_expanded) { | |
2164 GtkTreeIter i; | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2165 |
10354 | 2166 gaim_gtk_blist_expand_contact_cb(NULL, node); |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2167 |
10354 | 2168 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->contact_rect); |
2169 gdk_drawable_get_size(GDK_DRAWABLE(tv->window), &(gtkblist->contact_rect.width), NULL); | |
2170 gtkblist->mouseover_contact = node; | |
2171 gtk_tree_path_down (path); | |
2172 while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) { | |
2173 GdkRectangle rect; | |
2174 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &rect); | |
2175 gtkblist->contact_rect.height += rect.height; | |
2176 gtk_tree_path_next(path); | |
2177 } | |
2178 } | |
2179 gtk_tree_path_free(path); | |
2180 return FALSE; | |
2181 } | |
2182 | |
11890 | 2183 static gboolean buddy_is_displayable(GaimBuddy *buddy) |
2184 { | |
11910 | 2185 struct _gaim_gtk_blist_node *gtknode; |
2186 | |
2187 if(!buddy) | |
2188 return FALSE; | |
2189 | |
2190 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
2191 | |
2192 return (gaim_account_is_connected(buddy->account) && | |
11890 | 2193 (gaim_presence_is_online(buddy->presence) || |
11910 | 2194 (gtknode && gtknode->recent_signonoff) || |
2195 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies") || | |
2196 gaim_blist_node_get_bool((GaimBlistNode*)buddy, "show_offline"))); | |
11890 | 2197 } |
2198 | |
5228 | 2199 static gboolean gaim_gtk_blist_tooltip_timeout(GtkWidget *tv) |
2200 { | |
2201 GtkTreePath *path; | |
2202 GtkTreeIter iter; | |
2203 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2204 GValue val; |
9869 | 2205 int scr_w, scr_h, w, h, x, y; |
2206 #if GTK_CHECK_VERSION(2,2,0) | |
2207 int mon_num; | |
2208 GdkScreen *screen = NULL; | |
2209 #endif | |
7636 | 2210 gboolean tooltip_top = FALSE; |
2211 struct _gaim_gtk_blist_node *gtknode; | |
9773 | 2212 GdkRectangle mon_size; |
5228 | 2213 |
11636 | 2214 /* |
2215 * Attempt to free the previous tooltip. I have a feeling | |
2216 * this is never needed... but just in case. | |
2217 */ | |
2218 gaim_gtk_blist_tooltip_destroy(); | |
2219 | |
7636 | 2220 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y, &path, NULL, NULL, NULL)) |
5228 | 2221 return FALSE; |
2222 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2223 val.g_type = 0; |
5228 | 2224 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
2225 node = g_value_get_pointer(&val); | |
7620 | 2226 |
10504 | 2227 gtk_tree_path_free(path); |
2228 | |
11890 | 2229 gtkblist->tipwindow = gtk_window_new(GTK_WINDOW_POPUP); |
2230 | |
2231 if(GAIM_BLIST_NODE_IS_CHAT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
12530 | 2232 struct tooltip_data *td = create_tip_for_node(node, TRUE); |
11890 | 2233 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); |
11892 | 2234 w = td->width; |
12941
586f2b04e0c5
[gaim-migrate @ 15294]
Richard Laager <rlaager@wiktel.com>
parents:
12940
diff
changeset
|
2235 h = td->height; |
11890 | 2236 } else if(GAIM_BLIST_NODE_IS_CONTACT(node)) { |
2237 GaimBlistNode *child; | |
11988 | 2238 GaimBuddy *b = gaim_contact_get_priority_buddy((GaimContact *)node); |
11890 | 2239 w = h = 0; |
12530 | 2240 for(child = node->child; child; child = child->next) |
11890 | 2241 { |
2242 if(GAIM_BLIST_NODE_IS_BUDDY(child) && buddy_is_displayable((GaimBuddy*)child)) { | |
12530 | 2243 struct tooltip_data *td = create_tip_for_node(child, (b == (GaimBuddy*)child)); |
11988 | 2244 if (b == (GaimBuddy *)child) { |
2245 gtkblist->tooltipdata = g_list_prepend(gtkblist->tooltipdata, td); | |
2246 } else { | |
2247 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); | |
2248 } | |
11892 | 2249 w = MAX(w, td->width); |
2250 h += td->height; | |
11890 | 2251 } |
2252 } | |
2253 } else { | |
2254 gtk_widget_destroy(gtkblist->tipwindow); | |
11892 | 2255 gtkblist->tipwindow = NULL; |
5234 | 2256 return FALSE; |
11890 | 2257 } |
2258 | |
2259 if (gtkblist->tooltipdata == NULL) { | |
2260 gtk_widget_destroy(gtkblist->tipwindow); | |
11892 | 2261 gtkblist->tipwindow = NULL; |
11890 | 2262 return FALSE; |
2263 } | |
5228 | 2264 |
7636 | 2265 gtknode = node->ui_data; |
2266 | |
5234 | 2267 gtk_widget_set_app_paintable(gtkblist->tipwindow, TRUE); |
2268 gtk_window_set_resizable(GTK_WINDOW(gtkblist->tipwindow), FALSE); | |
2269 gtk_widget_set_name(gtkblist->tipwindow, "gtk-tooltips"); | |
2270 g_signal_connect(G_OBJECT(gtkblist->tipwindow), "expose_event", | |
11890 | 2271 G_CALLBACK(gaim_gtk_blist_paint_tip), NULL); |
5234 | 2272 gtk_widget_ensure_style (gtkblist->tipwindow); |
7837 | 2273 |
9773 | 2274 |
9869 | 2275 #if GTK_CHECK_VERSION(2,2,0) |
9773 | 2276 gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL); |
2277 mon_num = gdk_screen_get_monitor_at_point(screen, x, y); | |
2278 gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size); | |
2279 | |
2280 scr_w = mon_size.width + mon_size.x; | |
2281 scr_h = mon_size.height + mon_size.y; | |
9869 | 2282 #else |
2283 scr_w = gdk_screen_width(); | |
2284 scr_h = gdk_screen_height(); | |
2285 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
2286 mon_size.x = 0; | |
2287 mon_size.y = 0; | |
2288 #endif | |
9773 | 2289 |
9869 | 2290 #if GTK_CHECK_VERSION(2,2,0) |
10046 | 2291 if (w > mon_size.width) |
9773 | 2292 w = mon_size.width - 10; |
2293 | |
10046 | 2294 if (h > mon_size.height) |
9773 | 2295 h = mon_size.height - 10; |
9869 | 2296 #endif |
9773 | 2297 |
5234 | 2298 if (GTK_WIDGET_NO_WINDOW(gtkblist->window)) |
2299 y+=gtkblist->window->allocation.y; | |
2300 | |
2301 x -= ((w >> 1) + 4); | |
5228 | 2302 |
7636 | 2303 if ((y + h + 4) > scr_h || tooltip_top) |
7620 | 2304 y = y - h - 5; |
5234 | 2305 else |
2306 y = y + 6; | |
7620 | 2307 |
9773 | 2308 if (y < mon_size.y) |
2309 y = mon_size.y; | |
2310 | |
2311 if (y != mon_size.y) { | |
7719 | 2312 if ((x + w) > scr_w) |
2313 x -= (x + w + 5) - scr_w; | |
9773 | 2314 else if (x < mon_size.x) |
2315 x = mon_size.x; | |
7719 | 2316 } else { |
2317 x -= (w / 2 + 10); | |
9773 | 2318 if (x < mon_size.x) |
2319 x = mon_size.x; | |
7719 | 2320 } |
2321 | |
5234 | 2322 gtk_widget_set_size_request(gtkblist->tipwindow, w, h); |
2323 gtk_window_move(GTK_WINDOW(gtkblist->tipwindow), x, y); | |
2324 gtk_widget_show(gtkblist->tipwindow); | |
5228 | 2325 |
2326 return FALSE; | |
2327 } | |
2328 | |
10354 | 2329 static gboolean gaim_gtk_blist_drag_motion_cb(GtkWidget *tv, GdkDragContext *drag_context, |
2330 gint x, gint y, guint time, gpointer user_data) | |
2331 { | |
2332 GtkTreePath *path; | |
2333 int delay; | |
2334 | |
12679 | 2335 /* |
2336 * When dragging a buddy into a contact, this is the delay before | |
2337 * the contact auto-expands. | |
2338 */ | |
2339 delay = 900; | |
10354 | 2340 |
2341 if (gtkblist->drag_timeout) { | |
2342 if ((y > gtkblist->tip_rect.y) && ((y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) | |
2343 return FALSE; | |
2344 /* We've left the cell. Remove the timeout and create a new one below */ | |
2345 g_source_remove(gtkblist->drag_timeout); | |
2346 } | |
2347 | |
2348 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), x, y, &path, NULL, NULL, NULL); | |
2349 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->tip_rect); | |
2350 | |
2351 if (path) | |
2352 gtk_tree_path_free(path); | |
2353 gtkblist->drag_timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_expand_timeout, tv); | |
2354 | |
2355 if (gtkblist->mouseover_contact) { | |
2356 if ((y < gtkblist->contact_rect.y) || ((y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2357 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2358 gtkblist->mouseover_contact = NULL; | |
2359 } | |
2360 } | |
2361 | |
2362 return FALSE; | |
2363 } | |
2364 | |
5228 | 2365 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null) |
2366 { | |
2367 GtkTreePath *path; | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2368 int delay; |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2369 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2370 delay = gaim_prefs_get_int("/gaim/gtk/blist/tooltip_delay"); |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2371 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2372 if (delay == 0) |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2373 return FALSE; |
8083 | 2374 |
5228 | 2375 if (gtkblist->timeout) { |
7636 | 2376 if ((event->y > gtkblist->tip_rect.y) && ((event->y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) |
5228 | 2377 return FALSE; |
2378 /* We've left the cell. Remove the timeout and create a new one below */ | |
8254 | 2379 gaim_gtk_blist_tooltip_destroy(); |
5228 | 2380 g_source_remove(gtkblist->timeout); |
2381 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2382 |
5228 | 2383 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL); |
7636 | 2384 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->tip_rect); |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2385 |
5228 | 2386 if (path) |
2387 gtk_tree_path_free(path); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2388 gtkblist->timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_tooltip_timeout, tv); |
7636 | 2389 |
2390 if (gtkblist->mouseover_contact) { | |
2391 if ((event->y < gtkblist->contact_rect.y) || ((event->y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2392 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2393 gtkblist->mouseover_contact = NULL; | |
2394 } | |
2395 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2396 |
5228 | 2397 return FALSE; |
2398 } | |
2399 | |
2400 static void gaim_gtk_blist_leave_cb (GtkWidget *w, GdkEventCrossing *e, gpointer n) | |
2401 { | |
8083 | 2402 |
5228 | 2403 if (gtkblist->timeout) { |
2404 g_source_remove(gtkblist->timeout); | |
2405 gtkblist->timeout = 0; | |
2406 } | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2407 |
10354 | 2408 if (gtkblist->drag_timeout) { |
2409 g_source_remove(gtkblist->drag_timeout); | |
2410 gtkblist->drag_timeout = 0; | |
2411 } | |
2412 | |
8254 | 2413 gaim_gtk_blist_tooltip_destroy(); |
7720 | 2414 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2415 if (gtkblist->mouseover_contact && |
9811 | 2416 !((e->x > gtkblist->contact_rect.x) && (e->x < (gtkblist->contact_rect.x + gtkblist->contact_rect.width)) && |
2417 (e->y > gtkblist->contact_rect.y) && (e->y < (gtkblist->contact_rect.y + gtkblist->contact_rect.height)))) { | |
2418 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
7636 | 2419 gtkblist->mouseover_contact = NULL; |
2420 } | |
5228 | 2421 } |
2422 | |
2423 static void | |
2424 toggle_debug(void) | |
2425 { | |
7620 | 2426 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", |
2427 !gaim_prefs_get_bool("/gaim/gtk/debug/enabled")); | |
5228 | 2428 } |
2429 | |
2430 | |
2431 /*************************************************** | |
2432 * Crap * | |
2433 ***************************************************/ | |
2434 static GtkItemFactoryEntry blist_menu[] = | |
2435 { | |
2436 /* Buddies menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2437 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>", NULL }, |
9714 | 2438 { N_("/Buddies/New Instant _Message..."), "<CTL>M", gaim_gtkdialogs_im, 0, "<StockItem>", GAIM_STOCK_IM }, |
8940 | 2439 { N_("/Buddies/Join a _Chat..."), "<CTL>C", gaim_gtk_blist_joinchat_show, 0, "<StockItem>", GAIM_STOCK_CHAT }, |
9714 | 2440 { N_("/Buddies/Get User _Info..."), "<CTL>I", gaim_gtkdialogs_info, 0, "<StockItem>", GAIM_STOCK_INFO }, |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
2441 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, "<StockItem>", GAIM_STOCK_LOG }, |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2442 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2443 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2444 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2445 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>", NULL }, |
12656 | 2446 { N_("/Buddies/Show Idle _Times"), NULL, gaim_gtk_blist_show_idle_time_cb, 1, "<CheckItem>", NULL }, |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2447 { N_("/Buddies/_Sort Buddies"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2448 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
7853 | 2449 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
2450 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | |
2451 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD }, | |
12799 | 2452 { "/Buddies/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
2453 { N_("/Buddies/_Quit"), "<CTL>Q", gaim_core_quit, 0, "<StockItem>", GTK_STOCK_QUIT }, |
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
2454 |
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
2455 /* Accounts menu */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2456 { N_("/_Accounts"), NULL, NULL, 0, "<Branch>", NULL }, |
12348
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
2457 { N_("/Accounts/Add\\/Edit"), "<CTL>A", gaim_gtk_accounts_window_show, 0, "<StockItem>", GAIM_STOCK_ACCOUNTS }, |
5228 | 2458 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2459 /* Tools */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2460 { N_("/_Tools"), NULL, NULL, 0, "<Branch>", NULL }, |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
2461 { N_("/Tools/Buddy _Pounces"), NULL, gaim_gtk_pounces_manager_show, 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
12163
f6f08fd1841a
[gaim-migrate @ 14464]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
2462 { N_("/Tools/Plu_gins"), "<CTL>U", gaim_gtk_plugin_dialog_show, 0, "<StockItem>", GAIM_STOCK_PLUGIN }, |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
2463 { N_("/Tools/Pr_eferences"), "<CTL>P", gaim_gtk_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, |
10694 | 2464 { N_("/Tools/Pr_ivacy"), NULL, gaim_gtk_privacy_dialog_show, 0, "<StockItem>", GTK_STOCK_DIALOG_ERROR }, |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2465 { "/Tools/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
10019
8cc6f0bfa215
[gaim-migrate @ 10943]
Luke Schierer <lschiere@pidgin.im>
parents:
10018
diff
changeset
|
2466 { N_("/Tools/_File Transfers"), "<CTL>T", gaim_show_xfer_dialog, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
10694 | 2467 { N_("/Tools/R_oom List"), NULL, gaim_gtk_roomlist_dialog_show, 0, "<StockItem>", GTK_STOCK_INDEX }, |
12334 | 2468 { N_("/Tools/System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2469 { "/Tools/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2470 { N_("/Tools/Mute _Sounds"), "<CTL>S", gaim_gtk_blist_mute_sounds_cb, 0, "<CheckItem>", NULL }, |
5228 | 2471 |
2472 /* Help */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2473 { N_("/_Help"), NULL, NULL, 0, "<Branch>", NULL }, |
5228 | 2474 { N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "<StockItem>", GTK_STOCK_HELP }, |
12333 | 2475 { N_("/Help/_Debug Window"), NULL, toggle_debug, 0, "<StockItem>", GAIM_STOCK_DEBUG }, |
9753 | 2476 { N_("/Help/_About"), NULL, gaim_gtkdialogs_about, 0, "<StockItem>", GAIM_STOCK_ABOUT }, |
5228 | 2477 }; |
2478 | |
2479 /********************************************************* | |
2480 * Private Utility functions * | |
2481 *********************************************************/ | |
2482 | |
12530 | 2483 static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full) |
5228 | 2484 { |
10475 | 2485 GString *str = g_string_new(""); |
5237 | 2486 GaimPlugin *prpl; |
2487 GaimPluginProtocolInfo *prpl_info = NULL; | |
10475 | 2488 char *tmp; |
2489 | |
2490 if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
2491 { | |
2492 GaimChat *chat; | |
2493 GList *cur; | |
5274 | 2494 struct proto_chat_entry *pce; |
10475 | 2495 char *name, *value; |
2496 | |
2497 chat = (GaimChat *)node; | |
7956 | 2498 prpl = gaim_find_prpl(gaim_account_get_protocol_id(chat->account)); |
5274 | 2499 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2500 | |
10475 | 2501 tmp = g_markup_escape_text(gaim_chat_get_name(chat), -1); |
2502 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2503 g_free(tmp); | |
2504 | |
2505 if (g_list_length(gaim_connections_get_all()) > 1) | |
2506 { | |
2507 tmp = g_markup_escape_text(chat->account->username, -1); | |
2508 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2509 g_free(tmp); | |
2510 } | |
2511 | |
9959 | 2512 if (prpl_info->chat_info != NULL) |
10475 | 2513 cur = prpl_info->chat_info(chat->account->gc); |
2514 else | |
2515 cur = NULL; | |
2516 | |
2517 while (cur != NULL) | |
2518 { | |
2519 pce = cur->data; | |
2520 | |
2521 if (!pce->secret && (!pce->required && | |
2522 g_hash_table_lookup(chat->components, pce->identifier) == NULL)) | |
2523 { | |
2524 tmp = gaim_text_strip_mnemonic(pce->label); | |
2525 name = g_markup_escape_text(tmp, -1); | |
2526 g_free(tmp); | |
2527 value = g_markup_escape_text(g_hash_table_lookup( | |
2528 chat->components, pce->identifier), -1); | |
10924
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2529 g_string_append_printf(str, "\n<b>%s</b> %s", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2530 name ? name : "", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2531 value ? value : ""); |
10475 | 2532 g_free(name); |
8020 | 2533 g_free(value); |
2534 } | |
10475 | 2535 |
5274 | 2536 g_free(pce); |
10475 | 2537 cur = g_list_remove(cur, pce); |
5274 | 2538 } |
10475 | 2539 } |
2540 else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) | |
2541 { | |
12942
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2542 /* NOTE: THIS FUNCTION IS NO LONGER CALLED FOR CONTACTS |
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2543 * See create_tip_for_node(). */ |
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2544 |
10475 | 2545 GaimContact *c; |
7620 | 2546 GaimBuddy *b; |
9944 | 2547 GaimPresence *presence; |
10475 | 2548 char *tmp; |
10567 | 2549 time_t idle_secs, signon; |
10475 | 2550 |
2551 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2552 { | |
2553 c = (GaimContact *)node; | |
2554 b = gaim_contact_get_priority_buddy(c); | |
2555 } | |
2556 else | |
2557 { | |
7620 | 2558 b = (GaimBuddy *)node; |
10475 | 2559 c = gaim_buddy_get_contact(b); |
7620 | 2560 } |
2561 | |
7956 | 2562 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5234 | 2563 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2564 | |
10475 | 2565 presence = gaim_buddy_get_presence(b); |
2566 | |
2567 /* Buddy Name */ | |
2568 tmp = g_markup_escape_text(gaim_buddy_get_name(b), -1); | |
2569 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2570 g_free(tmp); | |
2571 | |
2572 /* Account */ | |
12530 | 2573 if (full && g_list_length(gaim_connections_get_all()) > 1) |
10475 | 2574 { |
2575 tmp = g_markup_escape_text(gaim_account_get_username( | |
2576 gaim_buddy_get_account(b)), -1); | |
2577 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2578 g_free(tmp); | |
2579 } | |
2580 | |
2581 /* Alias */ | |
12942
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2582 /* If there's not a contact alias, the node is being displayed with |
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2583 * this alias, so there's no point in showing it in the tooltip. */ |
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2584 if (full && b->alias != NULL && b->alias[0] != '\0' && |
13217
502a4de3365c
[gaim-migrate @ 15581]
Richard Laager <rlaager@wiktel.com>
parents:
13201
diff
changeset
|
2585 (c->alias != NULL && c->alias[0] != '\0') && |
502a4de3365c
[gaim-migrate @ 15581]
Richard Laager <rlaager@wiktel.com>
parents:
13201
diff
changeset
|
2586 strcmp(c->alias, b->alias) != 0) |
10475 | 2587 { |
2588 tmp = g_markup_escape_text(b->alias, -1); | |
12942
432894b3bdad
[gaim-migrate @ 15295]
Richard Laager <rlaager@wiktel.com>
parents:
12941
diff
changeset
|
2589 g_string_append_printf(str, _("\n<b>Buddy Alias:</b> %s"), tmp); |
10475 | 2590 g_free(tmp); |
2591 } | |
2592 | |
2593 /* Nickname/Server Alias */ | |
12966
03679a4db953
[gaim-migrate @ 15319]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2594 /* I'd like to only show this if there's a contact or buddy |
03679a4db953
[gaim-migrate @ 15319]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2595 * alias, but many people on MSN set long nicknames, which |
03679a4db953
[gaim-migrate @ 15319]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2596 * get ellipsized, so the only way to see the whole thing is |
03679a4db953
[gaim-migrate @ 15319]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2597 * to look at the tooltip. */ |
03679a4db953
[gaim-migrate @ 15319]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
2598 if (full && b->server_alias != NULL && b->server_alias[0] != '\0') |
10475 | 2599 { |
2600 tmp = g_markup_escape_text(b->server_alias, -1); | |
2601 g_string_append_printf(str, _("\n<b>Nickname:</b> %s"), tmp); | |
2602 g_free(tmp); | |
2603 } | |
2604 | |
2605 /* Logged In */ | |
10567 | 2606 signon = gaim_presence_get_login_time(presence); |
12530 | 2607 if (full && GAIM_BUDDY_IS_ONLINE(b) && signon > 0) |
10475 | 2608 { |
10567 | 2609 tmp = gaim_str_seconds_to_string(time(NULL) - signon); |
10475 | 2610 g_string_append_printf(str, _("\n<b>Logged In:</b> %s"), tmp); |
2611 g_free(tmp); | |
2612 } | |
2613 | |
2614 /* Idle */ | |
12979
78f8ef7f0f6d
[gaim-migrate @ 15332]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12971
diff
changeset
|
2615 if (gaim_presence_is_idle(presence)) |
10475 | 2616 { |
2617 idle_secs = gaim_presence_get_idle_time(presence); | |
2618 if (idle_secs > 0) | |
2619 { | |
2620 tmp = gaim_str_seconds_to_string(time(NULL) - idle_secs); | |
2621 g_string_append_printf(str, _("\n<b>Idle:</b> %s"), tmp); | |
2622 g_free(tmp); | |
2623 } | |
2624 } | |
2625 | |
2626 /* Last Seen */ | |
12883
d486bb706e82
[gaim-migrate @ 15235]
Richard Laager <rlaager@wiktel.com>
parents:
12849
diff
changeset
|
2627 if (full && !GAIM_BUDDY_IS_ONLINE(b)) |
10475 | 2628 { |
11023 | 2629 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode *)c)->ui_data; |
2630 GaimBlistNode *bnode; | |
2631 int lastseen = 0; | |
2632 | |
2633 if (!gtknode->contact_expanded || GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2634 { | |
11437
1c20849fc716
[gaim-migrate @ 13674]
Richard Laager <rlaager@wiktel.com>
parents:
11436
diff
changeset
|
2635 /* We're either looking at a buddy for a collapsed contact or |
11438
5451fe2d89c0
[gaim-migrate @ 13675]
Richard Laager <rlaager@wiktel.com>
parents:
11437
diff
changeset
|
2636 * an expanded contact itself so we show the most recent |
11023 | 2637 * (largest) last_seen time for any of the buddies under |
2638 * the contact. */ | |
2639 for (bnode = ((GaimBlistNode *)c)->child ; bnode != NULL ; bnode = bnode->next) | |
2640 { | |
2641 int value = gaim_blist_node_get_int(bnode, "last_seen"); | |
2642 if (value > lastseen) | |
2643 lastseen = value; | |
2644 } | |
2645 } | |
2646 else | |
2647 { | |
2648 /* We're dealing with a buddy under an expanded contact, | |
2649 * so we show the last_seen time for the buddy. */ | |
2650 lastseen = gaim_blist_node_get_int(&b->node, "last_seen"); | |
2651 } | |
2652 | |
10475 | 2653 if (lastseen > 0) |
2654 { | |
2655 tmp = gaim_str_seconds_to_string(time(NULL) - lastseen); | |
2656 g_string_append_printf(str, _("\n<b>Last Seen:</b> %s ago"), tmp); | |
2657 g_free(tmp); | |
5234 | 2658 } |
2659 } | |
2660 | |
10475 | 2661 |
2662 /* Offline? */ | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12966
diff
changeset
|
2663 /* FIXME: Why is this status special-cased by the core? -- rlaager */ |
10475 | 2664 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
2665 g_string_append_printf(str, _("\n<b>Status:</b> Offline")); | |
2666 } | |
10992
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2667 |
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2668 if (prpl_info && prpl_info->tooltip_text) |
10475 | 2669 { |
2670 /* Additional text from the PRPL */ | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12966
diff
changeset
|
2671 prpl_info->tooltip_text(b, str, full); |
10475 | 2672 } |
2673 | |
2674 /* These are Easter Eggs. Patches to remove them will be rejected. */ | |
2675 if (!g_ascii_strcasecmp(b->name, "robflynn")) | |
2676 g_string_append(str, _("\n<b>Description:</b> Spooky")); | |
2677 if (!g_ascii_strcasecmp(b->name, "seanegn")) | |
2678 g_string_append(str, _("\n<b>Status:</b> Awesome")); | |
2679 if (!g_ascii_strcasecmp(b->name, "chipx86")) | |
2680 g_string_append(str, _("\n<b>Status:</b> Rockin'")); | |
5234 | 2681 } |
10475 | 2682 |
8824 | 2683 gaim_signal_emit(gaim_gtk_blist_get_handle(), |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
2684 "drawing-tooltip", node, str, full); |
10475 | 2685 |
2686 return g_string_free(str, FALSE); | |
5228 | 2687 } |
2688 | |
7620 | 2689 struct _emblem_data { |
9954 | 2690 const char *filename; |
7620 | 2691 int x; |
2692 int y; | |
2693 }; | |
2694 | |
9944 | 2695 GdkPixbuf * |
2696 gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) | |
5228 | 2697 { |
7620 | 2698 GdkPixbuf *scale, *status = NULL; |
2699 int i, scalesize = 30; | |
2700 char *filename; | |
5228 | 2701 const char *protoname = NULL; |
7620 | 2702 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
11910 | 2703 struct _gaim_gtk_blist_node *gtkbuddynode = NULL; |
7620 | 2704 struct _emblem_data emblems[4] = {{NULL, 15, 15}, {NULL, 0, 15}, |
2705 {NULL, 0, 0}, {NULL, 15, 0}}; | |
9944 | 2706 GaimPresence *presence = NULL; |
7620 | 2707 GaimBuddy *buddy = NULL; |
2708 GaimChat *chat = NULL; | |
2709 | |
2710 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
11910 | 2711 if(!gtknode->contact_expanded) { |
7620 | 2712 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); |
11910 | 2713 gtkbuddynode = ((GaimBlistNode*)buddy)->ui_data; |
2714 } | |
7620 | 2715 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
2716 buddy = (GaimBuddy*)node; | |
11910 | 2717 gtkbuddynode = node->ui_data; |
7620 | 2718 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
2719 chat = (GaimChat*)node; | |
2720 } else { | |
5228 | 2721 return NULL; |
5234 | 2722 } |
2723 | |
7620 | 2724 if(buddy || chat) { |
2725 GaimAccount *account; | |
2726 GaimPlugin *prpl; | |
2727 GaimPluginProtocolInfo *prpl_info; | |
2728 | |
2729 if(buddy) | |
2730 account = buddy->account; | |
2731 else | |
2732 account = chat->account; | |
2733 | |
7956 | 2734 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
7620 | 2735 if(!prpl) |
2736 return NULL; | |
2737 | |
2738 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2739 | |
2740 if(prpl_info && prpl_info->list_icon) { | |
2741 protoname = prpl_info->list_icon(account, buddy); | |
2742 } | |
2743 if(prpl_info && prpl_info->list_emblems && buddy) { | |
11924 | 2744 if(gtknode && !gtknode->recent_signonoff) |
7620 | 2745 prpl_info->list_emblems(buddy, &emblems[0].filename, |
2746 &emblems[1].filename, &emblems[2].filename, | |
2747 &emblems[3].filename); | |
2748 } | |
5234 | 2749 } |
5228 | 2750 |
12744
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2751 if(buddy) { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2752 GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2753 gaim_buddy_get_name(buddy), |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2754 gaim_buddy_get_account(buddy)); |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2755 if(conv != NULL) { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2756 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2757 if(gtkconv != NULL && gaim_gtkconv_is_hidden(gtkconv)) { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2758 /* add pending emblem */ |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2759 if(size == GAIM_STATUS_ICON_SMALL) { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2760 emblems[0].filename="pending"; |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2761 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2762 else { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2763 emblems[3].filename=emblems[2].filename; |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2764 emblems[2].filename="pending"; |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2765 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2766 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2767 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2768 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
2769 |
7620 | 2770 if(size == GAIM_STATUS_ICON_SMALL) { |
5228 | 2771 scalesize = 15; |
7620 | 2772 /* So that only the se icon will composite */ |
2773 emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; | |
5228 | 2774 } |
2775 | |
11917 | 2776 if(buddy && GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2777 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); |
11917 | 2778 } else if(buddy && !GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2779 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "logout.png", NULL); |
2780 } else if(buddy || chat) { | |
5228 | 2781 char *image = g_strdup_printf("%s.png", protoname); |
2782 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2783 g_free(image); | |
7620 | 2784 } else { |
2785 /* gaim dude */ | |
2786 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); | |
5228 | 2787 } |
7620 | 2788 |
2789 status = gdk_pixbuf_new_from_file(filename, NULL); | |
2790 g_free(filename); | |
2791 | |
2792 if(!status) | |
2793 return NULL; | |
2794 | |
2795 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, | |
2796 GDK_INTERP_BILINEAR); | |
2797 g_object_unref(status); | |
2798 | |
2799 for(i=0; i<4; i++) { | |
2800 if(emblems[i].filename) { | |
2801 GdkPixbuf *emblem; | |
2802 char *image = g_strdup_printf("%s.png", emblems[i].filename); | |
2803 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2804 g_free(image); | |
2805 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
2806 g_free(filename); | |
2807 if(emblem) { | |
2808 if(i == 0 && size == GAIM_STATUS_ICON_SMALL) { | |
2809 gdk_pixbuf_composite(emblem, | |
2810 scale, 5, 5, | |
2811 10, 10, | |
2812 5, 5, | |
2813 .6, .6, | |
2814 GDK_INTERP_BILINEAR, | |
2815 255); | |
2816 } else { | |
2817 gdk_pixbuf_composite(emblem, | |
2818 scale, emblems[i].x, emblems[i].y, | |
2819 15, 15, | |
2820 emblems[i].x, emblems[i].y, | |
2821 1, 1, | |
2822 GDK_INTERP_BILINEAR, | |
2823 255); | |
2824 } | |
2825 g_object_unref(emblem); | |
2826 } | |
5228 | 2827 } |
2828 } | |
7620 | 2829 |
2830 if(buddy) { | |
9944 | 2831 presence = gaim_buddy_get_presence(buddy); |
2832 | |
2833 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | |
7620 | 2834 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
10118 | 2835 else if (gaim_presence_is_idle(presence)) |
9944 | 2836 { |
7620 | 2837 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.25, FALSE); |
9944 | 2838 } |
11111
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2839 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2840 if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2841 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2842 GdkPixbuf *emblem; |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2843 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "blocked.png", NULL); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2844 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2845 emblem = gdk_pixbuf_new_from_file(filename, NULL); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2846 g_free(filename); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2847 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2848 if (emblem) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2849 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2850 gdk_pixbuf_composite(emblem, scale, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2851 0, 0, scalesize, scalesize, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2852 0, 0, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2853 (double)scalesize / gdk_pixbuf_get_width(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2854 (double)scalesize / gdk_pixbuf_get_height(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2855 GDK_INTERP_BILINEAR, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2856 224); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2857 g_object_unref(emblem); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2858 } |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2859 } |
5228 | 2860 } |
7620 | 2861 |
5228 | 2862 return scale; |
2863 } | |
2864 | |
7620 | 2865 static gchar *gaim_gtk_blist_get_name_markup(GaimBuddy *b, gboolean selected) |
5228 | 2866 { |
7620 | 2867 const char *name; |
2868 char *esc, *text = NULL; | |
5228 | 2869 GaimPlugin *prpl; |
2870 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 2871 GaimContact *contact; |
9944 | 2872 GaimPresence *presence; |
7620 | 2873 struct _gaim_gtk_blist_node *gtkcontactnode = NULL; |
11257 | 2874 char *idletime = NULL, *statustext = NULL; |
5228 | 2875 time_t t; |
13889 | 2876 /* XXX Good luck cleaning up this crap */ |
7620 | 2877 |
2878 contact = (GaimContact*)((GaimBlistNode*)b)->parent; | |
2879 if(contact) | |
2880 gtkcontactnode = ((GaimBlistNode*)contact)->ui_data; | |
2881 | |
2882 if(gtkcontactnode && !gtkcontactnode->contact_expanded && contact->alias) | |
2883 name = contact->alias; | |
2884 else | |
9620 | 2885 name = gaim_buddy_get_alias(b); |
7620 | 2886 esc = g_markup_escape_text(name, strlen(name)); |
2887 | |
9944 | 2888 presence = gaim_buddy_get_presence(b); |
2889 | |
13034
615c84e94745
[gaim-migrate @ 15392]
Richard Laager <rlaager@wiktel.com>
parents:
13030
diff
changeset
|
2890 if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) |
615c84e94745
[gaim-migrate @ 15392]
Richard Laager <rlaager@wiktel.com>
parents:
13030
diff
changeset
|
2891 { |
13038
4005ad2b3ca9
[gaim-migrate @ 15397]
Richard Laager <rlaager@wiktel.com>
parents:
13034
diff
changeset
|
2892 if (!selected && gaim_presence_is_idle(presence)) |
9944 | 2893 { |
10118 | 2894 text = g_strdup_printf("<span color='%s'>%s</span>", |
2895 dim_grey(), esc); | |
5228 | 2896 g_free(esc); |
2897 return text; | |
7620 | 2898 } |
9944 | 2899 else |
5228 | 2900 return esc; |
2901 } | |
2902 | |
13889 | 2903 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
2904 | |
2905 if (prpl != NULL) | |
2906 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2907 | |
8122
36674144c510
[gaim-migrate @ 8826]
Christian Hammond <chipx86@chipx86.com>
parents:
8113
diff
changeset
|
2908 if (prpl_info && prpl_info->status_text && b->account->gc) { |
5228 | 2909 char *tmp = prpl_info->status_text(b); |
2910 const char *end; | |
2911 | |
2912 if(tmp && !g_utf8_validate(tmp, -1, &end)) { | |
2913 char *new = g_strndup(tmp, | |
2914 g_utf8_pointer_to_offset(tmp, end)); | |
2915 g_free(tmp); | |
2916 tmp = new; | |
2917 } | |
2918 | |
10288 | 2919 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 2920 if(tmp) { |
2921 char buf[32]; | |
2922 char *c = tmp; | |
2923 int length = 0, vis=0; | |
2924 gboolean inside = FALSE; | |
2925 g_strdelimit(tmp, "\n", ' '); | |
11920 | 2926 gaim_str_strip_char(tmp, '\r'); |
5228 | 2927 |
2928 while(*c && vis < 20) { | |
2929 if(*c == '&') | |
2930 inside = TRUE; | |
2931 else if(*c == ';') | |
2932 inside = FALSE; | |
2933 if(!inside) | |
2934 vis++; | |
7620 | 2935 c = g_utf8_next_char(c); /* this is fun */ |
5228 | 2936 } |
2937 | |
7620 | 2938 length = c - tmp; |
2939 | |
5228 | 2940 if(vis == 20) |
2941 g_snprintf(buf, sizeof(buf), "%%.%ds...", length); | |
2942 else | |
2943 g_snprintf(buf, sizeof(buf), "%%s "); | |
2944 | |
2945 statustext = g_strdup_printf(buf, tmp); | |
2946 | |
2947 g_free(tmp); | |
2948 } | |
10288 | 2949 #else |
13790
e744943e749c
[gaim-migrate @ 16202]
Richard Laager <rlaager@wiktel.com>
parents:
13766
diff
changeset
|
2950 if(tmp) { |
12437 | 2951 g_strdelimit(tmp, "\n", ' '); |
13790
e744943e749c
[gaim-migrate @ 16202]
Richard Laager <rlaager@wiktel.com>
parents:
13766
diff
changeset
|
2952 gaim_str_strip_char(tmp, '\r'); |
e744943e749c
[gaim-migrate @ 16202]
Richard Laager <rlaager@wiktel.com>
parents:
13766
diff
changeset
|
2953 } |
10288 | 2954 statustext = tmp; |
2955 #endif | |
5228 | 2956 } |
2957 | |
13034
615c84e94745
[gaim-migrate @ 15392]
Richard Laager <rlaager@wiktel.com>
parents:
13030
diff
changeset
|
2958 if(!gaim_presence_is_online(presence) && !statustext) |
615c84e94745
[gaim-migrate @ 15392]
Richard Laager <rlaager@wiktel.com>
parents:
13030
diff
changeset
|
2959 statustext = g_strdup(_("Offline")); |
13889 | 2960 else if (!statustext) |
2961 text = g_strdup(esc); | |
14035 | 2962 |
13889 | 2963 if (gaim_presence_is_idle(presence)) { |
2964 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { | |
2965 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
2966 | |
2967 if (idle_secs > 0) { | |
2968 int ihrs, imin; | |
2969 | |
2970 time(&t); | |
2971 ihrs = (t - idle_secs) / 3600; | |
2972 imin = ((t - idle_secs) / 60) % 60; | |
2973 | |
2974 if (ihrs) | |
2975 idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); | |
2976 else | |
2977 idletime = g_strdup_printf(_("Idle %dm"), imin); | |
2978 } | |
2979 else | |
2980 idletime = g_strdup(_("Idle")); | |
2981 | |
2982 if (!selected) | |
2983 text = g_strdup_printf("<span color='%s'>%s</span>\n" | |
2984 "<span color='%s' size='smaller'>%s%s%s</span>", | |
2985 dim_grey(), esc, dim_grey(), | |
2986 idletime != NULL ? idletime : "", | |
2987 (idletime != NULL && statustext != NULL) ? " - " : "", | |
2988 statustext != NULL ? statustext : ""); | |
13034
615c84e94745
[gaim-migrate @ 15392]
Richard Laager <rlaager@wiktel.com>
parents:
13030
diff
changeset
|
2989 } |
13889 | 2990 else if (!selected && !statustext) /* We handle selected text later */ |
2991 text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); | |
2992 else if (!selected && !text) | |
2993 text = g_strdup_printf("<span color='%s'>%s</span>\n" | |
2994 "<span color='%s' size='smaller'>%s%s%s</span>", | |
2995 dim_grey(), esc, dim_grey(), | |
2996 idletime != NULL ? idletime : "", | |
2997 (idletime != NULL && statustext != NULL) ? " - " : "", | |
2998 statustext != NULL ? statustext : ""); | |
5228 | 2999 } |
13889 | 3000 |
3001 /* Not idle and not selected */ | |
3002 else if (!selected && !text) | |
3003 { | |
13201
6ff5271afedc
[gaim-migrate @ 15564]
Richard Laager <rlaager@wiktel.com>
parents:
13196
diff
changeset
|
3004 text = g_strdup_printf("%s\n" |
14074
36bb845aa622
[gaim-migrate @ 16695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14035
diff
changeset
|
3005 "<span color='%s' size='smaller'>%s</span>", |
13889 | 3006 esc, dim_grey(), |
3007 statustext != NULL ? statustext : ""); | |
3008 } | |
3009 | |
3010 /* It is selected. */ | |
14035 | 3011 if ((selected && !text) || (selected && idletime)) |
13889 | 3012 text = g_strdup_printf("%s\n" |
3013 "<span size='smaller'>%s%s%s</span>", | |
3014 esc, | |
3015 idletime != NULL ? idletime : "", | |
3016 (idletime != NULL && statustext != NULL) ? " - " : "", | |
3017 statustext != NULL ? statustext : ""); | |
12656 | 3018 |
3019 g_free(idletime); | |
3020 g_free(statustext); | |
3021 g_free(esc); | |
5228 | 3022 |
3023 return text; | |
3024 } | |
3025 | |
3026 static void gaim_gtk_blist_restore_position() | |
3027 { | |
7620 | 3028 int blist_x, blist_y, blist_width, blist_height; |
3029 | |
3030 blist_width = gaim_prefs_get_int("/gaim/gtk/blist/width"); | |
3031 | |
3032 /* if the window exists, is hidden, we're saving positions, and the | |
3033 * position is sane... */ | |
3034 if (gtkblist && gtkblist->window && | |
3035 !GTK_WIDGET_VISIBLE(gtkblist->window) && blist_width != 0) { | |
3036 | |
3037 blist_x = gaim_prefs_get_int("/gaim/gtk/blist/x"); | |
3038 blist_y = gaim_prefs_get_int("/gaim/gtk/blist/y"); | |
3039 blist_height = gaim_prefs_get_int("/gaim/gtk/blist/height"); | |
3040 | |
5228 | 3041 /* ...check position is on screen... */ |
7620 | 3042 if (blist_x >= gdk_screen_width()) |
3043 blist_x = gdk_screen_width() - 100; | |
3044 else if (blist_x + blist_width < 0) | |
3045 blist_x = 100; | |
3046 | |
3047 if (blist_y >= gdk_screen_height()) | |
3048 blist_y = gdk_screen_height() - 100; | |
3049 else if (blist_y + blist_height < 0) | |
3050 blist_y = 100; | |
3051 | |
5228 | 3052 /* ...and move it back. */ |
7620 | 3053 gtk_window_move(GTK_WINDOW(gtkblist->window), blist_x, blist_y); |
3054 gtk_window_resize(GTK_WINDOW(gtkblist->window), blist_width, blist_height); | |
12279 | 3055 if (gaim_prefs_get_bool("/gaim/gtk/blist/list_maximized")) |
3056 gtk_window_maximize(GTK_WINDOW(gtkblist->window)); | |
5228 | 3057 } |
3058 } | |
3059 | |
7620 | 3060 static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list) |
5228 | 3061 { |
7620 | 3062 GaimBlistNode *gnode, *cnode; |
3063 | |
13889 | 3064 if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) |
3065 return TRUE; | |
14035 | 3066 |
7620 | 3067 for(gnode = list->root; gnode; gnode = gnode->next) { |
3068 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 3069 continue; |
7620 | 3070 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3071 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
9944 | 3072 GaimBuddy *buddy; |
3073 | |
3074 buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); | |
10012 | 3075 |
3076 if (buddy && | |
3077 gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | |
14035 | 3078 gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); |
7620 | 3079 } |
5228 | 3080 } |
3081 } | |
3082 | |
3083 /* keep on going */ | |
3084 return TRUE; | |
3085 } | |
3086 | |
7620 | 3087 static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node) |
5260 | 3088 { |
3089 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3090 GtkTreeIter iter; | |
3091 | |
3092 if (!gtknode || !gtknode->row || !gtkblist) | |
3093 return; | |
3094 | |
3095 if(gtkblist->selected_node == node) | |
3096 gtkblist->selected_node = NULL; | |
3097 | |
3098 if (get_iter_from_node(node, &iter)) { | |
3099 gtk_tree_store_remove(gtkblist->treemodel, &iter); | |
7620 | 3100 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) |
3101 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5260 | 3102 gaim_gtk_blist_update(list, node->parent); |
3103 } | |
3104 } | |
3105 gtk_tree_row_reference_free(gtknode->row); | |
3106 gtknode->row = NULL; | |
3107 } | |
3108 | |
10352 | 3109 static const char *require_connection[] = |
7620 | 3110 { |
10352 | 3111 N_("/Buddies/New Instant Message..."), |
3112 N_("/Buddies/Join a Chat..."), | |
3113 N_("/Buddies/Get User Info..."), | |
3114 N_("/Buddies/Add Buddy..."), | |
3115 N_("/Buddies/Add Chat..."), | |
3116 N_("/Buddies/Add Group..."), | |
3117 }; | |
3118 | |
10357 | 3119 static const int require_connection_size = sizeof(require_connection) |
3120 / sizeof(*require_connection); | |
10352 | 3121 |
3122 /** | |
3123 * Rebuild dynamic menus and make menu items sensitive/insensitive | |
3124 * where appropriate. | |
3125 */ | |
3126 static void | |
3127 update_menu_bar(GaimGtkBuddyList *gtkblist) | |
3128 { | |
8937 | 3129 GtkWidget *widget; |
10352 | 3130 gboolean sensitive; |
3131 int i; | |
3132 | |
3133 g_return_if_fail(gtkblist != NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3134 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3135 gaim_gtk_blist_update_accounts_menu(); |
8937 | 3136 |
10352 | 3137 sensitive = (gaim_connections_get_all() != NULL); |
3138 | |
10357 | 3139 for (i = 0; i < require_connection_size; i++) |
10352 | 3140 { |
3141 widget = gtk_item_factory_get_widget(gtkblist->ift, require_connection[i]); | |
3142 gtk_widget_set_sensitive(widget, sensitive); | |
3143 } | |
3144 | |
8940 | 3145 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Join a Chat...")); |
3146 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3147 | |
11988 | 3148 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat...")); |
3149 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3150 | |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3151 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounces")); |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3152 gtk_widget_set_sensitive(widget, (gaim_connections_get_all() != NULL)); |
8938 | 3153 |
3154 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy")); | |
13001
4bbd39576c52
[gaim-migrate @ 15354]
Richard Laager <rlaager@wiktel.com>
parents:
12979
diff
changeset
|
3155 gtk_widget_set_sensitive(widget, (gaim_connections_get_all() != NULL)); |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3156 |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3157 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List")); |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3158 gtk_widget_set_sensitive(widget, gaim_gtk_roomlist_is_showable()); |
7620 | 3159 } |
3160 | |
10352 | 3161 static void |
3162 sign_on_off_cb(GaimConnection *gc, GaimBuddyList *blist) | |
3163 { | |
3164 GaimGtkBuddyList *gtkblist = GAIM_GTK_BLIST(blist); | |
3165 | |
3166 update_menu_bar(gtkblist); | |
3167 } | |
8986 | 3168 |
3169 static void | |
3170 plugin_changed_cb(GaimPlugin *p, gpointer *data) | |
3171 { | |
3172 gaim_gtk_blist_update_plugin_actions(); | |
3173 } | |
3174 | |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3175 static void |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3176 unseen_conv_menu() |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3177 { |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3178 static GtkWidget *menu = NULL; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3179 GList *convs = NULL; |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3180 |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3181 if (menu) |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3182 gtk_widget_destroy(menu); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3183 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3184 menu = gtk_menu_new(); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3185 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3186 convs = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT, TRUE, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3187 if (!convs) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3188 /* no conversations added, don't show the menu */ |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3189 gtk_widget_destroy(menu); |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3190 return; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3191 } |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3192 gaim_gtk_conversations_fill_menu(menu, convs); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3193 g_list_free(convs); |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3194 gtk_widget_show_all(menu); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3195 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3196 gtk_get_current_event_time()); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3197 } |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3198 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3199 static gboolean |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3200 menutray_press_cb(GtkWidget *widget, GdkEventButton *event) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3201 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3202 GList *convs; |
12208 | 3203 |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3204 switch (event->button) { |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3205 case 1: |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3206 convs = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3207 GAIM_UNSEEN_TEXT, TRUE, 1); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3208 if (convs) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3209 gaim_gtkconv_present_conversation((GaimConversation*)convs->data); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3210 g_list_free(convs); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3211 } |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3212 break; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3213 case 3: |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3214 unseen_conv_menu(); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3215 break; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3216 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3217 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3218 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3219 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3220 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3221 conversation_updated_cb(GaimConversation *conv, GaimConvUpdateType type, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3222 GaimGtkBuddyList *gtkblist) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3223 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3224 GList *convs = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3225 GList *l = NULL; |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3226 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3227 if (type != GAIM_CONV_UPDATE_UNSEEN) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3228 return; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3229 |
12744
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3230 if(conv->account != NULL && conv->name != NULL) { |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3231 GaimBuddy *buddy = gaim_find_buddy(conv->account, conv->name); |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3232 if(buddy != NULL) |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3233 gaim_gtk_blist_update_buddy(NULL, (GaimBlistNode *)buddy); |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3234 } |
fcd9477e4476
[gaim-migrate @ 15091]
Luke Schierer <lschiere@pidgin.im>
parents:
12713
diff
changeset
|
3235 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3236 if (gtkblist->menutrayicon) { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3237 gtk_widget_destroy(gtkblist->menutrayicon); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3238 gtkblist->menutrayicon = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3239 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3240 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3241 convs = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT, TRUE, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3242 if (convs) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3243 GtkWidget *img = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3244 GString *tooltip_text = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3245 |
12117 | 3246 tooltip_text = g_string_new(""); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3247 l = convs; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3248 while (l != NULL) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3249 if (GAIM_IS_GTK_CONVERSATION(l->data)) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3250 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION((GaimConversation *)l->data); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3251 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3252 g_string_append_printf(tooltip_text, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3253 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3254 gtkconv->unseen_count, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3255 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
12117 | 3256 } |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3257 l = l->next; |
12117 | 3258 } |
12239 | 3259 if(tooltip_text->len > 0) { |
12302 | 3260 /* get rid of the last newline */ |
3261 tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len -1); | |
3262 img = gtk_image_new_from_stock(GAIM_STOCK_PENDING, GTK_ICON_SIZE_MENU); | |
3263 | |
3264 gtkblist->menutrayicon = gtk_event_box_new(); | |
3265 gtk_container_add(GTK_CONTAINER(gtkblist->menutrayicon), img); | |
3266 gtk_widget_show(img); | |
3267 gtk_widget_show(gtkblist->menutrayicon); | |
3268 g_signal_connect(G_OBJECT(gtkblist->menutrayicon), "button-press-event", G_CALLBACK(menutray_press_cb), NULL); | |
3269 | |
3270 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkblist->menutray), gtkblist->menutrayicon, tooltip_text->str); | |
12239 | 3271 } |
12302 | 3272 g_string_free(tooltip_text, TRUE); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3273 g_list_free(convs); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3274 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3275 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3276 |
12208 | 3277 static void |
3278 conversation_deleting_cb(GaimConversation *conv, GaimGtkBuddyList *gtkblist) | |
3279 { | |
3280 conversation_updated_cb(conv, GAIM_CONV_UPDATE_UNSEEN, gtkblist); | |
3281 } | |
3282 | |
5228 | 3283 /********************************************************************************** |
3284 * Public API Functions * | |
3285 **********************************************************************************/ | |
9774 | 3286 |
7620 | 3287 static void gaim_gtk_blist_new_list(GaimBuddyList *blist) |
5228 | 3288 { |
7620 | 3289 GaimGtkBuddyList *gtkblist; |
3290 | |
3291 gtkblist = g_new0(GaimGtkBuddyList, 1); | |
13015 | 3292 gtkblist->connection_errors = g_hash_table_new_full(g_direct_hash, |
3293 g_direct_equal, NULL, g_free); | |
7620 | 3294 blist->ui_data = gtkblist; |
5228 | 3295 } |
3296 | |
5256 | 3297 static void gaim_gtk_blist_new_node(GaimBlistNode *node) |
3298 { | |
3299 node->ui_data = g_new0(struct _gaim_gtk_blist_node, 1); | |
3300 } | |
3301 | |
11018 | 3302 gboolean gaim_gtk_blist_node_is_contact_expanded(GaimBlistNode *node) |
3303 { | |
3304 if GAIM_BLIST_NODE_IS_BUDDY(node) | |
3305 node = node->parent; | |
3306 | |
3307 g_return_val_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node), FALSE); | |
3308 | |
3309 return ((struct _gaim_gtk_blist_node *)node->ui_data)->contact_expanded; | |
3310 } | |
3311 | |
5228 | 3312 void gaim_gtk_blist_update_columns() |
3313 { | |
3314 if(!gtkblist) | |
3315 return; | |
3316 | |
7620 | 3317 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { |
5228 | 3318 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE); |
3319 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE); | |
3320 } else { | |
12656 | 3321 gtk_tree_view_column_set_visible(gtkblist->idle_column, |
3322 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
5228 | 3323 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE); |
3324 } | |
3325 } | |
3326 | |
12326 | 3327 static void |
3328 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, | |
12816 | 3329 gconstpointer val, gpointer data) |
12326 | 3330 { |
3331 gaim_gtk_blist_update_columns(); | |
3332 } | |
3333 | |
10433 | 3334 enum { |
3335 DRAG_BUDDY, | |
3336 DRAG_ROW, | |
3337 DRAG_VCARD, | |
3338 DRAG_TEXT, | |
3339 DRAG_URI, | |
3340 NUM_TARGETS | |
3341 }; | |
5228 | 3342 |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
3343 static const char * |
5228 | 3344 item_factory_translate_func (const char *path, gpointer func_data) |
3345 { | |
7620 | 3346 return _((char *)path); |
5228 | 3347 } |
3348 | |
5422 | 3349 void gaim_gtk_blist_setup_sort_methods() |
3350 { | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3351 gaim_gtk_blist_sort_method_reg("none", _("Manually"), sort_method_none); |
7620 | 3352 #if GTK_CHECK_VERSION(2,2,1) |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3353 gaim_gtk_blist_sort_method_reg("alphabetical", _("Alphabetically"), sort_method_alphabetical); |
7620 | 3354 gaim_gtk_blist_sort_method_reg("status", _("By status"), sort_method_status); |
3355 gaim_gtk_blist_sort_method_reg("log_size", _("By log size"), sort_method_log); | |
3356 #endif | |
3357 gaim_gtk_blist_sort_method_set(gaim_prefs_get_string("/gaim/gtk/blist/sort_type")); | |
3358 } | |
3359 | |
10433 | 3360 static void _prefs_change_redo_list() |
3361 { | |
13510
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3362 GtkTreeSelection *sel; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3363 GtkTreeIter iter; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3364 GaimBlistNode *node = NULL; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3365 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3366 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3367 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3368 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3369 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3370 } |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3371 |
7620 | 3372 redo_buddy_list(gaim_get_blist(), TRUE); |
13161
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3373 #if GTK_CHECK_VERSION(2,6,0) |
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3374 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3375 #endif |
13510
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3376 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3377 if (node) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3378 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3379 struct _gaim_gtk_blist_node *gtknode; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3380 GtkTreePath *path; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3381 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3382 gtknode = node->ui_data; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3383 if (gtknode && gtknode->row) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3384 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3385 path = gtk_tree_row_reference_get_path(gtknode->row); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3386 gtk_tree_selection_select_path(sel, path); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3387 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3388 gtk_tree_path_free(path); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3389 } |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3390 } |
7620 | 3391 } |
3392 | |
3393 static void _prefs_change_sort_method(const char *pref_name, GaimPrefType type, | |
12816 | 3394 gconstpointer val, gpointer data) |
10433 | 3395 { |
7620 | 3396 if(!strcmp(pref_name, "/gaim/gtk/blist/sort_type")) |
3397 gaim_gtk_blist_sort_method_set(val); | |
3398 } | |
3399 | |
10433 | 3400 /* |
3401 * "This is so dead sexy." | |
3402 * "Two thumbs up." | |
3403 * "Best movie of the year." | |
3404 * | |
3405 * This is the function that handles CTRL+F searching in the buddy list. | |
3406 * It finds the top-most buddy/group/chat/whatever containing the | |
3407 * entered string. | |
3408 * | |
3409 * It's somewhat ineffecient, because we strip all the HTML from the | |
3410 * "name" column of the buddy list (because the GtkTreeModel does not | |
3411 * contain the screen name in a non-markedup format). But the alternative | |
3412 * is to add an extra column to the GtkTreeModel. And this function is | |
3413 * used rarely, so it shouldn't matter TOO much. | |
3414 */ | |
3415 static gboolean | |
3416 _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) | |
3417 { | |
3418 gchar *enteredstring; | |
13612
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3419 gchar *tmp; |
10439 | 3420 gchar *withmarkup; |
10433 | 3421 gchar *nomarkup; |
11490 | 3422 gchar *normalized; |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3423 gboolean result; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3424 size_t i; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3425 size_t len; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3426 PangoLogAttr *log_attrs; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3427 gchar *word; |
10435 | 3428 |
13968 | 3429 if (strcasecmp(key, "Global Thermonuclear War") == 0) |
3430 { | |
3431 gaim_notify_info(NULL, "WOPR", | |
3432 "Wouldn't you prefer a nice game of chess?", NULL); | |
3433 return FALSE; | |
3434 } | |
3435 | |
10435 | 3436 gtk_tree_model_get(model, iter, column, &withmarkup, -1); |
10433 | 3437 |
13612
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3438 tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3439 enteredstring = g_utf8_casefold(tmp, -1); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3440 g_free(tmp); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3441 |
10433 | 3442 nomarkup = gaim_markup_strip_html(withmarkup); |
13612
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3443 tmp = g_utf8_normalize(nomarkup, -1, G_NORMALIZE_DEFAULT); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3444 g_free(nomarkup); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3445 normalized = g_utf8_casefold(tmp, -1); |
dd03aa8a28ad
[gaim-migrate @ 15998]
Richard Laager <rlaager@wiktel.com>
parents:
13559
diff
changeset
|
3446 g_free(tmp); |
10433 | 3447 |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3448 if (gaim_str_has_prefix(normalized, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3449 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3450 g_free(withmarkup); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3451 g_free(enteredstring); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3452 g_free(normalized); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3453 return FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3454 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3455 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3456 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3457 /* Use Pango to separate by words. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3458 len = g_utf8_strlen(normalized, -1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3459 log_attrs = g_new(PangoLogAttr, len + 1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3460 |
13684
a104ce6e2cca
[gaim-migrate @ 16087]
Richard Laager <rlaager@wiktel.com>
parents:
13674
diff
changeset
|
3461 pango_get_log_attrs(normalized, strlen(normalized), -1, NULL, log_attrs, len + 1); |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3462 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3463 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3464 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3465 for (i = 0; i < (len - 1) ; i++) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3466 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3467 if (log_attrs[i].is_word_start && |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3468 gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3469 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3470 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3471 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3472 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3473 word = g_utf8_next_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3474 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3475 g_free(log_attrs); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3476 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3477 /* The non-Pango version. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3478 #if 0 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3479 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3480 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3481 while (word[0] != '\0') |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3482 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3483 gunichar c = g_utf8_get_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3484 if (!g_unichar_isalnum(c)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3485 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3486 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3487 if (gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3488 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3489 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3490 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3491 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3492 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3493 else |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3494 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3495 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3496 #endif |
10433 | 3497 |
10439 | 3498 g_free(withmarkup); |
10433 | 3499 g_free(enteredstring); |
11490 | 3500 g_free(normalized); |
10433 | 3501 |
3502 return result; | |
3503 } | |
3504 | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3505 static void account_modified(GaimAccount *account, GaimGtkBuddyList *gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3506 { |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3507 if (!gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3508 return; |
12589 | 3509 |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3510 update_menu_bar(gtkblist); |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3511 } |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3512 |
12766 | 3513 static void |
3514 account_status_changed(GaimAccount *account, GaimStatus *old, | |
3515 GaimStatus *new, GaimGtkBuddyList *gtkblist) | |
3516 { | |
3517 if (!gtkblist) | |
3518 return; | |
3519 | |
3520 update_menu_bar(gtkblist); | |
3521 } | |
3522 | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3523 static gboolean |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3524 gtk_blist_window_key_press_cb(GtkWidget *w, GdkEventKey *event, GaimGtkBuddyList *gtkblist) |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3525 { |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3526 GtkWidget *imhtml; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3527 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3528 if (!gtkblist) |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3529 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3530 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3531 imhtml = gtk_window_get_focus(GTK_WINDOW(gtkblist->window)); |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3532 |
12474
24beec3e42ad
[gaim-migrate @ 14785]
Luke Schierer <lschiere@pidgin.im>
parents:
12473
diff
changeset
|
3533 if (GTK_IS_IMHTML(imhtml) && gtk_bindings_activate(GTK_OBJECT(imhtml), event->keyval, event->state)) |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3534 return TRUE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3535 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3536 } |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3537 |
13015 | 3538 /***********************************/ |
3539 /* Connection error handling stuff */ | |
3540 /***********************************/ | |
3541 | |
3542 static void | |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3543 ce_modify_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3544 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3545 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, account); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3546 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3547 |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3548 static void |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3549 ce_enable_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3550 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3551 gaim_account_set_enabled(account, gaim_core_get_ui(), TRUE); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3552 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3553 |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3554 static void |
13015 | 3555 connection_error_button_clicked_cb(GtkButton *widget, gpointer user_data) |
3556 { | |
3557 GaimAccount *account; | |
13023 | 3558 char *primary; |
3559 const char *text; | |
13730 | 3560 gboolean enabled; |
13015 | 3561 |
3562 account = user_data; | |
13023 | 3563 primary = g_strdup_printf(_("%s disconnected"), |
3564 gaim_account_get_username(account)); | |
13015 | 3565 text = g_hash_table_lookup(gtkblist->connection_errors, account); |
13375 | 3566 |
13730 | 3567 enabled = gaim_account_get_enabled(account, gaim_core_get_ui()); |
3568 gaim_request_action(account, _("Connection Error"), primary, text, 2, | |
3569 account, 3, | |
3570 _("OK"), NULL, | |
3571 _("Modify Account"), GAIM_CALLBACK(ce_modify_account_cb), | |
3572 enabled ? _("Connect") : _("Re-enable Account"), | |
3573 enabled ? GAIM_CALLBACK(gaim_account_connect) : | |
3574 GAIM_CALLBACK(ce_enable_account_cb)); | |
13629
3275a0f675e2
[gaim-migrate @ 16016]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13612
diff
changeset
|
3575 g_free(primary); |
13015 | 3576 gtk_widget_destroy(GTK_WIDGET(widget)); |
3577 g_hash_table_remove(gtkblist->connection_errors, account); | |
3578 } | |
3579 | |
3580 /* Add some buttons that show connection errors */ | |
3581 static void | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3582 create_connection_error_buttons(gpointer key, gpointer value, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3583 gpointer user_data) |
13015 | 3584 { |
3585 GaimAccount *account; | |
13090 | 3586 GaimStatusType *status_type; |
3587 gchar *escaped, *text; | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3588 GtkWidget *button, *label, *image, *hbox; |
13090 | 3589 GdkPixbuf *pixbuf; |
13015 | 3590 |
3591 account = key; | |
13049 | 3592 escaped = g_markup_escape_text((const gchar *)value, -1); |
13023 | 3593 text = g_strdup_printf(_("<span color=\"red\">%s disconnected: %s</span>"), |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3594 gaim_account_get_username(account), |
13049 | 3595 escaped); |
3596 g_free(escaped); | |
3597 | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3598 hbox = gtk_hbox_new(FALSE, 0); |
13049 | 3599 |
3600 /* Create the icon */ | |
14075
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3601 if ((status_type = gaim_account_get_status_type_with_primitive(account, |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3602 GAIM_STATUS_OFFLINE))) { |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3603 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3604 if (pixbuf != NULL) { |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3605 image = gtk_image_new_from_pixbuf(pixbuf); |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3606 g_object_unref(pixbuf); |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3607 |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3608 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3609 GAIM_HIG_BOX_SPACE); |
7fbca3653056
[gaim-migrate @ 16696]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14074
diff
changeset
|
3610 } |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3611 } |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3612 |
13049 | 3613 /* Create the text */ |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3614 label = gtk_label_new(""); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3615 gtk_label_set_markup(GTK_LABEL(label), text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3616 g_free(text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3617 #if GTK_CHECK_VERSION(2,6,0) |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3618 g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3619 #endif |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3620 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3621 GAIM_HIG_BOX_SPACE); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3622 |
13049 | 3623 /* Create the actual button and put the icon and text on it */ |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3624 button = gtk_button_new(); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3625 gtk_container_add(GTK_CONTAINER(button), hbox); |
13015 | 3626 g_signal_connect(G_OBJECT(button), "clicked", |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3627 G_CALLBACK(connection_error_button_clicked_cb), |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3628 account); |
13049 | 3629 gtk_widget_show_all(button); |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3630 gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3631 FALSE, FALSE, 0); |
13015 | 3632 } |
3633 | |
3634 void | |
3635 gaim_gtk_blist_update_account_error_state(GaimAccount *account, const char *text) | |
3636 { | |
3637 GList *l; | |
3638 | |
13016 | 3639 if (text == NULL) |
13015 | 3640 g_hash_table_remove(gtkblist->connection_errors, account); |
3641 else | |
3642 g_hash_table_insert(gtkblist->connection_errors, account, g_strdup(text)); | |
3643 | |
3644 /* Remove the old error buttons */ | |
3645 for (l = gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)); | |
3646 l != NULL; | |
3647 l = l->next) | |
3648 { | |
3649 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
3650 } | |
3651 | |
3652 /* Add new error buttons */ | |
3653 g_hash_table_foreach(gtkblist->connection_errors, | |
3654 create_connection_error_buttons, NULL); | |
3655 } | |
3656 | |
3657 /******************************************/ | |
3658 /* End of connection error handling stuff */ | |
3659 /******************************************/ | |
3660 | |
7620 | 3661 static void gaim_gtk_blist_show(GaimBuddyList *list) |
5228 | 3662 { |
10087 | 3663 void *handle; |
5228 | 3664 GtkCellRenderer *rend; |
3665 GtkTreeViewColumn *column; | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3666 GtkWidget *menu; |
5228 | 3667 GtkWidget *sw; |
3668 GtkAccelGroup *accel_group; | |
3669 GtkTreeSelection *selection; | |
9556 | 3670 GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
8089 | 3671 {"application/x-im-contact", 0, DRAG_BUDDY}, |
9495 | 3672 {"text/x-vcard", 0, DRAG_VCARD }, |
9525 | 3673 {"text/uri-list", 0, DRAG_URI}, |
3674 {"text/plain", 0, DRAG_TEXT}}; | |
9556 | 3675 GtkTargetEntry ste[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
3676 {"application/x-im-contact", 0, DRAG_BUDDY}, | |
3677 {"text/x-vcard", 0, DRAG_VCARD }}; | |
5228 | 3678 if (gtkblist && gtkblist->window) { |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3679 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3680 return; |
3681 } | |
3682 | |
3683 gtkblist = GAIM_GTK_BLIST(list); | |
3684 | |
3685 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3686 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
9746 | 3687 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
12328 | 3688 GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE; |
5228 | 3689 |
3690 gtkblist->vbox = gtk_vbox_new(FALSE, 0); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3691 gtk_widget_show(gtkblist->vbox); |
5228 | 3692 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); |
3693 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3694 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
5228 | 3695 g_signal_connect(G_OBJECT(gtkblist->window), "configure_event", G_CALLBACK(gtk_blist_configure_cb), NULL); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3696 g_signal_connect(G_OBJECT(gtkblist->window), "visibility_notify_event", G_CALLBACK(gtk_blist_visibility_cb), NULL); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3697 g_signal_connect(G_OBJECT(gtkblist->window), "window_state_event", G_CALLBACK(gtk_blist_window_state_cb), NULL); |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3698 g_signal_connect(G_OBJECT(gtkblist->window), "key_press_event", G_CALLBACK(gtk_blist_window_key_press_cb), gtkblist); |
5228 | 3699 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); |
3700 | |
3701 /******************************* Menu bar *************************************/ | |
3702 accel_group = gtk_accel_group_new(); | |
3703 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group); | |
3704 g_object_unref(accel_group); | |
5427 | 3705 gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group); |
9811 | 3706 gtk_item_factory_set_translate_func(gtkblist->ift, |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
3707 (GtkTranslateFunc)item_factory_translate_func, |
9811 | 3708 NULL, NULL); |
5427 | 3709 gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu), |
9811 | 3710 blist_menu, NULL); |
7620 | 3711 gaim_gtk_load_accels(); |
3712 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
3713 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3714 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3715 gtkblist->menutray = gaim_gtk_menu_tray_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3716 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3717 gtk_widget_show(gtkblist->menutray); |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3718 gtk_widget_show(menu); |
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3719 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
5228 | 3720 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3721 accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts")); |
10352 | 3722 |
5228 | 3723 /****************************** GtkTreeView **********************************/ |
3724 sw = gtk_scrolled_window_new(NULL,NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3725 gtk_widget_show(sw); |
5228 | 3726 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3727 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
3728 | |
7620 | 3729 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, |
11494 | 3730 GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, |
11257 | 3731 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
5228 | 3732 |
3733 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel)); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3734 gtk_widget_show(gtkblist->treeview); |
9176 | 3735 gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); |
5228 | 3736 |
3737 /* Set up selection stuff */ | |
3738 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
3739 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
3740 | |
3741 /* Set up dnd */ | |
7650 | 3742 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3743 GDK_BUTTON1_MASK, ste, 3, |
3744 GDK_ACTION_COPY); | |
7650 | 3745 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3746 dte, 5, |
3747 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
7636 | 3748 |
10544 | 3749 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
5228 | 3750 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL); |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3751 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3752 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-begin", G_CALLBACK(gaim_gtk_blist_drag_begin), NULL); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3753 #endif |
10433 | 3754 |
10354 | 3755 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); |
5228 | 3756 |
3757 /* Tooltips */ | |
3758 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
3759 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
3760 | |
3761 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
3762 | |
11016 | 3763 gtkblist->text_column = column = gtk_tree_view_column_new (); |
5228 | 3764 |
3765 rend = gtk_cell_renderer_pixbuf_new(); | |
9811 | 3766 gtk_tree_view_column_pack_start(column, rend, FALSE); |
3767 gtk_tree_view_column_set_attributes(column, rend, | |
3768 "pixbuf", STATUS_ICON_COLUMN, | |
3769 "visible", STATUS_ICON_VISIBLE_COLUMN, | |
3770 NULL); | |
5228 | 3771 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL); |
3772 | |
11016 | 3773 gtkblist->text_rend = rend = gtk_cell_renderer_text_new(); |
5228 | 3774 gtk_tree_view_column_pack_start (column, rend, TRUE); |
9811 | 3775 gtk_tree_view_column_set_attributes(column, rend, |
3776 "markup", NAME_COLUMN, | |
3777 NULL); | |
11016 | 3778 g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); |
5228 | 3779 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
10285 | 3780 #if GTK_CHECK_VERSION(2,6,0) |
3781 gtk_tree_view_column_set_expand (column, TRUE); | |
10501 | 3782 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
10285 | 3783 #endif |
5228 | 3784 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); |
3785 | |
3786 rend = gtk_cell_renderer_text_new(); | |
10351 | 3787 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
3788 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
5228 | 3789 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
3790 | |
3791 rend = gtk_cell_renderer_pixbuf_new(); | |
3792 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); | |
3793 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); | |
3794 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); | |
3795 | |
3796 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); | |
3797 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL); | |
3798 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL); | |
3799 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
7620 | 3800 g_signal_connect(G_OBJECT(gtkblist->treeview), "key-press-event", G_CALLBACK(gtk_blist_key_press_cb), NULL); |
8143 | 3801 g_signal_connect(G_OBJECT(gtkblist->treeview), "popup-menu", G_CALLBACK(gaim_gtk_blist_popup_menu_cb), NULL); |
5228 | 3802 |
5419 | 3803 /* Enable CTRL+F searching */ |
3804 gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); | |
10433 | 3805 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL); |
5419 | 3806 |
12583 | 3807 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); |
5228 | 3808 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); |
3809 gaim_gtk_blist_update_columns(); | |
3810 | |
13015 | 3811 /* Create an empty vbox used for showing connection errors */ |
3812 gtkblist->error_buttons = gtk_vbox_new(FALSE, 0); | |
3813 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0); | |
3814 | |
3815 /* Add the statusbox */ | |
12583 | 3816 gtkblist->statusbox = gtk_gaim_status_box_new(); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
3817 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); |
12656 | 3818 |
12583 | 3819 gtk_widget_show(gtkblist->statusbox); |
3820 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); | |
12656 | 3821 |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3822 |
5228 | 3823 /* set the Show Offline Buddies option. must be done |
3824 * after the treeview or faceprint gets mad. -Robot101 | |
3825 */ | |
5427 | 3826 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), |
7620 | 3827 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
12656 | 3828 |
5427 | 3829 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
7620 | 3830 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
12656 | 3831 |
10074 | 3832 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3833 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | |
12656 | 3834 |
11796 | 3835 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), |
11920 | 3836 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); |
12656 | 3837 |
3838 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Idle Times"))), | |
3839 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
3840 | |
10074 | 3841 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
11494 | 3842 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
5228 | 3843 |
10353 | 3844 /* Update some dynamic things */ |
3845 update_menu_bar(gtkblist); | |
3846 gaim_gtk_blist_update_plugin_actions(); | |
11796 | 3847 gaim_gtk_blist_update_sort_methods(); |
10353 | 3848 |
5228 | 3849 /* OK... let's show this bad boy. */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3850 gaim_gtk_blist_refresh(list); |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3851 gaim_gtk_blist_restore_position(); |
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3852 gtk_widget_show_all(GTK_WIDGET(gtkblist->window)); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3853 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3854 |
3855 /* start the refresh timer */ | |
10351 | 3856 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); |
10353 | 3857 |
10087 | 3858 handle = gaim_gtk_blist_get_handle(); |
3859 | |
7620 | 3860 /* things that affect how buddies are displayed */ |
10087 | 3861 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3862 _prefs_change_redo_list, NULL); | |
12656 | 3863 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3864 _prefs_change_redo_list, NULL); | |
10087 | 3865 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", |
3866 _prefs_change_redo_list, NULL); | |
3867 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", | |
3868 _prefs_change_redo_list, NULL); | |
7620 | 3869 |
3870 /* sorting */ | |
10087 | 3871 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", |
3872 _prefs_change_sort_method, NULL); | |
7620 | 3873 |
3874 /* things that affect what columns are displayed */ | |
10087 | 3875 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
12326 | 3876 show_buddy_icons_pref_cb, NULL); |
12656 | 3877 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3878 show_buddy_icons_pref_cb, NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3879 |
10074 | 3880 /* menus */ |
10087 | 3881 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", |
3882 gaim_gtk_blist_mute_pref_cb, NULL); | |
3883 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/method", | |
3884 gaim_gtk_blist_sound_method_pref_cb, NULL); | |
10074 | 3885 |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3886 /* Setup some gaim signal handlers. */ |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3887 gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", |
12583 | 3888 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3889 gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", |
12583 | 3890 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12226 | 3891 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", |
12583 | 3892 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12766 | 3893 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
3894 gtkblist, GAIM_CALLBACK(account_status_changed), gtkblist); | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3895 |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3896 gaim_signal_connect(gaim_gtk_account_get_handle(), "account-modified", |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3897 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3898 |
8937 | 3899 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
3900 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
3901 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
3902 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
8815 | 3903 |
8986 | 3904 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", |
3905 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3906 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", | |
3907 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3908 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3909 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3910 gtkblist, GAIM_CALLBACK(conversation_updated_cb), |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3911 gtkblist); |
12208 | 3912 gaim_signal_connect(gaim_conversations_get_handle(), "deleting-conversation", |
3913 gtkblist, GAIM_CALLBACK(conversation_deleting_cb), | |
3914 gtkblist); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3915 |
8815 | 3916 /* emit our created signal */ |
10087 | 3917 gaim_signal_emit(handle, "gtkblist-created", list); |
5228 | 3918 } |
3919 | |
7620 | 3920 static void redo_buddy_list(GaimBuddyList *list, gboolean remove) |
5228 | 3921 { |
12112 | 3922 GaimBlistNode *node = list->root; |
3923 | |
3924 while (node) | |
3925 { | |
13889 | 3926 if (remove && !GAIM_BLIST_NODE_IS_GROUP(node)) |
12112 | 3927 gaim_gtk_blist_hide_node(list, node); |
3928 | |
3929 gaim_gtk_blist_update(list, node); | |
3930 node = gaim_blist_node_next(node, FALSE); | |
5228 | 3931 } |
3932 } | |
3933 | |
7620 | 3934 void gaim_gtk_blist_refresh(GaimBuddyList *list) |
5422 | 3935 { |
3936 redo_buddy_list(list, FALSE); | |
3937 } | |
3938 | |
5297 | 3939 void |
3940 gaim_gtk_blist_update_refresh_timeout() | |
3941 { | |
7620 | 3942 GaimBuddyList *blist; |
3943 GaimGtkBuddyList *gtkblist; | |
5297 | 3944 |
3945 blist = gaim_get_blist(); | |
3946 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
3947 | |
10351 | 3948 gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)gaim_gtk_blist_refresh_timer, blist); |
5297 | 3949 } |
3950 | |
5256 | 3951 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { |
3952 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3953 GtkTreePath *path; | |
5228 | 3954 |
5263 | 3955 if (!gtknode) { |
3956 return FALSE; | |
3957 } | |
3958 | |
3959 if (!gtkblist) { | |
10006 | 3960 gaim_debug_error("gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n"); |
5263 | 3961 return FALSE; |
3962 } | |
3963 | |
3964 if (!gtknode->row) | |
5228 | 3965 return FALSE; |
11494 | 3966 |
5228 | 3967 |
5256 | 3968 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL) |
5228 | 3969 return FALSE; |
11016 | 3970 |
5256 | 3971 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) { |
3972 gtk_tree_path_free(path); | |
3973 return FALSE; | |
3974 } | |
3975 gtk_tree_path_free(path); | |
3976 return TRUE; | |
5228 | 3977 } |
3978 | |
7620 | 3979 static void gaim_gtk_blist_remove(GaimBuddyList *list, GaimBlistNode *node) |
5228 | 3980 { |
11910 | 3981 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
3982 | |
10222 | 3983 gaim_request_close_with_handle(node); |
3984 | |
5260 | 3985 gaim_gtk_blist_hide_node(list, node); |
5228 | 3986 |
7620 | 3987 if(node->parent) |
3988 gaim_gtk_blist_update(list, node->parent); | |
3989 | |
10504 | 3990 /* There's something I don't understand here - Ethan */ |
3991 /* Ethan said that back in 2003, but this g_free has been left commented | |
3992 * out ever since. I can't find any reason at all why this is bad and | |
3993 * valgrind found several reasons why it's good. If this causes problems | |
3994 * comment it out again. Stu */ | |
10510 | 3995 /* Of course it still causes problems - this breaks dragging buddies into |
10515 | 3996 * contacts, the dragged buddy mysteriously 'disappears'. Stu. */ |
3997 /* I think it's fixed now. Stu. */ | |
11910 | 3998 |
11915 | 3999 if(gtknode) { |
4000 if(gtknode->recent_signonoff_timer > 0) | |
4001 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
4002 | |
4003 g_free(node->ui_data); | |
4004 node->ui_data = NULL; | |
4005 } | |
5228 | 4006 } |
4007 | |
4008 static gboolean do_selection_changed(GaimBlistNode *new_selection) | |
4009 { | |
5254 | 4010 GaimBlistNode *old_selection = NULL; |
5228 | 4011 |
5254 | 4012 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */ |
4013 if (gtkblist && new_selection != gtkblist->selected_node) { | |
4014 old_selection = gtkblist->selected_node; | |
5228 | 4015 gtkblist->selected_node = new_selection; |
4016 if(new_selection) | |
4017 gaim_gtk_blist_update(NULL, new_selection); | |
4018 if(old_selection) | |
4019 gaim_gtk_blist_update(NULL, old_selection); | |
4020 } | |
4021 | |
4022 return FALSE; | |
4023 } | |
4024 | |
4025 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
4026 { | |
4027 GaimBlistNode *new_selection = NULL; | |
4028 GtkTreeIter iter; | |
4029 | |
4030 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
4031 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
4032 NODE_COLUMN, &new_selection, -1); | |
4033 } | |
5254 | 4034 |
5228 | 4035 /* we set this up as a timeout, otherwise the blist flickers */ |
4036 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
4037 } | |
4038 | |
8252 | 4039 static gboolean insert_node(GaimBuddyList *list, GaimBlistNode *node, GtkTreeIter *iter) |
7620 | 4040 { |
4041 GtkTreeIter parent_iter, cur, *curptr = NULL; | |
4042 struct _gaim_gtk_blist_node *gtknode = node->ui_data; | |
5256 | 4043 GtkTreePath *newpath; |
7620 | 4044 |
10515 | 4045 if(!iter) |
8252 | 4046 return FALSE; |
7620 | 4047 |
4048 if(node->parent && !get_iter_from_node(node->parent, &parent_iter)) | |
8252 | 4049 return FALSE; |
7620 | 4050 |
4051 if(get_iter_from_node(node, &cur)) | |
4052 curptr = &cur; | |
4053 | |
4054 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4055 current_sort_method->func(node, list, parent_iter, curptr, iter); |
7620 | 4056 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4057 sort_method_none(node, list, parent_iter, curptr, iter); |
5228 | 4058 } |
4059 | |
10515 | 4060 if(gtknode != NULL) { |
4061 gtk_tree_row_reference_free(gtknode->row); | |
4062 } else { | |
4063 gaim_gtk_blist_new_node(node); | |
4064 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
4065 } | |
4066 | |
7620 | 4067 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), |
4068 iter); | |
4069 gtknode->row = | |
4070 gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), | |
4071 newpath); | |
11494 | 4072 |
5256 | 4073 gtk_tree_path_free(newpath); |
4074 | |
5228 | 4075 gtk_tree_store_set(gtkblist->treemodel, iter, |
4076 NODE_COLUMN, node, | |
4077 -1); | |
7620 | 4078 |
4079 if(node->parent) { | |
4080 GtkTreePath *expand = NULL; | |
4081 struct _gaim_gtk_blist_node *gtkparentnode = node->parent->ui_data; | |
4082 | |
4083 if(GAIM_BLIST_NODE_IS_GROUP(node->parent)) { | |
7693 | 4084 if(!gaim_blist_node_get_bool(node->parent, "collapsed")) |
7620 | 4085 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); |
4086 } else if(GAIM_BLIST_NODE_IS_CONTACT(node->parent) && | |
4087 gtkparentnode->contact_expanded) { | |
4088 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); | |
4089 } | |
4090 if(expand) { | |
7693 | 4091 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, FALSE); |
7620 | 4092 gtk_tree_path_free(expand); |
4093 } | |
4094 } | |
4095 | |
8252 | 4096 return TRUE; |
5228 | 4097 } |
4098 | |
13889 | 4099 /*This version of gaim_gtk_blist_update_group can take the original buddy |
4100 or a group, but has much better algorithmic performance with a pre-known buddy*/ | |
7620 | 4101 static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) |
4102 { | |
4103 GaimGroup *group; | |
8203 | 4104 int count; |
12341 | 4105 gboolean show = FALSE; |
13889 | 4106 GaimBlistNode* gnode; |
4107 | |
13920 | 4108 g_return_if_fail(node != NULL); |
13889 | 4109 |
4110 if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
4111 gnode = node; | |
13921 | 4112 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
13889 | 4113 gnode = node->parent->parent; |
13921 | 4114 else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) |
13889 | 4115 gnode = node->parent; |
13920 | 4116 else |
4117 return; | |
13889 | 4118 |
4119 group = (GaimGroup*)gnode; | |
7620 | 4120 |
8203 | 4121 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) |
4122 count = gaim_blist_get_group_size(group, FALSE); | |
4123 else | |
4124 count = gaim_blist_get_group_online_count(group); | |
13195 | 4125 |
12341 | 4126 if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) |
4127 show = TRUE; | |
13889 | 4128 else if (GAIM_BLIST_NODE_IS_BUDDY(node)){ /* Or chat? */ |
4129 if (buddy_is_displayable((GaimBuddy*)node)) | |
4130 show = TRUE;} | |
12341 | 4131 |
4132 if (show) { | |
7620 | 4133 char *mark, *esc; |
4134 GtkTreeIter iter; | |
4135 | |
13889 | 4136 if(!insert_node(list, gnode, &iter)) |
8252 | 4137 return; |
7620 | 4138 |
4139 esc = g_markup_escape_text(group->name, -1); | |
8945 | 4140 mark = g_strdup_printf("<span weight='bold'>%s</span> (%d/%d)", |
4141 esc, gaim_blist_get_group_online_count(group), | |
4142 gaim_blist_get_group_size(group, FALSE)); | |
7620 | 4143 g_free(esc); |
4144 | |
4145 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
4146 STATUS_ICON_COLUMN, NULL, | |
4147 STATUS_ICON_VISIBLE_COLUMN, FALSE, | |
4148 NAME_COLUMN, mark, | |
13889 | 4149 NODE_COLUMN, gnode, |
7620 | 4150 -1); |
4151 g_free(mark); | |
4152 } else { | |
13889 | 4153 gaim_gtk_blist_hide_node(list, gnode); |
7620 | 4154 } |
4155 } | |
4156 | |
4157 static void buddy_node(GaimBuddy *buddy, GtkTreeIter *iter, GaimBlistNode *node) | |
5228 | 4158 { |
9944 | 4159 GaimPresence *presence; |
7620 | 4160 GdkPixbuf *status, *avatar; |
4161 char *mark; | |
11257 | 4162 char *idle = NULL; |
7620 | 4163 gboolean selected = (gtkblist->selected_node == node); |
4164 | |
9944 | 4165 presence = gaim_buddy_get_presence(buddy); |
4166 | |
7620 | 4167 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, |
4168 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") | |
4169 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4170 | |
10482 | 4171 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); |
7620 | 4172 mark = gaim_gtk_blist_get_name_markup(buddy, selected); |
4173 | |
12656 | 4174 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
13889 | 4175 gaim_presence_is_idle(presence) && |
4176 !gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) | |
9944 | 4177 { |
4178 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
4179 | |
4180 if (idle_secs > 0) | |
4181 { | |
4182 time_t t; | |
4183 int ihrs, imin; | |
4184 time(&t); | |
4185 ihrs = (t - idle_secs) / 3600; | |
4186 imin = ((t - idle_secs) / 60) % 60; | |
13819
f41a515307a9
[gaim-migrate @ 16251]
Richard Laager <rlaager@wiktel.com>
parents:
13790
diff
changeset
|
4187 idle = g_strdup_printf("%d:%02d", ihrs, imin); |
9944 | 4188 } |
7620 | 4189 } |
4190 | |
10118 | 4191 if (gaim_presence_is_idle(presence)) |
9944 | 4192 { |
4193 if (idle && !selected) { | |
10118 | 4194 char *i2 = g_strdup_printf("<span color='%s'>%s</span>", |
4195 dim_grey(), idle); | |
7620 | 4196 g_free(idle); |
4197 idle = i2; | |
5228 | 4198 } |
7620 | 4199 } |
4200 | |
4201 gtk_tree_store_set(gtkblist->treemodel, iter, | |
4202 STATUS_ICON_COLUMN, status, | |
4203 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4204 NAME_COLUMN, mark, | |
4205 IDLE_COLUMN, idle, | |
4206 BUDDY_ICON_COLUMN, avatar, | |
4207 -1); | |
4208 | |
4209 g_free(mark); | |
12656 | 4210 g_free(idle); |
7620 | 4211 if(status) |
4212 g_object_unref(status); | |
4213 if(avatar) | |
4214 g_object_unref(avatar); | |
4215 } | |
4216 | |
13889 | 4217 /* This is a variation on the original gtk_blist_update_contact. Here we |
4218 can know in advance which buddy has changed so we can just update that */ | |
7620 | 4219 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) |
4220 { | |
13889 | 4221 GaimBlistNode *cnode; |
7620 | 4222 GaimContact *contact; |
4223 GaimBuddy *buddy; | |
4224 struct _gaim_gtk_blist_node *gtknode; | |
4225 | |
13889 | 4226 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
4227 cnode = node->parent; | |
4228 else | |
4229 cnode = node; | |
4230 | |
4231 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(cnode)); | |
7620 | 4232 |
4233 /* First things first, update the group */ | |
13889 | 4234 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
4235 gaim_gtk_blist_update_group(list, node); | |
4236 else | |
4237 gaim_gtk_blist_update_group(list, cnode->parent); | |
4238 | |
4239 contact = (GaimContact*)cnode; | |
7620 | 4240 buddy = gaim_contact_get_priority_buddy(contact); |
14035 | 4241 |
11890 | 4242 if (buddy_is_displayable(buddy)) |
10006 | 4243 { |
7620 | 4244 GtkTreeIter iter; |
4245 | |
13889 | 4246 if(!insert_node(list, cnode, &iter)) |
8252 | 4247 return; |
7620 | 4248 |
13889 | 4249 gtknode = (struct _gaim_gtk_blist_node *)cnode->ui_data; |
10515 | 4250 |
7620 | 4251 if(gtknode->contact_expanded) { |
4252 GdkPixbuf *status; | |
5228 | 4253 char *mark; |
4254 | |
13889 | 4255 status = gaim_gtk_blist_get_status_icon(cnode, |
7620 | 4256 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
4257 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4258 | |
4259 mark = g_markup_escape_text(gaim_contact_get_alias(contact), -1); | |
4260 | |
5228 | 4261 gtk_tree_store_set(gtkblist->treemodel, &iter, |
7620 | 4262 STATUS_ICON_COLUMN, status, |
4263 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
5228 | 4264 NAME_COLUMN, mark, |
7620 | 4265 IDLE_COLUMN, NULL, |
4266 BUDDY_ICON_COLUMN, NULL, | |
5228 | 4267 -1); |
4268 g_free(mark); | |
7620 | 4269 if(status) |
4270 g_object_unref(status); | |
4271 } else { | |
13889 | 4272 buddy_node(buddy, &iter, cnode); |
5228 | 4273 } |
7620 | 4274 } else { |
13889 | 4275 gaim_gtk_blist_hide_node(list, cnode); |
5228 | 4276 } |
7620 | 4277 } |
4278 | |
13889 | 4279 |
4280 | |
7620 | 4281 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) |
4282 { | |
4283 GaimBuddy *buddy; | |
4284 struct _gaim_gtk_blist_node *gtkparentnode; | |
4285 | |
4286 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4287 | |
13889 | 4288 if (node->parent == NULL) |
14035 | 4289 return; |
13889 | 4290 |
7620 | 4291 buddy = (GaimBuddy*)node; |
14035 | 4292 |
7620 | 4293 /* First things first, update the contact */ |
13889 | 4294 gaim_gtk_blist_update_contact(list, node); |
7620 | 4295 |
10918 | 4296 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
4297 | |
12341 | 4298 if (gtkparentnode->contact_expanded && buddy_is_displayable(buddy)) |
10006 | 4299 { |
7620 | 4300 GtkTreeIter iter; |
4301 | |
10006 | 4302 if (!insert_node(list, node, &iter)) |
8252 | 4303 return; |
4304 | |
7620 | 4305 buddy_node(buddy, &iter, node); |
4306 | |
4307 } else { | |
4308 gaim_gtk_blist_hide_node(list, node); | |
4309 } | |
4310 | |
4311 } | |
4312 | |
4313 static void gaim_gtk_blist_update_chat(GaimBuddyList *list, GaimBlistNode *node) | |
4314 { | |
4315 GaimChat *chat; | |
4316 | |
4317 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); | |
4318 | |
4319 /* First things first, update the group */ | |
4320 gaim_gtk_blist_update_group(list, node->parent); | |
4321 | |
4322 chat = (GaimChat*)node; | |
4323 | |
4324 if(gaim_account_is_connected(chat->account)) { | |
4325 GtkTreeIter iter; | |
5234 | 4326 GdkPixbuf *status; |
7620 | 4327 char *mark; |
4328 | |
8252 | 4329 if(!insert_node(list, node, &iter)) |
4330 return; | |
5234 | 4331 |
4332 status = gaim_gtk_blist_get_status_icon(node, | |
7620 | 4333 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
4334 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4335 | |
4336 mark = g_markup_escape_text(gaim_chat_get_name(chat), -1); | |
5234 | 4337 |
4338 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
7620 | 4339 STATUS_ICON_COLUMN, status, |
4340 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4341 NAME_COLUMN, mark, | |
4342 -1); | |
5228 | 4343 |
4344 g_free(mark); | |
7620 | 4345 if(status) |
5228 | 4346 g_object_unref(status); |
7620 | 4347 } else { |
5260 | 4348 gaim_gtk_blist_hide_node(list, node); |
5228 | 4349 } |
7620 | 4350 } |
4351 | |
4352 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node) | |
4353 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12766
diff
changeset
|
4354 if(!gtkblist || !node) |
7620 | 4355 return; |
4356 | |
13195 | 4357 if (node->ui_data == NULL) |
4358 gaim_gtk_blist_new_node(node); | |
4359 | |
7620 | 4360 switch(node->type) { |
4361 case GAIM_BLIST_GROUP_NODE: | |
4362 gaim_gtk_blist_update_group(list, node); | |
4363 break; | |
4364 case GAIM_BLIST_CONTACT_NODE: | |
4365 gaim_gtk_blist_update_contact(list, node); | |
4366 break; | |
4367 case GAIM_BLIST_BUDDY_NODE: | |
4368 gaim_gtk_blist_update_buddy(list, node); | |
4369 break; | |
4370 case GAIM_BLIST_CHAT_NODE: | |
4371 gaim_gtk_blist_update_chat(list, node); | |
4372 break; | |
4373 case GAIM_BLIST_OTHER_NODE: | |
4374 return; | |
4375 } | |
5234 | 4376 |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4377 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 4378 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4379 #endif |
5228 | 4380 } |
4381 | |
7620 | 4382 |
4383 static void gaim_gtk_blist_destroy(GaimBuddyList *list) | |
5228 | 4384 { |
4385 if (!gtkblist) | |
4386 return; | |
4387 | |
8937 | 4388 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
4389 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
4390 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
4391 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
4392 |
5228 | 4393 gtk_widget_destroy(gtkblist->window); |
7620 | 4394 |
8254 | 4395 gaim_gtk_blist_tooltip_destroy(); |
7620 | 4396 |
5228 | 4397 if (gtkblist->refresh_timer) |
4398 g_source_remove(gtkblist->refresh_timer); | |
4399 if (gtkblist->timeout) | |
4400 g_source_remove(gtkblist->timeout); | |
10354 | 4401 if (gtkblist->drag_timeout) |
4402 g_source_remove(gtkblist->drag_timeout); | |
5228 | 4403 |
13015 | 4404 g_hash_table_destroy(gtkblist->connection_errors); |
5228 | 4405 gtkblist->refresh_timer = 0; |
4406 gtkblist->timeout = 0; | |
10354 | 4407 gtkblist->drag_timeout = 0; |
5228 | 4408 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; |
4409 gtkblist->treemodel = NULL; | |
4410 gtkblist->idle_column = NULL; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4411 gtkblist->buddy_icon_column = NULL; |
5427 | 4412 g_object_unref(G_OBJECT(gtkblist->ift)); |
13015 | 4413 g_free(gtkblist); |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4414 accountmenu = NULL; |
5228 | 4415 gtkblist = NULL; |
7620 | 4416 |
10087 | 4417 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
5228 | 4418 } |
4419 | |
7620 | 4420 static void gaim_gtk_blist_set_visible(GaimBuddyList *list, gboolean show) |
5228 | 4421 { |
4422 if (!(gtkblist && gtkblist->window)) | |
4423 return; | |
10325 | 4424 |
5228 | 4425 if (show) { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4426 if(!GAIM_WINDOW_ICONIFIED(gtkblist->window) && !GTK_WIDGET_VISIBLE(gtkblist->window)) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4427 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", gtkblist); |
5228 | 4428 gaim_gtk_blist_restore_position(); |
4429 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4430 } else { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4431 if(visibility_manager_count) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4432 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-hiding", gtkblist); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4433 gtk_widget_hide(gtkblist->window); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4434 } else { |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4435 if (!GTK_WIDGET_VISIBLE(gtkblist->window)) |
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4436 gtk_widget_show(gtkblist->window); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4437 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4438 } |
5228 | 4439 } |
4440 } | |
4441 | |
7620 | 4442 static GList * |
4443 groups_tree(void) | |
4444 { | |
4445 GList *tmp = NULL; | |
4446 char *tmp2; | |
4447 GaimGroup *g; | |
4448 GaimBlistNode *gnode; | |
4449 | |
4450 if (gaim_get_blist()->root == NULL) | |
4451 { | |
4452 tmp2 = g_strdup(_("Buddies")); | |
4453 tmp = g_list_append(tmp, tmp2); | |
4454 } | |
4455 else | |
4456 { | |
4457 for (gnode = gaim_get_blist()->root; | |
4458 gnode != NULL; | |
4459 gnode = gnode->next) | |
4460 { | |
4461 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4462 { | |
4463 g = (GaimGroup *)gnode; | |
4464 tmp2 = g->name; | |
4465 tmp = g_list_append(tmp, tmp2); | |
4466 } | |
4467 } | |
4468 } | |
4469 | |
4470 return tmp; | |
4471 } | |
4472 | |
4473 static void | |
4474 add_buddy_select_account_cb(GObject *w, GaimAccount *account, | |
4475 GaimGtkAddBuddyData *data) | |
4476 { | |
4477 /* Save our account */ | |
4478 data->account = account; | |
4479 } | |
4480 | |
4481 static void | |
4482 destroy_add_buddy_dialog_cb(GtkWidget *win, GaimGtkAddBuddyData *data) | |
4483 { | |
4484 g_free(data); | |
4485 } | |
4486 | |
4487 static void | |
4488 add_buddy_cb(GtkWidget *w, int resp, GaimGtkAddBuddyData *data) | |
4489 { | |
4490 const char *grp, *who, *whoalias; | |
13880 | 4491 GaimGroup *g; |
7620 | 4492 GaimBuddy *b; |
13880 | 4493 GaimConversation *c; |
4494 GaimBuddyIcon *icon; | |
7620 | 4495 |
4496 if (resp == GTK_RESPONSE_OK) | |
4497 { | |
4498 who = gtk_entry_get_text(GTK_ENTRY(data->entry)); | |
4499 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry)); | |
4500 whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); | |
9658 | 4501 if (*whoalias == '\0') |
4502 whoalias = NULL; | |
7620 | 4503 |
4504 if ((g = gaim_find_group(grp)) == NULL) | |
4505 { | |
4506 g = gaim_group_new(grp); | |
4507 gaim_blist_add_group(g, NULL); | |
4508 } | |
4509 | |
4510 b = gaim_buddy_new(data->account, who, whoalias); | |
4511 gaim_blist_add_buddy(b, NULL, g, NULL); | |
11643 | 4512 gaim_account_add_buddy(data->account, b); |
7620 | 4513 |
7887 | 4514 /* |
9285 | 4515 * XXX |
11643 | 4516 * It really seems like it would be better if the call to |
4517 * gaim_account_add_buddy() and gaim_conversation_update() were done in | |
4518 * blist.c, possibly in the gaim_blist_add_buddy() function. Maybe | |
4519 * gaim_account_add_buddy() should be renamed to | |
4520 * gaim_blist_add_new_buddy() or something, and have it call | |
7887 | 4521 * gaim_blist_add_buddy() after it creates it. --Mark |
9285 | 4522 * |
4523 * No that's not good. blist.c should only deal with adding nodes to the | |
11643 | 4524 * local list. We need a new, non-gtk file that calls both |
4525 * gaim_account_add_buddy and gaim_blist_add_buddy(). | |
4526 * Or something. --Mark | |
7887 | 4527 */ |
4528 | |
11338 | 4529 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, data->account); |
7620 | 4530 if (c != NULL) { |
13880 | 4531 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(c)); |
4532 if (icon != NULL) | |
4533 gaim_buddy_icon_update(icon); | |
7620 | 4534 } |
4535 } | |
4536 | |
4537 gtk_widget_destroy(data->window); | |
4538 } | |
4539 | |
4540 static void | |
4541 gaim_gtk_blist_request_add_buddy(GaimAccount *account, const char *username, | |
4542 const char *group, const char *alias) | |
4543 { | |
4544 GtkWidget *table; | |
4545 GtkWidget *label; | |
4546 GtkWidget *hbox; | |
4547 GtkWidget *vbox; | |
4548 GtkWidget *img; | |
4549 GaimGtkBuddyList *gtkblist; | |
4550 GaimGtkAddBuddyData *data = g_new0(GaimGtkAddBuddyData, 1); | |
4551 | |
4552 data->account = | |
4553 (account != NULL | |
4554 ? account | |
4555 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
4556 | |
4557 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4558 GTK_ICON_SIZE_DIALOG); | |
4559 | |
4560 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
4561 | |
4562 data->window = gtk_dialog_new_with_buttons(_("Add Buddy"), | |
8975 | 4563 NULL, GTK_DIALOG_NO_SEPARATOR, |
7620 | 4564 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
4565 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4566 NULL); | |
4567 | |
4568 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4569 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
7620 | 4570 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4571 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4572 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4573 gtk_window_set_role(GTK_WINDOW(data->window), "add_buddy"); |
8975 | 4574 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4575 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4576 |
11243 | 4577 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4578 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4579 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4580 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4581 | |
4582 vbox = gtk_vbox_new(FALSE, 0); | |
4583 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4584 | |
4585 label = gtk_label_new( | |
4586 _("Please enter the screen name of the person you would like " | |
4587 "to add to your buddy list. You may optionally enter an alias, " | |
4588 "or nickname, for the buddy. The alias will be displayed in " | |
4589 "place of the screen name whenever possible.\n")); | |
4590 | |
4591 gtk_widget_set_size_request(GTK_WIDGET(label), 400, -1); | |
4592 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4593 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4594 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4595 | |
11243 | 4596 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7620 | 4597 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
4598 | |
4599 g_signal_connect(G_OBJECT(data->window), "destroy", | |
4600 G_CALLBACK(destroy_add_buddy_dialog_cb), data); | |
4601 | |
4602 table = gtk_table_new(4, 2, FALSE); | |
4603 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
4604 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
4605 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | |
4606 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
4607 | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13542
diff
changeset
|
4608 label = gtk_label_new(_("Screen name:")); |
7620 | 4609 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4610 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
4611 | |
4612 data->entry = gtk_entry_new(); | |
4613 gtk_table_attach_defaults(GTK_TABLE(table), data->entry, 1, 2, 0, 1); | |
4614 gtk_widget_grab_focus(data->entry); | |
4615 | |
4616 if (username != NULL) | |
4617 gtk_entry_set_text(GTK_ENTRY(data->entry), username); | |
12337 | 4618 else |
4619 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), | |
4620 GTK_RESPONSE_OK, FALSE); | |
7620 | 4621 |
4622 gtk_entry_set_activates_default (GTK_ENTRY(data->entry), TRUE); | |
8137 | 4623 gaim_set_accessible_label (data->entry, label); |
7620 | 4624 |
12337 | 4625 g_signal_connect(G_OBJECT(data->entry), "changed", |
4626 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
4627 data->window); | |
4628 | |
7620 | 4629 label = gtk_label_new(_("Alias:")); |
4630 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4631 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
4632 | |
4633 data->entry_for_alias = gtk_entry_new(); | |
4634 gtk_table_attach_defaults(GTK_TABLE(table), | |
4635 data->entry_for_alias, 1, 2, 1, 2); | |
4636 | |
4637 if (alias != NULL) | |
4638 gtk_entry_set_text(GTK_ENTRY(data->entry_for_alias), alias); | |
4639 | |
10734
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4640 if (username != NULL) |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4641 gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4642 |
7620 | 4643 gtk_entry_set_activates_default (GTK_ENTRY(data->entry_for_alias), TRUE); |
8137 | 4644 gaim_set_accessible_label (data->entry_for_alias, label); |
7620 | 4645 |
4646 label = gtk_label_new(_("Group:")); | |
4647 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4648 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
4649 | |
4650 data->combo = gtk_combo_new(); | |
4651 gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree()); | |
4652 gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 2, 3); | |
8137 | 4653 gaim_set_accessible_label (data->combo, label); |
7620 | 4654 |
4655 /* Set up stuff for the account box */ | |
4656 label = gtk_label_new(_("Account:")); | |
4657 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4658 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
4659 | |
4660 data->account_box = gaim_gtk_account_option_menu_new(account, FALSE, | |
4661 G_CALLBACK(add_buddy_select_account_cb), NULL, data); | |
4662 | |
4663 gtk_table_attach_defaults(GTK_TABLE(table), data->account_box, 1, 2, 3, 4); | |
8137 | 4664 gaim_set_accessible_label (data->account_box, label); |
7620 | 4665 /* End of account box */ |
4666 | |
4667 g_signal_connect(G_OBJECT(data->window), "response", | |
4668 G_CALLBACK(add_buddy_cb), data); | |
4669 | |
4670 gtk_widget_show_all(data->window); | |
4671 | |
4672 if (group != NULL) | |
4673 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group); | |
4674 } | |
4675 | |
4676 static void | |
4677 add_chat_cb(GtkWidget *w, GaimGtkAddChatData *data) | |
4678 { | |
4679 GHashTable *components; | |
4680 GList *tmp; | |
4681 GaimChat *chat; | |
4682 GaimGroup *group; | |
4683 const char *group_name; | |
10475 | 4684 const char *value; |
7620 | 4685 |
4686 components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
4687 g_free, g_free); | |
4688 | |
4689 for (tmp = data->entries; tmp; tmp = tmp->next) | |
4690 { | |
4691 if (g_object_get_data(tmp->data, "is_spin")) | |
4692 { | |
4693 g_hash_table_replace(components, | |
4694 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4695 g_strdup_printf("%d", | |
4696 gtk_spin_button_get_value_as_int(tmp->data))); | |
4697 } | |
4698 else | |
4699 { | |
10475 | 4700 value = gtk_entry_get_text(tmp->data); |
4701 if (*value != '\0') | |
4702 g_hash_table_replace(components, | |
4703 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4704 g_strdup(value)); | |
7620 | 4705 } |
4706 } | |
4707 | |
4708 chat = gaim_chat_new(data->account, | |
4709 gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), | |
4710 components); | |
4711 | |
4712 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry)); | |
4713 | |
4714 if ((group = gaim_find_group(group_name)) == NULL) | |
4715 { | |
4716 group = gaim_group_new(group_name); | |
4717 gaim_blist_add_group(group, NULL); | |
4718 } | |
4719 | |
4720 if (chat != NULL) | |
4721 { | |
4722 gaim_blist_add_chat(chat, group, NULL); | |
4723 } | |
4724 | |
4725 gtk_widget_destroy(data->window); | |
9812 | 4726 g_free(data->default_chat_name); |
7620 | 4727 g_list_free(data->entries); |
4728 g_free(data); | |
4729 } | |
4730 | |
4731 static void | |
4732 add_chat_resp_cb(GtkWidget *w, int resp, GaimGtkAddChatData *data) | |
4733 { | |
4734 if (resp == GTK_RESPONSE_OK) | |
4735 { | |
4736 add_chat_cb(NULL, data); | |
4737 } | |
4738 else | |
4739 { | |
4740 gtk_widget_destroy(data->window); | |
9812 | 4741 g_free(data->default_chat_name); |
7620 | 4742 g_list_free(data->entries); |
4743 g_free(data); | |
4744 } | |
4745 } | |
4746 | |
10475 | 4747 /* |
4748 * Check the values of all the text entry boxes. If any required input | |
4749 * strings are empty then don't allow the user to click on "OK." | |
4750 */ | |
4751 static void | |
4752 addchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
4753 { | |
4754 GaimGtkAddChatData *data; | |
4755 GList *tmp; | |
4756 const char *text; | |
4757 gboolean required; | |
4758 gboolean sensitive = TRUE; | |
4759 | |
4760 data = user_data; | |
4761 | |
4762 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
4763 { | |
4764 if (!g_object_get_data(tmp->data, "is_spin")) | |
4765 { | |
4766 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
4767 text = gtk_entry_get_text(tmp->data); | |
4768 if (required && (*text == '\0')) | |
4769 sensitive = FALSE; | |
4770 } | |
4771 } | |
4772 | |
4773 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
4774 } | |
4775 | |
7620 | 4776 static void |
4777 rebuild_addchat_entries(GaimGtkAddChatData *data) | |
4778 { | |
4779 GaimConnection *gc; | |
9959 | 4780 GList *list = NULL, *tmp = NULL; |
9754 | 4781 GHashTable *defaults = NULL; |
7620 | 4782 struct proto_chat_entry *pce; |
4783 gboolean focus = TRUE; | |
4784 | |
10127 | 4785 g_return_if_fail(data->account != NULL); |
4786 | |
7620 | 4787 gc = gaim_account_get_connection(data->account); |
4788 | |
4789 while (GTK_BOX(data->entries_box)->children) | |
4790 { | |
4791 gtk_container_remove(GTK_CONTAINER(data->entries_box), | |
10475 | 4792 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
7620 | 4793 } |
4794 | |
14035 | 4795 g_list_free(data->entries); |
7620 | 4796 |
4797 data->entries = NULL; | |
4798 | |
9959 | 4799 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4800 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | |
7620 | 4801 |
9754 | 4802 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
10475 | 4803 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, data->default_chat_name); |
9754 | 4804 |
7620 | 4805 for (tmp = list; tmp; tmp = tmp->next) |
4806 { | |
4807 GtkWidget *label; | |
4808 GtkWidget *rowbox; | |
10475 | 4809 GtkWidget *input; |
7620 | 4810 |
4811 pce = tmp->data; | |
4812 | |
4813 rowbox = gtk_hbox_new(FALSE, 5); | |
4814 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); | |
4815 | |
7889 | 4816 label = gtk_label_new_with_mnemonic(pce->label); |
7620 | 4817 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4818 gtk_size_group_add_widget(data->sg, label); | |
4819 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4820 | |
4821 if (pce->is_int) | |
4822 { | |
4823 GtkObject *adjust; | |
4824 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, | |
4825 1, 10, 10); | |
10475 | 4826 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
4827 gtk_widget_set_size_request(input, 50, -1); | |
4828 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
7620 | 4829 } |
4830 else | |
4831 { | |
9754 | 4832 char *value; |
10475 | 4833 input = gtk_entry_new(); |
4834 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9754 | 4835 value = g_hash_table_lookup(defaults, pce->identifier); |
4836 if (value != NULL) | |
10475 | 4837 gtk_entry_set_text(GTK_ENTRY(input), value); |
7620 | 4838 if (pce->secret) |
11986 | 4839 { |
10475 | 4840 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 4841 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
4842 } | |
10475 | 4843 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
4844 g_signal_connect(G_OBJECT(input), "changed", | |
4845 G_CALLBACK(addchat_set_sensitive_if_input_cb), data); | |
7620 | 4846 } |
4847 | |
10475 | 4848 /* Do the following for any type of input widget */ |
4849 if (focus) | |
4850 { | |
4851 gtk_widget_grab_focus(input); | |
4852 focus = FALSE; | |
4853 } | |
4854 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
4855 gaim_set_accessible_label(input, label); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4856 g_object_set_data(G_OBJECT(input), "identifier", (gpointer)pce->identifier); |
10475 | 4857 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); |
4858 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
4859 data->entries = g_list_append(data->entries, input); | |
4860 | |
7620 | 4861 g_free(pce); |
4862 } | |
4863 | |
4864 g_list_free(list); | |
9754 | 4865 g_hash_table_destroy(defaults); |
7620 | 4866 |
10475 | 4867 /* Set whether the "OK" button should be clickable initially */ |
4868 addchat_set_sensitive_if_input_cb(NULL, data); | |
4869 | |
7620 | 4870 gtk_widget_show_all(data->entries_box); |
4871 } | |
4872 | |
4873 static void | |
10475 | 4874 addchat_select_account_cb(GObject *w, GaimAccount *account, |
7620 | 4875 GaimGtkAddChatData *data) |
4876 { | |
9460 | 4877 if (strcmp(gaim_account_get_protocol_id(data->account), |
4878 gaim_account_get_protocol_id(account)) == 0) | |
7620 | 4879 { |
4880 data->account = account; | |
4881 } | |
4882 else | |
4883 { | |
4884 data->account = account; | |
4885 rebuild_addchat_entries(data); | |
4886 } | |
4887 } | |
4888 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4889 static void |
7859 | 4890 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
9754 | 4891 const char *alias, const char *name) |
7620 | 4892 { |
4893 GaimGtkAddChatData *data; | |
8975 | 4894 GaimGtkBuddyList *gtkblist; |
4895 GList *l; | |
4896 GaimConnection *gc; | |
7620 | 4897 GtkWidget *label; |
4898 GtkWidget *rowbox; | |
4899 GtkWidget *hbox; | |
4900 GtkWidget *vbox; | |
4901 GtkWidget *img; | |
4902 | |
9812 | 4903 if (account != NULL) { |
4904 gc = gaim_account_get_connection(account); | |
4905 | |
4906 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | |
4907 gaim_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | |
4908 return; | |
4909 } | |
4910 } else { | |
4911 /* Find an account with chat capabilities */ | |
4912 for (l = gaim_connections_get_all(); l != NULL; l = l->next) { | |
4913 gc = (GaimConnection *)l->data; | |
4914 | |
4915 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | |
4916 account = gaim_connection_get_account(gc); | |
4917 break; | |
4918 } | |
4919 } | |
4920 | |
4921 if (account == NULL) { | |
4922 gaim_notify_error(NULL, NULL, | |
4923 _("You are not currently signed on with any " | |
4924 "protocols that have the ability to chat."), NULL); | |
4925 return; | |
4926 } | |
4927 } | |
4928 | |
7620 | 4929 data = g_new0(GaimGtkAddChatData, 1); |
9812 | 4930 data->account = account; |
4931 data->default_chat_name = g_strdup(name); | |
7620 | 4932 |
4933 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4934 GTK_ICON_SIZE_DIALOG); | |
4935 | |
8975 | 4936 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4937 | |
7620 | 4938 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4939 | |
8975 | 4940 data->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
4941 NULL, GTK_DIALOG_NO_SEPARATOR, | |
4942 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
4943 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4944 NULL); | |
4945 | |
4946 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4947 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8975 | 4948 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4949 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4950 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4951 gtk_window_set_role(GTK_WINDOW(data->window), "add_chat"); |
8975 | 4952 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4953 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4954 |
11243 | 4955 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4956 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4957 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4958 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4959 | |
4960 vbox = gtk_vbox_new(FALSE, 5); | |
4961 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4962 | |
4963 label = gtk_label_new( | |
4964 _("Please enter an alias, and the appropriate information " | |
4965 "about the chat you would like to add to your buddy list.\n")); | |
4966 gtk_widget_set_size_request(label, 400, -1); | |
4967 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4968 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4969 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4970 | |
4971 rowbox = gtk_hbox_new(FALSE, 5); | |
4972 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4973 | |
4974 label = gtk_label_new(_("Account:")); | |
4975 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4976 gtk_size_group_add_widget(data->sg, label); | |
4977 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4978 | |
4979 data->account_menu = gaim_gtk_account_option_menu_new(account, FALSE, | |
10475 | 4980 G_CALLBACK(addchat_select_account_cb), |
9987 | 4981 chat_account_filter_func, data); |
7620 | 4982 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
8137 | 4983 gaim_set_accessible_label (data->account_menu, label); |
7620 | 4984 |
4985 data->entries_box = gtk_vbox_new(FALSE, 5); | |
9811 | 4986 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
7620 | 4987 gtk_box_pack_start(GTK_BOX(vbox), data->entries_box, TRUE, TRUE, 0); |
4988 | |
4989 rebuild_addchat_entries(data); | |
4990 | |
4991 rowbox = gtk_hbox_new(FALSE, 5); | |
4992 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4993 | |
4994 label = gtk_label_new(_("Alias:")); | |
4995 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4996 gtk_size_group_add_widget(data->sg, label); | |
4997 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4998 | |
4999 data->alias_entry = gtk_entry_new(); | |
7859 | 5000 if (alias != NULL) |
5001 gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias); | |
7620 | 5002 gtk_box_pack_end(GTK_BOX(rowbox), data->alias_entry, TRUE, TRUE, 0); |
10311 | 5003 gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE); |
8137 | 5004 gaim_set_accessible_label (data->alias_entry, label); |
7620 | 5005 |
5006 rowbox = gtk_hbox_new(FALSE, 5); | |
5007 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
5008 | |
9811 | 5009 label = gtk_label_new(_("Group:")); |
7620 | 5010 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5011 gtk_size_group_add_widget(data->sg, label); | |
5012 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
5013 | |
9811 | 5014 data->group_combo = gtk_combo_new(); |
5015 gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree()); | |
7620 | 5016 gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0); |
5017 | |
5018 if (group) | |
5019 { | |
5020 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry), | |
5021 group->name); | |
5022 } | |
8137 | 5023 gaim_set_accessible_label (data->group_combo, label); |
7620 | 5024 |
5025 g_signal_connect(G_OBJECT(data->window), "response", | |
5026 G_CALLBACK(add_chat_resp_cb), data); | |
5027 | |
5028 gtk_widget_show_all(data->window); | |
5029 } | |
5030 | |
5031 static void | |
5032 add_group_cb(GaimConnection *gc, const char *group_name) | |
5033 { | |
9285 | 5034 GaimGroup *group; |
5035 | |
12458 | 5036 if ((group_name == NULL) || (*group_name == '\0')) |
5037 return; | |
5038 | |
9285 | 5039 group = gaim_group_new(group_name); |
5040 gaim_blist_add_group(group, NULL); | |
7620 | 5041 } |
5042 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5043 static void |
7620 | 5044 gaim_gtk_blist_request_add_group(void) |
5045 { | |
7853 | 5046 gaim_request_input(NULL, _("Add Group"), NULL, |
7620 | 5047 _("Please enter the name of the group to be added."), |
8697 | 5048 NULL, FALSE, FALSE, NULL, |
7620 | 5049 _("Add"), G_CALLBACK(add_group_cb), |
5050 _("Cancel"), NULL, NULL); | |
5051 } | |
5052 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5053 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5054 gaim_gtk_blist_toggle_visibility() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5055 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5056 if (gtkblist && gtkblist->window) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5057 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5058 gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gtk_blist_obscured); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5059 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5060 gaim_blist_set_visible(TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5061 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5062 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5063 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5064 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5065 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5066 gaim_gtk_blist_visibility_manager_add() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5067 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5068 visibility_manager_count++; |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
5069 gaim_debug_info("gtkblist", "added visibility manager: %d\n", visibility_manager_count); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5070 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5071 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5072 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5073 gaim_gtk_blist_visibility_manager_remove() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5074 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5075 if (visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5076 visibility_manager_count--; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5077 if (!visibility_manager_count) |
13674 | 5078 gaim_blist_set_visible(TRUE); |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
5079 gaim_debug_info("gtkblist", "removed visibility manager: %d\n", visibility_manager_count); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5080 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5081 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5082 |
7620 | 5083 static GaimBlistUiOps blist_ui_ops = |
5228 | 5084 { |
5085 gaim_gtk_blist_new_list, | |
5256 | 5086 gaim_gtk_blist_new_node, |
5228 | 5087 gaim_gtk_blist_show, |
5088 gaim_gtk_blist_update, | |
5089 gaim_gtk_blist_remove, | |
5090 gaim_gtk_blist_destroy, | |
7620 | 5091 gaim_gtk_blist_set_visible, |
5092 gaim_gtk_blist_request_add_buddy, | |
5093 gaim_gtk_blist_request_add_chat, | |
10012 | 5094 gaim_gtk_blist_request_add_group |
5228 | 5095 }; |
5096 | |
5097 | |
7620 | 5098 GaimBlistUiOps * |
5099 gaim_gtk_blist_get_ui_ops(void) | |
5228 | 5100 { |
5101 return &blist_ui_ops; | |
5102 } | |
5103 | |
10643 | 5104 GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() |
5105 { | |
5106 return gtkblist; | |
5107 } | |
5108 | |
7620 | 5109 static void account_signon_cb(GaimConnection *gc, gpointer z) |
5110 { | |
5111 GaimAccount *account = gaim_connection_get_account(gc); | |
5112 GaimBlistNode *gnode, *cnode; | |
5113 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) | |
5114 { | |
5115 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5116 continue; | |
5117 for(cnode = gnode->child; cnode; cnode = cnode->next) | |
5118 { | |
5119 GaimChat *chat; | |
5120 | |
5121 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
5122 continue; | |
5123 | |
5124 chat = (GaimChat *)cnode; | |
5125 | |
5126 if(chat->account != account) | |
5127 continue; | |
5128 | |
8197 | 5129 if(gaim_blist_node_get_bool((GaimBlistNode*)chat, "gtk-autojoin") || |
8198 | 5130 (gaim_blist_node_get_string((GaimBlistNode*)chat, |
5131 "gtk-autojoin") != NULL)) | |
7620 | 5132 serv_join_chat(gc, chat->components); |
5133 } | |
5134 } | |
5135 } | |
5136 | |
8815 | 5137 void * |
5138 gaim_gtk_blist_get_handle() { | |
5139 static int handle; | |
5140 | |
5141 return &handle; | |
5142 } | |
5143 | |
11910 | 5144 static gboolean buddy_signonoff_timeout_cb(GaimBuddy *buddy) |
5145 { | |
5146 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
5147 | |
5148 gtknode->recent_signonoff = FALSE; | |
5149 gtknode->recent_signonoff_timer = 0; | |
5150 | |
5151 gaim_gtk_blist_update(NULL, (GaimBlistNode*)buddy); | |
5152 | |
5153 return FALSE; | |
5154 } | |
5155 | |
5156 static void buddy_signonoff_cb(GaimBuddy *buddy) | |
5157 { | |
11915 | 5158 struct _gaim_gtk_blist_node *gtknode; |
5159 | |
5160 if(!((GaimBlistNode*)buddy)->ui_data) { | |
5161 gaim_gtk_blist_new_node((GaimBlistNode*)buddy); | |
5162 } | |
5163 | |
5164 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
11910 | 5165 |
5166 gtknode->recent_signonoff = TRUE; | |
5167 | |
5168 if(gtknode->recent_signonoff_timer > 0) | |
5169 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
5170 gtknode->recent_signonoff_timer = gaim_timeout_add(10000, | |
5171 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); | |
5172 } | |
5173 | |
7620 | 5174 void gaim_gtk_blist_init(void) |
5175 { | |
8815 | 5176 void *gtk_blist_handle = gaim_gtk_blist_get_handle(); |
7620 | 5177 |
5178 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
8815 | 5179 gtk_blist_handle, GAIM_CALLBACK(account_signon_cb), |
7620 | 5180 NULL); |
7731 | 5181 |
5182 /* Initialize prefs */ | |
8819 | 5183 gaim_prefs_add_none("/gaim/gtk/blist"); |
5184 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); | |
5185 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); | |
12656 | 5186 gaim_prefs_add_bool("/gaim/gtk/blist/show_idle_time", TRUE); |
8819 | 5187 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); |
10282 | 5188 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); |
12279 | 5189 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE); |
9711 | 5190 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); |
8819 | 5191 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
5192 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | |
9778 | 5193 gaim_prefs_add_int("/gaim/gtk/blist/width", 309); /* Golden ratio, baby */ |
5194 gaim_prefs_add_int("/gaim/gtk/blist/height", 500); /* Golden ratio, baby */ | |
8819 | 5195 gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500); |
7731 | 5196 |
8815 | 5197 /* Register our signals */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5198 gaim_signal_register(gtk_blist_handle, "gtkblist-hiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5199 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5200 gaim_value_new(GAIM_TYPE_POINTER)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5201 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5202 gaim_signal_register(gtk_blist_handle, "gtkblist-unhiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5203 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5204 gaim_value_new(GAIM_TYPE_SUBTYPE)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5205 |
8815 | 5206 gaim_signal_register(gtk_blist_handle, "gtkblist-created", |
9811 | 5207 gaim_marshal_VOID__POINTER, NULL, 1, |
5208 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
5209 GAIM_SUBTYPE_BLIST)); | |
8819 | 5210 |
5211 gaim_signal_register(gtk_blist_handle, "drawing-tooltip", | |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5212 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
9811 | 5213 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_BLIST_NODE), |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5214 gaim_value_new_outgoing(GAIM_TYPE_BOXED, "GString *"), |
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5215 gaim_value_new(GAIM_TYPE_BOOLEAN)); |
11910 | 5216 |
5217 | |
5218 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
5219 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
7620 | 5220 } |
5221 | |
8815 | 5222 void |
5223 gaim_gtk_blist_uninit(void) { | |
5224 gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle()); | |
5225 } | |
5228 | 5226 |
5227 /********************************************************************* | |
9811 | 5228 * Buddy List sorting functions * |
5422 | 5229 *********************************************************************/ |
5230 | |
11796 | 5231 GList *gaim_gtk_blist_get_sort_methods() |
5232 { | |
5233 return gaim_gtk_blist_sort_methods; | |
5234 } | |
5235 | |
7620 | 5236 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
5422 | 5237 { |
5238 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | |
7620 | 5239 method->id = g_strdup(id); |
5422 | 5240 method->name = g_strdup(name); |
9775 | 5241 method->func = func; |
11796 | 5242 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
5243 gaim_gtk_blist_update_sort_methods(); | |
5422 | 5244 } |
5245 | |
7620 | 5246 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
11796 | 5247 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5248 |
5249 while(l) { | |
5250 struct gaim_gtk_blist_sort_method *method = l->data; | |
5251 if(!strcmp(method->id, id)) { | |
11796 | 5252 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
7620 | 5253 g_free(method->id); |
5254 g_free(method->name); | |
5255 g_free(method); | |
5256 break; | |
5257 } | |
5258 } | |
11796 | 5259 gaim_gtk_blist_update_sort_methods(); |
5422 | 5260 } |
5261 | |
7620 | 5262 void gaim_gtk_blist_sort_method_set(const char *id){ |
11796 | 5263 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5264 |
5265 if(!id) | |
5266 id = "none"; | |
5267 | |
5268 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | |
5422 | 5269 l = l->next; |
7620 | 5270 |
5422 | 5271 if (l) { |
5272 current_sort_method = l->data; | |
5273 } else if (!current_sort_method) { | |
7620 | 5274 gaim_gtk_blist_sort_method_set("none"); |
5422 | 5275 return; |
5276 } | |
5277 redo_buddy_list(gaim_get_blist(), TRUE); | |
5278 | |
5279 } | |
5280 | |
5281 /****************************************** | |
5282 ** Sort Methods | |
5283 ******************************************/ | |
5284 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5285 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter parent_iter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5286 { |
7620 | 5287 GaimBlistNode *sibling = node->prev; |
5288 GtkTreeIter sibling_iter; | |
5289 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5290 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5291 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5292 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5293 } |
7620 | 5294 |
5295 while (sibling && !get_iter_from_node(sibling, &sibling_iter)) { | |
5296 sibling = sibling->prev; | |
5422 | 5297 } |
7620 | 5298 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5299 gtk_tree_store_insert_after(gtkblist->treemodel, iter, |
7620 | 5300 node->parent ? &parent_iter : NULL, |
5301 sibling ? &sibling_iter : NULL); | |
5422 | 5302 } |
5303 | |
7620 | 5304 #if GTK_CHECK_VERSION(2,2,1) |
5305 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5306 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5307 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5308 GtkTreeIter more_z; |
7620 | 5309 |
5310 const char *my_name; | |
5311 | |
5312 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5313 my_name = gaim_contact_get_alias((GaimContact*)node); | |
5314 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5315 my_name = gaim_chat_get_name((GaimChat*)node); | |
5316 } else { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5317 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5318 return; |
7620 | 5319 } |
5320 | |
5422 | 5321 |
5322 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5323 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5324 return; |
7620 | 5325 } |
5326 | |
5327 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5328 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5329 GaimBlistNode *n; |
7620 | 5330 const char *this_name; |
5331 int cmp; | |
5332 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5333 val.g_type = 0; |
7620 | 5334 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5335 n = g_value_get_pointer(&val); | |
5336 | |
5337 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5338 this_name = gaim_contact_get_alias((GaimContact*)n); | |
5339 } else if(GAIM_BLIST_NODE_IS_CHAT(n)) { | |
5340 this_name = gaim_chat_get_name((GaimChat*)n); | |
5341 } else { | |
5342 this_name = NULL; | |
5343 } | |
5344 | |
5345 cmp = gaim_utf8_strcasecmp(my_name, this_name); | |
5346 | |
5347 if(this_name && (cmp < 0 || (cmp == 0 && node < n))) { | |
5348 if(cur) { | |
5349 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5350 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5351 return; |
7620 | 5352 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5353 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5354 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5355 return; |
7620 | 5356 } |
5357 } | |
5358 g_value_unset(&val); | |
5359 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
5360 | |
5361 if(cur) { | |
5362 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5363 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5364 return; |
7620 | 5365 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5366 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5367 return; |
7620 | 5368 } |
5369 } | |
5370 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5371 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
7620 | 5372 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5373 GtkTreeIter more_z; |
7620 | 5374 |
5375 GaimBuddy *my_buddy, *this_buddy; | |
5376 | |
5377 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5378 my_buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
5379 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5380 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5381 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5382 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5383 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5384 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5385 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5386 return; |
7620 | 5387 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5388 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5389 return; |
7620 | 5390 } |
5391 | |
5392 | |
5393 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5394 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5395 return; |
5422 | 5396 } |
5397 | |
5398 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5399 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5400 GaimBlistNode *n; |
9944 | 5401 gint name_cmp; |
5402 gint presence_cmp; | |
7620 | 5403 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5404 val.g_type = 0; |
5422 | 5405 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5406 n = g_value_get_pointer(&val); | |
7620 | 5407 |
5408 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5409 this_buddy = gaim_contact_get_priority_buddy((GaimContact*)n); | |
5410 } else { | |
5411 this_buddy = NULL; | |
5412 } | |
5413 | |
9944 | 5414 name_cmp = gaim_utf8_strcasecmp( |
13670
a373da801dc1
[gaim-migrate @ 16072]
Richard Laager <rlaager@wiktel.com>
parents:
13629
diff
changeset
|
5415 gaim_contact_get_alias(gaim_buddy_get_contact(my_buddy)), |
9944 | 5416 (this_buddy |
5417 ? gaim_contact_get_alias(gaim_buddy_get_contact(this_buddy)) | |
5418 : NULL)); | |
5419 | |
5420 presence_cmp = gaim_presence_compare( | |
5421 gaim_buddy_get_presence(my_buddy), | |
13689
5fb687f9965c
[gaim-migrate @ 16092]
Richard Laager <rlaager@wiktel.com>
parents:
13684
diff
changeset
|
5422 this_buddy ? gaim_buddy_get_presence(this_buddy) : NULL); |
9944 | 5423 |
5424 if (this_buddy == NULL || | |
10860 | 5425 (presence_cmp < 0 || |
9944 | 5426 (presence_cmp == 0 && |
5427 (name_cmp < 0 || (name_cmp == 0 && node < n))))) | |
5428 { | |
5429 if (cur != NULL) | |
5430 { | |
7620 | 5431 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5432 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5433 return; |
9944 | 5434 } |
5435 else | |
5436 { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5437 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
9944 | 5438 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5439 return; |
7620 | 5440 } |
5422 | 5441 } |
9944 | 5442 |
5422 | 5443 g_value_unset(&val); |
9944 | 5444 } |
5445 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), | |
5446 &more_z)); | |
7620 | 5447 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5448 if (cur) { |
7620 | 5449 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5450 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5451 return; |
7620 | 5452 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5453 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5454 return; |
7620 | 5455 } |
5422 | 5456 } |
5457 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5458 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5459 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5460 GtkTreeIter more_z; |
7620 | 5461 |
5462 int log_size = 0, this_log_size = 0; | |
5463 const char *buddy_name, *this_buddy_name; | |
5464 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5465 if(cur && (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter) == 1)) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5466 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5467 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5468 } |
7620 | 5469 |
5470 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5471 GaimBlistNode *n; |
7620 | 5472 for (n = node->child; n; n = n->next) |
8898 | 5473 log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n))->name, ((GaimBuddy*)(n))->account); |
7620 | 5474 buddy_name = gaim_contact_get_alias((GaimContact*)node); |
5475 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5476 /* we don't have a reliable way of getting the log filename | |
5477 * from the chat info in the blist, yet */ | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5478 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5479 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5480 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5481 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5482 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5483 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5484 return; |
7620 | 5485 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5486 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5487 return; |
7620 | 5488 } |
5489 | |
5490 | |
5422 | 5491 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5492 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5493 return; |
5422 | 5494 } |
5495 | |
5496 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5497 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5498 GaimBlistNode *n; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5499 GaimBlistNode *n2; |
7620 | 5500 int cmp; |
5501 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5502 val.g_type = 0; |
5422 | 5503 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5504 n = g_value_get_pointer(&val); | |
7620 | 5505 this_log_size = 0; |
5506 | |
5507 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5508 for (n2 = n->child; n2; n2 = n2->next) | |
8898 | 5509 this_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n2))->name, ((GaimBuddy*)(n2))->account); |
7620 | 5510 this_buddy_name = gaim_contact_get_alias((GaimContact*)n); |
5511 } else { | |
5512 this_buddy_name = NULL; | |
5422 | 5513 } |
7620 | 5514 |
5515 cmp = gaim_utf8_strcasecmp(buddy_name, this_buddy_name); | |
5516 | |
5517 if (!GAIM_BLIST_NODE_IS_CONTACT(n) || log_size > this_log_size || | |
5518 ((log_size == this_log_size) && | |
5519 (cmp < 0 || (cmp == 0 && node < n)))) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5520 if (cur != NULL) { |
7620 | 5521 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5522 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5523 return; |
7620 | 5524 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5525 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5526 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5527 return; |
7620 | 5528 } |
5422 | 5529 } |
5530 g_value_unset(&val); | |
5531 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
7620 | 5532 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5533 if (cur != NULL) { |
7620 | 5534 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5535 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5536 return; |
7620 | 5537 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5538 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5539 return; |
7620 | 5540 } |
5541 } | |
5542 | |
5543 #endif | |
5544 | |
5545 static void | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5546 plugin_act(GtkObject *obj, GaimPluginAction *pam) |
7620 | 5547 { |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5548 if (pam && pam->callback) |
10352 | 5549 pam->callback(pam); |
5422 | 5550 } |
7620 | 5551 |
8986 | 5552 static void |
12333 | 5553 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin) |
8986 | 5554 { |
12333 | 5555 GtkWidget *menuitem; |
9015 | 5556 GaimPluginAction *action = NULL; |
12333 | 5557 GList *actions, *l; |
5558 | |
5559 actions = GAIM_PLUGIN_ACTIONS(plugin, NULL); | |
5560 | |
5561 for (l = actions; l != NULL; l = l->next) | |
5562 { | |
5563 if (l->data) | |
5564 { | |
9015 | 5565 action = (GaimPluginAction *) l->data; |
5566 action->plugin = plugin; | |
12333 | 5567 action->context = NULL; |
9015 | 5568 |
5569 menuitem = gtk_menu_item_new_with_label(action->label); | |
12333 | 5570 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
5571 | |
9015 | 5572 g_signal_connect(G_OBJECT(menuitem), "activate", |
5573 G_CALLBACK(plugin_act), action); | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5574 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5575 action, |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5576 (GDestroyNotify)gaim_plugin_action_free); |
9015 | 5577 gtk_widget_show(menuitem); |
5578 } | |
5579 else | |
5580 gaim_separator(menu); | |
5581 } | |
5582 | |
12333 | 5583 g_list_free(actions); |
8986 | 5584 } |
5585 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5586 static void |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5587 modify_account_cb(GtkWidget *widget, gpointer data) |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5588 { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5589 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, data); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5590 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5591 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5592 static void |
12330 | 5593 enable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5594 { |
12330 | 5595 GaimAccount *account = data; |
5596 const GaimSavedStatus *saved_status; | |
5597 | |
5598 saved_status = gaim_savedstatus_get_current(); | |
5599 gaim_savedstatus_activate_for_account(saved_status, account); | |
5600 | |
5601 gaim_account_set_enabled(account, GAIM_GTK_UI, TRUE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5602 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5603 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5604 static void |
12330 | 5605 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5606 { |
12330 | 5607 GaimAccount *account = data; |
5608 | |
5609 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5610 } |
8986 | 5611 |
7620 | 5612 void |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5613 gaim_gtk_blist_update_accounts_menu(void) |
7620 | 5614 { |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5615 GtkWidget *menuitem = NULL, *submenu = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5616 GList *l = NULL, *accounts = NULL; |
12330 | 5617 gboolean disabled_accounts = FALSE; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5618 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5619 if (accountmenu == NULL) |
7620 | 5620 return; |
5621 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5622 /* Clear the old Accounts menu */ |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5623 for (l = gtk_container_get_children(GTK_CONTAINER(accountmenu)); l; l = l->next) { |
12348
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5624 menuitem = l->data; |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5625 |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5626 if (menuitem != gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts/Add\\/Edit"))) |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5627 gtk_container_remove(GTK_CONTAINER(accountmenu), |
13132
ba82cc4d1abd
[gaim-migrate @ 15494]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
5628 menuitem); |
7620 | 5629 } |
5630 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5631 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5632 char *buf = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5633 GtkWidget *image = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5634 GaimConnection *gc = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5635 GaimAccount *account = NULL; |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
5636 GaimStatus *status = NULL; |
13090 | 5637 GdkPixbuf *pixbuf = NULL; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5638 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5639 account = accounts->data; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5640 |
12330 | 5641 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5642 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5643 gaim_account_get_protocol_name(account), ")", NULL); | |
5644 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5645 g_free(buf); | |
5646 status = gaim_account_get_active_status(account); | |
13090 | 5647 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status), 0.5); |
5648 if (pixbuf != NULL) | |
5649 { | |
12330 | 5650 if (!gaim_account_is_connected(account)) |
13090 | 5651 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, |
12330 | 5652 0.0, FALSE); |
13090 | 5653 image = gtk_image_new_from_pixbuf(pixbuf); |
12330 | 5654 g_object_unref(G_OBJECT(pixbuf)); |
5655 gtk_widget_show(image); | |
5656 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5657 } | |
5658 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); | |
5659 gtk_widget_show(menuitem); | |
5660 | |
5661 submenu = gtk_menu_new(); | |
5662 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5663 gtk_widget_show(submenu); | |
5664 | |
5665 | |
12334 | 5666 menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit Account")); |
12330 | 5667 g_signal_connect(G_OBJECT(menuitem), "activate", |
5668 G_CALLBACK(modify_account_cb), account); | |
5669 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5670 gtk_widget_show(menuitem); | |
5671 | |
5672 gaim_separator(submenu); | |
5673 | |
5674 gc = gaim_account_get_connection(account); | |
5675 if (gc && GAIM_CONNECTION_IS_CONNECTED(gc)) { | |
5676 GaimPlugin *plugin = NULL; | |
5677 | |
5678 plugin = gc->prpl; | |
5679 if (GAIM_PLUGIN_HAS_ACTIONS(plugin)) { | |
5680 GList *l, *ll = NULL; | |
5681 GaimPluginAction *action = NULL; | |
5682 | |
5683 for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, gc); l; l = l->next) { | |
5684 if (l->data) { | |
5685 action = (GaimPluginAction *)l->data; | |
5686 action->plugin = plugin; | |
5687 action->context = gc; | |
5688 | |
5689 menuitem = gtk_menu_item_new_with_label(action->label); | |
5690 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5691 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5692 G_CALLBACK(plugin_act), action); | |
13755 | 5693 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", action, (GDestroyNotify)gaim_plugin_action_free); |
12330 | 5694 gtk_widget_show(menuitem); |
5695 } else | |
5696 gaim_separator(submenu); | |
5697 } | |
5698 } else { | |
5699 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | |
5700 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5701 gtk_widget_set_sensitive(menuitem, FALSE); | |
5702 gtk_widget_show(menuitem); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5703 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5704 } else { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5705 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5706 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5707 gtk_widget_set_sensitive(menuitem, FALSE); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5708 gtk_widget_show(menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5709 } |
12330 | 5710 |
5711 gaim_separator(submenu); | |
5712 | |
5713 menuitem = gtk_menu_item_new_with_mnemonic(_("_Disable")); | |
5714 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5715 G_CALLBACK(disable_account_cb), account); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5716 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5717 gtk_widget_show(menuitem); |
12330 | 5718 } else { |
5719 disabled_accounts = TRUE; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5720 } |
7620 | 5721 } |
9019 | 5722 |
12330 | 5723 if(disabled_accounts) { |
5724 gaim_separator(accountmenu); | |
12338 | 5725 menuitem = gtk_menu_item_new_with_label(_("Enable Account")); |
12330 | 5726 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); |
5727 gtk_widget_show(menuitem); | |
5728 | |
5729 submenu = gtk_menu_new(); | |
5730 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5731 gtk_widget_show(submenu); | |
5732 | |
5733 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { | |
5734 char *buf = NULL; | |
5735 GtkWidget *image = NULL; | |
5736 GaimAccount *account = NULL; | |
13090 | 5737 GdkPixbuf *pixbuf = NULL; |
12330 | 5738 |
5739 account = accounts->data; | |
5740 | |
5741 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { | |
5742 | |
5743 disabled_accounts = TRUE; | |
5744 | |
5745 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5746 gaim_account_get_protocol_name(account), ")", NULL); | |
5747 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5748 g_free(buf); | |
13090 | 5749 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
5750 if (pixbuf != NULL) | |
5751 { | |
5752 if (!gaim_account_is_connected(account)) | |
5753 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); | |
5754 image = gtk_image_new_from_pixbuf(pixbuf); | |
12330 | 5755 g_object_unref(G_OBJECT(pixbuf)); |
5756 gtk_widget_show(image); | |
5757 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5758 } | |
5759 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5760 G_CALLBACK(enable_account_cb), account); | |
5761 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5762 gtk_widget_show(menuitem); | |
5763 } | |
9019 | 5764 } |
7620 | 5765 } |
5766 } | |
8986 | 5767 |
12333 | 5768 static GList *plugin_submenus = NULL; |
5769 | |
8986 | 5770 void |
5771 gaim_gtk_blist_update_plugin_actions(void) | |
5772 { | |
12333 | 5773 GtkWidget *menuitem, *submenu; |
9015 | 5774 GaimPlugin *plugin = NULL; |
8986 | 5775 GList *l; |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5776 GtkAccelGroup *accel_group; |
8986 | 5777 |
11742 | 5778 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); |
5779 | |
12333 | 5780 g_return_if_fail(pluginmenu != NULL); |
5781 | |
5782 /* Remove old plugin action submenus from the Tools menu */ | |
5783 for (l = plugin_submenus; l; l = l->next) | |
5784 { | |
5785 GList *menuitems; | |
5786 | |
5787 submenu = l->data; | |
5788 | |
5789 menuitems = gtk_container_get_children(GTK_CONTAINER(submenu)); | |
5790 while (menuitems != NULL) | |
5791 { | |
5792 GaimPluginAction *action; | |
5793 menuitem = menuitems->data; | |
5794 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | |
5795 g_free(action); | |
5796 menuitems = g_list_delete_link(menuitems, menuitems); | |
5797 } | |
5798 | |
5799 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(submenu)); | |
8986 | 5800 } |
12333 | 5801 g_list_free(plugin_submenus); |
5802 plugin_submenus = NULL; | |
5803 | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5804 accel_group = gtk_menu_get_accel_group(GTK_MENU(pluginmenu)); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5805 |
12333 | 5806 /* Add a submenu for each plugin with custom actions */ |
11742 | 5807 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5808 char *path; |
11923 | 5809 |
11742 | 5810 plugin = (GaimPlugin *) l->data; |
11923 | 5811 |
11742 | 5812 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5813 continue; | |
5814 | |
5815 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5816 continue; | |
9019 | 5817 |
13336
999571d910ed
[gaim-migrate @ 15706]
Richard Laager <rlaager@wiktel.com>
parents:
13315
diff
changeset
|
5818 menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name)); |
12333 | 5819 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); |
5820 gtk_widget_show(menuitem); | |
5821 | |
5822 plugin_submenus = g_list_append(plugin_submenus, menuitem); | |
5823 | |
5824 submenu = gtk_menu_new(); | |
5825 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5826 gtk_widget_show(submenu); | |
14035 | 5827 |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5828 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5829 path = g_strdup_printf("%s/Tools/%s", gtkblist->ift->path, plugin->info->name); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5830 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5831 g_free(path); |
12333 | 5832 |
5833 build_plugin_actions(submenu, plugin); | |
8986 | 5834 } |
5835 } | |
11796 | 5836 |
12246 | 5837 static void |
5838 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
11796 | 5839 { |
5840 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
11923 | 5841 { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5842 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5843 |
11796 | 5844 gaim_gtk_blist_sort_method_set(id); |
11923 | 5845 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5846 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5847 gaim_gtk_clear_cursor(gtkblist->window); |
11923 | 5848 } |
11796 | 5849 } |
5850 | |
5851 void | |
5852 gaim_gtk_blist_update_sort_methods(void) | |
5853 { | |
5854 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5855 GaimGtkBlistSortMethod *method = NULL; | |
5856 GList *l; | |
5857 GSList *sl = NULL; | |
5858 GtkWidget *sortmenu; | |
11797 | 5859 const char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); |
11796 | 5860 |
5861 if (gtkblist == NULL) | |
5862 return; | |
5863 | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
5864 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies")); |
11796 | 5865 |
5866 if (sortmenu == NULL) | |
5867 return; | |
5868 | |
5869 /* Clear the old menu */ | |
5870 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5871 menuitem = l->data; | |
5872 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5873 } | |
11923 | 5874 |
11796 | 5875 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { |
5876 method = (GaimGtkBlistSortMethod *) l->data; | |
5877 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5878 if (!strcmp(m, method->id)) | |
5879 activeitem = menuitem; | |
5880 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5881 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5882 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5883 G_CALLBACK(sortmethod_act), method->id); | |
11923 | 5884 gtk_widget_show(menuitem); |
11796 | 5885 } |
5886 if (activeitem) | |
5887 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5888 } |