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