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