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