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