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