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