Mercurial > pidgin.yaz
annotate src/gtkblist.c @ 13479:90740e70af91
[gaim-migrate @ 15855]
Patch from sadrul, expanded a bit by me, which fixes a crash when an MSN account disconnects while an msn_get_info() request is in progress and then completes after the disconnection. (Patch #1446189)
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Thu, 09 Mar 2006 15:44:08 +0000 |
parents | 38dcde2c8c4b |
children | 56abb67edec9 |
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 { | |
3378 gchar *enteredstring; | |
10439 | 3379 gchar *withmarkup; |
10433 | 3380 gchar *nomarkup; |
11490 | 3381 gchar *normalized; |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3382 gboolean result; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3383 size_t i; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3384 size_t len; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3385 PangoLogAttr *log_attrs; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3386 gchar *word; |
10435 | 3387 |
3388 gtk_tree_model_get(model, iter, column, &withmarkup, -1); | |
10433 | 3389 |
11490 | 3390 enteredstring = g_utf8_casefold(gaim_normalize(NULL, key), -1); |
10433 | 3391 nomarkup = gaim_markup_strip_html(withmarkup); |
11490 | 3392 normalized = g_utf8_casefold(gaim_normalize(NULL, nomarkup), -1); |
10433 | 3393 |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3394 if (gaim_str_has_prefix(normalized, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3395 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3396 g_free(withmarkup); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3397 g_free(enteredstring); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3398 g_free(nomarkup); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3399 g_free(normalized); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3400 return FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3401 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3402 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3403 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3404 /* Use Pango to separate by words. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3405 len = g_utf8_strlen(normalized, -1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3406 log_attrs = g_new(PangoLogAttr, len + 1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3407 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3408 pango_get_log_attrs(normalized, len, -1, NULL, log_attrs, len + 1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3409 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3410 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3411 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3412 for (i = 0; i < (len - 1) ; i++) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3413 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3414 if (log_attrs[i].is_word_start && |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3415 gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3416 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3417 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3418 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3419 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3420 word = g_utf8_next_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3421 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3422 g_free(log_attrs); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3423 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3424 /* The non-Pango version. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3425 #if 0 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3426 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3427 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3428 while (word[0] != '\0') |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3429 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3430 gunichar c = g_utf8_get_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3431 if (!g_unichar_isalnum(c)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3432 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3433 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3434 if (gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3435 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3436 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3437 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3438 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3439 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3440 else |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3441 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3442 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3443 #endif |
10433 | 3444 |
10439 | 3445 g_free(withmarkup); |
10433 | 3446 g_free(enteredstring); |
3447 g_free(nomarkup); | |
11490 | 3448 g_free(normalized); |
10433 | 3449 |
3450 return result; | |
3451 } | |
3452 | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3453 static void account_modified(GaimAccount *account, GaimGtkBuddyList *gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3454 { |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3455 if (!gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3456 return; |
12589 | 3457 |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3458 update_menu_bar(gtkblist); |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3459 } |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3460 |
12766 | 3461 static void |
3462 account_status_changed(GaimAccount *account, GaimStatus *old, | |
3463 GaimStatus *new, GaimGtkBuddyList *gtkblist) | |
3464 { | |
3465 if (!gtkblist) | |
3466 return; | |
3467 | |
3468 update_menu_bar(gtkblist); | |
3469 } | |
3470 | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3471 static gboolean |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3472 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
|
3473 { |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3474 GtkWidget *imhtml; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3475 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3476 if (!gtkblist) |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3477 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3478 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3479 imhtml = gtk_window_get_focus(GTK_WINDOW(gtkblist->window)); |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3480 |
12474
24beec3e42ad
[gaim-migrate @ 14785]
Luke Schierer <lschiere@pidgin.im>
parents:
12473
diff
changeset
|
3481 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
|
3482 return TRUE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3483 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3484 } |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3485 |
13015 | 3486 /***********************************/ |
3487 /* Connection error handling stuff */ | |
3488 /***********************************/ | |
3489 | |
3490 static void | |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3491 ce_modify_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3492 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3493 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, account); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3494 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3495 |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3496 static void |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3497 ce_enable_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3498 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3499 gaim_account_set_enabled(account, gaim_core_get_ui(), TRUE); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3500 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3501 |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3502 static void |
13015 | 3503 connection_error_button_clicked_cb(GtkButton *widget, gpointer user_data) |
3504 { | |
3505 GaimAccount *account; | |
13023 | 3506 char *primary; |
3507 const char *text; | |
13015 | 3508 |
3509 account = user_data; | |
13023 | 3510 primary = g_strdup_printf(_("%s disconnected"), |
3511 gaim_account_get_username(account)); | |
13015 | 3512 text = g_hash_table_lookup(gtkblist->connection_errors, account); |
13375 | 3513 |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3514 if (gaim_account_is_connected(account)) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3515 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3516 gaim_notify_formatted(NULL, _("Connection Error"), |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3517 primary, NULL, text, NULL, NULL); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3518 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3519 else |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3520 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3521 gboolean enabled = gaim_account_get_enabled(account, gaim_core_get_ui()); |
13375 | 3522 gaim_request_action(account, _("Connection Error"), primary, text, 2, |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3523 account, 3, |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3524 _("OK"), NULL, |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3525 _("Modify Account"), GAIM_CALLBACK(ce_modify_account_cb), |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3526 enabled ? _("Connect") : _("Enable Account"), |
13375 | 3527 enabled ? GAIM_CALLBACK(gaim_account_connect) : |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3528 GAIM_CALLBACK(ce_enable_account_cb)); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3529 } |
13015 | 3530 gtk_widget_destroy(GTK_WIDGET(widget)); |
3531 g_hash_table_remove(gtkblist->connection_errors, account); | |
3532 } | |
3533 | |
3534 /* Add some buttons that show connection errors */ | |
3535 static void | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3536 create_connection_error_buttons(gpointer key, gpointer value, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3537 gpointer user_data) |
13015 | 3538 { |
3539 GaimAccount *account; | |
13090 | 3540 GaimStatusType *status_type; |
3541 gchar *escaped, *text; | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3542 GtkWidget *button, *label, *image, *hbox; |
13090 | 3543 GdkPixbuf *pixbuf; |
13015 | 3544 |
3545 account = key; | |
13049 | 3546 escaped = g_markup_escape_text((const gchar *)value, -1); |
13023 | 3547 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
|
3548 gaim_account_get_username(account), |
13049 | 3549 escaped); |
3550 g_free(escaped); | |
3551 | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3552 hbox = gtk_hbox_new(FALSE, 0); |
13049 | 3553 |
3554 /* Create the icon */ | |
13090 | 3555 status_type = gaim_account_get_status_type_with_primitive(account, |
3556 GAIM_STATUS_OFFLINE); | |
3557 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
|
3558 if (pixbuf != NULL) { |
13090 | 3559 image = gtk_image_new_from_pixbuf(pixbuf); |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3560 g_object_unref(pixbuf); |
13030 | 3561 |
3562 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, | |
3563 GAIM_HIG_BOX_SPACE); | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3564 } |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3565 |
13049 | 3566 /* Create the text */ |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3567 label = gtk_label_new(""); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3568 gtk_label_set_markup(GTK_LABEL(label), text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3569 g_free(text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3570 #if GTK_CHECK_VERSION(2,6,0) |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3571 g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3572 #endif |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3573 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3574 GAIM_HIG_BOX_SPACE); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3575 |
13049 | 3576 /* 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
|
3577 button = gtk_button_new(); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3578 gtk_container_add(GTK_CONTAINER(button), hbox); |
13015 | 3579 g_signal_connect(G_OBJECT(button), "clicked", |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3580 G_CALLBACK(connection_error_button_clicked_cb), |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3581 account); |
13049 | 3582 gtk_widget_show_all(button); |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3583 gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3584 FALSE, FALSE, 0); |
13015 | 3585 } |
3586 | |
3587 void | |
3588 gaim_gtk_blist_update_account_error_state(GaimAccount *account, const char *text) | |
3589 { | |
3590 GList *l; | |
3591 | |
13016 | 3592 if (text == NULL) |
13015 | 3593 g_hash_table_remove(gtkblist->connection_errors, account); |
3594 else | |
3595 g_hash_table_insert(gtkblist->connection_errors, account, g_strdup(text)); | |
3596 | |
3597 /* Remove the old error buttons */ | |
3598 for (l = gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)); | |
3599 l != NULL; | |
3600 l = l->next) | |
3601 { | |
3602 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
3603 } | |
3604 | |
3605 /* Add new error buttons */ | |
3606 g_hash_table_foreach(gtkblist->connection_errors, | |
3607 create_connection_error_buttons, NULL); | |
3608 } | |
3609 | |
3610 /******************************************/ | |
3611 /* End of connection error handling stuff */ | |
3612 /******************************************/ | |
3613 | |
7620 | 3614 static void gaim_gtk_blist_show(GaimBuddyList *list) |
5228 | 3615 { |
10087 | 3616 void *handle; |
5228 | 3617 GtkCellRenderer *rend; |
3618 GtkTreeViewColumn *column; | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3619 GtkWidget *menu; |
5228 | 3620 GtkWidget *sw; |
3621 GtkAccelGroup *accel_group; | |
3622 GtkTreeSelection *selection; | |
9556 | 3623 GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
8089 | 3624 {"application/x-im-contact", 0, DRAG_BUDDY}, |
9495 | 3625 {"text/x-vcard", 0, DRAG_VCARD }, |
9525 | 3626 {"text/uri-list", 0, DRAG_URI}, |
3627 {"text/plain", 0, DRAG_TEXT}}; | |
9556 | 3628 GtkTargetEntry ste[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
3629 {"application/x-im-contact", 0, DRAG_BUDDY}, | |
3630 {"text/x-vcard", 0, DRAG_VCARD }}; | |
5228 | 3631 if (gtkblist && gtkblist->window) { |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3632 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3633 return; |
3634 } | |
3635 | |
3636 gtkblist = GAIM_GTK_BLIST(list); | |
3637 | |
3638 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3639 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
9746 | 3640 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
12328 | 3641 GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE; |
5228 | 3642 |
3643 gtkblist->vbox = gtk_vbox_new(FALSE, 0); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3644 gtk_widget_show(gtkblist->vbox); |
5228 | 3645 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); |
3646 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3647 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
5228 | 3648 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
|
3649 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
|
3650 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
|
3651 g_signal_connect(G_OBJECT(gtkblist->window), "key_press_event", G_CALLBACK(gtk_blist_window_key_press_cb), gtkblist); |
5228 | 3652 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); |
3653 | |
3654 /******************************* Menu bar *************************************/ | |
3655 accel_group = gtk_accel_group_new(); | |
3656 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group); | |
3657 g_object_unref(accel_group); | |
5427 | 3658 gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group); |
9811 | 3659 gtk_item_factory_set_translate_func(gtkblist->ift, |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
3660 (GtkTranslateFunc)item_factory_translate_func, |
9811 | 3661 NULL, NULL); |
5427 | 3662 gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu), |
9811 | 3663 blist_menu, NULL); |
7620 | 3664 gaim_gtk_load_accels(); |
3665 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
3666 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3667 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3668 gtkblist->menutray = gaim_gtk_menu_tray_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3669 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3670 gtk_widget_show(gtkblist->menutray); |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3671 gtk_widget_show(menu); |
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3672 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
5228 | 3673 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3674 accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts")); |
10352 | 3675 |
5228 | 3676 /****************************** GtkTreeView **********************************/ |
3677 sw = gtk_scrolled_window_new(NULL,NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3678 gtk_widget_show(sw); |
5228 | 3679 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3680 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
3681 | |
7620 | 3682 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, |
11494 | 3683 GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, |
11257 | 3684 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
5228 | 3685 |
3686 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
|
3687 gtk_widget_show(gtkblist->treeview); |
9176 | 3688 gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); |
5228 | 3689 |
3690 /* Set up selection stuff */ | |
3691 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
3692 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
3693 | |
3694 /* Set up dnd */ | |
7650 | 3695 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3696 GDK_BUTTON1_MASK, ste, 3, |
3697 GDK_ACTION_COPY); | |
7650 | 3698 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3699 dte, 5, |
3700 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
7636 | 3701 |
10544 | 3702 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
5228 | 3703 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
|
3704 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3705 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
|
3706 #endif |
10433 | 3707 |
10354 | 3708 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); |
5228 | 3709 |
3710 /* Tooltips */ | |
3711 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
3712 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
3713 | |
3714 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
3715 | |
11016 | 3716 gtkblist->text_column = column = gtk_tree_view_column_new (); |
5228 | 3717 |
3718 rend = gtk_cell_renderer_pixbuf_new(); | |
9811 | 3719 gtk_tree_view_column_pack_start(column, rend, FALSE); |
3720 gtk_tree_view_column_set_attributes(column, rend, | |
3721 "pixbuf", STATUS_ICON_COLUMN, | |
3722 "visible", STATUS_ICON_VISIBLE_COLUMN, | |
3723 NULL); | |
5228 | 3724 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL); |
3725 | |
11016 | 3726 gtkblist->text_rend = rend = gtk_cell_renderer_text_new(); |
5228 | 3727 gtk_tree_view_column_pack_start (column, rend, TRUE); |
9811 | 3728 gtk_tree_view_column_set_attributes(column, rend, |
3729 "markup", NAME_COLUMN, | |
3730 NULL); | |
11016 | 3731 g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); |
5228 | 3732 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
10285 | 3733 #if GTK_CHECK_VERSION(2,6,0) |
3734 gtk_tree_view_column_set_expand (column, TRUE); | |
10501 | 3735 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
10285 | 3736 #endif |
5228 | 3737 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); |
3738 | |
3739 rend = gtk_cell_renderer_text_new(); | |
10351 | 3740 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
3741 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
5228 | 3742 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
3743 | |
3744 rend = gtk_cell_renderer_pixbuf_new(); | |
3745 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); | |
3746 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); | |
3747 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); | |
3748 | |
3749 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); | |
3750 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL); | |
3751 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL); | |
3752 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
7620 | 3753 g_signal_connect(G_OBJECT(gtkblist->treeview), "key-press-event", G_CALLBACK(gtk_blist_key_press_cb), NULL); |
8143 | 3754 g_signal_connect(G_OBJECT(gtkblist->treeview), "popup-menu", G_CALLBACK(gaim_gtk_blist_popup_menu_cb), NULL); |
5228 | 3755 |
5419 | 3756 /* Enable CTRL+F searching */ |
3757 gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); | |
10433 | 3758 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL); |
5419 | 3759 |
12583 | 3760 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); |
5228 | 3761 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); |
3762 gaim_gtk_blist_update_columns(); | |
3763 | |
13015 | 3764 /* Create an empty vbox used for showing connection errors */ |
3765 gtkblist->error_buttons = gtk_vbox_new(FALSE, 0); | |
3766 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0); | |
3767 | |
3768 /* Add the statusbox */ | |
12583 | 3769 gtkblist->statusbox = gtk_gaim_status_box_new(); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
3770 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); |
12656 | 3771 |
12583 | 3772 gtk_widget_show(gtkblist->statusbox); |
3773 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); | |
12656 | 3774 |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3775 |
5228 | 3776 /* set the Show Offline Buddies option. must be done |
3777 * after the treeview or faceprint gets mad. -Robot101 | |
3778 */ | |
5427 | 3779 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), |
7620 | 3780 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
12656 | 3781 |
5427 | 3782 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
7620 | 3783 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
12656 | 3784 |
10074 | 3785 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3786 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | |
12656 | 3787 |
11796 | 3788 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), |
11920 | 3789 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); |
12656 | 3790 |
3791 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Idle Times"))), | |
3792 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
3793 | |
10074 | 3794 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
11494 | 3795 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
5228 | 3796 |
10353 | 3797 /* Update some dynamic things */ |
3798 update_menu_bar(gtkblist); | |
3799 gaim_gtk_blist_update_plugin_actions(); | |
11796 | 3800 gaim_gtk_blist_update_sort_methods(); |
10353 | 3801 |
5228 | 3802 /* OK... let's show this bad boy. */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3803 gaim_gtk_blist_refresh(list); |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3804 gaim_gtk_blist_restore_position(); |
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3805 gtk_widget_show_all(GTK_WIDGET(gtkblist->window)); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3806 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3807 |
3808 /* start the refresh timer */ | |
10351 | 3809 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); |
10353 | 3810 |
10087 | 3811 handle = gaim_gtk_blist_get_handle(); |
3812 | |
7620 | 3813 /* things that affect how buddies are displayed */ |
10087 | 3814 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3815 _prefs_change_redo_list, NULL); | |
12656 | 3816 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3817 _prefs_change_redo_list, NULL); | |
10087 | 3818 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", |
3819 _prefs_change_redo_list, NULL); | |
3820 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", | |
3821 _prefs_change_redo_list, NULL); | |
7620 | 3822 |
3823 /* sorting */ | |
10087 | 3824 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", |
3825 _prefs_change_sort_method, NULL); | |
7620 | 3826 |
3827 /* things that affect what columns are displayed */ | |
10087 | 3828 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
12326 | 3829 show_buddy_icons_pref_cb, NULL); |
12656 | 3830 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3831 show_buddy_icons_pref_cb, NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3832 |
10074 | 3833 /* menus */ |
10087 | 3834 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", |
3835 gaim_gtk_blist_mute_pref_cb, NULL); | |
3836 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/method", | |
3837 gaim_gtk_blist_sound_method_pref_cb, NULL); | |
10074 | 3838 |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3839 /* Setup some gaim signal handlers. */ |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3840 gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", |
12583 | 3841 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3842 gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", |
12583 | 3843 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12226 | 3844 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", |
12583 | 3845 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12766 | 3846 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
3847 gtkblist, GAIM_CALLBACK(account_status_changed), gtkblist); | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3848 |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3849 gaim_signal_connect(gaim_gtk_account_get_handle(), "account-modified", |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3850 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3851 |
8937 | 3852 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
3853 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
3854 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
3855 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
8815 | 3856 |
8986 | 3857 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", |
3858 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3859 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", | |
3860 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3861 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3862 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3863 gtkblist, GAIM_CALLBACK(conversation_updated_cb), |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3864 gtkblist); |
12208 | 3865 gaim_signal_connect(gaim_conversations_get_handle(), "deleting-conversation", |
3866 gtkblist, GAIM_CALLBACK(conversation_deleting_cb), | |
3867 gtkblist); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3868 |
8815 | 3869 /* emit our created signal */ |
10087 | 3870 gaim_signal_emit(handle, "gtkblist-created", list); |
5228 | 3871 } |
3872 | |
7620 | 3873 static void redo_buddy_list(GaimBuddyList *list, gboolean remove) |
5228 | 3874 { |
12112 | 3875 GaimBlistNode *node = list->root; |
3876 | |
3877 while (node) | |
3878 { | |
3879 if (!GAIM_BLIST_NODE_IS_GROUP(node) && remove) | |
3880 gaim_gtk_blist_hide_node(list, node); | |
3881 | |
3882 gaim_gtk_blist_update(list, node); | |
3883 node = gaim_blist_node_next(node, FALSE); | |
5228 | 3884 } |
3885 } | |
3886 | |
7620 | 3887 void gaim_gtk_blist_refresh(GaimBuddyList *list) |
5422 | 3888 { |
3889 redo_buddy_list(list, FALSE); | |
3890 } | |
3891 | |
5297 | 3892 void |
3893 gaim_gtk_blist_update_refresh_timeout() | |
3894 { | |
7620 | 3895 GaimBuddyList *blist; |
3896 GaimGtkBuddyList *gtkblist; | |
5297 | 3897 |
3898 blist = gaim_get_blist(); | |
3899 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
3900 | |
10351 | 3901 gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)gaim_gtk_blist_refresh_timer, blist); |
5297 | 3902 } |
3903 | |
5256 | 3904 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { |
3905 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3906 GtkTreePath *path; | |
5228 | 3907 |
5263 | 3908 if (!gtknode) { |
3909 return FALSE; | |
3910 } | |
3911 | |
3912 if (!gtkblist) { | |
10006 | 3913 gaim_debug_error("gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n"); |
5263 | 3914 return FALSE; |
3915 } | |
3916 | |
3917 if (!gtknode->row) | |
5228 | 3918 return FALSE; |
11494 | 3919 |
5228 | 3920 |
5256 | 3921 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL) |
5228 | 3922 return FALSE; |
11016 | 3923 |
5256 | 3924 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) { |
3925 gtk_tree_path_free(path); | |
3926 return FALSE; | |
3927 } | |
3928 gtk_tree_path_free(path); | |
3929 return TRUE; | |
5228 | 3930 } |
3931 | |
7620 | 3932 static void gaim_gtk_blist_remove(GaimBuddyList *list, GaimBlistNode *node) |
5228 | 3933 { |
11910 | 3934 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
3935 | |
10222 | 3936 gaim_request_close_with_handle(node); |
3937 | |
5260 | 3938 gaim_gtk_blist_hide_node(list, node); |
5228 | 3939 |
7620 | 3940 if(node->parent) |
3941 gaim_gtk_blist_update(list, node->parent); | |
3942 | |
10504 | 3943 /* There's something I don't understand here - Ethan */ |
3944 /* Ethan said that back in 2003, but this g_free has been left commented | |
3945 * out ever since. I can't find any reason at all why this is bad and | |
3946 * valgrind found several reasons why it's good. If this causes problems | |
3947 * comment it out again. Stu */ | |
10510 | 3948 /* Of course it still causes problems - this breaks dragging buddies into |
10515 | 3949 * contacts, the dragged buddy mysteriously 'disappears'. Stu. */ |
3950 /* I think it's fixed now. Stu. */ | |
11910 | 3951 |
11915 | 3952 if(gtknode) { |
3953 if(gtknode->recent_signonoff_timer > 0) | |
3954 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
3955 | |
3956 g_free(node->ui_data); | |
3957 node->ui_data = NULL; | |
3958 } | |
5228 | 3959 } |
3960 | |
3961 static gboolean do_selection_changed(GaimBlistNode *new_selection) | |
3962 { | |
5254 | 3963 GaimBlistNode *old_selection = NULL; |
5228 | 3964 |
5254 | 3965 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */ |
3966 if (gtkblist && new_selection != gtkblist->selected_node) { | |
3967 old_selection = gtkblist->selected_node; | |
5228 | 3968 gtkblist->selected_node = new_selection; |
3969 if(new_selection) | |
3970 gaim_gtk_blist_update(NULL, new_selection); | |
3971 if(old_selection) | |
3972 gaim_gtk_blist_update(NULL, old_selection); | |
3973 } | |
3974 | |
3975 return FALSE; | |
3976 } | |
3977 | |
3978 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
3979 { | |
3980 GaimBlistNode *new_selection = NULL; | |
3981 GtkTreeIter iter; | |
3982 | |
3983 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
3984 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
3985 NODE_COLUMN, &new_selection, -1); | |
3986 } | |
5254 | 3987 |
5228 | 3988 /* we set this up as a timeout, otherwise the blist flickers */ |
3989 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
3990 } | |
3991 | |
8252 | 3992 static gboolean insert_node(GaimBuddyList *list, GaimBlistNode *node, GtkTreeIter *iter) |
7620 | 3993 { |
3994 GtkTreeIter parent_iter, cur, *curptr = NULL; | |
3995 struct _gaim_gtk_blist_node *gtknode = node->ui_data; | |
5256 | 3996 GtkTreePath *newpath; |
7620 | 3997 |
10515 | 3998 if(!iter) |
8252 | 3999 return FALSE; |
7620 | 4000 |
4001 if(node->parent && !get_iter_from_node(node->parent, &parent_iter)) | |
8252 | 4002 return FALSE; |
7620 | 4003 |
4004 if(get_iter_from_node(node, &cur)) | |
4005 curptr = &cur; | |
4006 | |
4007 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
|
4008 current_sort_method->func(node, list, parent_iter, curptr, iter); |
7620 | 4009 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4010 sort_method_none(node, list, parent_iter, curptr, iter); |
5228 | 4011 } |
4012 | |
10515 | 4013 if(gtknode != NULL) { |
4014 gtk_tree_row_reference_free(gtknode->row); | |
4015 } else { | |
4016 gaim_gtk_blist_new_node(node); | |
4017 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
4018 } | |
4019 | |
7620 | 4020 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), |
4021 iter); | |
4022 gtknode->row = | |
4023 gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), | |
4024 newpath); | |
11494 | 4025 |
5256 | 4026 gtk_tree_path_free(newpath); |
4027 | |
5228 | 4028 gtk_tree_store_set(gtkblist->treemodel, iter, |
4029 NODE_COLUMN, node, | |
4030 -1); | |
7620 | 4031 |
4032 if(node->parent) { | |
4033 GtkTreePath *expand = NULL; | |
4034 struct _gaim_gtk_blist_node *gtkparentnode = node->parent->ui_data; | |
4035 | |
4036 if(GAIM_BLIST_NODE_IS_GROUP(node->parent)) { | |
7693 | 4037 if(!gaim_blist_node_get_bool(node->parent, "collapsed")) |
7620 | 4038 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); |
4039 } else if(GAIM_BLIST_NODE_IS_CONTACT(node->parent) && | |
4040 gtkparentnode->contact_expanded) { | |
4041 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); | |
4042 } | |
4043 if(expand) { | |
7693 | 4044 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, FALSE); |
7620 | 4045 gtk_tree_path_free(expand); |
4046 } | |
4047 } | |
4048 | |
8252 | 4049 return TRUE; |
5228 | 4050 } |
4051 | |
7620 | 4052 static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) |
4053 { | |
4054 GaimGroup *group; | |
8203 | 4055 int count; |
12341 | 4056 gboolean show = FALSE; |
7620 | 4057 |
4058 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); | |
4059 | |
4060 group = (GaimGroup*)node; | |
4061 | |
8203 | 4062 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) |
4063 count = gaim_blist_get_group_size(group, FALSE); | |
4064 else | |
4065 count = gaim_blist_get_group_online_count(group); | |
13195 | 4066 |
12341 | 4067 if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) |
4068 show = TRUE; | |
4069 else { | |
4070 GaimBlistNode *n; | |
4071 n = node->child; | |
4072 while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { | |
4073 if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
4074 if (buddy_is_displayable((GaimBuddy*)n)) { | |
4075 show = TRUE; | |
4076 break; | |
13195 | 4077 } |
12341 | 4078 } |
4079 n = gaim_blist_node_next(n, FALSE); | |
4080 } | |
4081 } | |
4082 | |
4083 if (show) { | |
7620 | 4084 char *mark, *esc; |
4085 GtkTreeIter iter; | |
4086 | |
8252 | 4087 if(!insert_node(list, node, &iter)) |
4088 return; | |
7620 | 4089 |
4090 esc = g_markup_escape_text(group->name, -1); | |
8945 | 4091 mark = g_strdup_printf("<span weight='bold'>%s</span> (%d/%d)", |
4092 esc, gaim_blist_get_group_online_count(group), | |
4093 gaim_blist_get_group_size(group, FALSE)); | |
7620 | 4094 g_free(esc); |
4095 | |
4096 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
4097 STATUS_ICON_COLUMN, NULL, | |
4098 STATUS_ICON_VISIBLE_COLUMN, FALSE, | |
4099 NAME_COLUMN, mark, | |
4100 NODE_COLUMN, node, | |
4101 -1); | |
4102 g_free(mark); | |
4103 } else { | |
4104 gaim_gtk_blist_hide_node(list, node); | |
4105 } | |
4106 } | |
4107 | |
4108 static void buddy_node(GaimBuddy *buddy, GtkTreeIter *iter, GaimBlistNode *node) | |
5228 | 4109 { |
9944 | 4110 GaimPresence *presence; |
7620 | 4111 GdkPixbuf *status, *avatar; |
4112 char *mark; | |
11257 | 4113 char *idle = NULL; |
7620 | 4114 gboolean selected = (gtkblist->selected_node == node); |
4115 | |
9944 | 4116 presence = gaim_buddy_get_presence(buddy); |
4117 | |
7620 | 4118 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, |
4119 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") | |
4120 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4121 | |
10482 | 4122 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); |
7620 | 4123 mark = gaim_gtk_blist_get_name_markup(buddy, selected); |
4124 | |
12656 | 4125 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
4126 gaim_presence_is_idle(presence)) | |
9944 | 4127 { |
4128 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
4129 | |
4130 if (idle_secs > 0) | |
4131 { | |
4132 time_t t; | |
4133 int ihrs, imin; | |
4134 time(&t); | |
4135 ihrs = (t - idle_secs) / 3600; | |
4136 imin = ((t - idle_secs) / 60) % 60; | |
4137 | |
4138 if (ihrs > 0) | |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4139 idle = g_strdup_printf("%d:%02d", ihrs, imin); |
9944 | 4140 else |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4141 idle = g_strdup_printf("%d", imin); |
9944 | 4142 } |
7620 | 4143 } |
4144 | |
10118 | 4145 if (gaim_presence_is_idle(presence)) |
9944 | 4146 { |
4147 if (idle && !selected) { | |
10118 | 4148 char *i2 = g_strdup_printf("<span color='%s'>%s</span>", |
4149 dim_grey(), idle); | |
7620 | 4150 g_free(idle); |
4151 idle = i2; | |
5228 | 4152 } |
7620 | 4153 } |
4154 | |
4155 gtk_tree_store_set(gtkblist->treemodel, iter, | |
4156 STATUS_ICON_COLUMN, status, | |
4157 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4158 NAME_COLUMN, mark, | |
4159 IDLE_COLUMN, idle, | |
4160 BUDDY_ICON_COLUMN, avatar, | |
4161 -1); | |
4162 | |
4163 g_free(mark); | |
12656 | 4164 g_free(idle); |
7620 | 4165 if(status) |
4166 g_object_unref(status); | |
4167 if(avatar) | |
4168 g_object_unref(avatar); | |
4169 } | |
4170 | |
11890 | 4171 |
7620 | 4172 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) |
4173 { | |
4174 GaimContact *contact; | |
4175 GaimBuddy *buddy; | |
4176 struct _gaim_gtk_blist_node *gtknode; | |
4177 | |
4178 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node)); | |
4179 | |
4180 /* First things first, update the group */ | |
4181 gaim_gtk_blist_update_group(list, node->parent); | |
4182 | |
4183 contact = (GaimContact*)node; | |
4184 buddy = gaim_contact_get_priority_buddy(contact); | |
4185 | |
11890 | 4186 if (buddy_is_displayable(buddy)) |
10006 | 4187 { |
7620 | 4188 GtkTreeIter iter; |
4189 | |
8252 | 4190 if(!insert_node(list, node, &iter)) |
4191 return; | |
7620 | 4192 |
10515 | 4193 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
4194 | |
7620 | 4195 if(gtknode->contact_expanded) { |
4196 GdkPixbuf *status; | |
5228 | 4197 char *mark; |
4198 | |
7620 | 4199 status = gaim_gtk_blist_get_status_icon(node, |
4200 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? | |
4201 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4202 | |
4203 mark = g_markup_escape_text(gaim_contact_get_alias(contact), -1); | |
4204 | |
5228 | 4205 gtk_tree_store_set(gtkblist->treemodel, &iter, |
7620 | 4206 STATUS_ICON_COLUMN, status, |
4207 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
5228 | 4208 NAME_COLUMN, mark, |
7620 | 4209 IDLE_COLUMN, NULL, |
4210 BUDDY_ICON_COLUMN, NULL, | |
5228 | 4211 -1); |
4212 g_free(mark); | |
7620 | 4213 if(status) |
4214 g_object_unref(status); | |
4215 } else { | |
4216 buddy_node(buddy, &iter, node); | |
5228 | 4217 } |
7620 | 4218 } else { |
4219 gaim_gtk_blist_hide_node(list, node); | |
5228 | 4220 } |
7620 | 4221 } |
4222 | |
4223 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) | |
4224 { | |
4225 GaimContact *contact; | |
4226 GaimBuddy *buddy; | |
4227 struct _gaim_gtk_blist_node *gtkparentnode; | |
4228 | |
4229 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4230 | |
4231 buddy = (GaimBuddy*)node; | |
4232 contact = (GaimContact*)node->parent; | |
4233 | |
11624 | 4234 if (contact == NULL) |
4235 return; | |
4236 | |
7620 | 4237 /* First things first, update the contact */ |
4238 gaim_gtk_blist_update_contact(list, node->parent); | |
4239 | |
10918 | 4240 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
4241 | |
12341 | 4242 if (gtkparentnode->contact_expanded && buddy_is_displayable(buddy)) |
10006 | 4243 { |
7620 | 4244 GtkTreeIter iter; |
4245 | |
10006 | 4246 if (!insert_node(list, node, &iter)) |
8252 | 4247 return; |
4248 | |
7620 | 4249 buddy_node(buddy, &iter, node); |
4250 | |
4251 } else { | |
4252 gaim_gtk_blist_hide_node(list, node); | |
4253 } | |
4254 | |
4255 } | |
4256 | |
4257 static void gaim_gtk_blist_update_chat(GaimBuddyList *list, GaimBlistNode *node) | |
4258 { | |
4259 GaimChat *chat; | |
4260 | |
4261 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); | |
4262 | |
4263 /* First things first, update the group */ | |
4264 gaim_gtk_blist_update_group(list, node->parent); | |
4265 | |
4266 chat = (GaimChat*)node; | |
4267 | |
4268 if(gaim_account_is_connected(chat->account)) { | |
4269 GtkTreeIter iter; | |
5234 | 4270 GdkPixbuf *status; |
7620 | 4271 char *mark; |
4272 | |
8252 | 4273 if(!insert_node(list, node, &iter)) |
4274 return; | |
5234 | 4275 |
4276 status = gaim_gtk_blist_get_status_icon(node, | |
7620 | 4277 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
4278 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4279 | |
4280 mark = g_markup_escape_text(gaim_chat_get_name(chat), -1); | |
5234 | 4281 |
4282 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
7620 | 4283 STATUS_ICON_COLUMN, status, |
4284 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4285 NAME_COLUMN, mark, | |
4286 -1); | |
5228 | 4287 |
4288 g_free(mark); | |
7620 | 4289 if(status) |
5228 | 4290 g_object_unref(status); |
7620 | 4291 } else { |
5260 | 4292 gaim_gtk_blist_hide_node(list, node); |
5228 | 4293 } |
7620 | 4294 } |
4295 | |
4296 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node) | |
4297 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12766
diff
changeset
|
4298 if(!gtkblist || !node) |
7620 | 4299 return; |
4300 | |
13195 | 4301 if (node->ui_data == NULL) |
4302 gaim_gtk_blist_new_node(node); | |
4303 | |
7620 | 4304 switch(node->type) { |
4305 case GAIM_BLIST_GROUP_NODE: | |
4306 gaim_gtk_blist_update_group(list, node); | |
4307 break; | |
4308 case GAIM_BLIST_CONTACT_NODE: | |
4309 gaim_gtk_blist_update_contact(list, node); | |
4310 break; | |
4311 case GAIM_BLIST_BUDDY_NODE: | |
4312 gaim_gtk_blist_update_buddy(list, node); | |
4313 break; | |
4314 case GAIM_BLIST_CHAT_NODE: | |
4315 gaim_gtk_blist_update_chat(list, node); | |
4316 break; | |
4317 case GAIM_BLIST_OTHER_NODE: | |
4318 return; | |
4319 } | |
5234 | 4320 |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4321 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 4322 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4323 #endif |
5228 | 4324 } |
4325 | |
7620 | 4326 |
4327 static void gaim_gtk_blist_destroy(GaimBuddyList *list) | |
5228 | 4328 { |
4329 if (!gtkblist) | |
4330 return; | |
4331 | |
8937 | 4332 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
4333 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
4334 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
4335 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
4336 |
5228 | 4337 gtk_widget_destroy(gtkblist->window); |
7620 | 4338 |
8254 | 4339 gaim_gtk_blist_tooltip_destroy(); |
7620 | 4340 |
5228 | 4341 if (gtkblist->refresh_timer) |
4342 g_source_remove(gtkblist->refresh_timer); | |
4343 if (gtkblist->timeout) | |
4344 g_source_remove(gtkblist->timeout); | |
10354 | 4345 if (gtkblist->drag_timeout) |
4346 g_source_remove(gtkblist->drag_timeout); | |
5228 | 4347 |
13015 | 4348 g_hash_table_destroy(gtkblist->connection_errors); |
5228 | 4349 gtkblist->refresh_timer = 0; |
4350 gtkblist->timeout = 0; | |
10354 | 4351 gtkblist->drag_timeout = 0; |
5228 | 4352 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; |
4353 gtkblist->treemodel = NULL; | |
4354 gtkblist->idle_column = NULL; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4355 gtkblist->buddy_icon_column = NULL; |
5427 | 4356 g_object_unref(G_OBJECT(gtkblist->ift)); |
13015 | 4357 g_free(gtkblist); |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4358 accountmenu = NULL; |
5228 | 4359 gtkblist = NULL; |
7620 | 4360 |
10087 | 4361 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
5228 | 4362 } |
4363 | |
7620 | 4364 static void gaim_gtk_blist_set_visible(GaimBuddyList *list, gboolean show) |
5228 | 4365 { |
4366 if (!(gtkblist && gtkblist->window)) | |
4367 return; | |
10325 | 4368 |
5228 | 4369 if (show) { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4370 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
|
4371 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", gtkblist); |
5228 | 4372 gaim_gtk_blist_restore_position(); |
4373 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4374 } else { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4375 if(visibility_manager_count) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4376 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
|
4377 gtk_widget_hide(gtkblist->window); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4378 } else { |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4379 if (!GTK_WIDGET_VISIBLE(gtkblist->window)) |
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4380 gtk_widget_show(gtkblist->window); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4381 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4382 } |
5228 | 4383 } |
4384 } | |
4385 | |
7620 | 4386 static GList * |
4387 groups_tree(void) | |
4388 { | |
4389 GList *tmp = NULL; | |
4390 char *tmp2; | |
4391 GaimGroup *g; | |
4392 GaimBlistNode *gnode; | |
4393 | |
4394 if (gaim_get_blist()->root == NULL) | |
4395 { | |
4396 tmp2 = g_strdup(_("Buddies")); | |
4397 tmp = g_list_append(tmp, tmp2); | |
4398 } | |
4399 else | |
4400 { | |
4401 for (gnode = gaim_get_blist()->root; | |
4402 gnode != NULL; | |
4403 gnode = gnode->next) | |
4404 { | |
4405 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4406 { | |
4407 g = (GaimGroup *)gnode; | |
4408 tmp2 = g->name; | |
4409 tmp = g_list_append(tmp, tmp2); | |
4410 } | |
4411 } | |
4412 } | |
4413 | |
4414 return tmp; | |
4415 } | |
4416 | |
4417 static void | |
4418 add_buddy_select_account_cb(GObject *w, GaimAccount *account, | |
4419 GaimGtkAddBuddyData *data) | |
4420 { | |
4421 /* Save our account */ | |
4422 data->account = account; | |
4423 } | |
4424 | |
4425 static void | |
4426 destroy_add_buddy_dialog_cb(GtkWidget *win, GaimGtkAddBuddyData *data) | |
4427 { | |
4428 g_free(data); | |
4429 } | |
4430 | |
4431 static void | |
4432 add_buddy_cb(GtkWidget *w, int resp, GaimGtkAddBuddyData *data) | |
4433 { | |
4434 const char *grp, *who, *whoalias; | |
4435 GaimConversation *c; | |
4436 GaimBuddy *b; | |
4437 GaimGroup *g; | |
4438 | |
4439 if (resp == GTK_RESPONSE_OK) | |
4440 { | |
4441 who = gtk_entry_get_text(GTK_ENTRY(data->entry)); | |
4442 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry)); | |
4443 whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); | |
9658 | 4444 if (*whoalias == '\0') |
4445 whoalias = NULL; | |
7620 | 4446 |
4447 if ((g = gaim_find_group(grp)) == NULL) | |
4448 { | |
4449 g = gaim_group_new(grp); | |
4450 gaim_blist_add_group(g, NULL); | |
4451 } | |
4452 | |
4453 b = gaim_buddy_new(data->account, who, whoalias); | |
4454 gaim_blist_add_buddy(b, NULL, g, NULL); | |
11643 | 4455 gaim_account_add_buddy(data->account, b); |
7620 | 4456 |
7887 | 4457 /* |
9285 | 4458 * XXX |
11643 | 4459 * It really seems like it would be better if the call to |
4460 * gaim_account_add_buddy() and gaim_conversation_update() were done in | |
4461 * blist.c, possibly in the gaim_blist_add_buddy() function. Maybe | |
4462 * gaim_account_add_buddy() should be renamed to | |
4463 * gaim_blist_add_new_buddy() or something, and have it call | |
7887 | 4464 * gaim_blist_add_buddy() after it creates it. --Mark |
9285 | 4465 * |
4466 * No that's not good. blist.c should only deal with adding nodes to the | |
11643 | 4467 * local list. We need a new, non-gtk file that calls both |
4468 * gaim_account_add_buddy and gaim_blist_add_buddy(). | |
4469 * Or something. --Mark | |
7887 | 4470 */ |
4471 | |
11338 | 4472 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, data->account); |
7620 | 4473 if (c != NULL) { |
4474 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(c))); | |
4475 } | |
4476 } | |
4477 | |
4478 gtk_widget_destroy(data->window); | |
4479 } | |
4480 | |
4481 static void | |
4482 gaim_gtk_blist_request_add_buddy(GaimAccount *account, const char *username, | |
4483 const char *group, const char *alias) | |
4484 { | |
4485 GtkWidget *table; | |
4486 GtkWidget *label; | |
4487 GtkWidget *hbox; | |
4488 GtkWidget *vbox; | |
4489 GtkWidget *img; | |
4490 GaimGtkBuddyList *gtkblist; | |
4491 GaimGtkAddBuddyData *data = g_new0(GaimGtkAddBuddyData, 1); | |
4492 | |
4493 data->account = | |
4494 (account != NULL | |
4495 ? account | |
4496 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
4497 | |
4498 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4499 GTK_ICON_SIZE_DIALOG); | |
4500 | |
4501 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
4502 | |
4503 data->window = gtk_dialog_new_with_buttons(_("Add Buddy"), | |
8975 | 4504 NULL, GTK_DIALOG_NO_SEPARATOR, |
7620 | 4505 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
4506 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4507 NULL); | |
4508 | |
4509 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4510 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
7620 | 4511 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4512 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4513 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4514 gtk_window_set_role(GTK_WINDOW(data->window), "add_buddy"); |
8975 | 4515 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4516 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4517 |
11243 | 4518 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4519 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4520 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4521 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4522 | |
4523 vbox = gtk_vbox_new(FALSE, 0); | |
4524 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4525 | |
4526 label = gtk_label_new( | |
4527 _("Please enter the screen name of the person you would like " | |
4528 "to add to your buddy list. You may optionally enter an alias, " | |
4529 "or nickname, for the buddy. The alias will be displayed in " | |
4530 "place of the screen name whenever possible.\n")); | |
4531 | |
4532 gtk_widget_set_size_request(GTK_WIDGET(label), 400, -1); | |
4533 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4534 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4535 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4536 | |
11243 | 4537 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7620 | 4538 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
4539 | |
4540 g_signal_connect(G_OBJECT(data->window), "destroy", | |
4541 G_CALLBACK(destroy_add_buddy_dialog_cb), data); | |
4542 | |
4543 table = gtk_table_new(4, 2, FALSE); | |
4544 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
4545 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
4546 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | |
4547 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
4548 | |
4549 label = gtk_label_new(_("Screen Name:")); | |
4550 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4551 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
4552 | |
4553 data->entry = gtk_entry_new(); | |
4554 gtk_table_attach_defaults(GTK_TABLE(table), data->entry, 1, 2, 0, 1); | |
4555 gtk_widget_grab_focus(data->entry); | |
4556 | |
4557 if (username != NULL) | |
4558 gtk_entry_set_text(GTK_ENTRY(data->entry), username); | |
12337 | 4559 else |
4560 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), | |
4561 GTK_RESPONSE_OK, FALSE); | |
7620 | 4562 |
4563 gtk_entry_set_activates_default (GTK_ENTRY(data->entry), TRUE); | |
8137 | 4564 gaim_set_accessible_label (data->entry, label); |
7620 | 4565 |
12337 | 4566 g_signal_connect(G_OBJECT(data->entry), "changed", |
4567 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
4568 data->window); | |
4569 | |
7620 | 4570 label = gtk_label_new(_("Alias:")); |
4571 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4572 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
4573 | |
4574 data->entry_for_alias = gtk_entry_new(); | |
4575 gtk_table_attach_defaults(GTK_TABLE(table), | |
4576 data->entry_for_alias, 1, 2, 1, 2); | |
4577 | |
4578 if (alias != NULL) | |
4579 gtk_entry_set_text(GTK_ENTRY(data->entry_for_alias), alias); | |
4580 | |
10734
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4581 if (username != NULL) |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4582 gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4583 |
7620 | 4584 gtk_entry_set_activates_default (GTK_ENTRY(data->entry_for_alias), TRUE); |
8137 | 4585 gaim_set_accessible_label (data->entry_for_alias, label); |
7620 | 4586 |
4587 label = gtk_label_new(_("Group:")); | |
4588 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4589 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
4590 | |
4591 data->combo = gtk_combo_new(); | |
4592 gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree()); | |
4593 gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 2, 3); | |
8137 | 4594 gaim_set_accessible_label (data->combo, label); |
7620 | 4595 |
4596 /* Set up stuff for the account box */ | |
4597 label = gtk_label_new(_("Account:")); | |
4598 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4599 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
4600 | |
4601 data->account_box = gaim_gtk_account_option_menu_new(account, FALSE, | |
4602 G_CALLBACK(add_buddy_select_account_cb), NULL, data); | |
4603 | |
4604 gtk_table_attach_defaults(GTK_TABLE(table), data->account_box, 1, 2, 3, 4); | |
8137 | 4605 gaim_set_accessible_label (data->account_box, label); |
7620 | 4606 /* End of account box */ |
4607 | |
4608 g_signal_connect(G_OBJECT(data->window), "response", | |
4609 G_CALLBACK(add_buddy_cb), data); | |
4610 | |
4611 gtk_widget_show_all(data->window); | |
4612 | |
4613 if (group != NULL) | |
4614 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group); | |
4615 } | |
4616 | |
4617 static void | |
4618 add_chat_cb(GtkWidget *w, GaimGtkAddChatData *data) | |
4619 { | |
4620 GHashTable *components; | |
4621 GList *tmp; | |
4622 GaimChat *chat; | |
4623 GaimGroup *group; | |
4624 const char *group_name; | |
10475 | 4625 const char *value; |
7620 | 4626 |
4627 components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
4628 g_free, g_free); | |
4629 | |
4630 for (tmp = data->entries; tmp; tmp = tmp->next) | |
4631 { | |
4632 if (g_object_get_data(tmp->data, "is_spin")) | |
4633 { | |
4634 g_hash_table_replace(components, | |
4635 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4636 g_strdup_printf("%d", | |
4637 gtk_spin_button_get_value_as_int(tmp->data))); | |
4638 } | |
4639 else | |
4640 { | |
10475 | 4641 value = gtk_entry_get_text(tmp->data); |
4642 if (*value != '\0') | |
4643 g_hash_table_replace(components, | |
4644 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4645 g_strdup(value)); | |
7620 | 4646 } |
4647 } | |
4648 | |
4649 chat = gaim_chat_new(data->account, | |
4650 gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), | |
4651 components); | |
4652 | |
4653 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry)); | |
4654 | |
4655 if ((group = gaim_find_group(group_name)) == NULL) | |
4656 { | |
4657 group = gaim_group_new(group_name); | |
4658 gaim_blist_add_group(group, NULL); | |
4659 } | |
4660 | |
4661 if (chat != NULL) | |
4662 { | |
4663 gaim_blist_add_chat(chat, group, NULL); | |
4664 } | |
4665 | |
4666 gtk_widget_destroy(data->window); | |
9812 | 4667 g_free(data->default_chat_name); |
7620 | 4668 g_list_free(data->entries); |
4669 g_free(data); | |
4670 } | |
4671 | |
4672 static void | |
4673 add_chat_resp_cb(GtkWidget *w, int resp, GaimGtkAddChatData *data) | |
4674 { | |
4675 if (resp == GTK_RESPONSE_OK) | |
4676 { | |
4677 add_chat_cb(NULL, data); | |
4678 } | |
4679 else | |
4680 { | |
4681 gtk_widget_destroy(data->window); | |
9812 | 4682 g_free(data->default_chat_name); |
7620 | 4683 g_list_free(data->entries); |
4684 g_free(data); | |
4685 } | |
4686 } | |
4687 | |
10475 | 4688 /* |
4689 * Check the values of all the text entry boxes. If any required input | |
4690 * strings are empty then don't allow the user to click on "OK." | |
4691 */ | |
4692 static void | |
4693 addchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
4694 { | |
4695 GaimGtkAddChatData *data; | |
4696 GList *tmp; | |
4697 const char *text; | |
4698 gboolean required; | |
4699 gboolean sensitive = TRUE; | |
4700 | |
4701 data = user_data; | |
4702 | |
4703 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
4704 { | |
4705 if (!g_object_get_data(tmp->data, "is_spin")) | |
4706 { | |
4707 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
4708 text = gtk_entry_get_text(tmp->data); | |
4709 if (required && (*text == '\0')) | |
4710 sensitive = FALSE; | |
4711 } | |
4712 } | |
4713 | |
4714 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
4715 } | |
4716 | |
7620 | 4717 static void |
4718 rebuild_addchat_entries(GaimGtkAddChatData *data) | |
4719 { | |
4720 GaimConnection *gc; | |
9959 | 4721 GList *list = NULL, *tmp = NULL; |
9754 | 4722 GHashTable *defaults = NULL; |
7620 | 4723 struct proto_chat_entry *pce; |
4724 gboolean focus = TRUE; | |
4725 | |
10127 | 4726 g_return_if_fail(data->account != NULL); |
4727 | |
7620 | 4728 gc = gaim_account_get_connection(data->account); |
4729 | |
4730 while (GTK_BOX(data->entries_box)->children) | |
4731 { | |
4732 gtk_container_remove(GTK_CONTAINER(data->entries_box), | |
10475 | 4733 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
7620 | 4734 } |
4735 | |
4736 if (data->entries != NULL) | |
4737 g_list_free(data->entries); | |
4738 | |
4739 data->entries = NULL; | |
4740 | |
9959 | 4741 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4742 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | |
7620 | 4743 |
9754 | 4744 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
10475 | 4745 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, data->default_chat_name); |
9754 | 4746 |
7620 | 4747 for (tmp = list; tmp; tmp = tmp->next) |
4748 { | |
4749 GtkWidget *label; | |
4750 GtkWidget *rowbox; | |
10475 | 4751 GtkWidget *input; |
7620 | 4752 |
4753 pce = tmp->data; | |
4754 | |
4755 rowbox = gtk_hbox_new(FALSE, 5); | |
4756 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); | |
4757 | |
7889 | 4758 label = gtk_label_new_with_mnemonic(pce->label); |
7620 | 4759 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4760 gtk_size_group_add_widget(data->sg, label); | |
4761 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4762 | |
4763 if (pce->is_int) | |
4764 { | |
4765 GtkObject *adjust; | |
4766 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, | |
4767 1, 10, 10); | |
10475 | 4768 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
4769 gtk_widget_set_size_request(input, 50, -1); | |
4770 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
7620 | 4771 } |
4772 else | |
4773 { | |
9754 | 4774 char *value; |
10475 | 4775 input = gtk_entry_new(); |
4776 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9754 | 4777 value = g_hash_table_lookup(defaults, pce->identifier); |
4778 if (value != NULL) | |
10475 | 4779 gtk_entry_set_text(GTK_ENTRY(input), value); |
7620 | 4780 if (pce->secret) |
11986 | 4781 { |
10475 | 4782 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 4783 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
4784 } | |
10475 | 4785 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
4786 g_signal_connect(G_OBJECT(input), "changed", | |
4787 G_CALLBACK(addchat_set_sensitive_if_input_cb), data); | |
7620 | 4788 } |
4789 | |
10475 | 4790 /* Do the following for any type of input widget */ |
4791 if (focus) | |
4792 { | |
4793 gtk_widget_grab_focus(input); | |
4794 focus = FALSE; | |
4795 } | |
4796 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
4797 gaim_set_accessible_label(input, label); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4798 g_object_set_data(G_OBJECT(input), "identifier", (gpointer)pce->identifier); |
10475 | 4799 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); |
4800 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
4801 data->entries = g_list_append(data->entries, input); | |
4802 | |
7620 | 4803 g_free(pce); |
4804 } | |
4805 | |
4806 g_list_free(list); | |
9754 | 4807 g_hash_table_destroy(defaults); |
7620 | 4808 |
10475 | 4809 /* Set whether the "OK" button should be clickable initially */ |
4810 addchat_set_sensitive_if_input_cb(NULL, data); | |
4811 | |
7620 | 4812 gtk_widget_show_all(data->entries_box); |
4813 } | |
4814 | |
4815 static void | |
10475 | 4816 addchat_select_account_cb(GObject *w, GaimAccount *account, |
7620 | 4817 GaimGtkAddChatData *data) |
4818 { | |
9460 | 4819 if (strcmp(gaim_account_get_protocol_id(data->account), |
4820 gaim_account_get_protocol_id(account)) == 0) | |
7620 | 4821 { |
4822 data->account = account; | |
4823 } | |
4824 else | |
4825 { | |
4826 data->account = account; | |
4827 rebuild_addchat_entries(data); | |
4828 } | |
4829 } | |
4830 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4831 static void |
7859 | 4832 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
9754 | 4833 const char *alias, const char *name) |
7620 | 4834 { |
4835 GaimGtkAddChatData *data; | |
8975 | 4836 GaimGtkBuddyList *gtkblist; |
4837 GList *l; | |
4838 GaimConnection *gc; | |
7620 | 4839 GtkWidget *label; |
4840 GtkWidget *rowbox; | |
4841 GtkWidget *hbox; | |
4842 GtkWidget *vbox; | |
4843 GtkWidget *img; | |
4844 | |
9812 | 4845 if (account != NULL) { |
4846 gc = gaim_account_get_connection(account); | |
4847 | |
4848 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | |
4849 gaim_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | |
4850 return; | |
4851 } | |
4852 } else { | |
4853 /* Find an account with chat capabilities */ | |
4854 for (l = gaim_connections_get_all(); l != NULL; l = l->next) { | |
4855 gc = (GaimConnection *)l->data; | |
4856 | |
4857 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | |
4858 account = gaim_connection_get_account(gc); | |
4859 break; | |
4860 } | |
4861 } | |
4862 | |
4863 if (account == NULL) { | |
4864 gaim_notify_error(NULL, NULL, | |
4865 _("You are not currently signed on with any " | |
4866 "protocols that have the ability to chat."), NULL); | |
4867 return; | |
4868 } | |
4869 } | |
4870 | |
7620 | 4871 data = g_new0(GaimGtkAddChatData, 1); |
9812 | 4872 data->account = account; |
4873 data->default_chat_name = g_strdup(name); | |
7620 | 4874 |
4875 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4876 GTK_ICON_SIZE_DIALOG); | |
4877 | |
8975 | 4878 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4879 | |
7620 | 4880 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4881 | |
8975 | 4882 data->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
4883 NULL, GTK_DIALOG_NO_SEPARATOR, | |
4884 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
4885 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4886 NULL); | |
4887 | |
4888 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4889 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8975 | 4890 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4891 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4892 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4893 gtk_window_set_role(GTK_WINDOW(data->window), "add_chat"); |
8975 | 4894 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4895 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4896 |
11243 | 4897 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4898 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4899 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4900 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4901 | |
4902 vbox = gtk_vbox_new(FALSE, 5); | |
4903 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4904 | |
4905 label = gtk_label_new( | |
4906 _("Please enter an alias, and the appropriate information " | |
4907 "about the chat you would like to add to your buddy list.\n")); | |
4908 gtk_widget_set_size_request(label, 400, -1); | |
4909 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4910 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4911 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4912 | |
4913 rowbox = gtk_hbox_new(FALSE, 5); | |
4914 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4915 | |
4916 label = gtk_label_new(_("Account:")); | |
4917 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4918 gtk_size_group_add_widget(data->sg, label); | |
4919 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4920 | |
4921 data->account_menu = gaim_gtk_account_option_menu_new(account, FALSE, | |
10475 | 4922 G_CALLBACK(addchat_select_account_cb), |
9987 | 4923 chat_account_filter_func, data); |
7620 | 4924 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
8137 | 4925 gaim_set_accessible_label (data->account_menu, label); |
7620 | 4926 |
4927 data->entries_box = gtk_vbox_new(FALSE, 5); | |
9811 | 4928 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
7620 | 4929 gtk_box_pack_start(GTK_BOX(vbox), data->entries_box, TRUE, TRUE, 0); |
4930 | |
4931 rebuild_addchat_entries(data); | |
4932 | |
4933 rowbox = gtk_hbox_new(FALSE, 5); | |
4934 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4935 | |
4936 label = gtk_label_new(_("Alias:")); | |
4937 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4938 gtk_size_group_add_widget(data->sg, label); | |
4939 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4940 | |
4941 data->alias_entry = gtk_entry_new(); | |
7859 | 4942 if (alias != NULL) |
4943 gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias); | |
7620 | 4944 gtk_box_pack_end(GTK_BOX(rowbox), data->alias_entry, TRUE, TRUE, 0); |
10311 | 4945 gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE); |
8137 | 4946 gaim_set_accessible_label (data->alias_entry, label); |
7620 | 4947 |
4948 rowbox = gtk_hbox_new(FALSE, 5); | |
4949 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4950 | |
9811 | 4951 label = gtk_label_new(_("Group:")); |
7620 | 4952 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4953 gtk_size_group_add_widget(data->sg, label); | |
4954 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4955 | |
9811 | 4956 data->group_combo = gtk_combo_new(); |
4957 gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree()); | |
7620 | 4958 gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0); |
4959 | |
4960 if (group) | |
4961 { | |
4962 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry), | |
4963 group->name); | |
4964 } | |
8137 | 4965 gaim_set_accessible_label (data->group_combo, label); |
7620 | 4966 |
4967 g_signal_connect(G_OBJECT(data->window), "response", | |
4968 G_CALLBACK(add_chat_resp_cb), data); | |
4969 | |
4970 gtk_widget_show_all(data->window); | |
4971 } | |
4972 | |
4973 static void | |
4974 add_group_cb(GaimConnection *gc, const char *group_name) | |
4975 { | |
9285 | 4976 GaimGroup *group; |
4977 | |
12458 | 4978 if ((group_name == NULL) || (*group_name == '\0')) |
4979 return; | |
4980 | |
9285 | 4981 group = gaim_group_new(group_name); |
4982 gaim_blist_add_group(group, NULL); | |
7620 | 4983 } |
4984 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4985 static void |
7620 | 4986 gaim_gtk_blist_request_add_group(void) |
4987 { | |
7853 | 4988 gaim_request_input(NULL, _("Add Group"), NULL, |
7620 | 4989 _("Please enter the name of the group to be added."), |
8697 | 4990 NULL, FALSE, FALSE, NULL, |
7620 | 4991 _("Add"), G_CALLBACK(add_group_cb), |
4992 _("Cancel"), NULL, NULL); | |
4993 } | |
4994 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4995 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4996 gaim_gtk_blist_toggle_visibility() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4997 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4998 if (gtkblist && gtkblist->window) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4999 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5000 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
|
5001 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5002 gaim_blist_set_visible(TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5003 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5004 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5005 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5006 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5007 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5008 gaim_gtk_blist_visibility_manager_add() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5009 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5010 visibility_manager_count++; |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
5011 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
|
5012 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5013 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5014 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5015 gaim_gtk_blist_visibility_manager_remove() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5016 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5017 if (visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5018 visibility_manager_count--; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5019 if (!visibility_manager_count) |
12115
e9790eb93216
[gaim-migrate @ 14415]
Luke Schierer <lschiere@pidgin.im>
parents:
12113
diff
changeset
|
5020 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
|
5021 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
|
5022 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5023 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5024 |
7620 | 5025 static GaimBlistUiOps blist_ui_ops = |
5228 | 5026 { |
5027 gaim_gtk_blist_new_list, | |
5256 | 5028 gaim_gtk_blist_new_node, |
5228 | 5029 gaim_gtk_blist_show, |
5030 gaim_gtk_blist_update, | |
5031 gaim_gtk_blist_remove, | |
5032 gaim_gtk_blist_destroy, | |
7620 | 5033 gaim_gtk_blist_set_visible, |
5034 gaim_gtk_blist_request_add_buddy, | |
5035 gaim_gtk_blist_request_add_chat, | |
10012 | 5036 gaim_gtk_blist_request_add_group |
5228 | 5037 }; |
5038 | |
5039 | |
7620 | 5040 GaimBlistUiOps * |
5041 gaim_gtk_blist_get_ui_ops(void) | |
5228 | 5042 { |
5043 return &blist_ui_ops; | |
5044 } | |
5045 | |
10643 | 5046 GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() |
5047 { | |
5048 return gtkblist; | |
5049 } | |
5050 | |
7620 | 5051 static void account_signon_cb(GaimConnection *gc, gpointer z) |
5052 { | |
5053 GaimAccount *account = gaim_connection_get_account(gc); | |
5054 GaimBlistNode *gnode, *cnode; | |
5055 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) | |
5056 { | |
5057 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5058 continue; | |
5059 for(cnode = gnode->child; cnode; cnode = cnode->next) | |
5060 { | |
5061 GaimChat *chat; | |
5062 | |
5063 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
5064 continue; | |
5065 | |
5066 chat = (GaimChat *)cnode; | |
5067 | |
5068 if(chat->account != account) | |
5069 continue; | |
5070 | |
8197 | 5071 if(gaim_blist_node_get_bool((GaimBlistNode*)chat, "gtk-autojoin") || |
8198 | 5072 (gaim_blist_node_get_string((GaimBlistNode*)chat, |
5073 "gtk-autojoin") != NULL)) | |
7620 | 5074 serv_join_chat(gc, chat->components); |
5075 } | |
5076 } | |
5077 } | |
5078 | |
8815 | 5079 void * |
5080 gaim_gtk_blist_get_handle() { | |
5081 static int handle; | |
5082 | |
5083 return &handle; | |
5084 } | |
5085 | |
11910 | 5086 static gboolean buddy_signonoff_timeout_cb(GaimBuddy *buddy) |
5087 { | |
5088 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
5089 | |
5090 gtknode->recent_signonoff = FALSE; | |
5091 gtknode->recent_signonoff_timer = 0; | |
5092 | |
5093 gaim_gtk_blist_update(NULL, (GaimBlistNode*)buddy); | |
5094 | |
5095 return FALSE; | |
5096 } | |
5097 | |
5098 static void buddy_signonoff_cb(GaimBuddy *buddy) | |
5099 { | |
11915 | 5100 struct _gaim_gtk_blist_node *gtknode; |
5101 | |
5102 if(!((GaimBlistNode*)buddy)->ui_data) { | |
5103 gaim_gtk_blist_new_node((GaimBlistNode*)buddy); | |
5104 } | |
5105 | |
5106 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
11910 | 5107 |
5108 gtknode->recent_signonoff = TRUE; | |
5109 | |
5110 if(gtknode->recent_signonoff_timer > 0) | |
5111 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
5112 gtknode->recent_signonoff_timer = gaim_timeout_add(10000, | |
5113 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); | |
5114 } | |
5115 | |
7620 | 5116 void gaim_gtk_blist_init(void) |
5117 { | |
8815 | 5118 void *gtk_blist_handle = gaim_gtk_blist_get_handle(); |
7620 | 5119 |
5120 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
8815 | 5121 gtk_blist_handle, GAIM_CALLBACK(account_signon_cb), |
7620 | 5122 NULL); |
7731 | 5123 |
5124 /* Initialize prefs */ | |
8819 | 5125 gaim_prefs_add_none("/gaim/gtk/blist"); |
5126 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); | |
5127 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); | |
12656 | 5128 gaim_prefs_add_bool("/gaim/gtk/blist/show_idle_time", TRUE); |
8819 | 5129 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); |
10282 | 5130 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); |
12279 | 5131 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE); |
9711 | 5132 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); |
8819 | 5133 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
5134 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | |
9778 | 5135 gaim_prefs_add_int("/gaim/gtk/blist/width", 309); /* Golden ratio, baby */ |
5136 gaim_prefs_add_int("/gaim/gtk/blist/height", 500); /* Golden ratio, baby */ | |
8819 | 5137 gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500); |
7731 | 5138 |
8815 | 5139 /* Register our signals */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5140 gaim_signal_register(gtk_blist_handle, "gtkblist-hiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5141 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5142 gaim_value_new(GAIM_TYPE_POINTER)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5143 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5144 gaim_signal_register(gtk_blist_handle, "gtkblist-unhiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5145 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5146 gaim_value_new(GAIM_TYPE_SUBTYPE)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5147 |
8815 | 5148 gaim_signal_register(gtk_blist_handle, "gtkblist-created", |
9811 | 5149 gaim_marshal_VOID__POINTER, NULL, 1, |
5150 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
5151 GAIM_SUBTYPE_BLIST)); | |
8819 | 5152 |
5153 gaim_signal_register(gtk_blist_handle, "drawing-tooltip", | |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5154 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
9811 | 5155 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_BLIST_NODE), |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5156 gaim_value_new_outgoing(GAIM_TYPE_BOXED, "GString *"), |
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5157 gaim_value_new(GAIM_TYPE_BOOLEAN)); |
11910 | 5158 |
5159 | |
5160 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
5161 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
7620 | 5162 } |
5163 | |
8815 | 5164 void |
5165 gaim_gtk_blist_uninit(void) { | |
5166 gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle()); | |
5167 } | |
5228 | 5168 |
5169 /********************************************************************* | |
9811 | 5170 * Buddy List sorting functions * |
5422 | 5171 *********************************************************************/ |
5172 | |
11796 | 5173 GList *gaim_gtk_blist_get_sort_methods() |
5174 { | |
5175 return gaim_gtk_blist_sort_methods; | |
5176 } | |
5177 | |
7620 | 5178 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
5422 | 5179 { |
5180 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | |
7620 | 5181 method->id = g_strdup(id); |
5422 | 5182 method->name = g_strdup(name); |
9775 | 5183 method->func = func; |
11796 | 5184 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
5185 gaim_gtk_blist_update_sort_methods(); | |
5422 | 5186 } |
5187 | |
7620 | 5188 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
11796 | 5189 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5190 |
5191 while(l) { | |
5192 struct gaim_gtk_blist_sort_method *method = l->data; | |
5193 if(!strcmp(method->id, id)) { | |
11796 | 5194 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
7620 | 5195 g_free(method->id); |
5196 g_free(method->name); | |
5197 g_free(method); | |
5198 break; | |
5199 } | |
5200 } | |
11796 | 5201 gaim_gtk_blist_update_sort_methods(); |
5422 | 5202 } |
5203 | |
7620 | 5204 void gaim_gtk_blist_sort_method_set(const char *id){ |
11796 | 5205 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5206 |
5207 if(!id) | |
5208 id = "none"; | |
5209 | |
5210 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | |
5422 | 5211 l = l->next; |
7620 | 5212 |
5422 | 5213 if (l) { |
5214 current_sort_method = l->data; | |
5215 } else if (!current_sort_method) { | |
7620 | 5216 gaim_gtk_blist_sort_method_set("none"); |
5422 | 5217 return; |
5218 } | |
5219 redo_buddy_list(gaim_get_blist(), TRUE); | |
5220 | |
5221 } | |
5222 | |
5223 /****************************************** | |
5224 ** Sort Methods | |
5225 ******************************************/ | |
5226 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5227 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter parent_iter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5228 { |
7620 | 5229 GaimBlistNode *sibling = node->prev; |
5230 GtkTreeIter sibling_iter; | |
5231 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5232 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5233 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5234 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5235 } |
7620 | 5236 |
5237 while (sibling && !get_iter_from_node(sibling, &sibling_iter)) { | |
5238 sibling = sibling->prev; | |
5422 | 5239 } |
7620 | 5240 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5241 gtk_tree_store_insert_after(gtkblist->treemodel, iter, |
7620 | 5242 node->parent ? &parent_iter : NULL, |
5243 sibling ? &sibling_iter : NULL); | |
5422 | 5244 } |
5245 | |
7620 | 5246 #if GTK_CHECK_VERSION(2,2,1) |
5247 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5248 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5249 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5250 GtkTreeIter more_z; |
7620 | 5251 |
5252 const char *my_name; | |
5253 | |
5254 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5255 my_name = gaim_contact_get_alias((GaimContact*)node); | |
5256 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5257 my_name = gaim_chat_get_name((GaimChat*)node); | |
5258 } else { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5259 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5260 return; |
7620 | 5261 } |
5262 | |
5422 | 5263 |
5264 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
|
5265 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5266 return; |
7620 | 5267 } |
5268 | |
5269 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5270 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5271 GaimBlistNode *n; |
7620 | 5272 const char *this_name; |
5273 int cmp; | |
5274 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5275 val.g_type = 0; |
7620 | 5276 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5277 n = g_value_get_pointer(&val); | |
5278 | |
5279 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5280 this_name = gaim_contact_get_alias((GaimContact*)n); | |
5281 } else if(GAIM_BLIST_NODE_IS_CHAT(n)) { | |
5282 this_name = gaim_chat_get_name((GaimChat*)n); | |
5283 } else { | |
5284 this_name = NULL; | |
5285 } | |
5286 | |
5287 cmp = gaim_utf8_strcasecmp(my_name, this_name); | |
5288 | |
5289 if(this_name && (cmp < 0 || (cmp == 0 && node < n))) { | |
5290 if(cur) { | |
5291 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5292 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5293 return; |
7620 | 5294 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5295 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5296 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5297 return; |
7620 | 5298 } |
5299 } | |
5300 g_value_unset(&val); | |
5301 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
5302 | |
5303 if(cur) { | |
5304 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5305 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5306 return; |
7620 | 5307 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5308 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5309 return; |
7620 | 5310 } |
5311 } | |
5312 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5313 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
7620 | 5314 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5315 GtkTreeIter more_z; |
7620 | 5316 |
5317 GaimBuddy *my_buddy, *this_buddy; | |
5318 | |
5319 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5320 my_buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
5321 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5322 if (cur != NULL) { |
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; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5325 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5326 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5327 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5328 return; |
7620 | 5329 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5330 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5331 return; |
7620 | 5332 } |
5333 | |
5334 | |
5335 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
|
5336 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5337 return; |
5422 | 5338 } |
5339 | |
5340 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5341 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5342 GaimBlistNode *n; |
9944 | 5343 gint name_cmp; |
5344 gint presence_cmp; | |
7620 | 5345 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5346 val.g_type = 0; |
5422 | 5347 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5348 n = g_value_get_pointer(&val); | |
7620 | 5349 |
5350 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5351 this_buddy = gaim_contact_get_priority_buddy((GaimContact*)n); | |
5352 } else { | |
5353 this_buddy = NULL; | |
5354 } | |
5355 | |
9944 | 5356 name_cmp = gaim_utf8_strcasecmp( |
5357 (my_buddy | |
5358 ? gaim_contact_get_alias(gaim_buddy_get_contact(my_buddy)) | |
5359 : NULL), | |
5360 (this_buddy | |
5361 ? gaim_contact_get_alias(gaim_buddy_get_contact(this_buddy)) | |
5362 : NULL)); | |
5363 | |
5364 presence_cmp = gaim_presence_compare( | |
5365 gaim_buddy_get_presence(my_buddy), | |
5366 gaim_buddy_get_presence(this_buddy)); | |
5367 | |
5368 if (this_buddy == NULL || | |
10860 | 5369 (presence_cmp < 0 || |
9944 | 5370 (presence_cmp == 0 && |
5371 (name_cmp < 0 || (name_cmp == 0 && node < n))))) | |
5372 { | |
5373 if (cur != NULL) | |
5374 { | |
7620 | 5375 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5376 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5377 return; |
9944 | 5378 } |
5379 else | |
5380 { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5381 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
9944 | 5382 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5383 return; |
7620 | 5384 } |
5422 | 5385 } |
9944 | 5386 |
5422 | 5387 g_value_unset(&val); |
9944 | 5388 } |
5389 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), | |
5390 &more_z)); | |
7620 | 5391 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5392 if (cur) { |
7620 | 5393 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5394 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5395 return; |
7620 | 5396 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5397 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5398 return; |
7620 | 5399 } |
5422 | 5400 } |
5401 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5402 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5403 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5404 GtkTreeIter more_z; |
7620 | 5405 |
5406 int log_size = 0, this_log_size = 0; | |
5407 const char *buddy_name, *this_buddy_name; | |
5408 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5409 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
|
5410 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5411 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5412 } |
7620 | 5413 |
5414 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5415 GaimBlistNode *n; |
7620 | 5416 for (n = node->child; n; n = n->next) |
8898 | 5417 log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n))->name, ((GaimBuddy*)(n))->account); |
7620 | 5418 buddy_name = gaim_contact_get_alias((GaimContact*)node); |
5419 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5420 /* we don't have a reliable way of getting the log filename | |
5421 * from the chat info in the blist, yet */ | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5422 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5423 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5424 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5425 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5426 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5427 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5428 return; |
7620 | 5429 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5430 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5431 return; |
7620 | 5432 } |
5433 | |
5434 | |
5422 | 5435 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
|
5436 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5437 return; |
5422 | 5438 } |
5439 | |
5440 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5441 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5442 GaimBlistNode *n; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5443 GaimBlistNode *n2; |
7620 | 5444 int cmp; |
5445 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5446 val.g_type = 0; |
5422 | 5447 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5448 n = g_value_get_pointer(&val); | |
7620 | 5449 this_log_size = 0; |
5450 | |
5451 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5452 for (n2 = n->child; n2; n2 = n2->next) | |
8898 | 5453 this_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n2))->name, ((GaimBuddy*)(n2))->account); |
7620 | 5454 this_buddy_name = gaim_contact_get_alias((GaimContact*)n); |
5455 } else { | |
5456 this_buddy_name = NULL; | |
5422 | 5457 } |
7620 | 5458 |
5459 cmp = gaim_utf8_strcasecmp(buddy_name, this_buddy_name); | |
5460 | |
5461 if (!GAIM_BLIST_NODE_IS_CONTACT(n) || log_size > this_log_size || | |
5462 ((log_size == this_log_size) && | |
5463 (cmp < 0 || (cmp == 0 && node < n)))) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5464 if (cur != NULL) { |
7620 | 5465 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5466 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5467 return; |
7620 | 5468 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5469 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5470 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5471 return; |
7620 | 5472 } |
5422 | 5473 } |
5474 g_value_unset(&val); | |
5475 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
7620 | 5476 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5477 if (cur != NULL) { |
7620 | 5478 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5479 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5480 return; |
7620 | 5481 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5482 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5483 return; |
7620 | 5484 } |
5485 } | |
5486 | |
5487 #endif | |
5488 | |
5489 static void | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5490 plugin_act(GtkObject *obj, GaimPluginAction *pam) |
7620 | 5491 { |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5492 if (pam && pam->callback) |
10352 | 5493 pam->callback(pam); |
5422 | 5494 } |
7620 | 5495 |
8986 | 5496 static void |
12333 | 5497 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin) |
8986 | 5498 { |
12333 | 5499 GtkWidget *menuitem; |
9015 | 5500 GaimPluginAction *action = NULL; |
12333 | 5501 GList *actions, *l; |
5502 | |
5503 actions = GAIM_PLUGIN_ACTIONS(plugin, NULL); | |
5504 | |
5505 for (l = actions; l != NULL; l = l->next) | |
5506 { | |
5507 if (l->data) | |
5508 { | |
9015 | 5509 action = (GaimPluginAction *) l->data; |
5510 action->plugin = plugin; | |
12333 | 5511 action->context = NULL; |
9015 | 5512 |
5513 menuitem = gtk_menu_item_new_with_label(action->label); | |
12333 | 5514 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
5515 | |
9015 | 5516 g_signal_connect(G_OBJECT(menuitem), "activate", |
5517 G_CALLBACK(plugin_act), action); | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5518 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5519 action, |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5520 (GDestroyNotify)gaim_plugin_action_free); |
9015 | 5521 gtk_widget_show(menuitem); |
5522 } | |
5523 else | |
5524 gaim_separator(menu); | |
5525 } | |
5526 | |
12333 | 5527 g_list_free(actions); |
8986 | 5528 } |
5529 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5530 static void |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5531 modify_account_cb(GtkWidget *widget, gpointer data) |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5532 { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5533 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, data); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5534 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5535 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5536 static void |
12330 | 5537 enable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5538 { |
12330 | 5539 GaimAccount *account = data; |
5540 const GaimSavedStatus *saved_status; | |
5541 | |
5542 saved_status = gaim_savedstatus_get_current(); | |
5543 gaim_savedstatus_activate_for_account(saved_status, account); | |
5544 | |
5545 gaim_account_set_enabled(account, GAIM_GTK_UI, TRUE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5546 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5547 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5548 static void |
12330 | 5549 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5550 { |
12330 | 5551 GaimAccount *account = data; |
5552 | |
5553 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5554 } |
8986 | 5555 |
7620 | 5556 void |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5557 gaim_gtk_blist_update_accounts_menu(void) |
7620 | 5558 { |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5559 GtkWidget *menuitem = NULL, *submenu = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5560 GList *l = NULL, *accounts = NULL; |
12330 | 5561 gboolean disabled_accounts = FALSE; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5562 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5563 if (accountmenu == NULL) |
7620 | 5564 return; |
5565 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5566 /* Clear the old Accounts menu */ |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5567 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
|
5568 menuitem = l->data; |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5569 |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5570 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
|
5571 gtk_container_remove(GTK_CONTAINER(accountmenu), |
13132
ba82cc4d1abd
[gaim-migrate @ 15494]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
5572 menuitem); |
7620 | 5573 } |
5574 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5575 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5576 char *buf = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5577 GtkWidget *image = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5578 GaimConnection *gc = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5579 GaimAccount *account = NULL; |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
5580 GaimStatus *status = NULL; |
13090 | 5581 GdkPixbuf *pixbuf = NULL; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5582 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5583 account = accounts->data; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5584 |
12330 | 5585 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5586 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5587 gaim_account_get_protocol_name(account), ")", NULL); | |
5588 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5589 g_free(buf); | |
5590 status = gaim_account_get_active_status(account); | |
13090 | 5591 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status), 0.5); |
5592 if (pixbuf != NULL) | |
5593 { | |
12330 | 5594 if (!gaim_account_is_connected(account)) |
13090 | 5595 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, |
12330 | 5596 0.0, FALSE); |
13090 | 5597 image = gtk_image_new_from_pixbuf(pixbuf); |
12330 | 5598 g_object_unref(G_OBJECT(pixbuf)); |
5599 gtk_widget_show(image); | |
5600 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5601 } | |
5602 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); | |
5603 gtk_widget_show(menuitem); | |
5604 | |
5605 submenu = gtk_menu_new(); | |
5606 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5607 gtk_widget_show(submenu); | |
5608 | |
5609 | |
12334 | 5610 menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit Account")); |
12330 | 5611 g_signal_connect(G_OBJECT(menuitem), "activate", |
5612 G_CALLBACK(modify_account_cb), account); | |
5613 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5614 gtk_widget_show(menuitem); | |
5615 | |
5616 gaim_separator(submenu); | |
5617 | |
5618 gc = gaim_account_get_connection(account); | |
5619 if (gc && GAIM_CONNECTION_IS_CONNECTED(gc)) { | |
5620 GaimPlugin *plugin = NULL; | |
5621 | |
5622 plugin = gc->prpl; | |
5623 if (GAIM_PLUGIN_HAS_ACTIONS(plugin)) { | |
5624 GList *l, *ll = NULL; | |
5625 GaimPluginAction *action = NULL; | |
5626 | |
5627 for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, gc); l; l = l->next) { | |
5628 if (l->data) { | |
5629 action = (GaimPluginAction *)l->data; | |
5630 action->plugin = plugin; | |
5631 action->context = gc; | |
5632 | |
5633 menuitem = gtk_menu_item_new_with_label(action->label); | |
5634 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5635 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5636 G_CALLBACK(plugin_act), action); | |
5637 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | |
5638 gtk_widget_show(menuitem); | |
5639 } else | |
5640 gaim_separator(submenu); | |
5641 } | |
5642 } else { | |
5643 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | |
5644 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5645 gtk_widget_set_sensitive(menuitem, FALSE); | |
5646 gtk_widget_show(menuitem); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5647 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5648 } else { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5649 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5650 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5651 gtk_widget_set_sensitive(menuitem, FALSE); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5652 gtk_widget_show(menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5653 } |
12330 | 5654 |
5655 gaim_separator(submenu); | |
5656 | |
5657 menuitem = gtk_menu_item_new_with_mnemonic(_("_Disable")); | |
5658 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5659 G_CALLBACK(disable_account_cb), account); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5660 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5661 gtk_widget_show(menuitem); |
12330 | 5662 } else { |
5663 disabled_accounts = TRUE; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5664 } |
7620 | 5665 } |
9019 | 5666 |
12330 | 5667 if(disabled_accounts) { |
5668 gaim_separator(accountmenu); | |
12338 | 5669 menuitem = gtk_menu_item_new_with_label(_("Enable Account")); |
12330 | 5670 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); |
5671 gtk_widget_show(menuitem); | |
5672 | |
5673 submenu = gtk_menu_new(); | |
5674 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5675 gtk_widget_show(submenu); | |
5676 | |
5677 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { | |
5678 char *buf = NULL; | |
5679 GtkWidget *image = NULL; | |
5680 GaimAccount *account = NULL; | |
13090 | 5681 GdkPixbuf *pixbuf = NULL; |
12330 | 5682 |
5683 account = accounts->data; | |
5684 | |
5685 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { | |
5686 | |
5687 disabled_accounts = TRUE; | |
5688 | |
5689 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5690 gaim_account_get_protocol_name(account), ")", NULL); | |
5691 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5692 g_free(buf); | |
13090 | 5693 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
5694 if (pixbuf != NULL) | |
5695 { | |
5696 if (!gaim_account_is_connected(account)) | |
5697 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); | |
5698 image = gtk_image_new_from_pixbuf(pixbuf); | |
12330 | 5699 g_object_unref(G_OBJECT(pixbuf)); |
5700 gtk_widget_show(image); | |
5701 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5702 } | |
5703 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5704 G_CALLBACK(enable_account_cb), account); | |
5705 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5706 gtk_widget_show(menuitem); | |
5707 } | |
9019 | 5708 } |
7620 | 5709 } |
5710 } | |
8986 | 5711 |
12333 | 5712 static GList *plugin_submenus = NULL; |
5713 | |
8986 | 5714 void |
5715 gaim_gtk_blist_update_plugin_actions(void) | |
5716 { | |
12333 | 5717 GtkWidget *menuitem, *submenu; |
9015 | 5718 GaimPlugin *plugin = NULL; |
8986 | 5719 GList *l; |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5720 GtkAccelGroup *accel_group; |
8986 | 5721 |
11742 | 5722 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); |
5723 | |
12333 | 5724 g_return_if_fail(pluginmenu != NULL); |
5725 | |
5726 /* Remove old plugin action submenus from the Tools menu */ | |
5727 for (l = plugin_submenus; l; l = l->next) | |
5728 { | |
5729 GList *menuitems; | |
5730 | |
5731 submenu = l->data; | |
5732 | |
5733 menuitems = gtk_container_get_children(GTK_CONTAINER(submenu)); | |
5734 while (menuitems != NULL) | |
5735 { | |
5736 GaimPluginAction *action; | |
5737 menuitem = menuitems->data; | |
5738 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | |
5739 g_free(action); | |
5740 menuitems = g_list_delete_link(menuitems, menuitems); | |
5741 } | |
5742 | |
5743 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(submenu)); | |
8986 | 5744 } |
12333 | 5745 g_list_free(plugin_submenus); |
5746 plugin_submenus = NULL; | |
5747 | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5748 accel_group = gtk_menu_get_accel_group(GTK_MENU(pluginmenu)); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5749 |
12333 | 5750 /* Add a submenu for each plugin with custom actions */ |
11742 | 5751 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5752 char *path; |
11923 | 5753 |
11742 | 5754 plugin = (GaimPlugin *) l->data; |
11923 | 5755 |
11742 | 5756 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5757 continue; | |
5758 | |
5759 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5760 continue; | |
9019 | 5761 |
13336
999571d910ed
[gaim-migrate @ 15706]
Richard Laager <rlaager@wiktel.com>
parents:
13315
diff
changeset
|
5762 menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name)); |
12333 | 5763 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); |
5764 gtk_widget_show(menuitem); | |
5765 | |
5766 plugin_submenus = g_list_append(plugin_submenus, menuitem); | |
5767 | |
5768 submenu = gtk_menu_new(); | |
5769 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5770 gtk_widget_show(submenu); | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5771 |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5772 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5773 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
|
5774 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5775 g_free(path); |
12333 | 5776 |
5777 build_plugin_actions(submenu, plugin); | |
8986 | 5778 } |
5779 } | |
11796 | 5780 |
12246 | 5781 static void |
5782 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
11796 | 5783 { |
5784 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
11923 | 5785 { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5786 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5787 |
11796 | 5788 gaim_gtk_blist_sort_method_set(id); |
11923 | 5789 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5790 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5791 gaim_gtk_clear_cursor(gtkblist->window); |
11923 | 5792 } |
11796 | 5793 } |
5794 | |
5795 void | |
5796 gaim_gtk_blist_update_sort_methods(void) | |
5797 { | |
5798 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5799 GaimGtkBlistSortMethod *method = NULL; | |
5800 GList *l; | |
5801 GSList *sl = NULL; | |
5802 GtkWidget *sortmenu; | |
11797 | 5803 const char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); |
11796 | 5804 |
5805 if (gtkblist == NULL) | |
5806 return; | |
5807 | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
5808 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies")); |
11796 | 5809 |
5810 if (sortmenu == NULL) | |
5811 return; | |
5812 | |
5813 /* Clear the old menu */ | |
5814 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5815 menuitem = l->data; | |
5816 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5817 } | |
11923 | 5818 |
11796 | 5819 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { |
5820 method = (GaimGtkBlistSortMethod *) l->data; | |
5821 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5822 if (!strcmp(m, method->id)) | |
5823 activeitem = menuitem; | |
5824 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5825 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5826 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5827 G_CALLBACK(sortmethod_act), method->id); | |
11923 | 5828 gtk_widget_show(menuitem); |
11796 | 5829 } |
5830 if (activeitem) | |
5831 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5832 } |