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