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