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