Mercurial > pidgin
annotate src/gtkblist.c @ 12659:4c50dd655c30
[gaim-migrate @ 15002]
basically the same thing as sf patch #1390269, from Kris Marsh
"There's a leak when selecting custom saved messages in
the status box. Variables title, message do not get
cleared up."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 26 Dec 2005 05:59:24 +0000 |
parents | 60cce1861e59 |
children | b18738b03b35 |
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 | |
2436 delay = 500; | |
2437 | |
2438 if (gtkblist->drag_timeout) { | |
2439 if ((y > gtkblist->tip_rect.y) && ((y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) | |
2440 return FALSE; | |
2441 /* We've left the cell. Remove the timeout and create a new one below */ | |
2442 g_source_remove(gtkblist->drag_timeout); | |
2443 } | |
2444 | |
2445 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), x, y, &path, NULL, NULL, NULL); | |
2446 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->tip_rect); | |
2447 | |
2448 if (path) | |
2449 gtk_tree_path_free(path); | |
2450 gtkblist->drag_timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_expand_timeout, tv); | |
2451 | |
2452 if (gtkblist->mouseover_contact) { | |
2453 if ((y < gtkblist->contact_rect.y) || ((y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2454 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2455 gtkblist->mouseover_contact = NULL; | |
2456 } | |
2457 } | |
2458 | |
2459 return FALSE; | |
2460 } | |
2461 | |
5228 | 2462 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null) |
2463 { | |
2464 GtkTreePath *path; | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2465 int delay; |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2466 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2467 delay = gaim_prefs_get_int("/gaim/gtk/blist/tooltip_delay"); |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2468 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2469 if (delay == 0) |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2470 return FALSE; |
8083 | 2471 |
5228 | 2472 if (gtkblist->timeout) { |
7636 | 2473 if ((event->y > gtkblist->tip_rect.y) && ((event->y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) |
5228 | 2474 return FALSE; |
2475 /* We've left the cell. Remove the timeout and create a new one below */ | |
8254 | 2476 gaim_gtk_blist_tooltip_destroy(); |
5228 | 2477 g_source_remove(gtkblist->timeout); |
2478 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2479 |
5228 | 2480 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL); |
7636 | 2481 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
|
2482 |
5228 | 2483 if (path) |
2484 gtk_tree_path_free(path); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2485 gtkblist->timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_tooltip_timeout, tv); |
7636 | 2486 |
2487 if (gtkblist->mouseover_contact) { | |
2488 if ((event->y < gtkblist->contact_rect.y) || ((event->y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2489 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2490 gtkblist->mouseover_contact = NULL; | |
2491 } | |
2492 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2493 |
5228 | 2494 return FALSE; |
2495 } | |
2496 | |
2497 static void gaim_gtk_blist_leave_cb (GtkWidget *w, GdkEventCrossing *e, gpointer n) | |
2498 { | |
8083 | 2499 |
5228 | 2500 if (gtkblist->timeout) { |
2501 g_source_remove(gtkblist->timeout); | |
2502 gtkblist->timeout = 0; | |
2503 } | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2504 |
10354 | 2505 if (gtkblist->drag_timeout) { |
2506 g_source_remove(gtkblist->drag_timeout); | |
2507 gtkblist->drag_timeout = 0; | |
2508 } | |
2509 | |
8254 | 2510 gaim_gtk_blist_tooltip_destroy(); |
7720 | 2511 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2512 if (gtkblist->mouseover_contact && |
9811 | 2513 !((e->x > gtkblist->contact_rect.x) && (e->x < (gtkblist->contact_rect.x + gtkblist->contact_rect.width)) && |
2514 (e->y > gtkblist->contact_rect.y) && (e->y < (gtkblist->contact_rect.y + gtkblist->contact_rect.height)))) { | |
2515 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
7636 | 2516 gtkblist->mouseover_contact = NULL; |
2517 } | |
5228 | 2518 } |
2519 | |
2520 static void | |
2521 toggle_debug(void) | |
2522 { | |
7620 | 2523 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", |
2524 !gaim_prefs_get_bool("/gaim/gtk/debug/enabled")); | |
5228 | 2525 } |
2526 | |
2527 | |
2528 /*************************************************** | |
2529 * Crap * | |
2530 ***************************************************/ | |
2531 static GtkItemFactoryEntry blist_menu[] = | |
2532 { | |
2533 /* Buddies menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2534 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>", NULL }, |
9714 | 2535 { N_("/Buddies/New Instant _Message..."), "<CTL>M", gaim_gtkdialogs_im, 0, "<StockItem>", GAIM_STOCK_IM }, |
8940 | 2536 { N_("/Buddies/Join a _Chat..."), "<CTL>C", gaim_gtk_blist_joinchat_show, 0, "<StockItem>", GAIM_STOCK_CHAT }, |
9714 | 2537 { 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
|
2538 { 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
|
2539 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2540 { 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
|
2541 { 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
|
2542 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>", NULL }, |
12656 | 2543 { 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
|
2544 { N_("/Buddies/_Sort Buddies"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2545 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
7853 | 2546 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
2547 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | |
2548 { 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
|
2549 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
2550 { 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
|
2551 |
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
2552 /* Accounts menu */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2553 { N_("/_Accounts"), NULL, NULL, 0, "<Branch>", NULL }, |
12348
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
2554 { N_("/Accounts/Add\\/Edit"), "<CTL>A", gaim_gtk_accounts_window_show, 0, "<StockItem>", GAIM_STOCK_ACCOUNTS }, |
5228 | 2555 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2556 /* Tools */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2557 { N_("/_Tools"), NULL, NULL, 0, "<Branch>", NULL }, |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
2558 { 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
|
2559 { 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
|
2560 { N_("/Tools/Pr_eferences"), "<CTL>P", gaim_gtk_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, |
10694 | 2561 { 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
|
2562 { "/Tools/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
10019
8cc6f0bfa215
[gaim-migrate @ 10943]
Luke Schierer <lschiere@pidgin.im>
parents:
10018
diff
changeset
|
2563 { N_("/Tools/_File Transfers"), "<CTL>T", gaim_show_xfer_dialog, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
10694 | 2564 { N_("/Tools/R_oom List"), NULL, gaim_gtk_roomlist_dialog_show, 0, "<StockItem>", GTK_STOCK_INDEX }, |
12334 | 2565 { 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
|
2566 { "/Tools/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2567 { N_("/Tools/Mute _Sounds"), "<CTL>S", gaim_gtk_blist_mute_sounds_cb, 0, "<CheckItem>", NULL }, |
5228 | 2568 |
2569 /* Help */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
2570 { N_("/_Help"), NULL, NULL, 0, "<Branch>", NULL }, |
5228 | 2571 { N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "<StockItem>", GTK_STOCK_HELP }, |
12333 | 2572 { N_("/Help/_Debug Window"), NULL, toggle_debug, 0, "<StockItem>", GAIM_STOCK_DEBUG }, |
9753 | 2573 { N_("/Help/_About"), NULL, gaim_gtkdialogs_about, 0, "<StockItem>", GAIM_STOCK_ABOUT }, |
5228 | 2574 }; |
2575 | |
2576 /********************************************************* | |
2577 * Private Utility functions * | |
2578 *********************************************************/ | |
2579 | |
12530 | 2580 static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full) |
5228 | 2581 { |
10475 | 2582 GString *str = g_string_new(""); |
5237 | 2583 GaimPlugin *prpl; |
2584 GaimPluginProtocolInfo *prpl_info = NULL; | |
10475 | 2585 char *tmp; |
2586 | |
2587 if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
2588 { | |
2589 GaimChat *chat; | |
2590 GList *cur; | |
5274 | 2591 struct proto_chat_entry *pce; |
10475 | 2592 char *name, *value; |
2593 | |
2594 chat = (GaimChat *)node; | |
7956 | 2595 prpl = gaim_find_prpl(gaim_account_get_protocol_id(chat->account)); |
5274 | 2596 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2597 | |
10475 | 2598 tmp = g_markup_escape_text(gaim_chat_get_name(chat), -1); |
2599 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2600 g_free(tmp); | |
2601 | |
2602 if (g_list_length(gaim_connections_get_all()) > 1) | |
2603 { | |
2604 tmp = g_markup_escape_text(chat->account->username, -1); | |
2605 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2606 g_free(tmp); | |
2607 } | |
2608 | |
9959 | 2609 if (prpl_info->chat_info != NULL) |
10475 | 2610 cur = prpl_info->chat_info(chat->account->gc); |
2611 else | |
2612 cur = NULL; | |
2613 | |
2614 while (cur != NULL) | |
2615 { | |
2616 pce = cur->data; | |
2617 | |
2618 if (!pce->secret && (!pce->required && | |
2619 g_hash_table_lookup(chat->components, pce->identifier) == NULL)) | |
2620 { | |
2621 tmp = gaim_text_strip_mnemonic(pce->label); | |
2622 name = g_markup_escape_text(tmp, -1); | |
2623 g_free(tmp); | |
2624 value = g_markup_escape_text(g_hash_table_lookup( | |
2625 chat->components, pce->identifier), -1); | |
10924
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2626 g_string_append_printf(str, "\n<b>%s</b> %s", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2627 name ? name : "", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2628 value ? value : ""); |
10475 | 2629 g_free(name); |
8020 | 2630 g_free(value); |
2631 } | |
10475 | 2632 |
5274 | 2633 g_free(pce); |
10475 | 2634 cur = g_list_remove(cur, pce); |
5274 | 2635 } |
10475 | 2636 } |
2637 else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) | |
2638 { | |
2639 GaimContact *c; | |
7620 | 2640 GaimBuddy *b; |
9944 | 2641 GaimPresence *presence; |
10475 | 2642 char *tmp; |
10567 | 2643 time_t idle_secs, signon; |
10475 | 2644 |
2645 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2646 { | |
2647 c = (GaimContact *)node; | |
2648 b = gaim_contact_get_priority_buddy(c); | |
2649 } | |
2650 else | |
2651 { | |
7620 | 2652 b = (GaimBuddy *)node; |
10475 | 2653 c = gaim_buddy_get_contact(b); |
7620 | 2654 } |
2655 | |
7956 | 2656 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5234 | 2657 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2658 | |
10475 | 2659 presence = gaim_buddy_get_presence(b); |
2660 | |
2661 /* Buddy Name */ | |
2662 tmp = g_markup_escape_text(gaim_buddy_get_name(b), -1); | |
2663 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2664 g_free(tmp); | |
2665 | |
2666 /* Account */ | |
12530 | 2667 if (full && g_list_length(gaim_connections_get_all()) > 1) |
10475 | 2668 { |
2669 tmp = g_markup_escape_text(gaim_account_get_username( | |
2670 gaim_buddy_get_account(b)), -1); | |
2671 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2672 g_free(tmp); | |
2673 } | |
2674 | |
2675 /* Contact Alias */ | |
12530 | 2676 if (full && GAIM_BLIST_NODE_IS_CONTACT(node) && |
10499 | 2677 (c->alias != NULL)) |
10475 | 2678 { |
10499 | 2679 tmp = g_markup_escape_text(c->alias, -1); |
10475 | 2680 g_string_append_printf(str, _("\n<b>Contact Alias:</b> %s"), tmp); |
2681 g_free(tmp); | |
2682 } | |
2683 | |
2684 /* Alias */ | |
12530 | 2685 if (full && (b->alias != NULL) && (b->alias[0] != '\0')) |
10475 | 2686 { |
2687 tmp = g_markup_escape_text(b->alias, -1); | |
2688 g_string_append_printf(str, _("\n<b>Alias:</b> %s"), tmp); | |
2689 g_free(tmp); | |
2690 } | |
2691 | |
2692 /* Nickname/Server Alias */ | |
12530 | 2693 if (full && b->server_alias != NULL) |
10475 | 2694 { |
2695 tmp = g_markup_escape_text(b->server_alias, -1); | |
2696 g_string_append_printf(str, _("\n<b>Nickname:</b> %s"), tmp); | |
2697 g_free(tmp); | |
2698 } | |
2699 | |
2700 /* Logged In */ | |
10567 | 2701 signon = gaim_presence_get_login_time(presence); |
12530 | 2702 if (full && GAIM_BUDDY_IS_ONLINE(b) && signon > 0) |
10475 | 2703 { |
10567 | 2704 tmp = gaim_str_seconds_to_string(time(NULL) - signon); |
10475 | 2705 g_string_append_printf(str, _("\n<b>Logged In:</b> %s"), tmp); |
2706 g_free(tmp); | |
2707 } | |
2708 | |
2709 /* Idle */ | |
12656 | 2710 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
2711 gaim_presence_is_idle(presence)) | |
10475 | 2712 { |
2713 idle_secs = gaim_presence_get_idle_time(presence); | |
2714 if (idle_secs > 0) | |
2715 { | |
2716 tmp = gaim_str_seconds_to_string(time(NULL) - idle_secs); | |
2717 g_string_append_printf(str, _("\n<b>Idle:</b> %s"), tmp); | |
2718 g_free(tmp); | |
2719 } | |
2720 } | |
2721 | |
2722 /* Last Seen */ | |
11910 | 2723 if (!GAIM_BUDDY_IS_ONLINE(b)) |
10475 | 2724 { |
11023 | 2725 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode *)c)->ui_data; |
2726 GaimBlistNode *bnode; | |
2727 int lastseen = 0; | |
2728 | |
2729 if (!gtknode->contact_expanded || GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2730 { | |
11437
1c20849fc716
[gaim-migrate @ 13674]
Richard Laager <rlaager@wiktel.com>
parents:
11436
diff
changeset
|
2731 /* 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
|
2732 * an expanded contact itself so we show the most recent |
11023 | 2733 * (largest) last_seen time for any of the buddies under |
2734 * the contact. */ | |
2735 for (bnode = ((GaimBlistNode *)c)->child ; bnode != NULL ; bnode = bnode->next) | |
2736 { | |
2737 int value = gaim_blist_node_get_int(bnode, "last_seen"); | |
2738 if (value > lastseen) | |
2739 lastseen = value; | |
2740 } | |
2741 } | |
2742 else | |
2743 { | |
2744 /* We're dealing with a buddy under an expanded contact, | |
2745 * so we show the last_seen time for the buddy. */ | |
2746 lastseen = gaim_blist_node_get_int(&b->node, "last_seen"); | |
2747 } | |
2748 | |
10475 | 2749 if (lastseen > 0) |
2750 { | |
2751 tmp = gaim_str_seconds_to_string(time(NULL) - lastseen); | |
2752 g_string_append_printf(str, _("\n<b>Last Seen:</b> %s ago"), tmp); | |
2753 g_free(tmp); | |
5234 | 2754 } |
2755 } | |
2756 | |
10475 | 2757 |
2758 /* Offline? */ | |
2759 if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
2760 g_string_append_printf(str, _("\n<b>Status:</b> Offline")); | |
2761 } | |
10992
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2762 |
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2763 if (prpl_info && prpl_info->tooltip_text) |
10475 | 2764 { |
2765 /* Additional text from the PRPL */ | |
2766 const char *end; | |
2767 tmp = prpl_info->tooltip_text(b); | |
2768 | |
2769 if (tmp && !g_utf8_validate(tmp, -1, &end)) | |
2770 { | |
2771 char *new = g_strndup(tmp, g_utf8_pointer_to_offset(tmp, end)); | |
2772 g_free(tmp); | |
2773 tmp = new; | |
2774 } | |
2775 | |
11634 | 2776 if (tmp != NULL) |
2777 g_string_append(str, tmp); | |
10476 | 2778 g_free(tmp); |
10475 | 2779 } |
2780 | |
2781 /* These are Easter Eggs. Patches to remove them will be rejected. */ | |
2782 if (!g_ascii_strcasecmp(b->name, "robflynn")) | |
2783 g_string_append(str, _("\n<b>Description:</b> Spooky")); | |
2784 if (!g_ascii_strcasecmp(b->name, "seanegn")) | |
2785 g_string_append(str, _("\n<b>Status:</b> Awesome")); | |
2786 if (!g_ascii_strcasecmp(b->name, "chipx86")) | |
2787 g_string_append(str, _("\n<b>Status:</b> Rockin'")); | |
5234 | 2788 } |
10475 | 2789 |
8824 | 2790 gaim_signal_emit(gaim_gtk_blist_get_handle(), |
10477 | 2791 "drawing-tooltip", node, str); |
10475 | 2792 |
2793 return g_string_free(str, FALSE); | |
5228 | 2794 } |
2795 | |
7620 | 2796 struct _emblem_data { |
9954 | 2797 const char *filename; |
7620 | 2798 int x; |
2799 int y; | |
2800 }; | |
2801 | |
9944 | 2802 GdkPixbuf * |
2803 gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) | |
5228 | 2804 { |
7620 | 2805 GdkPixbuf *scale, *status = NULL; |
2806 int i, scalesize = 30; | |
2807 char *filename; | |
5228 | 2808 const char *protoname = NULL; |
7620 | 2809 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
11910 | 2810 struct _gaim_gtk_blist_node *gtkbuddynode = NULL; |
7620 | 2811 struct _emblem_data emblems[4] = {{NULL, 15, 15}, {NULL, 0, 15}, |
2812 {NULL, 0, 0}, {NULL, 15, 0}}; | |
9944 | 2813 GaimPresence *presence = NULL; |
7620 | 2814 GaimBuddy *buddy = NULL; |
2815 GaimChat *chat = NULL; | |
2816 | |
2817 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
11910 | 2818 if(!gtknode->contact_expanded) { |
7620 | 2819 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); |
11910 | 2820 gtkbuddynode = ((GaimBlistNode*)buddy)->ui_data; |
2821 } | |
7620 | 2822 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
2823 buddy = (GaimBuddy*)node; | |
11910 | 2824 gtkbuddynode = node->ui_data; |
7620 | 2825 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
2826 chat = (GaimChat*)node; | |
2827 } else { | |
5228 | 2828 return NULL; |
5234 | 2829 } |
2830 | |
7620 | 2831 if(buddy || chat) { |
2832 GaimAccount *account; | |
2833 GaimPlugin *prpl; | |
2834 GaimPluginProtocolInfo *prpl_info; | |
2835 | |
2836 if(buddy) | |
2837 account = buddy->account; | |
2838 else | |
2839 account = chat->account; | |
2840 | |
7956 | 2841 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
7620 | 2842 if(!prpl) |
2843 return NULL; | |
2844 | |
2845 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2846 | |
2847 if(prpl_info && prpl_info->list_icon) { | |
2848 protoname = prpl_info->list_icon(account, buddy); | |
2849 } | |
2850 if(prpl_info && prpl_info->list_emblems && buddy) { | |
11924 | 2851 if(gtknode && !gtknode->recent_signonoff) |
7620 | 2852 prpl_info->list_emblems(buddy, &emblems[0].filename, |
2853 &emblems[1].filename, &emblems[2].filename, | |
2854 &emblems[3].filename); | |
2855 } | |
5234 | 2856 } |
5228 | 2857 |
7620 | 2858 if(size == GAIM_STATUS_ICON_SMALL) { |
5228 | 2859 scalesize = 15; |
7620 | 2860 /* So that only the se icon will composite */ |
2861 emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; | |
5228 | 2862 } |
2863 | |
11917 | 2864 if(buddy && GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2865 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); |
11917 | 2866 } else if(buddy && !GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2867 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "logout.png", NULL); |
2868 } else if(buddy || chat) { | |
5228 | 2869 char *image = g_strdup_printf("%s.png", protoname); |
2870 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2871 g_free(image); | |
7620 | 2872 } else { |
2873 /* gaim dude */ | |
2874 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); | |
5228 | 2875 } |
7620 | 2876 |
2877 status = gdk_pixbuf_new_from_file(filename, NULL); | |
2878 g_free(filename); | |
2879 | |
2880 if(!status) | |
2881 return NULL; | |
2882 | |
2883 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, | |
2884 GDK_INTERP_BILINEAR); | |
2885 g_object_unref(status); | |
2886 | |
2887 for(i=0; i<4; i++) { | |
2888 if(emblems[i].filename) { | |
2889 GdkPixbuf *emblem; | |
2890 char *image = g_strdup_printf("%s.png", emblems[i].filename); | |
2891 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2892 g_free(image); | |
2893 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
2894 g_free(filename); | |
2895 if(emblem) { | |
2896 if(i == 0 && size == GAIM_STATUS_ICON_SMALL) { | |
2897 gdk_pixbuf_composite(emblem, | |
2898 scale, 5, 5, | |
2899 10, 10, | |
2900 5, 5, | |
2901 .6, .6, | |
2902 GDK_INTERP_BILINEAR, | |
2903 255); | |
2904 } else { | |
2905 gdk_pixbuf_composite(emblem, | |
2906 scale, emblems[i].x, emblems[i].y, | |
2907 15, 15, | |
2908 emblems[i].x, emblems[i].y, | |
2909 1, 1, | |
2910 GDK_INTERP_BILINEAR, | |
2911 255); | |
2912 } | |
2913 g_object_unref(emblem); | |
2914 } | |
5228 | 2915 } |
2916 } | |
7620 | 2917 |
2918 if(buddy) { | |
9944 | 2919 presence = gaim_buddy_get_presence(buddy); |
2920 | |
2921 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | |
7620 | 2922 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
10118 | 2923 else if (gaim_presence_is_idle(presence)) |
9944 | 2924 { |
7620 | 2925 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.25, FALSE); |
9944 | 2926 } |
11111
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2927 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2928 if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2929 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2930 GdkPixbuf *emblem; |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2931 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
|
2932 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2933 emblem = gdk_pixbuf_new_from_file(filename, NULL); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2934 g_free(filename); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2935 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2936 if (emblem) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2937 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2938 gdk_pixbuf_composite(emblem, scale, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2939 0, 0, scalesize, scalesize, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2940 0, 0, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2941 (double)scalesize / gdk_pixbuf_get_width(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2942 (double)scalesize / gdk_pixbuf_get_height(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2943 GDK_INTERP_BILINEAR, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2944 224); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2945 g_object_unref(emblem); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2946 } |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2947 } |
5228 | 2948 } |
7620 | 2949 |
5228 | 2950 return scale; |
2951 } | |
2952 | |
7620 | 2953 static gchar *gaim_gtk_blist_get_name_markup(GaimBuddy *b, gboolean selected) |
5228 | 2954 { |
7620 | 2955 const char *name; |
2956 char *esc, *text = NULL; | |
5228 | 2957 GaimPlugin *prpl; |
2958 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 2959 GaimContact *contact; |
9944 | 2960 GaimPresence *presence; |
7620 | 2961 struct _gaim_gtk_blist_node *gtkcontactnode = NULL; |
11257 | 2962 char *idletime = NULL, *statustext = NULL; |
5228 | 2963 time_t t; |
7620 | 2964 /* XXX Clean up this crap */ |
2965 | |
2966 contact = (GaimContact*)((GaimBlistNode*)b)->parent; | |
2967 if(contact) | |
2968 gtkcontactnode = ((GaimBlistNode*)contact)->ui_data; | |
2969 | |
2970 if(gtkcontactnode && !gtkcontactnode->contact_expanded && contact->alias) | |
2971 name = contact->alias; | |
2972 else | |
9620 | 2973 name = gaim_buddy_get_alias(b); |
7620 | 2974 esc = g_markup_escape_text(name, strlen(name)); |
2975 | |
7956 | 2976 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5228 | 2977 |
2978 if (prpl != NULL) | |
2979 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2980 | |
9944 | 2981 presence = gaim_buddy_get_presence(b); |
2982 | |
7620 | 2983 if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { |
9944 | 2984 |
10118 | 2985 if ((gaim_presence_is_idle(presence) || !GAIM_BUDDY_IS_ONLINE(b)) && !selected) |
9944 | 2986 { |
10118 | 2987 text = g_strdup_printf("<span color='%s'>%s</span>", |
2988 dim_grey(), esc); | |
5228 | 2989 g_free(esc); |
2990 return text; | |
7620 | 2991 } |
9944 | 2992 else |
5228 | 2993 return esc; |
2994 } | |
2995 | |
8122
36674144c510
[gaim-migrate @ 8826]
Christian Hammond <chipx86@chipx86.com>
parents:
8113
diff
changeset
|
2996 if (prpl_info && prpl_info->status_text && b->account->gc) { |
5228 | 2997 char *tmp = prpl_info->status_text(b); |
2998 const char *end; | |
2999 | |
3000 if(tmp && !g_utf8_validate(tmp, -1, &end)) { | |
3001 char *new = g_strndup(tmp, | |
3002 g_utf8_pointer_to_offset(tmp, end)); | |
3003 g_free(tmp); | |
3004 tmp = new; | |
3005 } | |
3006 | |
10288 | 3007 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 3008 if(tmp) { |
3009 char buf[32]; | |
3010 char *c = tmp; | |
3011 int length = 0, vis=0; | |
3012 gboolean inside = FALSE; | |
3013 g_strdelimit(tmp, "\n", ' '); | |
11920 | 3014 gaim_str_strip_char(tmp, '\r'); |
5228 | 3015 |
3016 while(*c && vis < 20) { | |
3017 if(*c == '&') | |
3018 inside = TRUE; | |
3019 else if(*c == ';') | |
3020 inside = FALSE; | |
3021 if(!inside) | |
3022 vis++; | |
7620 | 3023 c = g_utf8_next_char(c); /* this is fun */ |
5228 | 3024 } |
3025 | |
7620 | 3026 length = c - tmp; |
3027 | |
5228 | 3028 if(vis == 20) |
3029 g_snprintf(buf, sizeof(buf), "%%.%ds...", length); | |
3030 else | |
3031 g_snprintf(buf, sizeof(buf), "%%s "); | |
3032 | |
3033 statustext = g_strdup_printf(buf, tmp); | |
3034 | |
3035 g_free(tmp); | |
3036 } | |
10288 | 3037 #else |
12437 | 3038 if(tmp) |
3039 g_strdelimit(tmp, "\n", ' '); | |
10288 | 3040 statustext = tmp; |
3041 #endif | |
5228 | 3042 } |
3043 | |
12656 | 3044 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
3045 gaim_presence_is_idle(presence)) | |
3046 { | |
9944 | 3047 time_t idle_secs = gaim_presence_get_idle_time(presence); |
3048 | |
10351 | 3049 if (idle_secs > 0) { |
9944 | 3050 int ihrs, imin; |
3051 | |
3052 time(&t); | |
3053 ihrs = (t - idle_secs) / 3600; | |
3054 imin = ((t - idle_secs) / 60) % 60; | |
3055 | |
3056 if (ihrs) | |
12450 | 3057 idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); |
9944 | 3058 else |
12450 | 3059 idletime = g_strdup_printf(_("Idle %dm"), imin); |
9944 | 3060 } |
5228 | 3061 else |
12450 | 3062 idletime = g_strdup(_("Idle")); |
5228 | 3063 } |
3064 | |
3065 if(!GAIM_BUDDY_IS_ONLINE(b) && !statustext) | |
7620 | 3066 statustext = g_strdup(_("Offline ")); |
3067 | |
10118 | 3068 if (gaim_presence_is_idle(presence) && !selected) { |
3069 text = g_strdup_printf("<span color='%s'>%s</span>\n" | |
11257 | 3070 "<span color='%s' size='smaller'>%s%s%s</span>", |
10118 | 3071 dim_grey(), esc, dim_grey(), |
12366 | 3072 idletime != NULL ? idletime : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
3073 (idletime != NULL && statustext != NULL) ? " - " : "", |
12366 | 3074 statustext != NULL ? statustext : ""); |
11257 | 3075 } else if (statustext == NULL && idletime == NULL && GAIM_BUDDY_IS_ONLINE(b)) { |
5228 | 3076 text = g_strdup(esc); |
3077 } else { | |
10118 | 3078 if (selected) |
3079 text = g_strdup_printf("%s\n" | |
11257 | 3080 "<span size='smaller'>%s%s%s</span>", esc, |
12366 | 3081 idletime != NULL ? idletime : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
3082 (idletime != NULL && statustext != NULL) ? " - " : "", |
12366 | 3083 statustext != NULL ? statustext : ""); |
10118 | 3084 else |
3085 text = g_strdup_printf("%s\n" | |
11257 | 3086 "<span color='%s' size='smaller'>%s%s%s</span>", esc, |
10144 | 3087 dim_grey(), |
12366 | 3088 idletime != NULL ? idletime : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
3089 (idletime != NULL && statustext != NULL) ? " - " : "", |
12366 | 3090 statustext != NULL ? statustext : ""); |
5228 | 3091 } |
12656 | 3092 |
3093 g_free(idletime); | |
3094 g_free(statustext); | |
3095 g_free(esc); | |
5228 | 3096 |
3097 return text; | |
3098 } | |
3099 | |
3100 static void gaim_gtk_blist_restore_position() | |
3101 { | |
7620 | 3102 int blist_x, blist_y, blist_width, blist_height; |
3103 | |
3104 blist_width = gaim_prefs_get_int("/gaim/gtk/blist/width"); | |
3105 | |
3106 /* if the window exists, is hidden, we're saving positions, and the | |
3107 * position is sane... */ | |
3108 if (gtkblist && gtkblist->window && | |
3109 !GTK_WIDGET_VISIBLE(gtkblist->window) && blist_width != 0) { | |
3110 | |
3111 blist_x = gaim_prefs_get_int("/gaim/gtk/blist/x"); | |
3112 blist_y = gaim_prefs_get_int("/gaim/gtk/blist/y"); | |
3113 blist_height = gaim_prefs_get_int("/gaim/gtk/blist/height"); | |
3114 | |
5228 | 3115 /* ...check position is on screen... */ |
7620 | 3116 if (blist_x >= gdk_screen_width()) |
3117 blist_x = gdk_screen_width() - 100; | |
3118 else if (blist_x + blist_width < 0) | |
3119 blist_x = 100; | |
3120 | |
3121 if (blist_y >= gdk_screen_height()) | |
3122 blist_y = gdk_screen_height() - 100; | |
3123 else if (blist_y + blist_height < 0) | |
3124 blist_y = 100; | |
3125 | |
5228 | 3126 /* ...and move it back. */ |
7620 | 3127 gtk_window_move(GTK_WINDOW(gtkblist->window), blist_x, blist_y); |
3128 gtk_window_resize(GTK_WINDOW(gtkblist->window), blist_width, blist_height); | |
12279 | 3129 if (gaim_prefs_get_bool("/gaim/gtk/blist/list_maximized")) |
3130 gtk_window_maximize(GTK_WINDOW(gtkblist->window)); | |
5228 | 3131 } |
3132 } | |
3133 | |
7620 | 3134 static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list) |
5228 | 3135 { |
7620 | 3136 GaimBlistNode *gnode, *cnode; |
3137 | |
3138 for(gnode = list->root; gnode; gnode = gnode->next) { | |
3139 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 3140 continue; |
7620 | 3141 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3142 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
9944 | 3143 GaimBuddy *buddy; |
3144 | |
3145 buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); | |
10012 | 3146 |
3147 if (buddy && | |
3148 gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | |
9944 | 3149 gaim_gtk_blist_update(list, cnode); |
7620 | 3150 } |
5228 | 3151 } |
3152 } | |
3153 | |
3154 /* keep on going */ | |
3155 return TRUE; | |
3156 } | |
3157 | |
7620 | 3158 static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node) |
5260 | 3159 { |
3160 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3161 GtkTreeIter iter; | |
3162 | |
3163 if (!gtknode || !gtknode->row || !gtkblist) | |
3164 return; | |
3165 | |
3166 if(gtkblist->selected_node == node) | |
3167 gtkblist->selected_node = NULL; | |
3168 | |
3169 if (get_iter_from_node(node, &iter)) { | |
3170 gtk_tree_store_remove(gtkblist->treemodel, &iter); | |
7620 | 3171 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) |
3172 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5260 | 3173 gaim_gtk_blist_update(list, node->parent); |
3174 } | |
3175 } | |
3176 gtk_tree_row_reference_free(gtknode->row); | |
3177 gtknode->row = NULL; | |
3178 } | |
3179 | |
10352 | 3180 static const char *require_connection[] = |
7620 | 3181 { |
10352 | 3182 N_("/Buddies/New Instant Message..."), |
3183 N_("/Buddies/Join a Chat..."), | |
3184 N_("/Buddies/Get User Info..."), | |
3185 N_("/Buddies/Add Buddy..."), | |
3186 N_("/Buddies/Add Chat..."), | |
3187 N_("/Buddies/Add Group..."), | |
3188 }; | |
3189 | |
10357 | 3190 static const int require_connection_size = sizeof(require_connection) |
3191 / sizeof(*require_connection); | |
10352 | 3192 |
3193 /** | |
3194 * Rebuild dynamic menus and make menu items sensitive/insensitive | |
3195 * where appropriate. | |
3196 */ | |
3197 static void | |
3198 update_menu_bar(GaimGtkBuddyList *gtkblist) | |
3199 { | |
8937 | 3200 GtkWidget *widget; |
10352 | 3201 gboolean sensitive; |
3202 int i; | |
3203 | |
3204 g_return_if_fail(gtkblist != NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3205 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3206 gaim_gtk_blist_update_accounts_menu(); |
8937 | 3207 |
10352 | 3208 sensitive = (gaim_connections_get_all() != NULL); |
3209 | |
10357 | 3210 for (i = 0; i < require_connection_size; i++) |
10352 | 3211 { |
3212 widget = gtk_item_factory_get_widget(gtkblist->ift, require_connection[i]); | |
3213 gtk_widget_set_sensitive(widget, sensitive); | |
3214 } | |
3215 | |
8940 | 3216 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Join a Chat...")); |
3217 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3218 | |
11988 | 3219 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat...")); |
3220 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3221 | |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3222 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
|
3223 gtk_widget_set_sensitive(widget, (gaim_connections_get_all() != NULL)); |
8938 | 3224 |
3225 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy")); | |
3226 gtk_widget_set_sensitive(widget, gaim_gtk_privacy_is_showable()); | |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3227 |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
3228 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
|
3229 gtk_widget_set_sensitive(widget, gaim_gtk_roomlist_is_showable()); |
7620 | 3230 } |
3231 | |
10352 | 3232 static void |
3233 sign_on_off_cb(GaimConnection *gc, GaimBuddyList *blist) | |
3234 { | |
3235 GaimGtkBuddyList *gtkblist = GAIM_GTK_BLIST(blist); | |
3236 | |
3237 update_menu_bar(gtkblist); | |
3238 } | |
8986 | 3239 |
3240 static void | |
3241 plugin_changed_cb(GaimPlugin *p, gpointer *data) | |
3242 { | |
3243 gaim_gtk_blist_update_plugin_actions(); | |
3244 } | |
3245 | |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3246 static void |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3247 unseen_conv_menu() |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3248 { |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3249 static GtkWidget *menu = NULL; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3250 GList *convs = NULL; |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3251 |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3252 if (menu) |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3253 gtk_widget_destroy(menu); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3254 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3255 menu = gtk_menu_new(); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3256 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3257 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
|
3258 if (!convs) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3259 /* no conversations added, don't show the menu */ |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3260 gtk_widget_destroy(menu); |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3261 return; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3262 } |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3263 gaim_gtk_conversations_fill_menu(menu, convs); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3264 g_list_free(convs); |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3265 gtk_widget_show_all(menu); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3266 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3267 gtk_get_current_event_time()); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3268 } |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3269 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3270 static gboolean |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3271 menutray_press_cb(GtkWidget *widget, GdkEventButton *event) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3272 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3273 GList *convs; |
12208 | 3274 |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3275 switch (event->button) { |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3276 case 1: |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3277 convs = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3278 GAIM_UNSEEN_TEXT, TRUE, 1); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3279 if (convs) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3280 gaim_gtkconv_present_conversation((GaimConversation*)convs->data); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3281 g_list_free(convs); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3282 } |
12133
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3283 break; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3284 case 3: |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3285 unseen_conv_menu(); |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3286 break; |
8254bb99f929
[gaim-migrate @ 14433]
Richard Laager <rlaager@wiktel.com>
parents:
12124
diff
changeset
|
3287 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3288 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3289 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3290 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3291 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3292 conversation_updated_cb(GaimConversation *conv, GaimConvUpdateType type, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3293 GaimGtkBuddyList *gtkblist) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3294 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3295 GList *convs = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3296 GList *l = NULL; |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3297 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3298 if (type != GAIM_CONV_UPDATE_UNSEEN) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3299 return; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3300 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12163
diff
changeset
|
3301 if (gtkblist->menutrayicon) { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3302 gtk_widget_destroy(gtkblist->menutrayicon); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3303 gtkblist->menutrayicon = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3304 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3305 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3306 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
|
3307 if (convs) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3308 GtkWidget *img = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3309 GString *tooltip_text = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3310 |
12117 | 3311 tooltip_text = g_string_new(""); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3312 l = convs; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3313 while (l != NULL) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3314 if (GAIM_IS_GTK_CONVERSATION(l->data)) { |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3315 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION((GaimConversation *)l->data); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3316 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3317 g_string_append_printf(tooltip_text, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3318 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
|
3319 gtkconv->unseen_count, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3320 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
12117 | 3321 } |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3322 l = l->next; |
12117 | 3323 } |
12239 | 3324 if(tooltip_text->len > 0) { |
12302 | 3325 /* get rid of the last newline */ |
3326 tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len -1); | |
3327 img = gtk_image_new_from_stock(GAIM_STOCK_PENDING, GTK_ICON_SIZE_MENU); | |
3328 | |
3329 gtkblist->menutrayicon = gtk_event_box_new(); | |
3330 gtk_container_add(GTK_CONTAINER(gtkblist->menutrayicon), img); | |
3331 gtk_widget_show(img); | |
3332 gtk_widget_show(gtkblist->menutrayicon); | |
3333 g_signal_connect(G_OBJECT(gtkblist->menutrayicon), "button-press-event", G_CALLBACK(menutray_press_cb), NULL); | |
3334 | |
3335 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkblist->menutray), gtkblist->menutrayicon, tooltip_text->str); | |
12239 | 3336 } |
12302 | 3337 g_string_free(tooltip_text, TRUE); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12466
diff
changeset
|
3338 g_list_free(convs); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3339 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3340 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3341 |
12208 | 3342 static void |
3343 conversation_deleting_cb(GaimConversation *conv, GaimGtkBuddyList *gtkblist) | |
3344 { | |
3345 conversation_updated_cb(conv, GAIM_CONV_UPDATE_UNSEEN, gtkblist); | |
3346 } | |
3347 | |
5228 | 3348 /********************************************************************************** |
3349 * Public API Functions * | |
3350 **********************************************************************************/ | |
9774 | 3351 |
7620 | 3352 static void gaim_gtk_blist_new_list(GaimBuddyList *blist) |
5228 | 3353 { |
7620 | 3354 GaimGtkBuddyList *gtkblist; |
3355 | |
3356 gtkblist = g_new0(GaimGtkBuddyList, 1); | |
3357 blist->ui_data = gtkblist; | |
5228 | 3358 } |
3359 | |
5256 | 3360 static void gaim_gtk_blist_new_node(GaimBlistNode *node) |
3361 { | |
3362 node->ui_data = g_new0(struct _gaim_gtk_blist_node, 1); | |
3363 } | |
3364 | |
11018 | 3365 gboolean gaim_gtk_blist_node_is_contact_expanded(GaimBlistNode *node) |
3366 { | |
3367 if GAIM_BLIST_NODE_IS_BUDDY(node) | |
3368 node = node->parent; | |
3369 | |
3370 g_return_val_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node), FALSE); | |
3371 | |
3372 return ((struct _gaim_gtk_blist_node *)node->ui_data)->contact_expanded; | |
3373 } | |
3374 | |
5228 | 3375 void gaim_gtk_blist_update_columns() |
3376 { | |
3377 if(!gtkblist) | |
3378 return; | |
3379 | |
7620 | 3380 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { |
5228 | 3381 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE); |
3382 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE); | |
3383 } else { | |
12656 | 3384 gtk_tree_view_column_set_visible(gtkblist->idle_column, |
3385 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
5228 | 3386 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE); |
3387 } | |
3388 } | |
3389 | |
12326 | 3390 static void |
3391 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, | |
3392 gpointer val, gpointer data) | |
3393 { | |
3394 gaim_gtk_blist_update_columns(); | |
3395 } | |
3396 | |
10433 | 3397 enum { |
3398 DRAG_BUDDY, | |
3399 DRAG_ROW, | |
3400 DRAG_VCARD, | |
3401 DRAG_TEXT, | |
3402 DRAG_URI, | |
3403 NUM_TARGETS | |
3404 }; | |
5228 | 3405 |
3406 static char * | |
3407 item_factory_translate_func (const char *path, gpointer func_data) | |
3408 { | |
7620 | 3409 return _((char *)path); |
5228 | 3410 } |
3411 | |
5422 | 3412 void gaim_gtk_blist_setup_sort_methods() |
3413 { | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3414 gaim_gtk_blist_sort_method_reg("none", _("Manually"), sort_method_none); |
7620 | 3415 #if GTK_CHECK_VERSION(2,2,1) |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3416 gaim_gtk_blist_sort_method_reg("alphabetical", _("Alphabetically"), sort_method_alphabetical); |
7620 | 3417 gaim_gtk_blist_sort_method_reg("status", _("By status"), sort_method_status); |
3418 gaim_gtk_blist_sort_method_reg("log_size", _("By log size"), sort_method_log); | |
3419 #endif | |
3420 gaim_gtk_blist_sort_method_set(gaim_prefs_get_string("/gaim/gtk/blist/sort_type")); | |
3421 } | |
3422 | |
10433 | 3423 static void _prefs_change_redo_list() |
3424 { | |
7620 | 3425 redo_buddy_list(gaim_get_blist(), TRUE); |
3426 } | |
3427 | |
3428 static void _prefs_change_sort_method(const char *pref_name, GaimPrefType type, | |
10433 | 3429 gpointer val, gpointer data) |
3430 { | |
7620 | 3431 if(!strcmp(pref_name, "/gaim/gtk/blist/sort_type")) |
3432 gaim_gtk_blist_sort_method_set(val); | |
3433 } | |
3434 | |
10433 | 3435 /* |
3436 * "This is so dead sexy." | |
3437 * "Two thumbs up." | |
3438 * "Best movie of the year." | |
3439 * | |
3440 * This is the function that handles CTRL+F searching in the buddy list. | |
3441 * It finds the top-most buddy/group/chat/whatever containing the | |
3442 * entered string. | |
3443 * | |
3444 * It's somewhat ineffecient, because we strip all the HTML from the | |
3445 * "name" column of the buddy list (because the GtkTreeModel does not | |
3446 * contain the screen name in a non-markedup format). But the alternative | |
3447 * is to add an extra column to the GtkTreeModel. And this function is | |
3448 * used rarely, so it shouldn't matter TOO much. | |
3449 */ | |
3450 static gboolean | |
3451 _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) | |
3452 { | |
10435 | 3453 gboolean result; |
10433 | 3454 gchar *enteredstring; |
10439 | 3455 gchar *withmarkup; |
10433 | 3456 gchar *nomarkup; |
11490 | 3457 gchar *normalized; |
10435 | 3458 |
3459 gtk_tree_model_get(model, iter, column, &withmarkup, -1); | |
10433 | 3460 |
11490 | 3461 enteredstring = g_utf8_casefold(gaim_normalize(NULL, key), -1); |
10433 | 3462 nomarkup = gaim_markup_strip_html(withmarkup); |
11490 | 3463 normalized = g_utf8_casefold(gaim_normalize(NULL, nomarkup), -1); |
10433 | 3464 |
3465 result = (g_strstr_len(normalized, strlen(normalized), enteredstring) == NULL); | |
3466 | |
10439 | 3467 g_free(withmarkup); |
10433 | 3468 g_free(enteredstring); |
3469 g_free(nomarkup); | |
11490 | 3470 g_free(normalized); |
10433 | 3471 |
3472 return result; | |
3473 } | |
3474 | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3475 static void account_modified(GaimAccount *account, GaimGtkBuddyList *gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3476 { |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3477 if (!gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3478 return; |
12589 | 3479 |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3480 update_menu_bar(gtkblist); |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3481 } |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3482 |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3483 static gboolean |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3484 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
|
3485 { |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3486 GtkWidget *imhtml; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3487 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3488 if (!gtkblist) |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3489 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3490 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3491 imhtml = gtk_window_get_focus(GTK_WINDOW(gtkblist->window)); |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3492 |
12474
24beec3e42ad
[gaim-migrate @ 14785]
Luke Schierer <lschiere@pidgin.im>
parents:
12473
diff
changeset
|
3493 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
|
3494 return TRUE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3495 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3496 } |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3497 |
7620 | 3498 static void gaim_gtk_blist_show(GaimBuddyList *list) |
5228 | 3499 { |
10087 | 3500 void *handle; |
5228 | 3501 GtkCellRenderer *rend; |
3502 GtkTreeViewColumn *column; | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3503 GtkWidget *menu; |
5228 | 3504 GtkWidget *sw; |
3505 GtkAccelGroup *accel_group; | |
3506 GtkTreeSelection *selection; | |
9556 | 3507 GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
8089 | 3508 {"application/x-im-contact", 0, DRAG_BUDDY}, |
9495 | 3509 {"text/x-vcard", 0, DRAG_VCARD }, |
9525 | 3510 {"text/uri-list", 0, DRAG_URI}, |
3511 {"text/plain", 0, DRAG_TEXT}}; | |
9556 | 3512 GtkTargetEntry ste[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
3513 {"application/x-im-contact", 0, DRAG_BUDDY}, | |
3514 {"text/x-vcard", 0, DRAG_VCARD }}; | |
5228 | 3515 if (gtkblist && gtkblist->window) { |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3516 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3517 return; |
3518 } | |
3519 | |
3520 gtkblist = GAIM_GTK_BLIST(list); | |
3521 | |
3522 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3523 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
9746 | 3524 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
12328 | 3525 GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE; |
5228 | 3526 |
3527 gtkblist->vbox = gtk_vbox_new(FALSE, 0); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3528 gtk_widget_show(gtkblist->vbox); |
5228 | 3529 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); |
3530 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3531 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
5228 | 3532 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
|
3533 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
|
3534 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
|
3535 g_signal_connect(G_OBJECT(gtkblist->window), "key_press_event", G_CALLBACK(gtk_blist_window_key_press_cb), gtkblist); |
5228 | 3536 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); |
3537 | |
3538 /******************************* Menu bar *************************************/ | |
3539 accel_group = gtk_accel_group_new(); | |
3540 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group); | |
3541 g_object_unref(accel_group); | |
5427 | 3542 gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group); |
9811 | 3543 gtk_item_factory_set_translate_func(gtkblist->ift, |
3544 item_factory_translate_func, | |
3545 NULL, NULL); | |
5427 | 3546 gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu), |
9811 | 3547 blist_menu, NULL); |
7620 | 3548 gaim_gtk_load_accels(); |
3549 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
3550 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3551 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3552 gtkblist->menutray = gaim_gtk_menu_tray_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3553 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3554 gtk_widget_show(gtkblist->menutray); |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3555 gtk_widget_show(menu); |
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3556 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
5228 | 3557 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3558 accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts")); |
10352 | 3559 |
5228 | 3560 /****************************** GtkTreeView **********************************/ |
3561 sw = gtk_scrolled_window_new(NULL,NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3562 gtk_widget_show(sw); |
5228 | 3563 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3564 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
3565 | |
7620 | 3566 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, |
11494 | 3567 GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, |
11257 | 3568 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
5228 | 3569 |
3570 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
|
3571 gtk_widget_show(gtkblist->treeview); |
9176 | 3572 gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); |
5228 | 3573 |
3574 /* Set up selection stuff */ | |
3575 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
3576 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
3577 | |
3578 /* Set up dnd */ | |
7650 | 3579 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3580 GDK_BUTTON1_MASK, ste, 3, |
3581 GDK_ACTION_COPY); | |
7650 | 3582 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3583 dte, 5, |
3584 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
7636 | 3585 |
10544 | 3586 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
5228 | 3587 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
|
3588 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3589 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
|
3590 #endif |
10433 | 3591 |
10354 | 3592 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); |
5228 | 3593 |
3594 /* Tooltips */ | |
3595 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
3596 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
3597 | |
3598 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
3599 | |
11016 | 3600 gtkblist->text_column = column = gtk_tree_view_column_new (); |
5228 | 3601 |
3602 rend = gtk_cell_renderer_pixbuf_new(); | |
9811 | 3603 gtk_tree_view_column_pack_start(column, rend, FALSE); |
3604 gtk_tree_view_column_set_attributes(column, rend, | |
3605 "pixbuf", STATUS_ICON_COLUMN, | |
3606 "visible", STATUS_ICON_VISIBLE_COLUMN, | |
3607 NULL); | |
5228 | 3608 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL); |
3609 | |
11016 | 3610 gtkblist->text_rend = rend = gtk_cell_renderer_text_new(); |
5228 | 3611 gtk_tree_view_column_pack_start (column, rend, TRUE); |
9811 | 3612 gtk_tree_view_column_set_attributes(column, rend, |
3613 "markup", NAME_COLUMN, | |
3614 NULL); | |
11016 | 3615 g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); |
5228 | 3616 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
10285 | 3617 #if GTK_CHECK_VERSION(2,6,0) |
3618 gtk_tree_view_column_set_expand (column, TRUE); | |
10501 | 3619 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
10285 | 3620 #endif |
5228 | 3621 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); |
3622 | |
3623 rend = gtk_cell_renderer_text_new(); | |
10351 | 3624 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
3625 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
5228 | 3626 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
3627 | |
3628 rend = gtk_cell_renderer_pixbuf_new(); | |
3629 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); | |
3630 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); | |
3631 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); | |
3632 | |
3633 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); | |
3634 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL); | |
3635 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL); | |
3636 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
7620 | 3637 g_signal_connect(G_OBJECT(gtkblist->treeview), "key-press-event", G_CALLBACK(gtk_blist_key_press_cb), NULL); |
8143 | 3638 g_signal_connect(G_OBJECT(gtkblist->treeview), "popup-menu", G_CALLBACK(gaim_gtk_blist_popup_menu_cb), NULL); |
5228 | 3639 |
5419 | 3640 /* Enable CTRL+F searching */ |
3641 gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); | |
10433 | 3642 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL); |
5419 | 3643 |
12583 | 3644 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); |
5228 | 3645 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); |
3646 gaim_gtk_blist_update_columns(); | |
3647 | |
12583 | 3648 gtkblist->statusbox = gtk_gaim_status_box_new(); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
3649 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); |
12656 | 3650 |
12583 | 3651 gtk_widget_show(gtkblist->statusbox); |
3652 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); | |
12656 | 3653 |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3654 |
5228 | 3655 /* set the Show Offline Buddies option. must be done |
3656 * after the treeview or faceprint gets mad. -Robot101 | |
3657 */ | |
5427 | 3658 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), |
7620 | 3659 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
12656 | 3660 |
5427 | 3661 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
7620 | 3662 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
12656 | 3663 |
10074 | 3664 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3665 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | |
12656 | 3666 |
11796 | 3667 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), |
11920 | 3668 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); |
12656 | 3669 |
3670 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Idle Times"))), | |
3671 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
3672 | |
10074 | 3673 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
11494 | 3674 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
5228 | 3675 |
10353 | 3676 /* Update some dynamic things */ |
3677 update_menu_bar(gtkblist); | |
3678 gaim_gtk_blist_update_plugin_actions(); | |
11796 | 3679 gaim_gtk_blist_update_sort_methods(); |
10353 | 3680 |
5228 | 3681 /* OK... let's show this bad boy. */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3682 gaim_gtk_blist_refresh(list); |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3683 gaim_gtk_blist_restore_position(); |
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3684 gtk_widget_show_all(GTK_WIDGET(gtkblist->window)); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3685 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3686 |
3687 /* start the refresh timer */ | |
10351 | 3688 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); |
10353 | 3689 |
10087 | 3690 handle = gaim_gtk_blist_get_handle(); |
3691 | |
7620 | 3692 /* things that affect how buddies are displayed */ |
10087 | 3693 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3694 _prefs_change_redo_list, NULL); | |
12656 | 3695 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3696 _prefs_change_redo_list, NULL); | |
10087 | 3697 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", |
3698 _prefs_change_redo_list, NULL); | |
3699 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", | |
3700 _prefs_change_redo_list, NULL); | |
7620 | 3701 |
3702 /* sorting */ | |
10087 | 3703 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", |
3704 _prefs_change_sort_method, NULL); | |
7620 | 3705 |
3706 /* things that affect what columns are displayed */ | |
10087 | 3707 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
12326 | 3708 show_buddy_icons_pref_cb, NULL); |
12656 | 3709 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3710 show_buddy_icons_pref_cb, NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3711 |
10074 | 3712 /* menus */ |
10087 | 3713 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", |
3714 gaim_gtk_blist_mute_pref_cb, NULL); | |
3715 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/method", | |
3716 gaim_gtk_blist_sound_method_pref_cb, NULL); | |
10074 | 3717 |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3718 /* Setup some gaim signal handlers. */ |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3719 gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", |
12583 | 3720 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3721 gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", |
12583 | 3722 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12226 | 3723 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", |
12583 | 3724 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3725 |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3726 gaim_signal_connect(gaim_gtk_account_get_handle(), "account-modified", |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3727 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3728 |
8937 | 3729 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
3730 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
3731 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
3732 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
8815 | 3733 |
8986 | 3734 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", |
3735 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3736 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", | |
3737 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3738 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3739 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3740 gtkblist, GAIM_CALLBACK(conversation_updated_cb), |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3741 gtkblist); |
12208 | 3742 gaim_signal_connect(gaim_conversations_get_handle(), "deleting-conversation", |
3743 gtkblist, GAIM_CALLBACK(conversation_deleting_cb), | |
3744 gtkblist); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3745 |
8815 | 3746 /* emit our created signal */ |
10087 | 3747 gaim_signal_emit(handle, "gtkblist-created", list); |
5228 | 3748 } |
3749 | |
7620 | 3750 static void redo_buddy_list(GaimBuddyList *list, gboolean remove) |
5228 | 3751 { |
12112 | 3752 GaimBlistNode *node = list->root; |
3753 | |
3754 while (node) | |
3755 { | |
3756 if (!GAIM_BLIST_NODE_IS_GROUP(node) && remove) | |
3757 gaim_gtk_blist_hide_node(list, node); | |
3758 | |
3759 gaim_gtk_blist_update(list, node); | |
3760 node = gaim_blist_node_next(node, FALSE); | |
5228 | 3761 } |
3762 } | |
3763 | |
7620 | 3764 void gaim_gtk_blist_refresh(GaimBuddyList *list) |
5422 | 3765 { |
3766 redo_buddy_list(list, FALSE); | |
3767 } | |
3768 | |
5297 | 3769 void |
3770 gaim_gtk_blist_update_refresh_timeout() | |
3771 { | |
7620 | 3772 GaimBuddyList *blist; |
3773 GaimGtkBuddyList *gtkblist; | |
5297 | 3774 |
3775 blist = gaim_get_blist(); | |
3776 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
3777 | |
10351 | 3778 gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)gaim_gtk_blist_refresh_timer, blist); |
5297 | 3779 } |
3780 | |
5256 | 3781 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { |
3782 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3783 GtkTreePath *path; | |
5228 | 3784 |
5263 | 3785 if (!gtknode) { |
3786 return FALSE; | |
3787 } | |
3788 | |
3789 if (!gtkblist) { | |
10006 | 3790 gaim_debug_error("gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n"); |
5263 | 3791 return FALSE; |
3792 } | |
3793 | |
3794 if (!gtknode->row) | |
5228 | 3795 return FALSE; |
11494 | 3796 |
5228 | 3797 |
5256 | 3798 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL) |
5228 | 3799 return FALSE; |
11016 | 3800 |
5256 | 3801 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) { |
3802 gtk_tree_path_free(path); | |
3803 return FALSE; | |
3804 } | |
3805 gtk_tree_path_free(path); | |
3806 return TRUE; | |
5228 | 3807 } |
3808 | |
7620 | 3809 static void gaim_gtk_blist_remove(GaimBuddyList *list, GaimBlistNode *node) |
5228 | 3810 { |
11910 | 3811 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
3812 | |
10222 | 3813 gaim_request_close_with_handle(node); |
3814 | |
5260 | 3815 gaim_gtk_blist_hide_node(list, node); |
5228 | 3816 |
7620 | 3817 if(node->parent) |
3818 gaim_gtk_blist_update(list, node->parent); | |
3819 | |
10504 | 3820 /* There's something I don't understand here - Ethan */ |
3821 /* Ethan said that back in 2003, but this g_free has been left commented | |
3822 * out ever since. I can't find any reason at all why this is bad and | |
3823 * valgrind found several reasons why it's good. If this causes problems | |
3824 * comment it out again. Stu */ | |
10510 | 3825 /* Of course it still causes problems - this breaks dragging buddies into |
10515 | 3826 * contacts, the dragged buddy mysteriously 'disappears'. Stu. */ |
3827 /* I think it's fixed now. Stu. */ | |
11910 | 3828 |
11915 | 3829 if(gtknode) { |
3830 if(gtknode->recent_signonoff_timer > 0) | |
3831 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
3832 | |
3833 g_free(node->ui_data); | |
3834 node->ui_data = NULL; | |
3835 } | |
5228 | 3836 } |
3837 | |
3838 static gboolean do_selection_changed(GaimBlistNode *new_selection) | |
3839 { | |
5254 | 3840 GaimBlistNode *old_selection = NULL; |
5228 | 3841 |
5254 | 3842 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */ |
3843 if (gtkblist && new_selection != gtkblist->selected_node) { | |
3844 old_selection = gtkblist->selected_node; | |
5228 | 3845 gtkblist->selected_node = new_selection; |
3846 if(new_selection) | |
3847 gaim_gtk_blist_update(NULL, new_selection); | |
3848 if(old_selection) | |
3849 gaim_gtk_blist_update(NULL, old_selection); | |
3850 } | |
3851 | |
3852 return FALSE; | |
3853 } | |
3854 | |
3855 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
3856 { | |
3857 GaimBlistNode *new_selection = NULL; | |
3858 GtkTreeIter iter; | |
3859 | |
3860 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
3861 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
3862 NODE_COLUMN, &new_selection, -1); | |
3863 } | |
5254 | 3864 |
5228 | 3865 /* we set this up as a timeout, otherwise the blist flickers */ |
3866 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
3867 } | |
3868 | |
8252 | 3869 static gboolean insert_node(GaimBuddyList *list, GaimBlistNode *node, GtkTreeIter *iter) |
7620 | 3870 { |
3871 GtkTreeIter parent_iter, cur, *curptr = NULL; | |
3872 struct _gaim_gtk_blist_node *gtknode = node->ui_data; | |
5256 | 3873 GtkTreePath *newpath; |
7620 | 3874 |
10515 | 3875 if(!iter) |
8252 | 3876 return FALSE; |
7620 | 3877 |
3878 if(node->parent && !get_iter_from_node(node->parent, &parent_iter)) | |
8252 | 3879 return FALSE; |
7620 | 3880 |
3881 if(get_iter_from_node(node, &cur)) | |
3882 curptr = &cur; | |
3883 | |
3884 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
|
3885 current_sort_method->func(node, list, parent_iter, curptr, iter); |
7620 | 3886 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
3887 sort_method_none(node, list, parent_iter, curptr, iter); |
5228 | 3888 } |
3889 | |
10515 | 3890 if(gtknode != NULL) { |
3891 gtk_tree_row_reference_free(gtknode->row); | |
3892 } else { | |
3893 gaim_gtk_blist_new_node(node); | |
3894 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3895 } | |
3896 | |
7620 | 3897 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), |
3898 iter); | |
3899 gtknode->row = | |
3900 gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), | |
3901 newpath); | |
11494 | 3902 |
5256 | 3903 gtk_tree_path_free(newpath); |
3904 | |
5228 | 3905 gtk_tree_store_set(gtkblist->treemodel, iter, |
3906 NODE_COLUMN, node, | |
3907 -1); | |
7620 | 3908 |
3909 if(node->parent) { | |
3910 GtkTreePath *expand = NULL; | |
3911 struct _gaim_gtk_blist_node *gtkparentnode = node->parent->ui_data; | |
3912 | |
3913 if(GAIM_BLIST_NODE_IS_GROUP(node->parent)) { | |
7693 | 3914 if(!gaim_blist_node_get_bool(node->parent, "collapsed")) |
7620 | 3915 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); |
3916 } else if(GAIM_BLIST_NODE_IS_CONTACT(node->parent) && | |
3917 gtkparentnode->contact_expanded) { | |
3918 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); | |
3919 } | |
3920 if(expand) { | |
7693 | 3921 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, FALSE); |
7620 | 3922 gtk_tree_path_free(expand); |
3923 } | |
3924 } | |
3925 | |
8252 | 3926 return TRUE; |
5228 | 3927 } |
3928 | |
7620 | 3929 static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) |
3930 { | |
3931 GaimGroup *group; | |
8203 | 3932 int count; |
12341 | 3933 gboolean show = FALSE; |
7620 | 3934 |
3935 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); | |
3936 | |
3937 group = (GaimGroup*)node; | |
3938 | |
8203 | 3939 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) |
3940 count = gaim_blist_get_group_size(group, FALSE); | |
3941 else | |
3942 count = gaim_blist_get_group_online_count(group); | |
12341 | 3943 |
3944 if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) | |
3945 show = TRUE; | |
3946 else { | |
3947 GaimBlistNode *n; | |
3948 n = node->child; | |
3949 while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { | |
3950 if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
3951 if (buddy_is_displayable((GaimBuddy*)n)) { | |
3952 show = TRUE; | |
3953 break; | |
3954 } | |
3955 } | |
3956 n = gaim_blist_node_next(n, FALSE); | |
3957 } | |
3958 } | |
3959 | |
3960 if (show) { | |
7620 | 3961 char *mark, *esc; |
3962 GtkTreeIter iter; | |
3963 | |
8252 | 3964 if(!insert_node(list, node, &iter)) |
3965 return; | |
7620 | 3966 |
3967 esc = g_markup_escape_text(group->name, -1); | |
8945 | 3968 mark = g_strdup_printf("<span weight='bold'>%s</span> (%d/%d)", |
3969 esc, gaim_blist_get_group_online_count(group), | |
3970 gaim_blist_get_group_size(group, FALSE)); | |
7620 | 3971 g_free(esc); |
3972 | |
3973 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
3974 STATUS_ICON_COLUMN, NULL, | |
3975 STATUS_ICON_VISIBLE_COLUMN, FALSE, | |
3976 NAME_COLUMN, mark, | |
3977 NODE_COLUMN, node, | |
3978 -1); | |
3979 g_free(mark); | |
3980 } else { | |
3981 gaim_gtk_blist_hide_node(list, node); | |
3982 } | |
3983 } | |
3984 | |
3985 static void buddy_node(GaimBuddy *buddy, GtkTreeIter *iter, GaimBlistNode *node) | |
5228 | 3986 { |
9944 | 3987 GaimPresence *presence; |
7620 | 3988 GdkPixbuf *status, *avatar; |
3989 char *mark; | |
11257 | 3990 char *idle = NULL; |
7620 | 3991 gboolean selected = (gtkblist->selected_node == node); |
3992 | |
9944 | 3993 presence = gaim_buddy_get_presence(buddy); |
3994 | |
7620 | 3995 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, |
3996 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") | |
3997 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
3998 | |
10482 | 3999 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); |
7620 | 4000 mark = gaim_gtk_blist_get_name_markup(buddy, selected); |
4001 | |
12656 | 4002 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
4003 gaim_presence_is_idle(presence)) | |
9944 | 4004 { |
4005 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
4006 | |
4007 if (idle_secs > 0) | |
4008 { | |
4009 time_t t; | |
4010 int ihrs, imin; | |
4011 time(&t); | |
4012 ihrs = (t - idle_secs) / 3600; | |
4013 imin = ((t - idle_secs) / 60) % 60; | |
4014 | |
4015 if (ihrs > 0) | |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4016 idle = g_strdup_printf("%d:%02d", ihrs, imin); |
9944 | 4017 else |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4018 idle = g_strdup_printf("%d", imin); |
9944 | 4019 } |
7620 | 4020 } |
4021 | |
10118 | 4022 if (gaim_presence_is_idle(presence)) |
9944 | 4023 { |
4024 if (idle && !selected) { | |
10118 | 4025 char *i2 = g_strdup_printf("<span color='%s'>%s</span>", |
4026 dim_grey(), idle); | |
7620 | 4027 g_free(idle); |
4028 idle = i2; | |
5228 | 4029 } |
7620 | 4030 } |
4031 | |
4032 gtk_tree_store_set(gtkblist->treemodel, iter, | |
4033 STATUS_ICON_COLUMN, status, | |
4034 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4035 NAME_COLUMN, mark, | |
4036 IDLE_COLUMN, idle, | |
4037 BUDDY_ICON_COLUMN, avatar, | |
4038 -1); | |
4039 | |
4040 g_free(mark); | |
12656 | 4041 g_free(idle); |
7620 | 4042 if(status) |
4043 g_object_unref(status); | |
4044 if(avatar) | |
4045 g_object_unref(avatar); | |
4046 } | |
4047 | |
11890 | 4048 |
7620 | 4049 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) |
4050 { | |
4051 GaimContact *contact; | |
4052 GaimBuddy *buddy; | |
4053 struct _gaim_gtk_blist_node *gtknode; | |
4054 | |
4055 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node)); | |
4056 | |
4057 /* First things first, update the group */ | |
4058 gaim_gtk_blist_update_group(list, node->parent); | |
4059 | |
4060 contact = (GaimContact*)node; | |
4061 buddy = gaim_contact_get_priority_buddy(contact); | |
4062 | |
11890 | 4063 if (buddy_is_displayable(buddy)) |
10006 | 4064 { |
7620 | 4065 GtkTreeIter iter; |
4066 | |
8252 | 4067 if(!insert_node(list, node, &iter)) |
4068 return; | |
7620 | 4069 |
10515 | 4070 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
4071 | |
7620 | 4072 if(gtknode->contact_expanded) { |
4073 GdkPixbuf *status; | |
5228 | 4074 char *mark; |
4075 | |
7620 | 4076 status = gaim_gtk_blist_get_status_icon(node, |
4077 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? | |
4078 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4079 | |
4080 mark = g_markup_escape_text(gaim_contact_get_alias(contact), -1); | |
4081 | |
5228 | 4082 gtk_tree_store_set(gtkblist->treemodel, &iter, |
7620 | 4083 STATUS_ICON_COLUMN, status, |
4084 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
5228 | 4085 NAME_COLUMN, mark, |
7620 | 4086 IDLE_COLUMN, NULL, |
4087 BUDDY_ICON_COLUMN, NULL, | |
5228 | 4088 -1); |
4089 g_free(mark); | |
7620 | 4090 if(status) |
4091 g_object_unref(status); | |
4092 } else { | |
4093 buddy_node(buddy, &iter, node); | |
5228 | 4094 } |
7620 | 4095 } else { |
4096 gaim_gtk_blist_hide_node(list, node); | |
5228 | 4097 } |
7620 | 4098 } |
4099 | |
4100 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) | |
4101 { | |
4102 GaimContact *contact; | |
4103 GaimBuddy *buddy; | |
4104 struct _gaim_gtk_blist_node *gtkparentnode; | |
4105 | |
4106 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4107 | |
4108 buddy = (GaimBuddy*)node; | |
4109 contact = (GaimContact*)node->parent; | |
4110 | |
11624 | 4111 if (contact == NULL) |
4112 return; | |
4113 | |
7620 | 4114 /* First things first, update the contact */ |
4115 gaim_gtk_blist_update_contact(list, node->parent); | |
4116 | |
10918 | 4117 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
4118 | |
12341 | 4119 if (gtkparentnode->contact_expanded && buddy_is_displayable(buddy)) |
10006 | 4120 { |
7620 | 4121 GtkTreeIter iter; |
4122 | |
10006 | 4123 if (!insert_node(list, node, &iter)) |
8252 | 4124 return; |
4125 | |
7620 | 4126 buddy_node(buddy, &iter, node); |
4127 | |
4128 } else { | |
4129 gaim_gtk_blist_hide_node(list, node); | |
4130 } | |
4131 | |
4132 } | |
4133 | |
4134 static void gaim_gtk_blist_update_chat(GaimBuddyList *list, GaimBlistNode *node) | |
4135 { | |
4136 GaimChat *chat; | |
4137 | |
4138 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); | |
4139 | |
4140 /* First things first, update the group */ | |
4141 gaim_gtk_blist_update_group(list, node->parent); | |
4142 | |
4143 chat = (GaimChat*)node; | |
4144 | |
4145 if(gaim_account_is_connected(chat->account)) { | |
4146 GtkTreeIter iter; | |
5234 | 4147 GdkPixbuf *status; |
7620 | 4148 char *mark; |
4149 | |
8252 | 4150 if(!insert_node(list, node, &iter)) |
4151 return; | |
5234 | 4152 |
4153 status = gaim_gtk_blist_get_status_icon(node, | |
7620 | 4154 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
4155 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4156 | |
4157 mark = g_markup_escape_text(gaim_chat_get_name(chat), -1); | |
5234 | 4158 |
4159 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
7620 | 4160 STATUS_ICON_COLUMN, status, |
4161 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4162 NAME_COLUMN, mark, | |
4163 -1); | |
5228 | 4164 |
4165 g_free(mark); | |
7620 | 4166 if(status) |
5228 | 4167 g_object_unref(status); |
7620 | 4168 } else { |
5260 | 4169 gaim_gtk_blist_hide_node(list, node); |
5228 | 4170 } |
7620 | 4171 } |
4172 | |
4173 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node) | |
4174 { | |
4175 if(!gtkblist) | |
4176 return; | |
4177 | |
4178 switch(node->type) { | |
4179 case GAIM_BLIST_GROUP_NODE: | |
4180 gaim_gtk_blist_update_group(list, node); | |
4181 break; | |
4182 case GAIM_BLIST_CONTACT_NODE: | |
4183 gaim_gtk_blist_update_contact(list, node); | |
4184 break; | |
4185 case GAIM_BLIST_BUDDY_NODE: | |
4186 gaim_gtk_blist_update_buddy(list, node); | |
4187 break; | |
4188 case GAIM_BLIST_CHAT_NODE: | |
4189 gaim_gtk_blist_update_chat(list, node); | |
4190 break; | |
4191 case GAIM_BLIST_OTHER_NODE: | |
4192 return; | |
4193 } | |
5234 | 4194 |
5228 | 4195 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
4196 } | |
4197 | |
7620 | 4198 |
4199 static void gaim_gtk_blist_destroy(GaimBuddyList *list) | |
5228 | 4200 { |
4201 if (!gtkblist) | |
4202 return; | |
4203 | |
8937 | 4204 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
4205 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
4206 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
4207 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
4208 |
5228 | 4209 gtk_widget_destroy(gtkblist->window); |
7620 | 4210 |
8254 | 4211 gaim_gtk_blist_tooltip_destroy(); |
7620 | 4212 |
5228 | 4213 if (gtkblist->refresh_timer) |
4214 g_source_remove(gtkblist->refresh_timer); | |
4215 if (gtkblist->timeout) | |
4216 g_source_remove(gtkblist->timeout); | |
10354 | 4217 if (gtkblist->drag_timeout) |
4218 g_source_remove(gtkblist->drag_timeout); | |
5228 | 4219 |
4220 gtkblist->refresh_timer = 0; | |
4221 gtkblist->timeout = 0; | |
10354 | 4222 gtkblist->drag_timeout = 0; |
5228 | 4223 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; |
4224 gtkblist->treemodel = NULL; | |
4225 gtkblist->idle_column = NULL; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4226 gtkblist->buddy_icon_column = NULL; |
5427 | 4227 g_object_unref(G_OBJECT(gtkblist->ift)); |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4228 accountmenu = NULL; |
5228 | 4229 gtkblist = NULL; |
7620 | 4230 |
10087 | 4231 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
5228 | 4232 } |
4233 | |
7620 | 4234 static void gaim_gtk_blist_set_visible(GaimBuddyList *list, gboolean show) |
5228 | 4235 { |
4236 if (!(gtkblist && gtkblist->window)) | |
4237 return; | |
10325 | 4238 |
5228 | 4239 if (show) { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4240 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
|
4241 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", gtkblist); |
5228 | 4242 gaim_gtk_blist_restore_position(); |
4243 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4244 } else { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4245 if(visibility_manager_count) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4246 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
|
4247 gtk_widget_hide(gtkblist->window); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4248 } else { |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4249 if (!GTK_WIDGET_VISIBLE(gtkblist->window)) |
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4250 gtk_widget_show(gtkblist->window); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4251 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4252 } |
5228 | 4253 } |
4254 } | |
4255 | |
7620 | 4256 static GList * |
4257 groups_tree(void) | |
4258 { | |
4259 GList *tmp = NULL; | |
4260 char *tmp2; | |
4261 GaimGroup *g; | |
4262 GaimBlistNode *gnode; | |
4263 | |
4264 if (gaim_get_blist()->root == NULL) | |
4265 { | |
4266 tmp2 = g_strdup(_("Buddies")); | |
4267 tmp = g_list_append(tmp, tmp2); | |
4268 } | |
4269 else | |
4270 { | |
4271 for (gnode = gaim_get_blist()->root; | |
4272 gnode != NULL; | |
4273 gnode = gnode->next) | |
4274 { | |
4275 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4276 { | |
4277 g = (GaimGroup *)gnode; | |
4278 tmp2 = g->name; | |
4279 tmp = g_list_append(tmp, tmp2); | |
4280 } | |
4281 } | |
4282 } | |
4283 | |
4284 return tmp; | |
4285 } | |
4286 | |
4287 static void | |
4288 add_buddy_select_account_cb(GObject *w, GaimAccount *account, | |
4289 GaimGtkAddBuddyData *data) | |
4290 { | |
4291 /* Save our account */ | |
4292 data->account = account; | |
4293 } | |
4294 | |
4295 static void | |
4296 destroy_add_buddy_dialog_cb(GtkWidget *win, GaimGtkAddBuddyData *data) | |
4297 { | |
4298 g_free(data); | |
4299 } | |
4300 | |
4301 static void | |
4302 add_buddy_cb(GtkWidget *w, int resp, GaimGtkAddBuddyData *data) | |
4303 { | |
4304 const char *grp, *who, *whoalias; | |
4305 GaimConversation *c; | |
4306 GaimBuddy *b; | |
4307 GaimGroup *g; | |
4308 | |
4309 if (resp == GTK_RESPONSE_OK) | |
4310 { | |
4311 who = gtk_entry_get_text(GTK_ENTRY(data->entry)); | |
4312 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry)); | |
4313 whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); | |
9658 | 4314 if (*whoalias == '\0') |
4315 whoalias = NULL; | |
7620 | 4316 |
4317 if ((g = gaim_find_group(grp)) == NULL) | |
4318 { | |
4319 g = gaim_group_new(grp); | |
4320 gaim_blist_add_group(g, NULL); | |
4321 } | |
4322 | |
4323 b = gaim_buddy_new(data->account, who, whoalias); | |
4324 gaim_blist_add_buddy(b, NULL, g, NULL); | |
11643 | 4325 gaim_account_add_buddy(data->account, b); |
7620 | 4326 |
7887 | 4327 /* |
9285 | 4328 * XXX |
11643 | 4329 * It really seems like it would be better if the call to |
4330 * gaim_account_add_buddy() and gaim_conversation_update() were done in | |
4331 * blist.c, possibly in the gaim_blist_add_buddy() function. Maybe | |
4332 * gaim_account_add_buddy() should be renamed to | |
4333 * gaim_blist_add_new_buddy() or something, and have it call | |
7887 | 4334 * gaim_blist_add_buddy() after it creates it. --Mark |
9285 | 4335 * |
4336 * No that's not good. blist.c should only deal with adding nodes to the | |
11643 | 4337 * local list. We need a new, non-gtk file that calls both |
4338 * gaim_account_add_buddy and gaim_blist_add_buddy(). | |
4339 * Or something. --Mark | |
7887 | 4340 */ |
4341 | |
11338 | 4342 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, data->account); |
7620 | 4343 if (c != NULL) { |
4344 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(c))); | |
4345 gaim_conversation_update(c, GAIM_CONV_UPDATE_ADD); | |
4346 } | |
4347 } | |
4348 | |
4349 gtk_widget_destroy(data->window); | |
4350 } | |
4351 | |
4352 static void | |
4353 gaim_gtk_blist_request_add_buddy(GaimAccount *account, const char *username, | |
4354 const char *group, const char *alias) | |
4355 { | |
4356 GtkWidget *table; | |
4357 GtkWidget *label; | |
4358 GtkWidget *hbox; | |
4359 GtkWidget *vbox; | |
4360 GtkWidget *img; | |
4361 GaimGtkBuddyList *gtkblist; | |
4362 GaimGtkAddBuddyData *data = g_new0(GaimGtkAddBuddyData, 1); | |
4363 | |
4364 data->account = | |
4365 (account != NULL | |
4366 ? account | |
4367 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
4368 | |
4369 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4370 GTK_ICON_SIZE_DIALOG); | |
4371 | |
4372 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
4373 | |
4374 data->window = gtk_dialog_new_with_buttons(_("Add Buddy"), | |
8975 | 4375 NULL, GTK_DIALOG_NO_SEPARATOR, |
7620 | 4376 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
4377 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4378 NULL); | |
4379 | |
4380 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4381 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
7620 | 4382 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4383 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4384 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4385 gtk_window_set_role(GTK_WINDOW(data->window), "add_buddy"); |
8975 | 4386 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4387 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4388 |
11243 | 4389 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4390 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4391 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4392 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4393 | |
4394 vbox = gtk_vbox_new(FALSE, 0); | |
4395 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4396 | |
4397 label = gtk_label_new( | |
4398 _("Please enter the screen name of the person you would like " | |
4399 "to add to your buddy list. You may optionally enter an alias, " | |
4400 "or nickname, for the buddy. The alias will be displayed in " | |
4401 "place of the screen name whenever possible.\n")); | |
4402 | |
4403 gtk_widget_set_size_request(GTK_WIDGET(label), 400, -1); | |
4404 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4405 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4406 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4407 | |
11243 | 4408 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7620 | 4409 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
4410 | |
4411 g_signal_connect(G_OBJECT(data->window), "destroy", | |
4412 G_CALLBACK(destroy_add_buddy_dialog_cb), data); | |
4413 | |
4414 table = gtk_table_new(4, 2, FALSE); | |
4415 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
4416 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
4417 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | |
4418 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
4419 | |
4420 label = gtk_label_new(_("Screen Name:")); | |
4421 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4422 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
4423 | |
4424 data->entry = gtk_entry_new(); | |
4425 gtk_table_attach_defaults(GTK_TABLE(table), data->entry, 1, 2, 0, 1); | |
4426 gtk_widget_grab_focus(data->entry); | |
4427 | |
4428 if (username != NULL) | |
4429 gtk_entry_set_text(GTK_ENTRY(data->entry), username); | |
12337 | 4430 else |
4431 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), | |
4432 GTK_RESPONSE_OK, FALSE); | |
7620 | 4433 |
4434 gtk_entry_set_activates_default (GTK_ENTRY(data->entry), TRUE); | |
8137 | 4435 gaim_set_accessible_label (data->entry, label); |
7620 | 4436 |
12337 | 4437 g_signal_connect(G_OBJECT(data->entry), "changed", |
4438 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
4439 data->window); | |
4440 | |
7620 | 4441 label = gtk_label_new(_("Alias:")); |
4442 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4443 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
4444 | |
4445 data->entry_for_alias = gtk_entry_new(); | |
4446 gtk_table_attach_defaults(GTK_TABLE(table), | |
4447 data->entry_for_alias, 1, 2, 1, 2); | |
4448 | |
4449 if (alias != NULL) | |
4450 gtk_entry_set_text(GTK_ENTRY(data->entry_for_alias), alias); | |
4451 | |
10734
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4452 if (username != NULL) |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4453 gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4454 |
7620 | 4455 gtk_entry_set_activates_default (GTK_ENTRY(data->entry_for_alias), TRUE); |
8137 | 4456 gaim_set_accessible_label (data->entry_for_alias, label); |
7620 | 4457 |
4458 label = gtk_label_new(_("Group:")); | |
4459 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4460 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
4461 | |
4462 data->combo = gtk_combo_new(); | |
4463 gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree()); | |
4464 gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 2, 3); | |
8137 | 4465 gaim_set_accessible_label (data->combo, label); |
7620 | 4466 |
4467 /* Set up stuff for the account box */ | |
4468 label = gtk_label_new(_("Account:")); | |
4469 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4470 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
4471 | |
4472 data->account_box = gaim_gtk_account_option_menu_new(account, FALSE, | |
4473 G_CALLBACK(add_buddy_select_account_cb), NULL, data); | |
4474 | |
4475 gtk_table_attach_defaults(GTK_TABLE(table), data->account_box, 1, 2, 3, 4); | |
8137 | 4476 gaim_set_accessible_label (data->account_box, label); |
7620 | 4477 /* End of account box */ |
4478 | |
4479 g_signal_connect(G_OBJECT(data->window), "response", | |
4480 G_CALLBACK(add_buddy_cb), data); | |
4481 | |
4482 gtk_widget_show_all(data->window); | |
4483 | |
4484 if (group != NULL) | |
4485 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group); | |
4486 } | |
4487 | |
4488 static void | |
4489 add_chat_cb(GtkWidget *w, GaimGtkAddChatData *data) | |
4490 { | |
4491 GHashTable *components; | |
4492 GList *tmp; | |
4493 GaimChat *chat; | |
4494 GaimGroup *group; | |
4495 const char *group_name; | |
9918 | 4496 char *chat_name = NULL; |
4497 GaimConversation *conv = NULL; | |
10475 | 4498 const char *value; |
7620 | 4499 |
4500 components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
4501 g_free, g_free); | |
4502 | |
4503 for (tmp = data->entries; tmp; tmp = tmp->next) | |
4504 { | |
4505 if (g_object_get_data(tmp->data, "is_spin")) | |
4506 { | |
4507 g_hash_table_replace(components, | |
4508 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4509 g_strdup_printf("%d", | |
4510 gtk_spin_button_get_value_as_int(tmp->data))); | |
4511 } | |
4512 else | |
4513 { | |
10475 | 4514 value = gtk_entry_get_text(tmp->data); |
4515 if (*value != '\0') | |
4516 g_hash_table_replace(components, | |
4517 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4518 g_strdup(value)); | |
7620 | 4519 } |
4520 } | |
4521 | |
4522 chat = gaim_chat_new(data->account, | |
4523 gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), | |
4524 components); | |
4525 | |
4526 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry)); | |
4527 | |
4528 if ((group = gaim_find_group(group_name)) == NULL) | |
4529 { | |
4530 group = gaim_group_new(group_name); | |
4531 gaim_blist_add_group(group, NULL); | |
4532 } | |
4533 | |
4534 if (chat != NULL) | |
4535 { | |
4536 gaim_blist_add_chat(chat, group, NULL); | |
9918 | 4537 |
4538 if (GAIM_PLUGIN_PROTOCOL_INFO(data->account->gc->prpl)->get_chat_name != NULL) | |
4539 chat_name = GAIM_PLUGIN_PROTOCOL_INFO( | |
4540 data->account->gc->prpl)->get_chat_name(chat->components); | |
10246 | 4541 |
9918 | 4542 if (chat_name != NULL) { |
11338 | 4543 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
10246 | 4544 chat_name, |
4545 data->account); | |
9918 | 4546 g_free(chat_name); |
4547 } | |
4548 | |
4549 if (conv != NULL) | |
4550 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ADD); | |
7620 | 4551 } |
4552 | |
4553 gtk_widget_destroy(data->window); | |
9812 | 4554 g_free(data->default_chat_name); |
7620 | 4555 g_list_free(data->entries); |
4556 g_free(data); | |
4557 } | |
4558 | |
4559 static void | |
4560 add_chat_resp_cb(GtkWidget *w, int resp, GaimGtkAddChatData *data) | |
4561 { | |
4562 if (resp == GTK_RESPONSE_OK) | |
4563 { | |
4564 add_chat_cb(NULL, data); | |
4565 } | |
4566 else | |
4567 { | |
4568 gtk_widget_destroy(data->window); | |
9812 | 4569 g_free(data->default_chat_name); |
7620 | 4570 g_list_free(data->entries); |
4571 g_free(data); | |
4572 } | |
4573 } | |
4574 | |
10475 | 4575 /* |
4576 * Check the values of all the text entry boxes. If any required input | |
4577 * strings are empty then don't allow the user to click on "OK." | |
4578 */ | |
4579 static void | |
4580 addchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
4581 { | |
4582 GaimGtkAddChatData *data; | |
4583 GList *tmp; | |
4584 const char *text; | |
4585 gboolean required; | |
4586 gboolean sensitive = TRUE; | |
4587 | |
4588 data = user_data; | |
4589 | |
4590 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
4591 { | |
4592 if (!g_object_get_data(tmp->data, "is_spin")) | |
4593 { | |
4594 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
4595 text = gtk_entry_get_text(tmp->data); | |
4596 if (required && (*text == '\0')) | |
4597 sensitive = FALSE; | |
4598 } | |
4599 } | |
4600 | |
4601 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
4602 } | |
4603 | |
7620 | 4604 static void |
4605 rebuild_addchat_entries(GaimGtkAddChatData *data) | |
4606 { | |
4607 GaimConnection *gc; | |
9959 | 4608 GList *list = NULL, *tmp = NULL; |
9754 | 4609 GHashTable *defaults = NULL; |
7620 | 4610 struct proto_chat_entry *pce; |
4611 gboolean focus = TRUE; | |
4612 | |
10127 | 4613 g_return_if_fail(data->account != NULL); |
4614 | |
7620 | 4615 gc = gaim_account_get_connection(data->account); |
4616 | |
4617 while (GTK_BOX(data->entries_box)->children) | |
4618 { | |
4619 gtk_container_remove(GTK_CONTAINER(data->entries_box), | |
10475 | 4620 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
7620 | 4621 } |
4622 | |
4623 if (data->entries != NULL) | |
4624 g_list_free(data->entries); | |
4625 | |
4626 data->entries = NULL; | |
4627 | |
9959 | 4628 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4629 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | |
7620 | 4630 |
9754 | 4631 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
10475 | 4632 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, data->default_chat_name); |
9754 | 4633 |
7620 | 4634 for (tmp = list; tmp; tmp = tmp->next) |
4635 { | |
4636 GtkWidget *label; | |
4637 GtkWidget *rowbox; | |
10475 | 4638 GtkWidget *input; |
7620 | 4639 |
4640 pce = tmp->data; | |
4641 | |
4642 rowbox = gtk_hbox_new(FALSE, 5); | |
4643 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); | |
4644 | |
7889 | 4645 label = gtk_label_new_with_mnemonic(pce->label); |
7620 | 4646 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4647 gtk_size_group_add_widget(data->sg, label); | |
4648 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4649 | |
4650 if (pce->is_int) | |
4651 { | |
4652 GtkObject *adjust; | |
4653 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, | |
4654 1, 10, 10); | |
10475 | 4655 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
4656 gtk_widget_set_size_request(input, 50, -1); | |
4657 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
7620 | 4658 } |
4659 else | |
4660 { | |
9754 | 4661 char *value; |
10475 | 4662 input = gtk_entry_new(); |
4663 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9754 | 4664 value = g_hash_table_lookup(defaults, pce->identifier); |
4665 if (value != NULL) | |
10475 | 4666 gtk_entry_set_text(GTK_ENTRY(input), value); |
7620 | 4667 if (pce->secret) |
11986 | 4668 { |
10475 | 4669 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 4670 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
4671 } | |
10475 | 4672 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
4673 g_signal_connect(G_OBJECT(input), "changed", | |
4674 G_CALLBACK(addchat_set_sensitive_if_input_cb), data); | |
7620 | 4675 } |
4676 | |
10475 | 4677 /* Do the following for any type of input widget */ |
4678 if (focus) | |
4679 { | |
4680 gtk_widget_grab_focus(input); | |
4681 focus = FALSE; | |
4682 } | |
4683 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
4684 gaim_set_accessible_label(input, label); | |
4685 g_object_set_data(G_OBJECT(input), "identifier", pce->identifier); | |
4686 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); | |
4687 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
4688 data->entries = g_list_append(data->entries, input); | |
4689 | |
7620 | 4690 g_free(pce); |
4691 } | |
4692 | |
4693 g_list_free(list); | |
9754 | 4694 g_hash_table_destroy(defaults); |
7620 | 4695 |
10475 | 4696 /* Set whether the "OK" button should be clickable initially */ |
4697 addchat_set_sensitive_if_input_cb(NULL, data); | |
4698 | |
7620 | 4699 gtk_widget_show_all(data->entries_box); |
4700 } | |
4701 | |
4702 static void | |
10475 | 4703 addchat_select_account_cb(GObject *w, GaimAccount *account, |
7620 | 4704 GaimGtkAddChatData *data) |
4705 { | |
9460 | 4706 if (strcmp(gaim_account_get_protocol_id(data->account), |
4707 gaim_account_get_protocol_id(account)) == 0) | |
7620 | 4708 { |
4709 data->account = account; | |
4710 } | |
4711 else | |
4712 { | |
4713 data->account = account; | |
4714 rebuild_addchat_entries(data); | |
4715 } | |
4716 } | |
4717 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4718 static void |
7859 | 4719 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
9754 | 4720 const char *alias, const char *name) |
7620 | 4721 { |
4722 GaimGtkAddChatData *data; | |
8975 | 4723 GaimGtkBuddyList *gtkblist; |
4724 GList *l; | |
4725 GaimConnection *gc; | |
7620 | 4726 GtkWidget *label; |
4727 GtkWidget *rowbox; | |
4728 GtkWidget *hbox; | |
4729 GtkWidget *vbox; | |
4730 GtkWidget *img; | |
4731 | |
9812 | 4732 if (account != NULL) { |
4733 gc = gaim_account_get_connection(account); | |
4734 | |
4735 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | |
4736 gaim_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | |
4737 return; | |
4738 } | |
4739 } else { | |
4740 /* Find an account with chat capabilities */ | |
4741 for (l = gaim_connections_get_all(); l != NULL; l = l->next) { | |
4742 gc = (GaimConnection *)l->data; | |
4743 | |
4744 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | |
4745 account = gaim_connection_get_account(gc); | |
4746 break; | |
4747 } | |
4748 } | |
4749 | |
4750 if (account == NULL) { | |
4751 gaim_notify_error(NULL, NULL, | |
4752 _("You are not currently signed on with any " | |
4753 "protocols that have the ability to chat."), NULL); | |
4754 return; | |
4755 } | |
4756 } | |
4757 | |
7620 | 4758 data = g_new0(GaimGtkAddChatData, 1); |
9812 | 4759 data->account = account; |
4760 data->default_chat_name = g_strdup(name); | |
7620 | 4761 |
4762 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4763 GTK_ICON_SIZE_DIALOG); | |
4764 | |
8975 | 4765 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4766 | |
7620 | 4767 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4768 | |
8975 | 4769 data->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
4770 NULL, GTK_DIALOG_NO_SEPARATOR, | |
4771 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
4772 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4773 NULL); | |
4774 | |
4775 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4776 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8975 | 4777 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4778 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4779 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4780 gtk_window_set_role(GTK_WINDOW(data->window), "add_chat"); |
8975 | 4781 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4782 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4783 |
11243 | 4784 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4785 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4786 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4787 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4788 | |
4789 vbox = gtk_vbox_new(FALSE, 5); | |
4790 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4791 | |
4792 label = gtk_label_new( | |
4793 _("Please enter an alias, and the appropriate information " | |
4794 "about the chat you would like to add to your buddy list.\n")); | |
4795 gtk_widget_set_size_request(label, 400, -1); | |
4796 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4797 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4798 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4799 | |
4800 rowbox = gtk_hbox_new(FALSE, 5); | |
4801 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4802 | |
4803 label = gtk_label_new(_("Account:")); | |
4804 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4805 gtk_size_group_add_widget(data->sg, label); | |
4806 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4807 | |
4808 data->account_menu = gaim_gtk_account_option_menu_new(account, FALSE, | |
10475 | 4809 G_CALLBACK(addchat_select_account_cb), |
9987 | 4810 chat_account_filter_func, data); |
7620 | 4811 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
8137 | 4812 gaim_set_accessible_label (data->account_menu, label); |
7620 | 4813 |
4814 data->entries_box = gtk_vbox_new(FALSE, 5); | |
9811 | 4815 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
7620 | 4816 gtk_box_pack_start(GTK_BOX(vbox), data->entries_box, TRUE, TRUE, 0); |
4817 | |
4818 rebuild_addchat_entries(data); | |
4819 | |
4820 rowbox = gtk_hbox_new(FALSE, 5); | |
4821 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4822 | |
4823 label = gtk_label_new(_("Alias:")); | |
4824 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4825 gtk_size_group_add_widget(data->sg, label); | |
4826 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4827 | |
4828 data->alias_entry = gtk_entry_new(); | |
7859 | 4829 if (alias != NULL) |
4830 gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias); | |
7620 | 4831 gtk_box_pack_end(GTK_BOX(rowbox), data->alias_entry, TRUE, TRUE, 0); |
10311 | 4832 gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE); |
8137 | 4833 gaim_set_accessible_label (data->alias_entry, label); |
7620 | 4834 |
4835 rowbox = gtk_hbox_new(FALSE, 5); | |
4836 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4837 | |
9811 | 4838 label = gtk_label_new(_("Group:")); |
7620 | 4839 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4840 gtk_size_group_add_widget(data->sg, label); | |
4841 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4842 | |
9811 | 4843 data->group_combo = gtk_combo_new(); |
4844 gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree()); | |
7620 | 4845 gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0); |
4846 | |
4847 if (group) | |
4848 { | |
4849 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry), | |
4850 group->name); | |
4851 } | |
8137 | 4852 gaim_set_accessible_label (data->group_combo, label); |
7620 | 4853 |
4854 g_signal_connect(G_OBJECT(data->window), "response", | |
4855 G_CALLBACK(add_chat_resp_cb), data); | |
4856 | |
4857 gtk_widget_show_all(data->window); | |
4858 } | |
4859 | |
4860 static void | |
4861 add_group_cb(GaimConnection *gc, const char *group_name) | |
4862 { | |
9285 | 4863 GaimGroup *group; |
4864 | |
12458 | 4865 if ((group_name == NULL) || (*group_name == '\0')) |
4866 return; | |
4867 | |
9285 | 4868 group = gaim_group_new(group_name); |
4869 gaim_blist_add_group(group, NULL); | |
7620 | 4870 } |
4871 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4872 static void |
7620 | 4873 gaim_gtk_blist_request_add_group(void) |
4874 { | |
7853 | 4875 gaim_request_input(NULL, _("Add Group"), NULL, |
7620 | 4876 _("Please enter the name of the group to be added."), |
8697 | 4877 NULL, FALSE, FALSE, NULL, |
7620 | 4878 _("Add"), G_CALLBACK(add_group_cb), |
4879 _("Cancel"), NULL, NULL); | |
4880 } | |
4881 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4882 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4883 gaim_gtk_blist_toggle_visibility() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4884 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4885 if (gtkblist && gtkblist->window) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4886 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4887 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
|
4888 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4889 gaim_blist_set_visible(TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4890 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4891 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4892 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4893 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4894 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4895 gaim_gtk_blist_visibility_manager_add() |
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 visibility_manager_count++; |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4898 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
|
4899 } |
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 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4902 gaim_gtk_blist_visibility_manager_remove() |
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 if (visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4905 visibility_manager_count--; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4906 if (!visibility_manager_count) |
12115
e9790eb93216
[gaim-migrate @ 14415]
Luke Schierer <lschiere@pidgin.im>
parents:
12113
diff
changeset
|
4907 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
|
4908 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
|
4909 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4910 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4911 |
7620 | 4912 static GaimBlistUiOps blist_ui_ops = |
5228 | 4913 { |
4914 gaim_gtk_blist_new_list, | |
5256 | 4915 gaim_gtk_blist_new_node, |
5228 | 4916 gaim_gtk_blist_show, |
4917 gaim_gtk_blist_update, | |
4918 gaim_gtk_blist_remove, | |
4919 gaim_gtk_blist_destroy, | |
7620 | 4920 gaim_gtk_blist_set_visible, |
4921 gaim_gtk_blist_request_add_buddy, | |
4922 gaim_gtk_blist_request_add_chat, | |
10012 | 4923 gaim_gtk_blist_request_add_group |
5228 | 4924 }; |
4925 | |
4926 | |
7620 | 4927 GaimBlistUiOps * |
4928 gaim_gtk_blist_get_ui_ops(void) | |
5228 | 4929 { |
4930 return &blist_ui_ops; | |
4931 } | |
4932 | |
10643 | 4933 GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() |
4934 { | |
4935 return gtkblist; | |
4936 } | |
4937 | |
7620 | 4938 static void account_signon_cb(GaimConnection *gc, gpointer z) |
4939 { | |
4940 GaimAccount *account = gaim_connection_get_account(gc); | |
4941 GaimBlistNode *gnode, *cnode; | |
4942 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) | |
4943 { | |
4944 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4945 continue; | |
4946 for(cnode = gnode->child; cnode; cnode = cnode->next) | |
4947 { | |
4948 GaimChat *chat; | |
4949 | |
4950 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
4951 continue; | |
4952 | |
4953 chat = (GaimChat *)cnode; | |
4954 | |
4955 if(chat->account != account) | |
4956 continue; | |
4957 | |
8197 | 4958 if(gaim_blist_node_get_bool((GaimBlistNode*)chat, "gtk-autojoin") || |
8198 | 4959 (gaim_blist_node_get_string((GaimBlistNode*)chat, |
4960 "gtk-autojoin") != NULL)) | |
7620 | 4961 serv_join_chat(gc, chat->components); |
4962 } | |
4963 } | |
4964 } | |
4965 | |
8815 | 4966 void * |
4967 gaim_gtk_blist_get_handle() { | |
4968 static int handle; | |
4969 | |
4970 return &handle; | |
4971 } | |
4972 | |
11910 | 4973 static gboolean buddy_signonoff_timeout_cb(GaimBuddy *buddy) |
4974 { | |
4975 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
4976 GaimConversation *conv; | |
4977 | |
4978 gtknode->recent_signonoff = FALSE; | |
4979 gtknode->recent_signonoff_timer = 0; | |
4980 | |
4981 gaim_gtk_blist_update(NULL, (GaimBlistNode*)buddy); | |
4982 | |
4983 if((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account))) { | |
4984 if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
4985 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
4986 } else { | |
4987 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE); | |
4988 } | |
4989 } | |
4990 | |
4991 return FALSE; | |
4992 } | |
4993 | |
4994 static void buddy_signonoff_cb(GaimBuddy *buddy) | |
4995 { | |
11915 | 4996 struct _gaim_gtk_blist_node *gtknode; |
4997 | |
4998 if(!((GaimBlistNode*)buddy)->ui_data) { | |
4999 gaim_gtk_blist_new_node((GaimBlistNode*)buddy); | |
5000 } | |
5001 | |
5002 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
11910 | 5003 |
5004 gtknode->recent_signonoff = TRUE; | |
5005 | |
5006 if(gtknode->recent_signonoff_timer > 0) | |
5007 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
5008 gtknode->recent_signonoff_timer = gaim_timeout_add(10000, | |
5009 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); | |
5010 } | |
5011 | |
7620 | 5012 void gaim_gtk_blist_init(void) |
5013 { | |
8815 | 5014 void *gtk_blist_handle = gaim_gtk_blist_get_handle(); |
7620 | 5015 |
5016 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
8815 | 5017 gtk_blist_handle, GAIM_CALLBACK(account_signon_cb), |
7620 | 5018 NULL); |
7731 | 5019 |
5020 /* Initialize prefs */ | |
8819 | 5021 gaim_prefs_add_none("/gaim/gtk/blist"); |
5022 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); | |
5023 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); | |
12656 | 5024 gaim_prefs_add_bool("/gaim/gtk/blist/show_idle_time", TRUE); |
8819 | 5025 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); |
10282 | 5026 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); |
12279 | 5027 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE); |
9711 | 5028 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); |
8819 | 5029 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
5030 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | |
9778 | 5031 gaim_prefs_add_int("/gaim/gtk/blist/width", 309); /* Golden ratio, baby */ |
5032 gaim_prefs_add_int("/gaim/gtk/blist/height", 500); /* Golden ratio, baby */ | |
8819 | 5033 gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500); |
7731 | 5034 |
8815 | 5035 /* Register our signals */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5036 gaim_signal_register(gtk_blist_handle, "gtkblist-hiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5037 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5038 gaim_value_new(GAIM_TYPE_POINTER)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5039 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5040 gaim_signal_register(gtk_blist_handle, "gtkblist-unhiding", |
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_SUBTYPE)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5043 |
8815 | 5044 gaim_signal_register(gtk_blist_handle, "gtkblist-created", |
9811 | 5045 gaim_marshal_VOID__POINTER, NULL, 1, |
5046 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
5047 GAIM_SUBTYPE_BLIST)); | |
8819 | 5048 |
5049 gaim_signal_register(gtk_blist_handle, "drawing-tooltip", | |
9811 | 5050 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
5051 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_BLIST_NODE), | |
10477 | 5052 gaim_value_new_outgoing(GAIM_TYPE_BOXED, "GString *")); |
11910 | 5053 |
5054 | |
5055 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
5056 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
7620 | 5057 } |
5058 | |
8815 | 5059 void |
5060 gaim_gtk_blist_uninit(void) { | |
5061 gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle()); | |
5062 } | |
5228 | 5063 |
5064 /********************************************************************* | |
9811 | 5065 * Buddy List sorting functions * |
5422 | 5066 *********************************************************************/ |
5067 | |
11796 | 5068 GList *gaim_gtk_blist_get_sort_methods() |
5069 { | |
5070 return gaim_gtk_blist_sort_methods; | |
5071 } | |
5072 | |
7620 | 5073 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
5422 | 5074 { |
5075 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | |
7620 | 5076 method->id = g_strdup(id); |
5422 | 5077 method->name = g_strdup(name); |
9775 | 5078 method->func = func; |
11796 | 5079 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
5080 gaim_gtk_blist_update_sort_methods(); | |
5422 | 5081 } |
5082 | |
7620 | 5083 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
11796 | 5084 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5085 |
5086 while(l) { | |
5087 struct gaim_gtk_blist_sort_method *method = l->data; | |
5088 if(!strcmp(method->id, id)) { | |
11796 | 5089 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
7620 | 5090 g_free(method->id); |
5091 g_free(method->name); | |
5092 g_free(method); | |
5093 break; | |
5094 } | |
5095 } | |
11796 | 5096 gaim_gtk_blist_update_sort_methods(); |
5422 | 5097 } |
5098 | |
7620 | 5099 void gaim_gtk_blist_sort_method_set(const char *id){ |
11796 | 5100 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5101 |
5102 if(!id) | |
5103 id = "none"; | |
5104 | |
5105 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | |
5422 | 5106 l = l->next; |
7620 | 5107 |
5422 | 5108 if (l) { |
5109 current_sort_method = l->data; | |
5110 } else if (!current_sort_method) { | |
7620 | 5111 gaim_gtk_blist_sort_method_set("none"); |
5422 | 5112 return; |
5113 } | |
5114 redo_buddy_list(gaim_get_blist(), TRUE); | |
5115 | |
5116 } | |
5117 | |
5118 /****************************************** | |
5119 ** Sort Methods | |
5120 ******************************************/ | |
5121 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5122 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter parent_iter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5123 { |
7620 | 5124 GaimBlistNode *sibling = node->prev; |
5125 GtkTreeIter sibling_iter; | |
5126 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5127 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5128 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5129 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5130 } |
7620 | 5131 |
5132 while (sibling && !get_iter_from_node(sibling, &sibling_iter)) { | |
5133 sibling = sibling->prev; | |
5422 | 5134 } |
7620 | 5135 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5136 gtk_tree_store_insert_after(gtkblist->treemodel, iter, |
7620 | 5137 node->parent ? &parent_iter : NULL, |
5138 sibling ? &sibling_iter : NULL); | |
5422 | 5139 } |
5140 | |
7620 | 5141 #if GTK_CHECK_VERSION(2,2,1) |
5142 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5143 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5144 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5145 GtkTreeIter more_z; |
7620 | 5146 |
5147 const char *my_name; | |
5148 | |
5149 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5150 my_name = gaim_contact_get_alias((GaimContact*)node); | |
5151 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5152 my_name = gaim_chat_get_name((GaimChat*)node); | |
5153 } else { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5154 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5155 return; |
7620 | 5156 } |
5157 | |
5422 | 5158 |
5159 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
|
5160 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5161 return; |
7620 | 5162 } |
5163 | |
5164 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5165 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5166 GaimBlistNode *n; |
7620 | 5167 const char *this_name; |
5168 int cmp; | |
5169 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5170 val.g_type = 0; |
7620 | 5171 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5172 n = g_value_get_pointer(&val); | |
5173 | |
5174 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5175 this_name = gaim_contact_get_alias((GaimContact*)n); | |
5176 } else if(GAIM_BLIST_NODE_IS_CHAT(n)) { | |
5177 this_name = gaim_chat_get_name((GaimChat*)n); | |
5178 } else { | |
5179 this_name = NULL; | |
5180 } | |
5181 | |
5182 cmp = gaim_utf8_strcasecmp(my_name, this_name); | |
5183 | |
5184 if(this_name && (cmp < 0 || (cmp == 0 && node < n))) { | |
5185 if(cur) { | |
5186 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5187 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5188 return; |
7620 | 5189 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5190 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5191 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5192 return; |
7620 | 5193 } |
5194 } | |
5195 g_value_unset(&val); | |
5196 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
5197 | |
5198 if(cur) { | |
5199 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5200 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5201 return; |
7620 | 5202 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5203 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5204 return; |
7620 | 5205 } |
5206 } | |
5207 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5208 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
7620 | 5209 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5210 GtkTreeIter more_z; |
7620 | 5211 |
5212 GaimBuddy *my_buddy, *this_buddy; | |
5213 | |
5214 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5215 my_buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
5216 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5217 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5218 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5219 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5220 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5221 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5222 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5223 return; |
7620 | 5224 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5225 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5226 return; |
7620 | 5227 } |
5228 | |
5229 | |
5230 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
|
5231 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5232 return; |
5422 | 5233 } |
5234 | |
5235 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5236 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5237 GaimBlistNode *n; |
9944 | 5238 gint name_cmp; |
5239 gint presence_cmp; | |
7620 | 5240 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5241 val.g_type = 0; |
5422 | 5242 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5243 n = g_value_get_pointer(&val); | |
7620 | 5244 |
5245 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5246 this_buddy = gaim_contact_get_priority_buddy((GaimContact*)n); | |
5247 } else { | |
5248 this_buddy = NULL; | |
5249 } | |
5250 | |
9944 | 5251 name_cmp = gaim_utf8_strcasecmp( |
5252 (my_buddy | |
5253 ? gaim_contact_get_alias(gaim_buddy_get_contact(my_buddy)) | |
5254 : NULL), | |
5255 (this_buddy | |
5256 ? gaim_contact_get_alias(gaim_buddy_get_contact(this_buddy)) | |
5257 : NULL)); | |
5258 | |
5259 presence_cmp = gaim_presence_compare( | |
5260 gaim_buddy_get_presence(my_buddy), | |
5261 gaim_buddy_get_presence(this_buddy)); | |
5262 | |
5263 if (this_buddy == NULL || | |
10860 | 5264 (presence_cmp < 0 || |
9944 | 5265 (presence_cmp == 0 && |
5266 (name_cmp < 0 || (name_cmp == 0 && node < n))))) | |
5267 { | |
5268 if (cur != NULL) | |
5269 { | |
7620 | 5270 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5271 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5272 return; |
9944 | 5273 } |
5274 else | |
5275 { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5276 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
9944 | 5277 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5278 return; |
7620 | 5279 } |
5422 | 5280 } |
9944 | 5281 |
5422 | 5282 g_value_unset(&val); |
9944 | 5283 } |
5284 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), | |
5285 &more_z)); | |
7620 | 5286 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5287 if (cur) { |
7620 | 5288 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5289 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5290 return; |
7620 | 5291 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5292 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5293 return; |
7620 | 5294 } |
5422 | 5295 } |
5296 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5297 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5298 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5299 GtkTreeIter more_z; |
7620 | 5300 |
5301 int log_size = 0, this_log_size = 0; | |
5302 const char *buddy_name, *this_buddy_name; | |
5303 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5304 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
|
5305 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5306 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5307 } |
7620 | 5308 |
5309 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5310 GaimBlistNode *n; |
7620 | 5311 for (n = node->child; n; n = n->next) |
8898 | 5312 log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n))->name, ((GaimBuddy*)(n))->account); |
7620 | 5313 buddy_name = gaim_contact_get_alias((GaimContact*)node); |
5314 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5315 /* we don't have a reliable way of getting the log filename | |
5316 * from the chat info in the blist, yet */ | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5317 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5318 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5319 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5320 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5321 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5322 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5323 return; |
7620 | 5324 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5325 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5326 return; |
7620 | 5327 } |
5328 | |
5329 | |
5422 | 5330 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
|
5331 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5332 return; |
5422 | 5333 } |
5334 | |
5335 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5336 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5337 GaimBlistNode *n; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5338 GaimBlistNode *n2; |
7620 | 5339 int cmp; |
5340 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5341 val.g_type = 0; |
5422 | 5342 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5343 n = g_value_get_pointer(&val); | |
7620 | 5344 this_log_size = 0; |
5345 | |
5346 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5347 for (n2 = n->child; n2; n2 = n2->next) | |
8898 | 5348 this_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n2))->name, ((GaimBuddy*)(n2))->account); |
7620 | 5349 this_buddy_name = gaim_contact_get_alias((GaimContact*)n); |
5350 } else { | |
5351 this_buddy_name = NULL; | |
5422 | 5352 } |
7620 | 5353 |
5354 cmp = gaim_utf8_strcasecmp(buddy_name, this_buddy_name); | |
5355 | |
5356 if (!GAIM_BLIST_NODE_IS_CONTACT(n) || log_size > this_log_size || | |
5357 ((log_size == this_log_size) && | |
5358 (cmp < 0 || (cmp == 0 && node < n)))) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5359 if (cur != NULL) { |
7620 | 5360 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5361 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5362 return; |
7620 | 5363 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5364 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5365 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5366 return; |
7620 | 5367 } |
5422 | 5368 } |
5369 g_value_unset(&val); | |
5370 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
7620 | 5371 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5372 if (cur != NULL) { |
7620 | 5373 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5374 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5375 return; |
7620 | 5376 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5377 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5378 return; |
7620 | 5379 } |
5380 } | |
5381 | |
5382 #endif | |
5383 | |
5384 static void | |
9015 | 5385 plugin_act(GtkObject *obk, GaimPluginAction *pam) |
7620 | 5386 { |
10352 | 5387 if (pam->callback) |
5388 pam->callback(pam); | |
5422 | 5389 } |
7620 | 5390 |
8986 | 5391 static void |
12333 | 5392 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin) |
8986 | 5393 { |
12333 | 5394 GtkWidget *menuitem; |
9015 | 5395 GaimPluginAction *action = NULL; |
12333 | 5396 GList *actions, *l; |
5397 | |
5398 actions = GAIM_PLUGIN_ACTIONS(plugin, NULL); | |
5399 | |
5400 for (l = actions; l != NULL; l = l->next) | |
5401 { | |
5402 if (l->data) | |
5403 { | |
9015 | 5404 action = (GaimPluginAction *) l->data; |
5405 action->plugin = plugin; | |
12333 | 5406 action->context = NULL; |
9015 | 5407 |
5408 menuitem = gtk_menu_item_new_with_label(action->label); | |
12333 | 5409 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
5410 | |
9015 | 5411 g_signal_connect(G_OBJECT(menuitem), "activate", |
5412 G_CALLBACK(plugin_act), action); | |
5413 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | |
5414 gtk_widget_show(menuitem); | |
5415 } | |
5416 else | |
5417 gaim_separator(menu); | |
5418 } | |
5419 | |
12333 | 5420 g_list_free(actions); |
8986 | 5421 } |
5422 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5423 static void |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5424 modify_account_cb(GtkWidget *widget, gpointer data) |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5425 { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5426 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, data); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5427 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5428 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5429 static void |
12330 | 5430 enable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5431 { |
12330 | 5432 GaimAccount *account = data; |
5433 const GaimSavedStatus *saved_status; | |
5434 | |
5435 saved_status = gaim_savedstatus_get_current(); | |
5436 gaim_savedstatus_activate_for_account(saved_status, account); | |
5437 | |
5438 gaim_account_set_enabled(account, GAIM_GTK_UI, TRUE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5439 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5440 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5441 static void |
12330 | 5442 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5443 { |
12330 | 5444 GaimAccount *account = data; |
5445 | |
5446 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5447 } |
8986 | 5448 |
7620 | 5449 void |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5450 gaim_gtk_blist_update_accounts_menu(void) |
7620 | 5451 { |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5452 GtkWidget *menuitem = NULL, *submenu = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5453 GList *l = NULL, *accounts = NULL; |
12330 | 5454 gboolean disabled_accounts = FALSE; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5455 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5456 if (accountmenu == NULL) |
7620 | 5457 return; |
5458 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5459 /* Clear the old Accounts menu */ |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5460 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
|
5461 menuitem = l->data; |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5462 |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5463 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
|
5464 gtk_container_remove(GTK_CONTAINER(accountmenu), |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5465 GTK_WIDGET(l->data)); |
7620 | 5466 } |
5467 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5468 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5469 char *buf = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5470 GtkWidget *image = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5471 GaimConnection *gc = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5472 GaimAccount *account = NULL; |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
5473 GaimStatus *status = NULL; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5474 GdkPixbuf *pixbuf = NULL, *scale = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5475 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5476 account = accounts->data; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5477 |
12330 | 5478 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5479 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5480 gaim_account_get_protocol_name(account), ")", NULL); | |
5481 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5482 g_free(buf); | |
5483 status = gaim_account_get_active_status(account); | |
5484 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status)); | |
5485 if (pixbuf) { | |
5486 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
5487 GDK_INTERP_BILINEAR); | |
5488 if (!gaim_account_is_connected(account)) | |
5489 gdk_pixbuf_saturate_and_pixelate(scale, scale, | |
5490 0.0, FALSE); | |
5491 image = gtk_image_new_from_pixbuf(scale); | |
5492 g_object_unref(G_OBJECT(pixbuf)); | |
5493 g_object_unref(G_OBJECT(scale)); | |
5494 gtk_widget_show(image); | |
5495 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5496 } | |
5497 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); | |
5498 gtk_widget_show(menuitem); | |
5499 | |
5500 submenu = gtk_menu_new(); | |
5501 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5502 gtk_widget_show(submenu); | |
5503 | |
5504 | |
12334 | 5505 menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit Account")); |
12330 | 5506 g_signal_connect(G_OBJECT(menuitem), "activate", |
5507 G_CALLBACK(modify_account_cb), account); | |
5508 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5509 gtk_widget_show(menuitem); | |
5510 | |
5511 gaim_separator(submenu); | |
5512 | |
5513 gc = gaim_account_get_connection(account); | |
5514 if (gc && GAIM_CONNECTION_IS_CONNECTED(gc)) { | |
5515 GaimPlugin *plugin = NULL; | |
5516 | |
5517 plugin = gc->prpl; | |
5518 if (GAIM_PLUGIN_HAS_ACTIONS(plugin)) { | |
5519 GList *l, *ll = NULL; | |
5520 GaimPluginAction *action = NULL; | |
5521 | |
5522 for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, gc); l; l = l->next) { | |
5523 if (l->data) { | |
5524 action = (GaimPluginAction *)l->data; | |
5525 action->plugin = plugin; | |
5526 action->context = gc; | |
5527 | |
5528 menuitem = gtk_menu_item_new_with_label(action->label); | |
5529 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5530 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5531 G_CALLBACK(plugin_act), action); | |
5532 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | |
5533 gtk_widget_show(menuitem); | |
5534 } else | |
5535 gaim_separator(submenu); | |
5536 } | |
5537 } else { | |
5538 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | |
5539 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5540 gtk_widget_set_sensitive(menuitem, FALSE); | |
5541 gtk_widget_show(menuitem); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5542 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5543 } else { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5544 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5545 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5546 gtk_widget_set_sensitive(menuitem, FALSE); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5547 gtk_widget_show(menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5548 } |
12330 | 5549 |
5550 gaim_separator(submenu); | |
5551 | |
5552 menuitem = gtk_menu_item_new_with_mnemonic(_("_Disable")); | |
5553 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5554 G_CALLBACK(disable_account_cb), account); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5555 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5556 gtk_widget_show(menuitem); |
12330 | 5557 } else { |
5558 disabled_accounts = TRUE; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5559 } |
7620 | 5560 } |
9019 | 5561 |
12330 | 5562 if(disabled_accounts) { |
5563 gaim_separator(accountmenu); | |
12338 | 5564 menuitem = gtk_menu_item_new_with_label(_("Enable Account")); |
12330 | 5565 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); |
5566 gtk_widget_show(menuitem); | |
5567 | |
5568 submenu = gtk_menu_new(); | |
5569 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5570 gtk_widget_show(submenu); | |
5571 | |
5572 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { | |
5573 char *buf = NULL; | |
5574 GtkWidget *image = NULL; | |
5575 GaimAccount *account = NULL; | |
5576 GdkPixbuf *pixbuf = NULL, *scale = NULL; | |
5577 | |
5578 account = accounts->data; | |
5579 | |
5580 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { | |
5581 | |
5582 disabled_accounts = TRUE; | |
5583 | |
5584 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5585 gaim_account_get_protocol_name(account), ")", NULL); | |
5586 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5587 g_free(buf); | |
5588 pixbuf = gaim_gtk_create_prpl_icon(account); | |
5589 if (pixbuf) { | |
5590 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
5591 GDK_INTERP_BILINEAR); | |
12466
31e4eb57cc86
[gaim-migrate @ 14776]
Richard Laager <rlaager@wiktel.com>
parents:
12464
diff
changeset
|
5592 if (gaim_account_is_disconnected(account)) |
31e4eb57cc86
[gaim-migrate @ 14776]
Richard Laager <rlaager@wiktel.com>
parents:
12464
diff
changeset
|
5593 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.00, FALSE); |
12330 | 5594 image = gtk_image_new_from_pixbuf(scale); |
5595 g_object_unref(G_OBJECT(pixbuf)); | |
5596 g_object_unref(G_OBJECT(scale)); | |
5597 gtk_widget_show(image); | |
5598 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5599 } | |
5600 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5601 G_CALLBACK(enable_account_cb), account); | |
5602 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5603 gtk_widget_show(menuitem); | |
5604 } | |
9019 | 5605 } |
7620 | 5606 } |
5607 } | |
8986 | 5608 |
12333 | 5609 static GList *plugin_submenus = NULL; |
5610 | |
8986 | 5611 void |
5612 gaim_gtk_blist_update_plugin_actions(void) | |
5613 { | |
12333 | 5614 GtkWidget *menuitem, *submenu; |
9015 | 5615 GaimPlugin *plugin = NULL; |
8986 | 5616 GList *l; |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5617 GtkAccelGroup *accel_group; |
8986 | 5618 |
11742 | 5619 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); |
5620 | |
12333 | 5621 g_return_if_fail(pluginmenu != NULL); |
5622 | |
5623 /* Remove old plugin action submenus from the Tools menu */ | |
5624 for (l = plugin_submenus; l; l = l->next) | |
5625 { | |
5626 GList *menuitems; | |
5627 | |
5628 submenu = l->data; | |
5629 | |
5630 menuitems = gtk_container_get_children(GTK_CONTAINER(submenu)); | |
5631 while (menuitems != NULL) | |
5632 { | |
5633 GaimPluginAction *action; | |
5634 menuitem = menuitems->data; | |
5635 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | |
5636 g_free(action); | |
5637 menuitems = g_list_delete_link(menuitems, menuitems); | |
5638 } | |
5639 | |
5640 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(submenu)); | |
8986 | 5641 } |
12333 | 5642 g_list_free(plugin_submenus); |
5643 plugin_submenus = NULL; | |
5644 | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5645 accel_group = gtk_menu_get_accel_group(GTK_MENU(pluginmenu)); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5646 |
12333 | 5647 /* Add a submenu for each plugin with custom actions */ |
11742 | 5648 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5649 char *path; |
11923 | 5650 |
11742 | 5651 plugin = (GaimPlugin *) l->data; |
11923 | 5652 |
11742 | 5653 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5654 continue; | |
5655 | |
5656 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5657 continue; | |
9019 | 5658 |
12333 | 5659 menuitem = gtk_image_menu_item_new_with_label(plugin->info->name); |
5660 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); | |
5661 gtk_widget_show(menuitem); | |
5662 | |
5663 plugin_submenus = g_list_append(plugin_submenus, menuitem); | |
5664 | |
5665 submenu = gtk_menu_new(); | |
5666 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5667 gtk_widget_show(submenu); | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5668 |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5669 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5670 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
|
5671 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5672 g_free(path); |
12333 | 5673 |
5674 build_plugin_actions(submenu, plugin); | |
8986 | 5675 } |
5676 } | |
11796 | 5677 |
12246 | 5678 static void |
5679 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
11796 | 5680 { |
5681 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
11923 | 5682 { |
12431
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5683 if (gtkblist->window->window != NULL) |
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5684 { |
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5685 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); |
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5686 gdk_window_set_cursor(gtkblist->window->window, cursor); |
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5687 gdk_cursor_unref(cursor); |
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 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5690 while (gtk_events_pending()) |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5691 gtk_main_iteration(); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5692 |
11796 | 5693 gaim_gtk_blist_sort_method_set(id); |
11923 | 5694 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5695 |
12431
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5696 if (gtkblist->window->window != NULL) |
8a1de97b477f
[gaim-migrate @ 14738]
Richard Laager <rlaager@wiktel.com>
parents:
12413
diff
changeset
|
5697 gdk_window_set_cursor(gtkblist->window->window, NULL); |
11923 | 5698 } |
11796 | 5699 } |
5700 | |
5701 void | |
5702 gaim_gtk_blist_update_sort_methods(void) | |
5703 { | |
5704 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5705 GaimGtkBlistSortMethod *method = NULL; | |
5706 GList *l; | |
5707 GSList *sl = NULL; | |
5708 GtkWidget *sortmenu; | |
11797 | 5709 const char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); |
11796 | 5710 |
5711 if (gtkblist == NULL) | |
5712 return; | |
5713 | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
5714 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies")); |
11796 | 5715 |
5716 if (sortmenu == NULL) | |
5717 return; | |
5718 | |
5719 /* Clear the old menu */ | |
5720 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5721 menuitem = l->data; | |
5722 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5723 } | |
11923 | 5724 |
11796 | 5725 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { |
5726 method = (GaimGtkBlistSortMethod *) l->data; | |
5727 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5728 if (!strcmp(m, method->id)) | |
5729 activeitem = menuitem; | |
5730 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5731 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5732 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5733 G_CALLBACK(sortmethod_act), method->id); | |
11923 | 5734 gtk_widget_show(menuitem); |
11796 | 5735 } |
5736 if (activeitem) | |
5737 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5738 } |