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