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