Mercurial > pidgin
annotate src/gtkblist.c @ 13547:689228bcf920
[gaim-migrate @ 15924]
Bj??rn Voigt found two untranslated strings.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 22 Mar 2006 06:20:14 +0000 |
parents | cfc2f7fcb3dd |
children | bbbde2f5c03b |
rev | line source |
---|---|
5228 | 1 /* |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
2 * @file gtkblist.c GTK+ BuddyList API |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
3 * @ingroup gtkui |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
4 * |
5228 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5228 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
7620 | 28 |
29 #include "account.h" | |
9015 | 30 #include "connection.h" |
7620 | 31 #include "core.h" |
32 #include "debug.h" | |
33 #include "notify.h" | |
34 #include "prpl.h" | |
35 #include "prefs.h" | |
8986 | 36 #include "plugin.h" |
7620 | 37 #include "request.h" |
38 #include "signals.h" | |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
39 #include "gtkstock.h" |
7620 | 40 #include "util.h" |
41 | |
42 #include "gtkaccount.h" | |
43 #include "gtkblist.h" | |
44 #include "gtkconv.h" | |
45 #include "gtkdebug.h" | |
9709 | 46 #include "gtkdialogs.h" |
7620 | 47 #include "gtkft.h" |
48 #include "gtklog.h" | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
49 #include "gtkmenutray.h" |
7620 | 50 #include "gtkpounce.h" |
11740 | 51 #include "gtkplugin.h" |
7620 | 52 #include "gtkprefs.h" |
53 #include "gtkprivacy.h" | |
8113 | 54 #include "gtkroomlist.h" |
10643 | 55 #include "gtkstatusbox.h" |
7620 | 56 #include "gtkutils.h" |
57 | |
5228 | 58 #include <gdk/gdkkeysyms.h> |
59 #include <gtk/gtk.h> | |
7620 | 60 #include <gdk/gdk.h> |
61 | |
62 typedef struct | |
63 { | |
64 GaimAccount *account; | |
65 | |
66 GtkWidget *window; | |
67 GtkWidget *combo; | |
68 GtkWidget *entry; | |
69 GtkWidget *entry_for_alias; | |
70 GtkWidget *account_box; | |
71 | |
72 } GaimGtkAddBuddyData; | |
73 | |
74 typedef struct | |
75 { | |
9811 | 76 GaimAccount *account; |
9812 | 77 gchar *default_chat_name; |
9811 | 78 |
79 GtkWidget *window; | |
7620 | 80 GtkWidget *account_menu; |
81 GtkWidget *alias_entry; | |
82 GtkWidget *group_combo; | |
83 GtkWidget *entries_box; | |
84 GtkSizeGroup *sg; | |
85 | |
86 GList *entries; | |
87 | |
88 } GaimGtkAddChatData; | |
89 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
90 typedef struct |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
91 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
92 GaimAccount *account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
93 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
94 GtkWidget *window; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
95 GtkWidget *account_menu; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
96 GtkWidget *entries_box; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
97 GtkSizeGroup *sg; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
98 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
99 GList *entries; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
100 } GaimGtkJoinChatData; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
101 |
7620 | 102 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
103 static GtkWidget *accountmenu = NULL; |
5228 | 104 |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
105 static guint visibility_manager_count = 0; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
106 static gboolean gtk_blist_obscured = FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
107 |
11796 | 108 static GList *gaim_gtk_blist_sort_methods = NULL; |
5422 | 109 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
110 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
7620 | 111 |
112 /* The functions we use for sorting aren't available in gtk 2.0.x, and | |
113 * segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */ | |
114 #if GTK_CHECK_VERSION(2,2,1) | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
115 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
116 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
117 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); |
7620 | 118 #endif |
119 static GaimGtkBuddyList *gtkblist = NULL; | |
5228 | 120 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
121 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); |
5228 | 122 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); |
7620 | 123 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); |
12530 | 124 static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
125 static const char *item_factory_translate_func (const char *path, gpointer func_data); |
5273 | 126 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); |
7620 | 127 static void redo_buddy_list(GaimBuddyList *list, gboolean remove); |
128 static void gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node); | |
129 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
130 static void gaim_gtk_blist_tooltip_destroy(void); |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
131 |
5256 | 132 struct _gaim_gtk_blist_node { |
133 GtkTreeRowReference *row; | |
7620 | 134 gboolean contact_expanded; |
11910 | 135 gboolean recent_signonoff; |
136 gint recent_signonoff_timer; | |
5256 | 137 }; |
138 | |
10968
e0d5038fbb7e
[gaim-migrate @ 12789]
Christopher O'Brien <siege@pidgin.im>
parents:
10924
diff
changeset
|
139 |
10118 | 140 static char dim_grey_string[8] = ""; |
10144 | 141 static char *dim_grey() |
10118 | 142 { |
143 if (!gtkblist) | |
144 return "dim grey"; | |
145 if (!dim_grey_string[0]) { | |
146 GtkStyle *style = gtk_widget_get_style(gtkblist->treeview); | |
147 snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x", | |
148 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
149 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
150 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
151 } | |
152 return dim_grey_string; | |
153 } | |
10144 | 154 |
5228 | 155 /*************************************************** |
156 * Callbacks * | |
157 ***************************************************/ | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
158 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
159 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
160 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
161 gtk_blist_obscured = TRUE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
162 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
163 gtk_blist_obscured = FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
164 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
165 /* continue to handle event normally */ |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
166 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
167 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
168 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
169 static gboolean gtk_blist_window_state_cb(GtkWidget *w, GdkEventWindowState *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
170 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
171 if(event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
172 if(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
173 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", FALSE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
174 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
175 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
176 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
177 |
12279 | 178 if(event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { |
179 if(event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) | |
180 gaim_prefs_set_bool("/gaim/gtk/blist/list_maximized", TRUE); | |
181 else | |
182 gaim_prefs_set_bool("/gaim/gtk/blist/list_maximized", FALSE); | |
183 } | |
184 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
185 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
186 } |
5228 | 187 |
188 static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) | |
189 { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
190 if(visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
191 gaim_blist_set_visible(FALSE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
192 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
193 gaim_core_quit(); |
5228 | 194 |
195 /* we handle everything, event should not propogate further */ | |
196 return TRUE; | |
197 } | |
198 | |
199 static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) | |
200 { | |
201 /* unfortunately GdkEventConfigure ignores the window gravity, but * | |
202 * the only way we have of setting the position doesn't. we have to * | |
7620 | 203 * call get_position because it does pay attention to the gravity. * |
204 * this is inefficient and I agree it sucks, but it's more likely * | |
205 * to work correctly. - Robot101 */ | |
5228 | 206 gint x, y; |
207 | |
208 /* check for visibility because when we aren't visible, this will * | |
209 * give us bogus (0,0) coordinates. - xOr */ | |
7620 | 210 if (GTK_WIDGET_VISIBLE(w)) |
5228 | 211 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
7620 | 212 else |
213 return FALSE; /* carry on normally */ | |
214 | |
215 /* don't save if nothing changed */ | |
216 if (x == gaim_prefs_get_int("/gaim/gtk/blist/x") && | |
217 y == gaim_prefs_get_int("/gaim/gtk/blist/y") && | |
218 event->width == gaim_prefs_get_int("/gaim/gtk/blist/width") && | |
219 event->height == gaim_prefs_get_int("/gaim/gtk/blist/height")) { | |
220 | |
221 return FALSE; /* carry on normally */ | |
5228 | 222 } |
223 | |
7620 | 224 /* don't save off-screen positioning */ |
225 if (x + event->width < 0 || | |
9811 | 226 y + event->height < 0 || |
227 x > gdk_screen_width() || | |
228 y > gdk_screen_height()) { | |
7620 | 229 |
230 return FALSE; /* carry on normally */ | |
231 } | |
232 | |
12279 | 233 /* ignore changes when maximized */ |
234 if(gaim_prefs_get_bool("/gaim/gtk/blist/list_maximized")) | |
235 return FALSE; | |
236 | |
7620 | 237 /* store the position */ |
238 gaim_prefs_set_int("/gaim/gtk/blist/x", x); | |
239 gaim_prefs_set_int("/gaim/gtk/blist/y", y); | |
240 gaim_prefs_set_int("/gaim/gtk/blist/width", event->width); | |
241 gaim_prefs_set_int("/gaim/gtk/blist/height", event->height); | |
242 | |
5228 | 243 /* continue to handle event normally */ |
244 return FALSE; | |
245 } | |
246 | |
7620 | 247 static void gtk_blist_menu_info_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 248 { |
249 serv_get_info(b->account->gc, b->name); | |
250 } | |
251 | |
7620 | 252 static void gtk_blist_menu_im_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 253 { |
9728 | 254 gaim_gtkdialogs_im_with_user(b->account, b->name); |
5228 | 255 } |
256 | |
9466 | 257 static void gtk_blist_menu_send_file_cb(GtkWidget *w, GaimBuddy *b) |
258 { | |
259 serv_send_file(b->account->gc, b->name, NULL); | |
260 } | |
261 | |
7620 | 262 static void gtk_blist_menu_autojoin_cb(GtkWidget *w, GaimChat *chat) |
263 { | |
7693 | 264 gaim_blist_node_set_bool((GaimBlistNode*)chat, "gtk-autojoin", |
265 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))); | |
7620 | 266 } |
267 | |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
268 static void gtk_blist_join_chat(GaimChat *chat) |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
269 { |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
270 GaimConversation *conv; |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
271 |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
272 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
273 gaim_chat_get_name(chat), |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
274 chat->account); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
275 |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
276 if (conv != NULL) |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
277 gaim_gtkconv_present_conversation(conv); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
278 |
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
279 serv_join_chat(chat->account->gc, chat->components); |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
280 } |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
281 |
7620 | 282 static void gtk_blist_menu_join_cb(GtkWidget *w, GaimChat *chat) |
5228 | 283 { |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
284 gtk_blist_join_chat(chat); |
5234 | 285 } |
286 | |
11016 | 287 static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1, |
288 char *arg2, gpointer nada) | |
289 { | |
290 GtkTreeIter iter; | |
291 GtkTreePath *path; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
292 GValue val; |
11016 | 293 GaimBlistNode *node; |
294 | |
295 path = gtk_tree_path_new_from_string (arg1); | |
296 gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
297 gtk_tree_path_free (path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
298 val.g_type = 0; |
11016 | 299 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
300 node = g_value_get_pointer(&val); | |
301 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), TRUE); | |
302 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", FALSE, NULL); | |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
303 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
304 switch (node->type) |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
305 { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
306 case GAIM_BLIST_CONTACT_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
307 { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
308 GaimContact *contact = (GaimContact *)node; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
309 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
310 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
311 if (contact->alias || gtknode->contact_expanded) |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
312 gaim_blist_alias_contact(contact, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
313 else |
12478
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
314 { |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
315 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
316 gaim_blist_alias_buddy(buddy, arg2); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
317 serv_alias_buddy(buddy); |
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
318 } |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
319 } |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
320 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
321 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
322 case GAIM_BLIST_BUDDY_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
323 gaim_blist_alias_buddy((GaimBuddy*)node, arg2); |
12478
8489040cf97b
[gaim-migrate @ 14789]
Richard Laager <rlaager@wiktel.com>
parents:
12474
diff
changeset
|
324 serv_alias_buddy((GaimBuddy *)node); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
325 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
326 case GAIM_BLIST_GROUP_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
327 gaim_blist_rename_group((GaimGroup*)node, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
328 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
329 case GAIM_BLIST_CHAT_NODE: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
330 gaim_blist_alias_chat((GaimChat*)node, arg2); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
331 break; |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
332 default: |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
333 break; |
11016 | 334 } |
335 } | |
336 | |
5234 | 337 static void gtk_blist_menu_alias_cb(GtkWidget *w, GaimBlistNode *node) |
338 { | |
11016 | 339 GtkTreeIter iter; |
340 GtkTreePath *path; | |
11258 | 341 const char *text = NULL; |
13509
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
342 char *esc; |
11494 | 343 |
11258 | 344 if (!(get_iter_from_node(node, &iter))) { |
11016 | 345 /* This is either a bug, or the buddy is in a collapsed contact */ |
346 node = node->parent; | |
347 if (!get_iter_from_node(node, &iter)) | |
348 /* Now it's definitely a bug */ | |
349 return; | |
350 } | |
11258 | 351 |
352 switch (node->type) { | |
353 case GAIM_BLIST_BUDDY_NODE: | |
354 text = gaim_buddy_get_alias((GaimBuddy *)node); | |
355 break; | |
356 case GAIM_BLIST_CONTACT_NODE: | |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
357 text = gaim_contact_get_alias((GaimContact *)node); |
11258 | 358 break; |
359 case GAIM_BLIST_GROUP_NODE: | |
360 text = ((GaimGroup *)node)->name; | |
361 break; | |
362 case GAIM_BLIST_CHAT_NODE: | |
363 text = gaim_chat_get_name((GaimChat *)node); | |
364 break; | |
365 default: | |
366 g_return_if_reached(); | |
367 } | |
368 | |
13509
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
369 esc = g_markup_escape_text(text, -1); |
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
370 gtk_tree_store_set(gtkblist->treemodel, &iter, NAME_COLUMN, esc, -1); |
56abb67edec9
[gaim-migrate @ 15885]
Richard Laager <rlaager@wiktel.com>
parents:
13478
diff
changeset
|
371 g_free(esc); |
11258 | 372 |
11016 | 373 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
374 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); | |
375 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
376 gtk_widget_grab_focus(gtkblist->treeview); | |
377 gtk_tree_view_set_cursor(GTK_TREE_VIEW(gtkblist->treeview), path, gtkblist->text_column, TRUE); | |
378 gtk_tree_path_free(path); | |
5228 | 379 } |
380 | |
7620 | 381 static void gtk_blist_menu_bp_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 382 { |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12133
diff
changeset
|
383 gaim_gtk_pounce_editor_show(b->account, b->name, NULL); |
5228 | 384 } |
385 | |
9917 | 386 static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 387 { |
9917 | 388 GaimLogType type; |
389 GaimAccount *account; | |
390 char *name = NULL; | |
10663 | 391 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
392 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
393 |
9917 | 394 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
395 GaimBuddy *b = (GaimBuddy*) node; | |
396 type = GAIM_LOG_IM; | |
397 name = g_strdup(b->name); | |
398 account = b->account; | |
399 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { | |
400 GaimChat *c = (GaimChat*) node; | |
401 GaimPluginProtocolInfo *prpl_info = NULL; | |
402 type = GAIM_LOG_CHAT; | |
403 account = c->account; | |
404 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account))); | |
405 if (prpl_info && prpl_info->get_chat_name) { | |
406 name = prpl_info->get_chat_name(c->components); | |
407 } | |
10663 | 408 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
409 gaim_gtk_log_show_contact((GaimContact *)node); | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
410 gaim_gtk_clear_cursor(gtkblist->window); |
10663 | 411 return; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
412 } else { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
413 gaim_gtk_clear_cursor(gtkblist->window); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
414 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
415 /* This callback should not have been registered for a node |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
416 * that doesn't match the type of one of the blocks above. */ |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
417 g_return_if_reached(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
418 } |
9917 | 419 |
420 if (name && account) { | |
421 gaim_gtk_log_show(type, name, account); | |
422 g_free(name); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12226
diff
changeset
|
423 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
424 gaim_gtk_clear_cursor(gtkblist->window); |
9917 | 425 } |
7620 | 426 } |
427 | |
5228 | 428 static void gtk_blist_show_systemlog_cb() |
429 { | |
8573 | 430 gaim_gtk_syslog_show(); |
5228 | 431 } |
432 | |
433 static void gtk_blist_show_onlinehelp_cb() | |
434 { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10229
diff
changeset
|
435 gaim_notify_uri(NULL, GAIM_WEBSITE "documentation.php"); |
5228 | 436 } |
437 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
438 static void |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
439 do_join_chat(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
440 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
441 if (data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
442 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
443 GHashTable *components = |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
444 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
445 GList *tmp; |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
446 GaimChat *chat; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
447 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
448 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
449 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
450 if (g_object_get_data(tmp->data, "is_spin")) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
451 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
452 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
453 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
454 g_strdup_printf("%d", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
455 gtk_spin_button_get_value_as_int(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
456 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
457 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
458 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
459 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
460 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
461 g_strdup(gtk_entry_get_text(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
462 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
463 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
464 |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
465 chat = gaim_chat_new(data->account, NULL, components); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
466 gtk_blist_join_chat(chat); |
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
467 gaim_blist_remove_chat(chat); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
468 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
469 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
470 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
471 static void |
8940 | 472 do_joinchat(GtkWidget *dialog, int id, GaimGtkJoinChatData *info) |
473 { | |
474 switch(id) | |
475 { | |
476 case GTK_RESPONSE_OK: | |
477 do_join_chat(info); | |
478 | |
479 break; | |
480 } | |
481 | |
482 gtk_widget_destroy(GTK_WIDGET(dialog)); | |
483 g_list_free(info->entries); | |
484 g_free(info); | |
485 } | |
486 | |
10475 | 487 /* |
488 * Check the values of all the text entry boxes. If any required input | |
489 * strings are empty then don't allow the user to click on "OK." | |
490 */ | |
491 static void | |
492 joinchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
493 { | |
494 GaimGtkJoinChatData *data; | |
495 GList *tmp; | |
496 const char *text; | |
497 gboolean required; | |
498 gboolean sensitive = TRUE; | |
499 | |
500 data = user_data; | |
501 | |
502 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
503 { | |
504 if (!g_object_get_data(tmp->data, "is_spin")) | |
505 { | |
506 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
507 text = gtk_entry_get_text(tmp->data); | |
508 if (required && (*text == '\0')) | |
509 sensitive = FALSE; | |
510 } | |
511 } | |
512 | |
513 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
514 } | |
515 | |
8940 | 516 static void |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
517 rebuild_joinchat_entries(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
518 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
519 GaimConnection *gc; |
9959 | 520 GList *list = NULL, *tmp = NULL; |
9770 | 521 GHashTable *defaults = NULL; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
522 struct proto_chat_entry *pce; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
523 gboolean focus = TRUE; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
524 |
10127 | 525 g_return_if_fail(data->account != NULL); |
526 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
527 gc = gaim_account_get_connection(data->account); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
528 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
529 while (GTK_BOX(data->entries_box)->children) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
530 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
531 gtk_container_remove(GTK_CONTAINER(data->entries_box), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
532 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
533 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
534 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
535 if (data->entries != NULL) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
536 g_list_free(data->entries); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
537 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
538 data->entries = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
539 |
9987 | 540 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
9959 | 541 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
542 |
9770 | 543 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
544 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, NULL); | |
545 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
546 for (tmp = list; tmp; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
547 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
548 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
549 GtkWidget *rowbox; |
10475 | 550 GtkWidget *input; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
551 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
552 pce = tmp->data; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
553 |
11243 | 554 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
555 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
556 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
557 label = gtk_label_new_with_mnemonic(pce->label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
558 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
559 gtk_size_group_add_widget(data->sg, label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
560 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
561 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
562 if (pce->is_int) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
563 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
564 GtkObject *adjust; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
565 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
566 1, 10, 10); |
10475 | 567 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
568 gtk_widget_set_size_request(input, 50, -1); | |
569 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
570 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
571 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
572 { |
9770 | 573 char *value; |
10475 | 574 input = gtk_entry_new(); |
575 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9770 | 576 value = g_hash_table_lookup(defaults, pce->identifier); |
577 if (value != NULL) | |
10475 | 578 gtk_entry_set_text(GTK_ENTRY(input), value); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
579 if (pce->secret) |
11986 | 580 { |
10475 | 581 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 582 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
583 } | |
10475 | 584 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
585 g_signal_connect(G_OBJECT(input), "changed", | |
586 G_CALLBACK(joinchat_set_sensitive_if_input_cb), data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
587 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
588 |
10475 | 589 /* Do the following for any type of input widget */ |
590 if (focus) | |
591 { | |
592 gtk_widget_grab_focus(input); | |
593 focus = FALSE; | |
594 } | |
595 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
596 gaim_set_accessible_label(input, label); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
597 g_object_set_data(G_OBJECT(input), "identifier", (gpointer)pce->identifier); |
10475 | 598 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); |
599 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
600 data->entries = g_list_append(data->entries, input); | |
601 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
602 g_free(pce); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
603 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
604 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
605 g_list_free(list); |
10475 | 606 g_hash_table_destroy(defaults); |
607 | |
608 /* Set whether the "OK" button should be clickable initially */ | |
609 joinchat_set_sensitive_if_input_cb(NULL, data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
610 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
611 gtk_widget_show_all(data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
612 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
613 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
614 static void |
8940 | 615 joinchat_select_account_cb(GObject *w, GaimAccount *account, |
10475 | 616 GaimGtkJoinChatData *data) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
617 { |
9460 | 618 if (strcmp(gaim_account_get_protocol_id(data->account), |
10475 | 619 gaim_account_get_protocol_id(account)) == 0) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
620 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
621 data->account = account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
622 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
623 else |
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 data->account = account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
626 rebuild_joinchat_entries(data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
627 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
628 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
629 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
630 static gboolean |
9987 | 631 chat_account_filter_func(GaimAccount *account) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
632 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
633 GaimConnection *gc = gaim_account_get_connection(account); |
8940 | 634 GaimPluginProtocolInfo *prpl_info = NULL; |
635 | |
636 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
637 | |
638 return (prpl_info->chat_info != NULL); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
639 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
640 |
8940 | 641 gboolean |
642 gaim_gtk_blist_joinchat_is_showable() | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
643 { |
8940 | 644 GList *c; |
645 GaimConnection *gc; | |
646 | |
647 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { | |
648 gc = c->data; | |
649 | |
9987 | 650 if (chat_account_filter_func(gaim_connection_get_account(gc))) |
8940 | 651 return TRUE; |
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 |
8940 | 654 return FALSE; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
655 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
656 |
8305
57bdd25752c1
[gaim-migrate @ 9029]
Christian Hammond <chipx86@chipx86.com>
parents:
8303
diff
changeset
|
657 void |
8940 | 658 gaim_gtk_blist_joinchat_show(void) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
659 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
660 GtkWidget *hbox, *vbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
661 GtkWidget *rowbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
662 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
663 GaimGtkBuddyList *gtkblist; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
664 GtkWidget *img = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
665 GaimGtkJoinChatData *data = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
666 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
667 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
668 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
669 GTK_ICON_SIZE_DIALOG); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
670 data = g_new0(GaimGtkJoinChatData, 1); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
671 |
8975 | 672 data->window = gtk_dialog_new_with_buttons(_("Join a Chat"), |
673 NULL, GTK_DIALOG_NO_SEPARATOR, | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
674 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
8308 | 675 GAIM_STOCK_CHAT, GTK_RESPONSE_OK, NULL); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
676 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); |
11243 | 677 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
|
678 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 679 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
|
680 gtk_container_set_border_width( |
11243 | 681 GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); |
8975 | 682 gtk_window_set_role(GTK_WINDOW(data->window), "join_chat"); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
683 |
11243 | 684 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
685 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
686 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
687 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
688 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
689 vbox = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
690 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
691 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
692 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
693 label = gtk_label_new(_("Please enter the appropriate information " |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
694 "about the chat you would like to join.\n")); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
695 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
696 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
697 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
698 |
11243 | 699 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
700 gtk_box_pack_start(GTK_BOX(vbox), rowbox, TRUE, TRUE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
701 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
702 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
703 |
8940 | 704 label = gtk_label_new_with_mnemonic(_("_Account:")); |
705 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
706 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
707 gtk_size_group_add_widget(data->sg, label); | |
708 | |
709 data->account_menu = gaim_gtk_account_option_menu_new(NULL, FALSE, | |
710 G_CALLBACK(joinchat_select_account_cb), | |
9987 | 711 chat_account_filter_func, data); |
8940 | 712 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
713 gtk_label_set_mnemonic_widget(GTK_LABEL(label), | |
714 GTK_WIDGET(data->account_menu)); | |
715 gaim_set_accessible_label (data->account_menu, label); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
716 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
717 data->entries_box = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
718 gtk_container_add(GTK_CONTAINER(vbox), data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
719 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
720 |
8940 | 721 data->account = gaim_gtk_account_option_menu_get_selected(data->account_menu); |
722 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
723 rebuild_joinchat_entries(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_signal_connect(G_OBJECT(data->window), "response", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
726 G_CALLBACK(do_joinchat), data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
727 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
728 g_object_unref(data->sg); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
729 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
730 gtk_widget_show_all(data->window); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
731 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
732 |
5228 | 733 static void gtk_blist_row_expanded_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { |
734 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
735 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
736 |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
737 val.g_type = 0; |
5228 | 738 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); |
739 | |
740 node = g_value_get_pointer(&val); | |
741 | |
742 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 743 gaim_blist_node_set_bool(node, "collapsed", FALSE); |
5228 | 744 } |
745 } | |
746 | |
747 static void gtk_blist_row_collapsed_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { | |
748 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
749 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
750 |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
751 val.g_type = 0; |
5228 | 752 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); |
753 | |
754 node = g_value_get_pointer(&val); | |
755 | |
756 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 757 gaim_blist_node_set_bool(node, "collapsed", TRUE); |
7620 | 758 } else if(GAIM_BLIST_NODE_IS_CONTACT(node)) { |
759 gaim_gtk_blist_collapse_contact_cb(NULL, node); | |
5228 | 760 } |
761 } | |
762 | |
763 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { | |
764 GaimBlistNode *node; | |
765 GtkTreeIter iter; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
766 GValue val; |
5228 | 767 |
768 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
769 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
770 val.g_type = 0; |
5228 | 771 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
772 node = g_value_get_pointer(&val); | |
773 | |
7620 | 774 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { |
775 GaimBuddy *buddy; | |
776 | |
777 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
778 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
779 else | |
780 buddy = (GaimBuddy*)node; | |
781 | |
9728 | 782 gaim_gtkdialogs_im_with_user(buddy->account, buddy->name); |
5234 | 783 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
12576
1246935dd047
[gaim-migrate @ 14898]
Richard Laager <rlaager@wiktel.com>
parents:
12569
diff
changeset
|
784 gtk_blist_join_chat((GaimChat *)node); |
5228 | 785 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
786 if (gtk_tree_view_row_expanded(tv, path)) | |
787 gtk_tree_view_collapse_row(tv, path); | |
788 else | |
789 gtk_tree_view_expand_row(tv,path,FALSE); | |
790 } | |
791 } | |
792 | |
5234 | 793 static void gaim_gtk_blist_add_chat_cb() |
794 { | |
795 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
796 GtkTreeIter iter; | |
797 GaimBlistNode *node; | |
798 | |
799 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
800 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 801 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
9754 | 802 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent->parent, NULL, NULL); |
7620 | 803 if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) |
9754 | 804 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent, NULL, NULL); |
5234 | 805 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
9754 | 806 gaim_blist_request_add_chat(NULL, (GaimGroup*)node, NULL, NULL); |
5234 | 807 } |
808 else { | |
9754 | 809 gaim_blist_request_add_chat(NULL, NULL, NULL, NULL); |
5234 | 810 } |
811 } | |
812 | |
5228 | 813 static void gaim_gtk_blist_add_buddy_cb() |
814 { | |
815 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
816 GtkTreeIter iter; | |
817 GaimBlistNode *node; | |
818 | |
819 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
820 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 821 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
822 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent->parent)->name, | |
823 NULL); | |
824 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) | |
825 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
826 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent)->name, NULL); | |
827 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
828 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node)->name, NULL); | |
829 } | |
5228 | 830 } |
831 else { | |
7620 | 832 gaim_blist_request_add_buddy(NULL, NULL, NULL, NULL); |
833 } | |
834 } | |
835 | |
836 static void | |
837 gaim_gtk_blist_remove_cb (GtkWidget *w, GaimBlistNode *node) | |
838 { | |
839 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
9730 | 840 gaim_gtkdialogs_remove_buddy((GaimBuddy*)node); |
7620 | 841 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
9730 | 842 gaim_gtkdialogs_remove_chat((GaimChat*)node); |
7620 | 843 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
9730 | 844 gaim_gtkdialogs_remove_group((GaimGroup*)node); |
7620 | 845 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
9730 | 846 gaim_gtkdialogs_remove_contact((GaimContact*)node); |
5228 | 847 } |
848 } | |
849 | |
850 static void | |
7620 | 851 gaim_gtk_blist_expand_contact_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 852 { |
7620 | 853 struct _gaim_gtk_blist_node *gtknode; |
9632 | 854 GtkTreeIter iter, parent; |
7620 | 855 GaimBlistNode *bnode; |
10325 | 856 GtkTreePath *path; |
7620 | 857 |
858 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
859 return; | |
860 | |
861 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
862 | |
863 gtknode->contact_expanded = TRUE; | |
864 | |
865 for(bnode = node->child; bnode; bnode = bnode->next) { | |
866 gaim_gtk_blist_update(NULL, bnode); | |
867 } | |
10353 | 868 |
9632 | 869 /* This ensures that the bottom buddy is visible, i.e. not scrolled off the alignment */ |
870 get_iter_from_node(node, &parent); | |
10353 | 871 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(gtkblist->treemodel), &iter, &parent, |
9811 | 872 gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtkblist->treemodel), &parent) -1); |
9632 | 873 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
874 /* Let the treeview draw so it knows where to scroll */ | |
875 while (gtk_events_pending()) | |
876 gtk_main_iteration(); | |
10353 | 877 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); |
878 | |
9632 | 879 |
7620 | 880 gaim_gtk_blist_update(NULL, node); |
9632 | 881 gtk_tree_path_free(path); |
7620 | 882 } |
883 | |
884 static void | |
885 gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node) | |
886 { | |
887 GaimBlistNode *bnode; | |
888 struct _gaim_gtk_blist_node *gtknode; | |
889 | |
890 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
891 return; | |
892 | |
893 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
894 | |
895 gtknode->contact_expanded = FALSE; | |
896 | |
897 for(bnode = node->child; bnode; bnode = bnode->next) { | |
898 gaim_gtk_blist_update(NULL, bnode); | |
5228 | 899 } |
900 } | |
901 | |
9051 | 902 void |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
903 gaim_gtk_append_blist_node_proto_menu(GtkWidget *menu, GaimConnection *gc, |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
904 GaimBlistNode *node) |
9030 | 905 { |
906 GList *l, *ll; | |
907 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
908 | |
909 if(!prpl_info || !prpl_info->blist_node_menu) | |
910 return; | |
911 | |
912 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
|
913 GaimMenuAction *act = (GaimMenuAction *) l->data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
914 gaim_gtk_append_menu_action(menu, act, node); |
9030 | 915 } |
916 g_list_free(ll); | |
917 } | |
918 | |
9051 | 919 void |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
920 gaim_gtk_append_blist_node_extended_menu(GtkWidget *menu, GaimBlistNode *node) |
9030 | 921 { |
922 GList *l, *ll; | |
923 | |
924 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
|
925 GaimMenuAction *act = (GaimMenuAction *) l->data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12883
diff
changeset
|
926 gaim_gtk_append_menu_action(menu, act, node); |
9030 | 927 } |
928 g_list_free(ll); | |
929 } | |
930 | |
9774 | 931 void |
10484 | 932 gaim_gtk_blist_make_buddy_menu(GtkWidget *menu, GaimBuddy *buddy, gboolean sub) { |
9774 | 933 GaimPluginProtocolInfo *prpl_info; |
10663 | 934 GaimContact *contact; |
935 gboolean contact_expanded = FALSE; | |
9774 | 936 |
937 g_return_if_fail(menu); | |
938 g_return_if_fail(buddy); | |
939 | |
940 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); | |
941 | |
10663 | 942 contact = gaim_buddy_get_contact(buddy); |
943 if (contact) { | |
944 contact_expanded = ((struct _gaim_gtk_blist_node *)(((GaimBlistNode*)contact)->ui_data))->contact_expanded; | |
945 } | |
946 | |
7620 | 947 if (prpl_info && prpl_info->get_info) { |
8137 | 948 gaim_new_item_from_stock(menu, _("Get _Info"), GAIM_STOCK_INFO, |
9774 | 949 G_CALLBACK(gtk_blist_menu_info_cb), buddy, 0, 0, NULL); |
7620 | 950 } |
8137 | 951 gaim_new_item_from_stock(menu, _("I_M"), GAIM_STOCK_IM, |
9774 | 952 G_CALLBACK(gtk_blist_menu_im_cb), buddy, 0, 0, NULL); |
9466 | 953 if (prpl_info && prpl_info->send_file) { |
9774 | 954 if (!prpl_info->can_receive_file || |
955 prpl_info->can_receive_file(buddy->account->gc, buddy->name)) | |
956 { | |
957 gaim_new_item_from_stock(menu, _("_Send File"), | |
958 GAIM_STOCK_FILE_TRANSFER, | |
959 G_CALLBACK(gtk_blist_menu_send_file_cb), | |
960 buddy, 0, 0, NULL); | |
9466 | 961 } |
962 } | |
12024 | 963 |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
964 gaim_new_item_from_stock(menu, _("Add Buddy _Pounce"), GAIM_STOCK_POUNCE, |
9774 | 965 G_CALLBACK(gtk_blist_menu_bp_cb), buddy, 0, 0, NULL); |
10663 | 966 |
967 if(((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
968 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 969 G_CALLBACK(gtk_blist_menu_showlog_cb), |
970 contact, 0, 0, NULL); | |
971 } else if (!sub) { | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
972 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 973 G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL); |
974 } | |
9774 | 975 |
976 gaim_gtk_append_blist_node_proto_menu(menu, buddy->account->gc, | |
977 (GaimBlistNode *)buddy); | |
978 gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); | |
7620 | 979 |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
980 if (((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
981 gaim_separator(menu); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
982 |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
983 gaim_new_item_from_stock(menu, _("Alias..."), GAIM_STOCK_ALIAS, |
9925 | 984 G_CALLBACK(gtk_blist_menu_alias_cb), |
10663 | 985 contact, 0, 0, NULL); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
986 gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
9925 | 987 G_CALLBACK(gaim_gtk_blist_remove_cb), |
10663 | 988 contact, 0, 0, NULL); |
12319
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
989 } else if (!sub || contact_expanded) { |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
990 gaim_separator(menu); |
7630a95f3b8b
[gaim-migrate @ 14623]
Richard Laager <rlaager@wiktel.com>
parents:
12302
diff
changeset
|
991 |
9925 | 992 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
993 G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); | |
994 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
995 G_CALLBACK(gaim_gtk_blist_remove_cb), buddy, | |
996 0, 0, NULL); | |
997 } | |
7620 | 998 } |
999 | |
9774 | 1000 static gboolean |
1001 gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data) { | |
7620 | 1002 GaimBlistNode *node; |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1003 GValue val; |
7620 | 1004 GtkTreeIter iter; |
1005 GtkTreeSelection *sel; | |
1006 | |
1007 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1008 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1009 return FALSE; | |
1010 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1011 val.g_type = 0; |
7620 | 1012 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, |
1013 NODE_COLUMN, &val); | |
1014 node = g_value_get_pointer(&val); | |
1015 | |
1016 if(event->state & GDK_CONTROL_MASK && | |
1017 (event->keyval == 'o' || event->keyval == 'O')) { | |
1018 GaimBuddy *buddy; | |
1019 | |
1020 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1021 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1022 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1023 buddy = (GaimBuddy*)node; | |
1024 } else { | |
1025 return FALSE; | |
1026 } | |
1027 if(buddy) | |
1028 serv_get_info(buddy->account->gc, buddy->name); | |
1029 } | |
1030 | |
1031 return FALSE; | |
1032 } | |
1033 | |
9013 | 1034 |
8143 | 1035 static GtkWidget * |
8952 | 1036 create_group_menu (GaimBlistNode *node, GaimGroup *g) |
8143 | 1037 { |
1038 GtkWidget *menu; | |
11988 | 1039 GtkWidget *item; |
8143 | 1040 |
1041 menu = gtk_menu_new(); | |
1042 gaim_new_item_from_stock(menu, _("Add a _Buddy"), GTK_STOCK_ADD, | |
1043 G_CALLBACK(gaim_gtk_blist_add_buddy_cb), node, 0, 0, NULL); | |
11988 | 1044 item = gaim_new_item_from_stock(menu, _("Add a C_hat"), GTK_STOCK_ADD, |
8143 | 1045 G_CALLBACK(gaim_gtk_blist_add_chat_cb), node, 0, 0, NULL); |
11988 | 1046 gtk_widget_set_sensitive(item, gaim_gtk_blist_joinchat_is_showable()); |
8143 | 1047 gaim_new_item_from_stock(menu, _("_Delete Group"), GTK_STOCK_REMOVE, |
1048 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1049 gaim_new_item_from_stock(menu, _("_Rename"), NULL, | |
11016 | 1050 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
8952 | 1051 |
9051 | 1052 gaim_gtk_append_blist_node_extended_menu(menu, node); |
8952 | 1053 |
8143 | 1054 return menu; |
1055 } | |
1056 | |
8586 | 1057 |
8143 | 1058 static GtkWidget * |
9774 | 1059 create_chat_menu(GaimBlistNode *node, GaimChat *c) { |
8143 | 1060 GtkWidget *menu; |
9030 | 1061 gboolean autojoin; |
8143 | 1062 |
1063 menu = gtk_menu_new(); | |
9030 | 1064 autojoin = (gaim_blist_node_get_bool(node, "gtk-autojoin") || |
1065 (gaim_blist_node_get_string(node, "gtk-autojoin") != NULL)); | |
1066 | |
8143 | 1067 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, |
9030 | 1068 G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL); |
8143 | 1069 gaim_new_check_item(menu, _("Auto-Join"), |
9030 | 1070 G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin); |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
1071 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
9917 | 1072 G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL); |
9030 | 1073 |
9051 | 1074 gaim_gtk_append_blist_node_proto_menu(menu, c->account->gc, node); |
1075 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
8586 | 1076 |
1077 gaim_separator(menu); | |
9030 | 1078 |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1079 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1080 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
1081 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
1082 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
8586 | 1083 |
8143 | 1084 return menu; |
1085 } | |
1086 | |
1087 static GtkWidget * | |
1088 create_contact_menu (GaimBlistNode *node) | |
1089 { | |
1090 GtkWidget *menu; | |
1091 | |
1092 menu = gtk_menu_new(); | |
10663 | 1093 |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12179
diff
changeset
|
1094 gaim_new_item_from_stock(menu, _("View _Log"), GAIM_STOCK_LOG, |
10663 | 1095 G_CALLBACK(gtk_blist_menu_showlog_cb), |
1096 node, 0, 0, NULL); | |
1097 | |
1098 gaim_separator(menu); | |
1099 | |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1100 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1101 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
10663 | 1102 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, |
1103 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1104 | |
1105 gaim_separator(menu); | |
1106 | |
8143 | 1107 gaim_new_item_from_stock(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT, |
1108 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1109 node, 0, 0, NULL); | |
9051 | 1110 |
1111 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
1112 | |
8143 | 1113 return menu; |
1114 } | |
1115 | |
1116 static GtkWidget * | |
9774 | 1117 create_buddy_menu(GaimBlistNode *node, GaimBuddy *b) { |
8143 | 1118 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1119 GtkWidget *menu; | |
1120 GtkWidget *menuitem; | |
1121 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
|
1122 |
8143 | 1123 menu = gtk_menu_new(); |
10484 | 1124 gaim_gtk_blist_make_buddy_menu(menu, b, FALSE); |
8143 | 1125 |
1126 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1127 gaim_separator(menu); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1128 |
8143 | 1129 if(gtknode->contact_expanded) { |
1130 gaim_new_item_from_stock(menu, _("_Collapse"), | |
1131 GTK_STOCK_ZOOM_OUT, | |
1132 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1133 node, 0, 0, NULL); | |
1134 } else { | |
1135 gaim_new_item_from_stock(menu, _("_Expand"), | |
1136 GTK_STOCK_ZOOM_IN, | |
1137 G_CALLBACK(gaim_gtk_blist_expand_contact_cb), node, | |
1138 0, 0, NULL); | |
1139 } | |
1140 if(node->child->next) { | |
1141 GaimBlistNode *bnode; | |
1142 | |
1143 for(bnode = node->child; bnode; bnode = bnode->next) { | |
1144 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
9340 | 1145 GdkPixbuf *buf; |
8143 | 1146 GtkWidget *submenu; |
1147 GtkWidget *image; | |
1148 | |
1149 if(buddy == b) | |
1150 continue; | |
1151 if(!buddy->account->gc) | |
1152 continue; | |
1153 if(!show_offline && !GAIM_BUDDY_IS_ONLINE(buddy)) | |
1154 continue; | |
1155 | |
1156 menuitem = gtk_image_menu_item_new_with_label(buddy->name); | |
9340 | 1157 buf = gaim_gtk_blist_get_status_icon(bnode, |
1158 GAIM_STATUS_ICON_SMALL); | |
1159 image = gtk_image_new_from_pixbuf(buf); | |
1160 g_object_unref(G_OBJECT(buf)); | |
8143 | 1161 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), |
9811 | 1162 image); |
8143 | 1163 gtk_widget_show(image); |
1164 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
1165 gtk_widget_show(menuitem); | |
1166 | |
1167 submenu = gtk_menu_new(); | |
1168 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1169 gtk_widget_show(submenu); | |
1170 | |
10484 | 1171 gaim_gtk_blist_make_buddy_menu(submenu, buddy, TRUE); |
8143 | 1172 } |
1173 } | |
1174 } | |
1175 return menu; | |
1176 } | |
1177 | |
1178 static gboolean | |
1179 gaim_gtk_blist_show_context_menu(GaimBlistNode *node, | |
1180 GtkMenuPositionFunc func, | |
1181 GtkWidget *tv, | |
1182 guint button, | |
1183 guint32 time) | |
1184 { | |
1185 struct _gaim_gtk_blist_node *gtknode; | |
1186 GtkWidget *menu = NULL; | |
1187 gboolean handled = FALSE; | |
1188 | |
1189 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
1190 | |
1191 /* Create a menu based on the thing we right-clicked on */ | |
1192 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
8952 | 1193 GaimGroup *g = (GaimGroup *)node; |
9774 | 1194 |
8952 | 1195 menu = create_group_menu(node, g); |
8143 | 1196 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
8586 | 1197 GaimChat *c = (GaimChat *)node; |
9774 | 1198 |
1199 menu = create_chat_menu(node, c); | |
8143 | 1200 } else if ((GAIM_BLIST_NODE_IS_CONTACT(node)) && (gtknode->contact_expanded)) { |
1201 menu = create_contact_menu(node); | |
1202 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1203 GaimBuddy *b; | |
1204 | |
1205 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1206 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1207 else | |
1208 b = (GaimBuddy *)node; | |
1209 | |
9774 | 1210 menu = create_buddy_menu(node, b); |
8143 | 1211 } |
1212 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1213 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1214 /* 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
|
1215 * 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
|
1216 This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1217 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1218 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1219 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1220 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1221 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1222 |
8143 | 1223 /* Now display the menu */ |
1224 if (menu != NULL) { | |
1225 gtk_widget_show_all(menu); | |
1226 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, func, tv, button, time); | |
1227 handled = TRUE; | |
1228 } | |
1229 | |
1230 return handled; | |
1231 } | |
1232 | |
1233 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer user_data) | |
5228 | 1234 { |
1235 GtkTreePath *path; | |
1236 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1237 GValue val; |
5228 | 1238 GtkTreeIter iter; |
1239 GtkTreeSelection *sel; | |
1240 GaimPlugin *prpl = NULL; | |
1241 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 1242 struct _gaim_gtk_blist_node *gtknode; |
1243 gboolean handled = FALSE; | |
5228 | 1244 |
1245 /* Here we figure out which node was clicked */ | |
1246 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
1247 return FALSE; | |
1248 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
|
1249 val.g_type = 0; |
8143 | 1250 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
5228 | 1251 node = g_value_get_pointer(&val); |
7620 | 1252 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1253 | |
8143 | 1254 /* Right click draws a context menu */ |
1255 if ((event->button == 3) && (event->type == GDK_BUTTON_PRESS)) { | |
1256 handled = gaim_gtk_blist_show_context_menu(node, NULL, tv, 3, event->time); | |
1257 | |
1258 /* CTRL+middle click expands or collapse a contact */ | |
1259 } else if ((event->button == 2) && (event->type == GDK_BUTTON_PRESS) && | |
1260 (event->state & GDK_CONTROL_MASK) && (GAIM_BLIST_NODE_IS_CONTACT(node))) { | |
1261 if (gtknode->contact_expanded) | |
7620 | 1262 gaim_gtk_blist_collapse_contact_cb(NULL, node); |
1263 else | |
1264 gaim_gtk_blist_expand_contact_cb(NULL, node); | |
1265 handled = TRUE; | |
8143 | 1266 |
1267 /* Double middle click gets info */ | |
1268 } else if ((event->button == 2) && (event->type == GDK_2BUTTON_PRESS) && | |
1269 ((GAIM_BLIST_NODE_IS_CONTACT(node)) || (GAIM_BLIST_NODE_IS_BUDDY(node)))) { | |
7620 | 1270 GaimBuddy *b; |
1271 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1272 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1273 else | |
1274 b = (GaimBuddy *)node; | |
1275 | |
7956 | 1276 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5228 | 1277 if (prpl != NULL) |
1278 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
1279 | |
8143 | 1280 if (prpl && prpl_info->get_info) |
1281 serv_get_info(b->account->gc, b->name); | |
1282 handled = TRUE; | |
5228 | 1283 } |
1284 | |
8143 | 1285 #if (1) |
1286 /* | |
10814
364a2ef907ae
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10780
diff
changeset
|
1287 * This code only exists because GTK+ doesn't work. If we return |
8143 | 1288 * FALSE here, as would be normal the event propoagates down and |
1289 * somehow gets interpreted as the start of a drag event. | |
1290 * | |
1291 * Um, isn't it _normal_ to return TRUE here? Since the event | |
1292 * was handled? --Mark | |
1293 */ | |
7620 | 1294 if(handled) { |
1295 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1296 gtk_tree_selection_select_path(sel, path); | |
1297 gtk_tree_path_free(path); | |
1298 return TRUE; | |
1299 } | |
5228 | 1300 #endif |
7753 | 1301 gtk_tree_path_free(path); |
8143 | 1302 |
7620 | 1303 return FALSE; |
5228 | 1304 } |
1305 | |
8143 | 1306 static gboolean |
1307 gaim_gtk_blist_popup_menu_cb(GtkWidget *tv, void *user_data) | |
1308 { | |
1309 GaimBlistNode *node; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1310 GValue val; |
8143 | 1311 GtkTreeIter iter; |
1312 GtkTreeSelection *sel; | |
1313 gboolean handled = FALSE; | |
1314 | |
1315 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1316 if (!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1317 return FALSE; | |
1318 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1319 val.g_type = 0; |
8143 | 1320 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), |
1321 &iter, NODE_COLUMN, &val); | |
1322 node = g_value_get_pointer(&val); | |
1323 | |
1324 /* Shift+F10 draws a context menu */ | |
1325 handled = gaim_gtk_blist_show_context_menu(node, gaim_gtk_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME); | |
1326 | |
1327 return handled; | |
1328 } | |
1329 | |
11796 | 1330 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item) |
1331 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1332 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1333 |
11796 | 1334 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", |
1335 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
|
1336 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1337 gaim_gtk_clear_cursor(gtkblist->window); |
11796 | 1338 } |
1339 | |
12656 | 1340 static void gaim_gtk_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item) |
1341 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1342 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12656 | 1343 |
1344 gaim_prefs_set_bool("/gaim/gtk/blist/show_idle_time", | |
1345 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
1346 | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1347 gaim_gtk_clear_cursor(gtkblist->window); |
12656 | 1348 } |
1349 | |
5228 | 1350 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) |
1351 { | |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1352 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1353 |
7620 | 1354 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", |
1355 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
12569
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1356 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1357 gaim_gtk_clear_cursor(gtkblist->window); |
5228 | 1358 } |
1359 | |
1360 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
|
1361 GtkWidget *checkitem) |
853e85b6d98c
[gaim-migrate @ 14888]
Richard Laager <rlaager@wiktel.com>
parents:
12530
diff
changeset
|
1362 { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1363 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
5228 | 1364 |
7620 | 1365 gaim_prefs_set_bool("/gaim/gtk/blist/show_offline_buddies", |
1366 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem))); | |
5228 | 1367 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
1368 gaim_gtk_clear_cursor(gtkblist->window); |
5228 | 1369 } |
1370 | |
10074 | 1371 static void gaim_gtk_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item) |
1372 { | |
1373 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(item)->active); | |
1374 } | |
1375 | |
12816 | 1376 static void |
1377 gaim_gtk_blist_mute_pref_cb(const char *name, GaimPrefType type, | |
1378 gconstpointer value, gpointer data) | |
10074 | 1379 { |
1380 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(gtkblist->ift, | |
1381 N_("/Tools/Mute Sounds"))), (gboolean)GPOINTER_TO_INT(value)); | |
1382 } | |
1383 | |
12816 | 1384 static void |
1385 gaim_gtk_blist_sound_method_pref_cb(const char *name, GaimPrefType type, | |
1386 gconstpointer value, gpointer data) | |
10074 | 1387 { |
1388 gboolean sensitive = TRUE; | |
1389 | |
1390 if(!strcmp(value, "none")) | |
1391 sensitive = FALSE; | |
1392 | |
1393 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), sensitive); | |
1394 } | |
1395 | |
8089 | 1396 static void |
1397 add_buddies_from_vcard(const char *prpl_id, GaimGroup *group, GList *list, | |
1398 const char *alias) | |
1399 { | |
1400 GList *l; | |
1401 GaimAccount *account = NULL; | |
1402 GaimConnection *gc; | |
1403 | |
1404 if (list == NULL) | |
1405 return; | |
1406 | |
1407 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
1408 { | |
1409 gc = (GaimConnection *)l->data; | |
1410 account = gaim_connection_get_account(gc); | |
1411 | |
1412 if (!strcmp(gaim_account_get_protocol_id(account), prpl_id)) | |
1413 break; | |
1414 | |
1415 account = NULL; | |
1416 } | |
1417 | |
1418 if (account != NULL) | |
1419 { | |
1420 for (l = list; l != NULL; l = l->next) | |
1421 { | |
1422 gaim_blist_request_add_buddy(account, l->data, | |
1423 (group ? group->name : NULL), | |
1424 alias); | |
1425 } | |
1426 } | |
1427 | |
1428 g_list_foreach(list, (GFunc)g_free, NULL); | |
1429 g_list_free(list); | |
1430 } | |
1431 | |
1432 static gboolean | |
1433 parse_vcard(const char *vcard, GaimGroup *group) | |
1434 { | |
1435 char *temp_vcard; | |
1436 char *s, *c; | |
1437 char *alias = NULL; | |
1438 GList *aims = NULL; | |
1439 GList *icqs = NULL; | |
1440 GList *yahoos = NULL; | |
1441 GList *msns = NULL; | |
1442 GList *jabbers = NULL; | |
1443 | |
1444 s = temp_vcard = g_strdup(vcard); | |
1445 | |
1446 while (*s != '\0' && strncmp(s, "END:vCard", strlen("END:vCard"))) | |
1447 { | |
1448 char *field, *value; | |
1449 | |
1450 field = s; | |
1451 | |
1452 /* Grab the field */ | |
1453 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ':') | |
1454 s++; | |
1455 | |
1456 if (*s == '\r') s++; | |
1457 if (*s == '\n') | |
1458 { | |
1459 s++; | |
1460 continue; | |
1461 } | |
1462 | |
1463 if (*s != '\0') *s++ = '\0'; | |
1464 | |
1465 if ((c = strchr(field, ';')) != NULL) | |
1466 *c = '\0'; | |
1467 | |
1468 /* Proceed to the end of the line */ | |
1469 value = s; | |
1470 | |
1471 while (*s != '\r' && *s != '\n' && *s != '\0') | |
1472 s++; | |
1473 | |
1474 if (*s == '\r') *s++ = '\0'; | |
1475 if (*s == '\n') *s++ = '\0'; | |
1476 | |
1477 /* We only want to worry about a few fields here. */ | |
1478 if (!strcmp(field, "FN")) | |
1479 alias = g_strdup(value); | |
1480 else if (!strcmp(field, "X-AIM") || !strcmp(field, "X-ICQ") || | |
1481 !strcmp(field, "X-YAHOO") || !strcmp(field, "X-MSN") || | |
1482 !strcmp(field, "X-JABBER")) | |
1483 { | |
1484 char **values = g_strsplit(value, ":", 0); | |
1485 char **im; | |
1486 | |
1487 for (im = values; *im != NULL; im++) | |
1488 { | |
1489 if (!strcmp(field, "X-AIM")) | |
1490 aims = g_list_append(aims, g_strdup(*im)); | |
1491 else if (!strcmp(field, "X-ICQ")) | |
1492 icqs = g_list_append(icqs, g_strdup(*im)); | |
1493 else if (!strcmp(field, "X-YAHOO")) | |
1494 yahoos = g_list_append(yahoos, g_strdup(*im)); | |
1495 else if (!strcmp(field, "X-MSN")) | |
1496 msns = g_list_append(msns, g_strdup(*im)); | |
1497 else if (!strcmp(field, "X-JABBER")) | |
1498 jabbers = g_list_append(jabbers, g_strdup(*im)); | |
1499 } | |
1500 | |
1501 g_strfreev(values); | |
1502 } | |
1503 } | |
1504 | |
1505 g_free(temp_vcard); | |
1506 | |
1507 if (aims == NULL && icqs == NULL && yahoos == NULL && | |
1508 msns == NULL && jabbers == NULL) | |
1509 { | |
1510 if (alias != NULL) | |
1511 g_free(alias); | |
1512 | |
1513 return FALSE; | |
1514 } | |
1515 | |
1516 add_buddies_from_vcard("prpl-oscar", group, aims, alias); | |
1517 add_buddies_from_vcard("prpl-oscar", group, icqs, alias); | |
1518 add_buddies_from_vcard("prpl-yahoo", group, yahoos, alias); | |
1519 add_buddies_from_vcard("prpl-msn", group, msns, alias); | |
1520 add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); | |
1521 | |
1522 if (alias != NULL) | |
1523 g_free(alias); | |
1524 | |
1525 return TRUE; | |
1526 } | |
1527 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1528 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1529 static void gaim_gtk_blist_drag_begin(GtkWidget *widget, |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1530 GdkDragContext *drag_context, gpointer user_data) |
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 gaim_gtk_blist_tooltip_destroy(); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1533 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1534 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1535 /* 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
|
1536 * to appear and obscure the dragging operation. |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1537 * This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1538 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1539 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1540 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1541 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1542 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1543 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1544 |
9811 | 1545 static void gaim_gtk_blist_drag_data_get_cb(GtkWidget *widget, |
1546 GdkDragContext *dc, | |
1547 GtkSelectionData *data, | |
1548 guint info, | |
1549 guint time, | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1550 gpointer null) |
5228 | 1551 { |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1552 |
8089 | 1553 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
1554 { | |
5228 | 1555 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); |
1556 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); | |
1557 GtkTreeIter iter; | |
1558 GaimBlistNode *node = NULL; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1559 GValue val; |
5273 | 1560 if(!sourcerow) |
1561 return; | |
5228 | 1562 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
|
1563 val.g_type = 0; |
5228 | 1564 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
1565 node = g_value_get_pointer(&val); | |
1566 gtk_selection_data_set (data, | |
1567 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE), | |
1568 8, /* bits */ | |
1569 (void*)&node, | |
1570 sizeof (node)); | |
5273 | 1571 |
5228 | 1572 gtk_tree_path_free(sourcerow); |
1573 } | |
8089 | 1574 else if (data->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
1575 { | |
7706 | 1576 GtkTreeRowReference *ref; |
1577 GtkTreePath *sourcerow; | |
1578 GtkTreeIter iter; | |
1579 GaimBlistNode *node = NULL; | |
1580 GaimBuddy *buddy; | |
1581 GaimConnection *gc; | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1582 GValue val; |
7706 | 1583 GString *str; |
1584 const char *protocol; | |
1585 char *mime_str; | |
1586 | |
1587 ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); | |
1588 sourcerow = gtk_tree_row_reference_get_path(ref); | |
1589 | |
1590 if (!sourcerow) | |
1591 return; | |
1592 | |
1593 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1594 sourcerow); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1595 val.g_type = 0; |
7706 | 1596 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, |
1597 NODE_COLUMN, &val); | |
1598 | |
1599 node = g_value_get_pointer(&val); | |
1600 | |
1601 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1602 { | |
1603 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
1604 } | |
1605 else if (!GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1606 { | |
1607 gtk_tree_path_free(sourcerow); | |
1608 return; | |
1609 } | |
1610 else | |
1611 { | |
1612 buddy = (GaimBuddy *)node; | |
1613 } | |
1614 | |
1615 gc = gaim_account_get_connection(buddy->account); | |
1616 | |
1617 if (gc == NULL) | |
1618 { | |
1619 gtk_tree_path_free(sourcerow); | |
1620 return; | |
1621 } | |
1622 | |
1623 protocol = | |
1624 GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(buddy->account, | |
1625 buddy); | |
1626 | |
1627 str = g_string_new(NULL); | |
1628 g_string_printf(str, | |
1629 "MIME-Version: 1.0\r\n" | |
1630 "Content-Type: application/x-im-contact\r\n" | |
1631 "X-IM-Protocol: %s\r\n" | |
1632 "X-IM-Username: %s\r\n", | |
1633 protocol, | |
1634 buddy->name); | |
1635 | |
1636 if (buddy->alias != NULL) | |
1637 { | |
1638 g_string_append_printf(str, | |
1639 "X-IM-Alias: %s\r\n", | |
1640 buddy->alias); | |
1641 } | |
1642 | |
1643 str = g_string_append(str, "\r\n"); | |
1644 | |
1645 mime_str = g_string_free(str, FALSE); | |
1646 | |
1647 gtk_selection_data_set(data, | |
1648 gdk_atom_intern("application/x-im-contact", FALSE), | |
1649 8, /* bits */ | |
11137 | 1650 (const guchar *)mime_str, |
7706 | 1651 strlen(mime_str) + 1); |
1652 | |
1653 g_free(mime_str); | |
1654 gtk_tree_path_free(sourcerow); | |
1655 } | |
5228 | 1656 } |
1657 | |
1658 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
1659 GtkSelectionData *sd, guint info, guint t) | |
7620 | 1660 { |
5228 | 1661 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) { |
1662 GaimBlistNode *n = NULL; | |
1663 GtkTreePath *path = NULL; | |
1664 GtkTreeViewDropPosition position; | |
1665 memcpy(&n, sd->data, sizeof(n)); | |
1666 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
|
1667 /* if we're here, I think it means the drop is ok */ |
7642 | 1668 GtkTreeIter iter; |
5228 | 1669 GaimBlistNode *node; |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1670 GValue val; |
7620 | 1671 struct _gaim_gtk_blist_node *gtknode; |
1672 | |
1673 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1674 &iter, path); | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
1675 val.g_type = 0; |
7620 | 1676 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), |
1677 &iter, NODE_COLUMN, &val); | |
5228 | 1678 node = g_value_get_pointer(&val); |
7620 | 1679 gtknode = node->ui_data; |
1680 | |
1681 if (GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
1682 GaimContact *c = (GaimContact*)n; | |
1683 if (GAIM_BLIST_NODE_IS_CONTACT(node) && gtknode->contact_expanded) { | |
1684 gaim_blist_merge_contact(c, node); | |
1685 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1686 GAIM_BLIST_NODE_IS_CHAT(node)) { |
5228 | 1687 switch(position) { |
1688 case GTK_TREE_VIEW_DROP_AFTER: | |
1689 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
7620 | 1690 gaim_blist_add_contact(c, (GaimGroup*)node->parent, |
1691 node); | |
1692 break; | |
1693 case GTK_TREE_VIEW_DROP_BEFORE: | |
1694 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1695 gaim_blist_add_contact(c, (GaimGroup*)node->parent, | |
1696 node->prev); | |
1697 break; | |
1698 } | |
1699 } else if(GAIM_BLIST_NODE_IS_GROUP(node)) { | |
1700 gaim_blist_add_contact(c, (GaimGroup*)node, NULL); | |
1701 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1702 gaim_blist_merge_contact(c, node); | |
1703 } | |
1704 } else if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
1705 GaimBuddy *b = (GaimBuddy*)n; | |
1706 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1707 switch(position) { | |
1708 case GTK_TREE_VIEW_DROP_AFTER: | |
1709 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1710 gaim_blist_add_buddy(b, (GaimContact*)node->parent, | |
1711 (GaimGroup*)node->parent->parent, node); | |
5228 | 1712 break; |
1713 case GTK_TREE_VIEW_DROP_BEFORE: | |
1714 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
7620 | 1715 gaim_blist_add_buddy(b, (GaimContact*)node->parent, |
1716 (GaimGroup*)node->parent->parent, | |
1717 node->prev); | |
5228 | 1718 break; |
1719 } | |
7620 | 1720 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
1721 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node->parent, | |
1722 NULL); | |
5228 | 1723 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
7620 | 1724 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node, NULL); |
1725 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1726 if(gtknode->contact_expanded) { | |
1727 switch(position) { | |
1728 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1729 case GTK_TREE_VIEW_DROP_AFTER: | |
1730 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1731 gaim_blist_add_buddy(b, (GaimContact*)node, | |
1732 (GaimGroup*)node->parent, NULL); | |
1733 break; | |
1734 case GTK_TREE_VIEW_DROP_BEFORE: | |
1735 gaim_blist_add_buddy(b, NULL, | |
1736 (GaimGroup*)node->parent, node->prev); | |
1737 break; | |
1738 } | |
1739 } else { | |
1740 switch(position) { | |
1741 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1742 case GTK_TREE_VIEW_DROP_AFTER: | |
1743 gaim_blist_add_buddy(b, NULL, | |
1744 (GaimGroup*)node->parent, NULL); | |
1745 break; | |
1746 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1747 case GTK_TREE_VIEW_DROP_BEFORE: | |
1748 gaim_blist_add_buddy(b, NULL, | |
1749 (GaimGroup*)node->parent, node->prev); | |
1750 break; | |
1751 } | |
1752 } | |
5228 | 1753 } |
5234 | 1754 } else if (GAIM_BLIST_NODE_IS_CHAT(n)) { |
7620 | 1755 GaimChat *chat = (GaimChat *)n; |
1756 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1757 switch(position) { | |
1758 case GTK_TREE_VIEW_DROP_AFTER: | |
1759 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
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, | |
13542
2235ada6c746
[gaim-migrate @ 15919]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13540
diff
changeset
|
1764 node->parent); |
7620 | 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 { | |
13510
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3347 GtkTreeSelection *sel; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3348 GtkTreeIter iter; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3349 GaimBlistNode *node = NULL; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3350 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3351 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3352 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3353 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3354 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3355 } |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3356 |
7620 | 3357 redo_buddy_list(gaim_get_blist(), TRUE); |
13161
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3358 #if GTK_CHECK_VERSION(2,6,0) |
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3359 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
02268b52ced3
[gaim-migrate @ 15524]
Richard Laager <rlaager@wiktel.com>
parents:
13146
diff
changeset
|
3360 #endif |
13510
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3361 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3362 if (node) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3363 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3364 struct _gaim_gtk_blist_node *gtknode; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3365 GtkTreePath *path; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3366 |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3367 gtknode = node->ui_data; |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3368 if (gtknode && gtknode->row) |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3369 { |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3370 path = gtk_tree_row_reference_get_path(gtknode->row); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3371 gtk_tree_selection_select_path(sel, path); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3372 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3373 gtk_tree_path_free(path); |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3374 } |
65486b7e8e45
[gaim-migrate @ 15886]
Richard Laager <rlaager@wiktel.com>
parents:
13509
diff
changeset
|
3375 } |
7620 | 3376 } |
3377 | |
3378 static void _prefs_change_sort_method(const char *pref_name, GaimPrefType type, | |
12816 | 3379 gconstpointer val, gpointer data) |
10433 | 3380 { |
7620 | 3381 if(!strcmp(pref_name, "/gaim/gtk/blist/sort_type")) |
3382 gaim_gtk_blist_sort_method_set(val); | |
3383 } | |
3384 | |
10433 | 3385 /* |
3386 * "This is so dead sexy." | |
3387 * "Two thumbs up." | |
3388 * "Best movie of the year." | |
3389 * | |
3390 * This is the function that handles CTRL+F searching in the buddy list. | |
3391 * It finds the top-most buddy/group/chat/whatever containing the | |
3392 * entered string. | |
3393 * | |
3394 * It's somewhat ineffecient, because we strip all the HTML from the | |
3395 * "name" column of the buddy list (because the GtkTreeModel does not | |
3396 * contain the screen name in a non-markedup format). But the alternative | |
3397 * is to add an extra column to the GtkTreeModel. And this function is | |
3398 * used rarely, so it shouldn't matter TOO much. | |
3399 */ | |
3400 static gboolean | |
3401 _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) | |
3402 { | |
3403 gchar *enteredstring; | |
10439 | 3404 gchar *withmarkup; |
10433 | 3405 gchar *nomarkup; |
11490 | 3406 gchar *normalized; |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3407 gboolean result; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3408 size_t i; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3409 size_t len; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3410 PangoLogAttr *log_attrs; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3411 gchar *word; |
10435 | 3412 |
3413 gtk_tree_model_get(model, iter, column, &withmarkup, -1); | |
10433 | 3414 |
11490 | 3415 enteredstring = g_utf8_casefold(gaim_normalize(NULL, key), -1); |
10433 | 3416 nomarkup = gaim_markup_strip_html(withmarkup); |
11490 | 3417 normalized = g_utf8_casefold(gaim_normalize(NULL, nomarkup), -1); |
10433 | 3418 |
13478
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3419 if (gaim_str_has_prefix(normalized, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3420 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3421 g_free(withmarkup); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3422 g_free(enteredstring); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3423 g_free(nomarkup); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3424 g_free(normalized); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3425 return FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3426 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3427 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3428 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3429 /* Use Pango to separate by words. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3430 len = g_utf8_strlen(normalized, -1); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3431 log_attrs = g_new(PangoLogAttr, len + 1); |
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 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
|
3434 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3435 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3436 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3437 for (i = 0; i < (len - 1) ; i++) |
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 if (log_attrs[i].is_word_start && |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3440 gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3441 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3442 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3443 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3444 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3445 word = g_utf8_next_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3446 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3447 g_free(log_attrs); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3448 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3449 /* The non-Pango version. */ |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3450 #if 0 |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3451 word = normalized; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3452 result = TRUE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3453 while (word[0] != '\0') |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3454 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3455 gunichar c = g_utf8_get_char(word); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3456 if (!g_unichar_isalnum(c)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3457 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3458 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3459 if (gaim_str_has_prefix(word, enteredstring)) |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3460 { |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3461 result = FALSE; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3462 break; |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3463 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3464 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3465 else |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3466 word = g_utf8_find_next_char(word, NULL); |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3467 } |
38dcde2c8c4b
[gaim-migrate @ 15854]
Richard Laager <rlaager@wiktel.com>
parents:
13450
diff
changeset
|
3468 #endif |
10433 | 3469 |
10439 | 3470 g_free(withmarkup); |
10433 | 3471 g_free(enteredstring); |
3472 g_free(nomarkup); | |
11490 | 3473 g_free(normalized); |
10433 | 3474 |
3475 return result; | |
3476 } | |
3477 | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3478 static void account_modified(GaimAccount *account, GaimGtkBuddyList *gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3479 { |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3480 if (!gtkblist) |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3481 return; |
12589 | 3482 |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3483 update_menu_bar(gtkblist); |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3484 } |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3485 |
12766 | 3486 static void |
3487 account_status_changed(GaimAccount *account, GaimStatus *old, | |
3488 GaimStatus *new, GaimGtkBuddyList *gtkblist) | |
3489 { | |
3490 if (!gtkblist) | |
3491 return; | |
3492 | |
3493 update_menu_bar(gtkblist); | |
3494 } | |
3495 | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3496 static gboolean |
12461
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3497 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
|
3498 { |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3499 GtkWidget *imhtml; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3500 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3501 if (!gtkblist) |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3502 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3503 |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3504 imhtml = gtk_window_get_focus(GTK_WINDOW(gtkblist->window)); |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3505 |
12474
24beec3e42ad
[gaim-migrate @ 14785]
Luke Schierer <lschiere@pidgin.im>
parents:
12473
diff
changeset
|
3506 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
|
3507 return TRUE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3508 return FALSE; |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3509 } |
27671f780081
[gaim-migrate @ 14771]
Richard Laager <rlaager@wiktel.com>
parents:
12458
diff
changeset
|
3510 |
13015 | 3511 /***********************************/ |
3512 /* Connection error handling stuff */ | |
3513 /***********************************/ | |
3514 | |
3515 static void | |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3516 ce_modify_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3517 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3518 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, account); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3519 } |
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 static void |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3522 ce_enable_account_cb(GaimAccount *account) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3523 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3524 gaim_account_set_enabled(account, gaim_core_get_ui(), TRUE); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3525 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3526 |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3527 static void |
13015 | 3528 connection_error_button_clicked_cb(GtkButton *widget, gpointer user_data) |
3529 { | |
3530 GaimAccount *account; | |
13023 | 3531 char *primary; |
3532 const char *text; | |
13015 | 3533 |
3534 account = user_data; | |
13023 | 3535 primary = g_strdup_printf(_("%s disconnected"), |
3536 gaim_account_get_username(account)); | |
13015 | 3537 text = g_hash_table_lookup(gtkblist->connection_errors, account); |
13375 | 3538 |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3539 if (gaim_account_is_connected(account)) |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3540 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3541 gaim_notify_formatted(NULL, _("Connection Error"), |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3542 primary, NULL, text, NULL, NULL); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3543 } |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3544 else |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3545 { |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3546 gboolean enabled = gaim_account_get_enabled(account, gaim_core_get_ui()); |
13375 | 3547 gaim_request_action(account, _("Connection Error"), primary, text, 2, |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3548 account, 3, |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3549 _("OK"), NULL, |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3550 _("Modify Account"), GAIM_CALLBACK(ce_modify_account_cb), |
13540
0bdcd590cd05
[gaim-migrate @ 15917]
Richard Laager <rlaager@wiktel.com>
parents:
13510
diff
changeset
|
3551 enabled ? _("Connect") : _("Re-enable Account"), |
13375 | 3552 enabled ? GAIM_CALLBACK(gaim_account_connect) : |
13315
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3553 GAIM_CALLBACK(ce_enable_account_cb)); |
d65250edebe0
[gaim-migrate @ 15681]
Richard Laager <rlaager@wiktel.com>
parents:
13293
diff
changeset
|
3554 } |
13015 | 3555 gtk_widget_destroy(GTK_WIDGET(widget)); |
3556 g_hash_table_remove(gtkblist->connection_errors, account); | |
3557 } | |
3558 | |
3559 /* Add some buttons that show connection errors */ | |
3560 static void | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3561 create_connection_error_buttons(gpointer key, gpointer value, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3562 gpointer user_data) |
13015 | 3563 { |
3564 GaimAccount *account; | |
13090 | 3565 GaimStatusType *status_type; |
3566 gchar *escaped, *text; | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3567 GtkWidget *button, *label, *image, *hbox; |
13090 | 3568 GdkPixbuf *pixbuf; |
13015 | 3569 |
3570 account = key; | |
13049 | 3571 escaped = g_markup_escape_text((const gchar *)value, -1); |
13023 | 3572 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
|
3573 gaim_account_get_username(account), |
13049 | 3574 escaped); |
3575 g_free(escaped); | |
3576 | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3577 hbox = gtk_hbox_new(FALSE, 0); |
13049 | 3578 |
3579 /* Create the icon */ | |
13090 | 3580 status_type = gaim_account_get_status_type_with_primitive(account, |
3581 GAIM_STATUS_OFFLINE); | |
3582 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
|
3583 if (pixbuf != NULL) { |
13090 | 3584 image = gtk_image_new_from_pixbuf(pixbuf); |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3585 g_object_unref(pixbuf); |
13030 | 3586 |
3587 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, | |
3588 GAIM_HIG_BOX_SPACE); | |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3589 } |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3590 |
13049 | 3591 /* Create the text */ |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3592 label = gtk_label_new(""); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3593 gtk_label_set_markup(GTK_LABEL(label), text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3594 g_free(text); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3595 #if GTK_CHECK_VERSION(2,6,0) |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3596 g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3597 #endif |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3598 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3599 GAIM_HIG_BOX_SPACE); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3600 |
13049 | 3601 /* 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
|
3602 button = gtk_button_new(); |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3603 gtk_container_add(GTK_CONTAINER(button), hbox); |
13015 | 3604 g_signal_connect(G_OBJECT(button), "clicked", |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3605 G_CALLBACK(connection_error_button_clicked_cb), |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3606 account); |
13049 | 3607 gtk_widget_show_all(button); |
13022
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3608 gtk_box_pack_end(GTK_BOX(gtkblist->error_buttons), button, |
228b1f95e5b4
[gaim-migrate @ 15375]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13016
diff
changeset
|
3609 FALSE, FALSE, 0); |
13015 | 3610 } |
3611 | |
3612 void | |
3613 gaim_gtk_blist_update_account_error_state(GaimAccount *account, const char *text) | |
3614 { | |
3615 GList *l; | |
3616 | |
13016 | 3617 if (text == NULL) |
13015 | 3618 g_hash_table_remove(gtkblist->connection_errors, account); |
3619 else | |
3620 g_hash_table_insert(gtkblist->connection_errors, account, g_strdup(text)); | |
3621 | |
3622 /* Remove the old error buttons */ | |
3623 for (l = gtk_container_get_children(GTK_CONTAINER(gtkblist->error_buttons)); | |
3624 l != NULL; | |
3625 l = l->next) | |
3626 { | |
3627 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
3628 } | |
3629 | |
3630 /* Add new error buttons */ | |
3631 g_hash_table_foreach(gtkblist->connection_errors, | |
3632 create_connection_error_buttons, NULL); | |
3633 } | |
3634 | |
3635 /******************************************/ | |
3636 /* End of connection error handling stuff */ | |
3637 /******************************************/ | |
3638 | |
7620 | 3639 static void gaim_gtk_blist_show(GaimBuddyList *list) |
5228 | 3640 { |
10087 | 3641 void *handle; |
5228 | 3642 GtkCellRenderer *rend; |
3643 GtkTreeViewColumn *column; | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3644 GtkWidget *menu; |
5228 | 3645 GtkWidget *sw; |
3646 GtkAccelGroup *accel_group; | |
3647 GtkTreeSelection *selection; | |
9556 | 3648 GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
8089 | 3649 {"application/x-im-contact", 0, DRAG_BUDDY}, |
9495 | 3650 {"text/x-vcard", 0, DRAG_VCARD }, |
9525 | 3651 {"text/uri-list", 0, DRAG_URI}, |
3652 {"text/plain", 0, DRAG_TEXT}}; | |
9556 | 3653 GtkTargetEntry ste[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
3654 {"application/x-im-contact", 0, DRAG_BUDDY}, | |
3655 {"text/x-vcard", 0, DRAG_VCARD }}; | |
5228 | 3656 if (gtkblist && gtkblist->window) { |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3657 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3658 return; |
3659 } | |
3660 | |
3661 gtkblist = GAIM_GTK_BLIST(list); | |
3662 | |
3663 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3664 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
9746 | 3665 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
12328 | 3666 GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE; |
5228 | 3667 |
3668 gtkblist->vbox = gtk_vbox_new(FALSE, 0); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3669 gtk_widget_show(gtkblist->vbox); |
5228 | 3670 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); |
3671 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3672 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
5228 | 3673 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
|
3674 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
|
3675 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
|
3676 g_signal_connect(G_OBJECT(gtkblist->window), "key_press_event", G_CALLBACK(gtk_blist_window_key_press_cb), gtkblist); |
5228 | 3677 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); |
3678 | |
3679 /******************************* Menu bar *************************************/ | |
3680 accel_group = gtk_accel_group_new(); | |
3681 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group); | |
3682 g_object_unref(accel_group); | |
5427 | 3683 gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group); |
9811 | 3684 gtk_item_factory_set_translate_func(gtkblist->ift, |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
3685 (GtkTranslateFunc)item_factory_translate_func, |
9811 | 3686 NULL, NULL); |
5427 | 3687 gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu), |
9811 | 3688 blist_menu, NULL); |
7620 | 3689 gaim_gtk_load_accels(); |
3690 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
3691 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3692 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3693 gtkblist->menutray = gaim_gtk_menu_tray_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3694 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3695 gtk_widget_show(gtkblist->menutray); |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3696 gtk_widget_show(menu); |
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3697 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
5228 | 3698 |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
3699 accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts")); |
10352 | 3700 |
5228 | 3701 /****************************** GtkTreeView **********************************/ |
3702 sw = gtk_scrolled_window_new(NULL,NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3703 gtk_widget_show(sw); |
5228 | 3704 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3705 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
3706 | |
7620 | 3707 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, |
11494 | 3708 GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, |
11257 | 3709 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
5228 | 3710 |
3711 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
|
3712 gtk_widget_show(gtkblist->treeview); |
9176 | 3713 gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); |
5228 | 3714 |
3715 /* Set up selection stuff */ | |
3716 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
3717 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
3718 | |
3719 /* Set up dnd */ | |
7650 | 3720 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3721 GDK_BUTTON1_MASK, ste, 3, |
3722 GDK_ACTION_COPY); | |
7650 | 3723 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3724 dte, 5, |
3725 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
7636 | 3726 |
10544 | 3727 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
5228 | 3728 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
|
3729 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3730 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
|
3731 #endif |
10433 | 3732 |
10354 | 3733 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); |
5228 | 3734 |
3735 /* Tooltips */ | |
3736 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
3737 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
3738 | |
3739 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
3740 | |
11016 | 3741 gtkblist->text_column = column = gtk_tree_view_column_new (); |
5228 | 3742 |
3743 rend = gtk_cell_renderer_pixbuf_new(); | |
9811 | 3744 gtk_tree_view_column_pack_start(column, rend, FALSE); |
3745 gtk_tree_view_column_set_attributes(column, rend, | |
3746 "pixbuf", STATUS_ICON_COLUMN, | |
3747 "visible", STATUS_ICON_VISIBLE_COLUMN, | |
3748 NULL); | |
5228 | 3749 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL); |
3750 | |
11016 | 3751 gtkblist->text_rend = rend = gtk_cell_renderer_text_new(); |
5228 | 3752 gtk_tree_view_column_pack_start (column, rend, TRUE); |
9811 | 3753 gtk_tree_view_column_set_attributes(column, rend, |
3754 "markup", NAME_COLUMN, | |
3755 NULL); | |
11016 | 3756 g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); |
5228 | 3757 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
10285 | 3758 #if GTK_CHECK_VERSION(2,6,0) |
3759 gtk_tree_view_column_set_expand (column, TRUE); | |
10501 | 3760 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
10285 | 3761 #endif |
5228 | 3762 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); |
3763 | |
3764 rend = gtk_cell_renderer_text_new(); | |
10351 | 3765 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
3766 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
5228 | 3767 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
3768 | |
3769 rend = gtk_cell_renderer_pixbuf_new(); | |
3770 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); | |
3771 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); | |
3772 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); | |
3773 | |
3774 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); | |
3775 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL); | |
3776 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL); | |
3777 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
7620 | 3778 g_signal_connect(G_OBJECT(gtkblist->treeview), "key-press-event", G_CALLBACK(gtk_blist_key_press_cb), NULL); |
8143 | 3779 g_signal_connect(G_OBJECT(gtkblist->treeview), "popup-menu", G_CALLBACK(gaim_gtk_blist_popup_menu_cb), NULL); |
5228 | 3780 |
5419 | 3781 /* Enable CTRL+F searching */ |
3782 gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); | |
10433 | 3783 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL); |
5419 | 3784 |
12583 | 3785 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); |
5228 | 3786 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); |
3787 gaim_gtk_blist_update_columns(); | |
3788 | |
13015 | 3789 /* Create an empty vbox used for showing connection errors */ |
3790 gtkblist->error_buttons = gtk_vbox_new(FALSE, 0); | |
3791 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0); | |
3792 | |
3793 /* Add the statusbox */ | |
12583 | 3794 gtkblist->statusbox = gtk_gaim_status_box_new(); |
12592
37160dd563fa
[gaim-migrate @ 14922]
Richard Laager <rlaager@wiktel.com>
parents:
12589
diff
changeset
|
3795 gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); |
12656 | 3796 |
12583 | 3797 gtk_widget_show(gtkblist->statusbox); |
3798 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); | |
12656 | 3799 |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3800 |
5228 | 3801 /* set the Show Offline Buddies option. must be done |
3802 * after the treeview or faceprint gets mad. -Robot101 | |
3803 */ | |
5427 | 3804 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), |
7620 | 3805 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
12656 | 3806 |
5427 | 3807 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
7620 | 3808 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
12656 | 3809 |
10074 | 3810 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3811 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | |
12656 | 3812 |
11796 | 3813 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), |
11920 | 3814 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); |
12656 | 3815 |
3816 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Idle Times"))), | |
3817 gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")); | |
3818 | |
10074 | 3819 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
11494 | 3820 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
5228 | 3821 |
10353 | 3822 /* Update some dynamic things */ |
3823 update_menu_bar(gtkblist); | |
3824 gaim_gtk_blist_update_plugin_actions(); | |
11796 | 3825 gaim_gtk_blist_update_sort_methods(); |
10353 | 3826 |
5228 | 3827 /* OK... let's show this bad boy. */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3828 gaim_gtk_blist_refresh(list); |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3829 gaim_gtk_blist_restore_position(); |
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3830 gtk_widget_show_all(GTK_WIDGET(gtkblist->window)); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3831 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3832 |
3833 /* start the refresh timer */ | |
10351 | 3834 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); |
10353 | 3835 |
10087 | 3836 handle = gaim_gtk_blist_get_handle(); |
3837 | |
7620 | 3838 /* things that affect how buddies are displayed */ |
10087 | 3839 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3840 _prefs_change_redo_list, NULL); | |
12656 | 3841 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3842 _prefs_change_redo_list, NULL); | |
10087 | 3843 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", |
3844 _prefs_change_redo_list, NULL); | |
3845 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", | |
3846 _prefs_change_redo_list, NULL); | |
7620 | 3847 |
3848 /* sorting */ | |
10087 | 3849 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", |
3850 _prefs_change_sort_method, NULL); | |
7620 | 3851 |
3852 /* things that affect what columns are displayed */ | |
10087 | 3853 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
12326 | 3854 show_buddy_icons_pref_cb, NULL); |
12656 | 3855 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_idle_time", |
3856 show_buddy_icons_pref_cb, NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3857 |
10074 | 3858 /* menus */ |
10087 | 3859 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", |
3860 gaim_gtk_blist_mute_pref_cb, NULL); | |
3861 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/method", | |
3862 gaim_gtk_blist_sound_method_pref_cb, NULL); | |
10074 | 3863 |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3864 /* Setup some gaim signal handlers. */ |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3865 gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", |
12583 | 3866 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3867 gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", |
12583 | 3868 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12226 | 3869 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", |
12583 | 3870 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12766 | 3871 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
3872 gtkblist, GAIM_CALLBACK(account_status_changed), gtkblist); | |
12522
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3873 |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3874 gaim_signal_connect(gaim_gtk_account_get_handle(), "account-modified", |
560ddc8d26f3
[gaim-migrate @ 14834]
Richard Laager <rlaager@wiktel.com>
parents:
12519
diff
changeset
|
3875 gtkblist, GAIM_CALLBACK(account_modified), gtkblist); |
12070 | 3876 |
8937 | 3877 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
3878 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
3879 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
3880 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
8815 | 3881 |
8986 | 3882 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", |
3883 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3884 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", | |
3885 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3886 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3887 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3888 gtkblist, GAIM_CALLBACK(conversation_updated_cb), |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3889 gtkblist); |
12208 | 3890 gaim_signal_connect(gaim_conversations_get_handle(), "deleting-conversation", |
3891 gtkblist, GAIM_CALLBACK(conversation_deleting_cb), | |
3892 gtkblist); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3893 |
8815 | 3894 /* emit our created signal */ |
10087 | 3895 gaim_signal_emit(handle, "gtkblist-created", list); |
5228 | 3896 } |
3897 | |
7620 | 3898 static void redo_buddy_list(GaimBuddyList *list, gboolean remove) |
5228 | 3899 { |
12112 | 3900 GaimBlistNode *node = list->root; |
3901 | |
3902 while (node) | |
3903 { | |
3904 if (!GAIM_BLIST_NODE_IS_GROUP(node) && remove) | |
3905 gaim_gtk_blist_hide_node(list, node); | |
3906 | |
3907 gaim_gtk_blist_update(list, node); | |
3908 node = gaim_blist_node_next(node, FALSE); | |
5228 | 3909 } |
3910 } | |
3911 | |
7620 | 3912 void gaim_gtk_blist_refresh(GaimBuddyList *list) |
5422 | 3913 { |
3914 redo_buddy_list(list, FALSE); | |
3915 } | |
3916 | |
5297 | 3917 void |
3918 gaim_gtk_blist_update_refresh_timeout() | |
3919 { | |
7620 | 3920 GaimBuddyList *blist; |
3921 GaimGtkBuddyList *gtkblist; | |
5297 | 3922 |
3923 blist = gaim_get_blist(); | |
3924 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
3925 | |
10351 | 3926 gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)gaim_gtk_blist_refresh_timer, blist); |
5297 | 3927 } |
3928 | |
5256 | 3929 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { |
3930 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3931 GtkTreePath *path; | |
5228 | 3932 |
5263 | 3933 if (!gtknode) { |
3934 return FALSE; | |
3935 } | |
3936 | |
3937 if (!gtkblist) { | |
10006 | 3938 gaim_debug_error("gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n"); |
5263 | 3939 return FALSE; |
3940 } | |
3941 | |
3942 if (!gtknode->row) | |
5228 | 3943 return FALSE; |
11494 | 3944 |
5228 | 3945 |
5256 | 3946 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL) |
5228 | 3947 return FALSE; |
11016 | 3948 |
5256 | 3949 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) { |
3950 gtk_tree_path_free(path); | |
3951 return FALSE; | |
3952 } | |
3953 gtk_tree_path_free(path); | |
3954 return TRUE; | |
5228 | 3955 } |
3956 | |
7620 | 3957 static void gaim_gtk_blist_remove(GaimBuddyList *list, GaimBlistNode *node) |
5228 | 3958 { |
11910 | 3959 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
3960 | |
10222 | 3961 gaim_request_close_with_handle(node); |
3962 | |
5260 | 3963 gaim_gtk_blist_hide_node(list, node); |
5228 | 3964 |
7620 | 3965 if(node->parent) |
3966 gaim_gtk_blist_update(list, node->parent); | |
3967 | |
10504 | 3968 /* There's something I don't understand here - Ethan */ |
3969 /* Ethan said that back in 2003, but this g_free has been left commented | |
3970 * out ever since. I can't find any reason at all why this is bad and | |
3971 * valgrind found several reasons why it's good. If this causes problems | |
3972 * comment it out again. Stu */ | |
10510 | 3973 /* Of course it still causes problems - this breaks dragging buddies into |
10515 | 3974 * contacts, the dragged buddy mysteriously 'disappears'. Stu. */ |
3975 /* I think it's fixed now. Stu. */ | |
11910 | 3976 |
11915 | 3977 if(gtknode) { |
3978 if(gtknode->recent_signonoff_timer > 0) | |
3979 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
3980 | |
3981 g_free(node->ui_data); | |
3982 node->ui_data = NULL; | |
3983 } | |
5228 | 3984 } |
3985 | |
3986 static gboolean do_selection_changed(GaimBlistNode *new_selection) | |
3987 { | |
5254 | 3988 GaimBlistNode *old_selection = NULL; |
5228 | 3989 |
5254 | 3990 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */ |
3991 if (gtkblist && new_selection != gtkblist->selected_node) { | |
3992 old_selection = gtkblist->selected_node; | |
5228 | 3993 gtkblist->selected_node = new_selection; |
3994 if(new_selection) | |
3995 gaim_gtk_blist_update(NULL, new_selection); | |
3996 if(old_selection) | |
3997 gaim_gtk_blist_update(NULL, old_selection); | |
3998 } | |
3999 | |
4000 return FALSE; | |
4001 } | |
4002 | |
4003 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
4004 { | |
4005 GaimBlistNode *new_selection = NULL; | |
4006 GtkTreeIter iter; | |
4007 | |
4008 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
4009 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
4010 NODE_COLUMN, &new_selection, -1); | |
4011 } | |
5254 | 4012 |
5228 | 4013 /* we set this up as a timeout, otherwise the blist flickers */ |
4014 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
4015 } | |
4016 | |
8252 | 4017 static gboolean insert_node(GaimBuddyList *list, GaimBlistNode *node, GtkTreeIter *iter) |
7620 | 4018 { |
4019 GtkTreeIter parent_iter, cur, *curptr = NULL; | |
4020 struct _gaim_gtk_blist_node *gtknode = node->ui_data; | |
5256 | 4021 GtkTreePath *newpath; |
7620 | 4022 |
10515 | 4023 if(!iter) |
8252 | 4024 return FALSE; |
7620 | 4025 |
4026 if(node->parent && !get_iter_from_node(node->parent, &parent_iter)) | |
8252 | 4027 return FALSE; |
7620 | 4028 |
4029 if(get_iter_from_node(node, &cur)) | |
4030 curptr = &cur; | |
4031 | |
4032 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
|
4033 current_sort_method->func(node, list, parent_iter, curptr, iter); |
7620 | 4034 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4035 sort_method_none(node, list, parent_iter, curptr, iter); |
5228 | 4036 } |
4037 | |
10515 | 4038 if(gtknode != NULL) { |
4039 gtk_tree_row_reference_free(gtknode->row); | |
4040 } else { | |
4041 gaim_gtk_blist_new_node(node); | |
4042 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
4043 } | |
4044 | |
7620 | 4045 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), |
4046 iter); | |
4047 gtknode->row = | |
4048 gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), | |
4049 newpath); | |
11494 | 4050 |
5256 | 4051 gtk_tree_path_free(newpath); |
4052 | |
5228 | 4053 gtk_tree_store_set(gtkblist->treemodel, iter, |
4054 NODE_COLUMN, node, | |
4055 -1); | |
7620 | 4056 |
4057 if(node->parent) { | |
4058 GtkTreePath *expand = NULL; | |
4059 struct _gaim_gtk_blist_node *gtkparentnode = node->parent->ui_data; | |
4060 | |
4061 if(GAIM_BLIST_NODE_IS_GROUP(node->parent)) { | |
7693 | 4062 if(!gaim_blist_node_get_bool(node->parent, "collapsed")) |
7620 | 4063 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); |
4064 } else if(GAIM_BLIST_NODE_IS_CONTACT(node->parent) && | |
4065 gtkparentnode->contact_expanded) { | |
4066 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); | |
4067 } | |
4068 if(expand) { | |
7693 | 4069 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, FALSE); |
7620 | 4070 gtk_tree_path_free(expand); |
4071 } | |
4072 } | |
4073 | |
8252 | 4074 return TRUE; |
5228 | 4075 } |
4076 | |
7620 | 4077 static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) |
4078 { | |
4079 GaimGroup *group; | |
8203 | 4080 int count; |
12341 | 4081 gboolean show = FALSE; |
7620 | 4082 |
4083 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); | |
4084 | |
4085 group = (GaimGroup*)node; | |
4086 | |
8203 | 4087 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) |
4088 count = gaim_blist_get_group_size(group, FALSE); | |
4089 else | |
4090 count = gaim_blist_get_group_online_count(group); | |
13195 | 4091 |
12341 | 4092 if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) |
4093 show = TRUE; | |
4094 else { | |
4095 GaimBlistNode *n; | |
4096 n = node->child; | |
4097 while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { | |
4098 if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
4099 if (buddy_is_displayable((GaimBuddy*)n)) { | |
4100 show = TRUE; | |
4101 break; | |
13195 | 4102 } |
12341 | 4103 } |
4104 n = gaim_blist_node_next(n, FALSE); | |
4105 } | |
4106 } | |
4107 | |
4108 if (show) { | |
7620 | 4109 char *mark, *esc; |
4110 GtkTreeIter iter; | |
4111 | |
8252 | 4112 if(!insert_node(list, node, &iter)) |
4113 return; | |
7620 | 4114 |
4115 esc = g_markup_escape_text(group->name, -1); | |
8945 | 4116 mark = g_strdup_printf("<span weight='bold'>%s</span> (%d/%d)", |
4117 esc, gaim_blist_get_group_online_count(group), | |
4118 gaim_blist_get_group_size(group, FALSE)); | |
7620 | 4119 g_free(esc); |
4120 | |
4121 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
4122 STATUS_ICON_COLUMN, NULL, | |
4123 STATUS_ICON_VISIBLE_COLUMN, FALSE, | |
4124 NAME_COLUMN, mark, | |
4125 NODE_COLUMN, node, | |
4126 -1); | |
4127 g_free(mark); | |
4128 } else { | |
4129 gaim_gtk_blist_hide_node(list, node); | |
4130 } | |
4131 } | |
4132 | |
4133 static void buddy_node(GaimBuddy *buddy, GtkTreeIter *iter, GaimBlistNode *node) | |
5228 | 4134 { |
9944 | 4135 GaimPresence *presence; |
7620 | 4136 GdkPixbuf *status, *avatar; |
4137 char *mark; | |
11257 | 4138 char *idle = NULL; |
7620 | 4139 gboolean selected = (gtkblist->selected_node == node); |
4140 | |
9944 | 4141 presence = gaim_buddy_get_presence(buddy); |
4142 | |
7620 | 4143 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, |
4144 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") | |
4145 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4146 | |
10482 | 4147 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); |
7620 | 4148 mark = gaim_gtk_blist_get_name_markup(buddy, selected); |
4149 | |
12656 | 4150 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && |
4151 gaim_presence_is_idle(presence)) | |
9944 | 4152 { |
4153 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
4154 | |
4155 if (idle_secs > 0) | |
4156 { | |
4157 time_t t; | |
4158 int ihrs, imin; | |
4159 time(&t); | |
4160 ihrs = (t - idle_secs) / 3600; | |
4161 imin = ((t - idle_secs) / 60) % 60; | |
4162 | |
4163 if (ihrs > 0) | |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4164 idle = g_strdup_printf("%d:%02d", ihrs, imin); |
9944 | 4165 else |
12357
8dd086d0f2b3
[gaim-migrate @ 14661]
Richard Laager <rlaager@wiktel.com>
parents:
12348
diff
changeset
|
4166 idle = g_strdup_printf("%d", imin); |
9944 | 4167 } |
7620 | 4168 } |
4169 | |
10118 | 4170 if (gaim_presence_is_idle(presence)) |
9944 | 4171 { |
4172 if (idle && !selected) { | |
10118 | 4173 char *i2 = g_strdup_printf("<span color='%s'>%s</span>", |
4174 dim_grey(), idle); | |
7620 | 4175 g_free(idle); |
4176 idle = i2; | |
5228 | 4177 } |
7620 | 4178 } |
4179 | |
4180 gtk_tree_store_set(gtkblist->treemodel, iter, | |
4181 STATUS_ICON_COLUMN, status, | |
4182 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4183 NAME_COLUMN, mark, | |
4184 IDLE_COLUMN, idle, | |
4185 BUDDY_ICON_COLUMN, avatar, | |
4186 -1); | |
4187 | |
4188 g_free(mark); | |
12656 | 4189 g_free(idle); |
7620 | 4190 if(status) |
4191 g_object_unref(status); | |
4192 if(avatar) | |
4193 g_object_unref(avatar); | |
4194 } | |
4195 | |
11890 | 4196 |
7620 | 4197 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) |
4198 { | |
4199 GaimContact *contact; | |
4200 GaimBuddy *buddy; | |
4201 struct _gaim_gtk_blist_node *gtknode; | |
4202 | |
4203 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node)); | |
4204 | |
4205 /* First things first, update the group */ | |
4206 gaim_gtk_blist_update_group(list, node->parent); | |
4207 | |
4208 contact = (GaimContact*)node; | |
4209 buddy = gaim_contact_get_priority_buddy(contact); | |
4210 | |
11890 | 4211 if (buddy_is_displayable(buddy)) |
10006 | 4212 { |
7620 | 4213 GtkTreeIter iter; |
4214 | |
8252 | 4215 if(!insert_node(list, node, &iter)) |
4216 return; | |
7620 | 4217 |
10515 | 4218 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
4219 | |
7620 | 4220 if(gtknode->contact_expanded) { |
4221 GdkPixbuf *status; | |
5228 | 4222 char *mark; |
4223 | |
7620 | 4224 status = gaim_gtk_blist_get_status_icon(node, |
4225 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? | |
4226 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4227 | |
4228 mark = g_markup_escape_text(gaim_contact_get_alias(contact), -1); | |
4229 | |
5228 | 4230 gtk_tree_store_set(gtkblist->treemodel, &iter, |
7620 | 4231 STATUS_ICON_COLUMN, status, |
4232 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
5228 | 4233 NAME_COLUMN, mark, |
7620 | 4234 IDLE_COLUMN, NULL, |
4235 BUDDY_ICON_COLUMN, NULL, | |
5228 | 4236 -1); |
4237 g_free(mark); | |
7620 | 4238 if(status) |
4239 g_object_unref(status); | |
4240 } else { | |
4241 buddy_node(buddy, &iter, node); | |
5228 | 4242 } |
7620 | 4243 } else { |
4244 gaim_gtk_blist_hide_node(list, node); | |
5228 | 4245 } |
7620 | 4246 } |
4247 | |
4248 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) | |
4249 { | |
4250 GaimContact *contact; | |
4251 GaimBuddy *buddy; | |
4252 struct _gaim_gtk_blist_node *gtkparentnode; | |
4253 | |
4254 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
4255 | |
4256 buddy = (GaimBuddy*)node; | |
4257 contact = (GaimContact*)node->parent; | |
4258 | |
11624 | 4259 if (contact == NULL) |
4260 return; | |
4261 | |
7620 | 4262 /* First things first, update the contact */ |
4263 gaim_gtk_blist_update_contact(list, node->parent); | |
4264 | |
10918 | 4265 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
4266 | |
12341 | 4267 if (gtkparentnode->contact_expanded && buddy_is_displayable(buddy)) |
10006 | 4268 { |
7620 | 4269 GtkTreeIter iter; |
4270 | |
10006 | 4271 if (!insert_node(list, node, &iter)) |
8252 | 4272 return; |
4273 | |
7620 | 4274 buddy_node(buddy, &iter, node); |
4275 | |
4276 } else { | |
4277 gaim_gtk_blist_hide_node(list, node); | |
4278 } | |
4279 | |
4280 } | |
4281 | |
4282 static void gaim_gtk_blist_update_chat(GaimBuddyList *list, GaimBlistNode *node) | |
4283 { | |
4284 GaimChat *chat; | |
4285 | |
4286 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); | |
4287 | |
4288 /* First things first, update the group */ | |
4289 gaim_gtk_blist_update_group(list, node->parent); | |
4290 | |
4291 chat = (GaimChat*)node; | |
4292 | |
4293 if(gaim_account_is_connected(chat->account)) { | |
4294 GtkTreeIter iter; | |
5234 | 4295 GdkPixbuf *status; |
7620 | 4296 char *mark; |
4297 | |
8252 | 4298 if(!insert_node(list, node, &iter)) |
4299 return; | |
5234 | 4300 |
4301 status = gaim_gtk_blist_get_status_icon(node, | |
7620 | 4302 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
4303 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
4304 | |
4305 mark = g_markup_escape_text(gaim_chat_get_name(chat), -1); | |
5234 | 4306 |
4307 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
7620 | 4308 STATUS_ICON_COLUMN, status, |
4309 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4310 NAME_COLUMN, mark, | |
4311 -1); | |
5228 | 4312 |
4313 g_free(mark); | |
7620 | 4314 if(status) |
5228 | 4315 g_object_unref(status); |
7620 | 4316 } else { |
5260 | 4317 gaim_gtk_blist_hide_node(list, node); |
5228 | 4318 } |
7620 | 4319 } |
4320 | |
4321 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node) | |
4322 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12766
diff
changeset
|
4323 if(!gtkblist || !node) |
7620 | 4324 return; |
4325 | |
13195 | 4326 if (node->ui_data == NULL) |
4327 gaim_gtk_blist_new_node(node); | |
4328 | |
7620 | 4329 switch(node->type) { |
4330 case GAIM_BLIST_GROUP_NODE: | |
4331 gaim_gtk_blist_update_group(list, node); | |
4332 break; | |
4333 case GAIM_BLIST_CONTACT_NODE: | |
4334 gaim_gtk_blist_update_contact(list, node); | |
4335 break; | |
4336 case GAIM_BLIST_BUDDY_NODE: | |
4337 gaim_gtk_blist_update_buddy(list, node); | |
4338 break; | |
4339 case GAIM_BLIST_CHAT_NODE: | |
4340 gaim_gtk_blist_update_chat(list, node); | |
4341 break; | |
4342 case GAIM_BLIST_OTHER_NODE: | |
4343 return; | |
4344 } | |
5234 | 4345 |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4346 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 4347 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
13146
a3c1112bb190
[gaim-migrate @ 15509]
Richard Laager <rlaager@wiktel.com>
parents:
13140
diff
changeset
|
4348 #endif |
5228 | 4349 } |
4350 | |
7620 | 4351 |
4352 static void gaim_gtk_blist_destroy(GaimBuddyList *list) | |
5228 | 4353 { |
4354 if (!gtkblist) | |
4355 return; | |
4356 | |
8937 | 4357 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
4358 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
4359 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
4360 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
4361 |
5228 | 4362 gtk_widget_destroy(gtkblist->window); |
7620 | 4363 |
8254 | 4364 gaim_gtk_blist_tooltip_destroy(); |
7620 | 4365 |
5228 | 4366 if (gtkblist->refresh_timer) |
4367 g_source_remove(gtkblist->refresh_timer); | |
4368 if (gtkblist->timeout) | |
4369 g_source_remove(gtkblist->timeout); | |
10354 | 4370 if (gtkblist->drag_timeout) |
4371 g_source_remove(gtkblist->drag_timeout); | |
5228 | 4372 |
13015 | 4373 g_hash_table_destroy(gtkblist->connection_errors); |
5228 | 4374 gtkblist->refresh_timer = 0; |
4375 gtkblist->timeout = 0; | |
10354 | 4376 gtkblist->drag_timeout = 0; |
5228 | 4377 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; |
4378 gtkblist->treemodel = NULL; | |
4379 gtkblist->idle_column = NULL; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4380 gtkblist->buddy_icon_column = NULL; |
5427 | 4381 g_object_unref(G_OBJECT(gtkblist->ift)); |
13015 | 4382 g_free(gtkblist); |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
4383 accountmenu = NULL; |
5228 | 4384 gtkblist = NULL; |
7620 | 4385 |
10087 | 4386 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
5228 | 4387 } |
4388 | |
7620 | 4389 static void gaim_gtk_blist_set_visible(GaimBuddyList *list, gboolean show) |
5228 | 4390 { |
4391 if (!(gtkblist && gtkblist->window)) | |
4392 return; | |
10325 | 4393 |
5228 | 4394 if (show) { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4395 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
|
4396 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", gtkblist); |
5228 | 4397 gaim_gtk_blist_restore_position(); |
4398 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4399 } else { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4400 if(visibility_manager_count) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4401 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
|
4402 gtk_widget_hide(gtkblist->window); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4403 } else { |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4404 if (!GTK_WIDGET_VISIBLE(gtkblist->window)) |
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
4405 gtk_widget_show(gtkblist->window); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4406 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4407 } |
5228 | 4408 } |
4409 } | |
4410 | |
7620 | 4411 static GList * |
4412 groups_tree(void) | |
4413 { | |
4414 GList *tmp = NULL; | |
4415 char *tmp2; | |
4416 GaimGroup *g; | |
4417 GaimBlistNode *gnode; | |
4418 | |
4419 if (gaim_get_blist()->root == NULL) | |
4420 { | |
4421 tmp2 = g_strdup(_("Buddies")); | |
4422 tmp = g_list_append(tmp, tmp2); | |
4423 } | |
4424 else | |
4425 { | |
4426 for (gnode = gaim_get_blist()->root; | |
4427 gnode != NULL; | |
4428 gnode = gnode->next) | |
4429 { | |
4430 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4431 { | |
4432 g = (GaimGroup *)gnode; | |
4433 tmp2 = g->name; | |
4434 tmp = g_list_append(tmp, tmp2); | |
4435 } | |
4436 } | |
4437 } | |
4438 | |
4439 return tmp; | |
4440 } | |
4441 | |
4442 static void | |
4443 add_buddy_select_account_cb(GObject *w, GaimAccount *account, | |
4444 GaimGtkAddBuddyData *data) | |
4445 { | |
4446 /* Save our account */ | |
4447 data->account = account; | |
4448 } | |
4449 | |
4450 static void | |
4451 destroy_add_buddy_dialog_cb(GtkWidget *win, GaimGtkAddBuddyData *data) | |
4452 { | |
4453 g_free(data); | |
4454 } | |
4455 | |
4456 static void | |
4457 add_buddy_cb(GtkWidget *w, int resp, GaimGtkAddBuddyData *data) | |
4458 { | |
4459 const char *grp, *who, *whoalias; | |
4460 GaimConversation *c; | |
4461 GaimBuddy *b; | |
4462 GaimGroup *g; | |
4463 | |
4464 if (resp == GTK_RESPONSE_OK) | |
4465 { | |
4466 who = gtk_entry_get_text(GTK_ENTRY(data->entry)); | |
4467 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry)); | |
4468 whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); | |
9658 | 4469 if (*whoalias == '\0') |
4470 whoalias = NULL; | |
7620 | 4471 |
4472 if ((g = gaim_find_group(grp)) == NULL) | |
4473 { | |
4474 g = gaim_group_new(grp); | |
4475 gaim_blist_add_group(g, NULL); | |
4476 } | |
4477 | |
4478 b = gaim_buddy_new(data->account, who, whoalias); | |
4479 gaim_blist_add_buddy(b, NULL, g, NULL); | |
11643 | 4480 gaim_account_add_buddy(data->account, b); |
7620 | 4481 |
7887 | 4482 /* |
9285 | 4483 * XXX |
11643 | 4484 * It really seems like it would be better if the call to |
4485 * gaim_account_add_buddy() and gaim_conversation_update() were done in | |
4486 * blist.c, possibly in the gaim_blist_add_buddy() function. Maybe | |
4487 * gaim_account_add_buddy() should be renamed to | |
4488 * gaim_blist_add_new_buddy() or something, and have it call | |
7887 | 4489 * gaim_blist_add_buddy() after it creates it. --Mark |
9285 | 4490 * |
4491 * No that's not good. blist.c should only deal with adding nodes to the | |
11643 | 4492 * local list. We need a new, non-gtk file that calls both |
4493 * gaim_account_add_buddy and gaim_blist_add_buddy(). | |
4494 * Or something. --Mark | |
7887 | 4495 */ |
4496 | |
11338 | 4497 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, data->account); |
7620 | 4498 if (c != NULL) { |
4499 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(c))); | |
4500 } | |
4501 } | |
4502 | |
4503 gtk_widget_destroy(data->window); | |
4504 } | |
4505 | |
4506 static void | |
4507 gaim_gtk_blist_request_add_buddy(GaimAccount *account, const char *username, | |
4508 const char *group, const char *alias) | |
4509 { | |
4510 GtkWidget *table; | |
4511 GtkWidget *label; | |
4512 GtkWidget *hbox; | |
4513 GtkWidget *vbox; | |
4514 GtkWidget *img; | |
4515 GaimGtkBuddyList *gtkblist; | |
4516 GaimGtkAddBuddyData *data = g_new0(GaimGtkAddBuddyData, 1); | |
4517 | |
4518 data->account = | |
4519 (account != NULL | |
4520 ? account | |
4521 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
4522 | |
4523 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4524 GTK_ICON_SIZE_DIALOG); | |
4525 | |
4526 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
4527 | |
4528 data->window = gtk_dialog_new_with_buttons(_("Add Buddy"), | |
8975 | 4529 NULL, GTK_DIALOG_NO_SEPARATOR, |
7620 | 4530 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
4531 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4532 NULL); | |
4533 | |
4534 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4535 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
7620 | 4536 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4537 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4538 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4539 gtk_window_set_role(GTK_WINDOW(data->window), "add_buddy"); |
8975 | 4540 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4541 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4542 |
11243 | 4543 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4544 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4545 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4546 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4547 | |
4548 vbox = gtk_vbox_new(FALSE, 0); | |
4549 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4550 | |
4551 label = gtk_label_new( | |
4552 _("Please enter the screen name of the person you would like " | |
4553 "to add to your buddy list. You may optionally enter an alias, " | |
4554 "or nickname, for the buddy. The alias will be displayed in " | |
4555 "place of the screen name whenever possible.\n")); | |
4556 | |
4557 gtk_widget_set_size_request(GTK_WIDGET(label), 400, -1); | |
4558 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4559 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4560 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4561 | |
11243 | 4562 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7620 | 4563 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
4564 | |
4565 g_signal_connect(G_OBJECT(data->window), "destroy", | |
4566 G_CALLBACK(destroy_add_buddy_dialog_cb), data); | |
4567 | |
4568 table = gtk_table_new(4, 2, FALSE); | |
4569 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
4570 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
4571 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | |
4572 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
4573 | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13542
diff
changeset
|
4574 label = gtk_label_new(_("Screen name:")); |
7620 | 4575 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4576 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
4577 | |
4578 data->entry = gtk_entry_new(); | |
4579 gtk_table_attach_defaults(GTK_TABLE(table), data->entry, 1, 2, 0, 1); | |
4580 gtk_widget_grab_focus(data->entry); | |
4581 | |
4582 if (username != NULL) | |
4583 gtk_entry_set_text(GTK_ENTRY(data->entry), username); | |
12337 | 4584 else |
4585 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), | |
4586 GTK_RESPONSE_OK, FALSE); | |
7620 | 4587 |
4588 gtk_entry_set_activates_default (GTK_ENTRY(data->entry), TRUE); | |
8137 | 4589 gaim_set_accessible_label (data->entry, label); |
7620 | 4590 |
12337 | 4591 g_signal_connect(G_OBJECT(data->entry), "changed", |
4592 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
4593 data->window); | |
4594 | |
7620 | 4595 label = gtk_label_new(_("Alias:")); |
4596 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4597 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
4598 | |
4599 data->entry_for_alias = gtk_entry_new(); | |
4600 gtk_table_attach_defaults(GTK_TABLE(table), | |
4601 data->entry_for_alias, 1, 2, 1, 2); | |
4602 | |
4603 if (alias != NULL) | |
4604 gtk_entry_set_text(GTK_ENTRY(data->entry_for_alias), alias); | |
4605 | |
10734
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4606 if (username != NULL) |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4607 gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4608 |
7620 | 4609 gtk_entry_set_activates_default (GTK_ENTRY(data->entry_for_alias), TRUE); |
8137 | 4610 gaim_set_accessible_label (data->entry_for_alias, label); |
7620 | 4611 |
4612 label = gtk_label_new(_("Group:")); | |
4613 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4614 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
4615 | |
4616 data->combo = gtk_combo_new(); | |
4617 gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree()); | |
4618 gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 2, 3); | |
8137 | 4619 gaim_set_accessible_label (data->combo, label); |
7620 | 4620 |
4621 /* Set up stuff for the account box */ | |
4622 label = gtk_label_new(_("Account:")); | |
4623 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4624 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
4625 | |
4626 data->account_box = gaim_gtk_account_option_menu_new(account, FALSE, | |
4627 G_CALLBACK(add_buddy_select_account_cb), NULL, data); | |
4628 | |
4629 gtk_table_attach_defaults(GTK_TABLE(table), data->account_box, 1, 2, 3, 4); | |
8137 | 4630 gaim_set_accessible_label (data->account_box, label); |
7620 | 4631 /* End of account box */ |
4632 | |
4633 g_signal_connect(G_OBJECT(data->window), "response", | |
4634 G_CALLBACK(add_buddy_cb), data); | |
4635 | |
4636 gtk_widget_show_all(data->window); | |
4637 | |
4638 if (group != NULL) | |
4639 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group); | |
4640 } | |
4641 | |
4642 static void | |
4643 add_chat_cb(GtkWidget *w, GaimGtkAddChatData *data) | |
4644 { | |
4645 GHashTable *components; | |
4646 GList *tmp; | |
4647 GaimChat *chat; | |
4648 GaimGroup *group; | |
4649 const char *group_name; | |
10475 | 4650 const char *value; |
7620 | 4651 |
4652 components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
4653 g_free, g_free); | |
4654 | |
4655 for (tmp = data->entries; tmp; tmp = tmp->next) | |
4656 { | |
4657 if (g_object_get_data(tmp->data, "is_spin")) | |
4658 { | |
4659 g_hash_table_replace(components, | |
4660 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4661 g_strdup_printf("%d", | |
4662 gtk_spin_button_get_value_as_int(tmp->data))); | |
4663 } | |
4664 else | |
4665 { | |
10475 | 4666 value = gtk_entry_get_text(tmp->data); |
4667 if (*value != '\0') | |
4668 g_hash_table_replace(components, | |
4669 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4670 g_strdup(value)); | |
7620 | 4671 } |
4672 } | |
4673 | |
4674 chat = gaim_chat_new(data->account, | |
4675 gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), | |
4676 components); | |
4677 | |
4678 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry)); | |
4679 | |
4680 if ((group = gaim_find_group(group_name)) == NULL) | |
4681 { | |
4682 group = gaim_group_new(group_name); | |
4683 gaim_blist_add_group(group, NULL); | |
4684 } | |
4685 | |
4686 if (chat != NULL) | |
4687 { | |
4688 gaim_blist_add_chat(chat, group, NULL); | |
4689 } | |
4690 | |
4691 gtk_widget_destroy(data->window); | |
9812 | 4692 g_free(data->default_chat_name); |
7620 | 4693 g_list_free(data->entries); |
4694 g_free(data); | |
4695 } | |
4696 | |
4697 static void | |
4698 add_chat_resp_cb(GtkWidget *w, int resp, GaimGtkAddChatData *data) | |
4699 { | |
4700 if (resp == GTK_RESPONSE_OK) | |
4701 { | |
4702 add_chat_cb(NULL, data); | |
4703 } | |
4704 else | |
4705 { | |
4706 gtk_widget_destroy(data->window); | |
9812 | 4707 g_free(data->default_chat_name); |
7620 | 4708 g_list_free(data->entries); |
4709 g_free(data); | |
4710 } | |
4711 } | |
4712 | |
10475 | 4713 /* |
4714 * Check the values of all the text entry boxes. If any required input | |
4715 * strings are empty then don't allow the user to click on "OK." | |
4716 */ | |
4717 static void | |
4718 addchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
4719 { | |
4720 GaimGtkAddChatData *data; | |
4721 GList *tmp; | |
4722 const char *text; | |
4723 gboolean required; | |
4724 gboolean sensitive = TRUE; | |
4725 | |
4726 data = user_data; | |
4727 | |
4728 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
4729 { | |
4730 if (!g_object_get_data(tmp->data, "is_spin")) | |
4731 { | |
4732 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
4733 text = gtk_entry_get_text(tmp->data); | |
4734 if (required && (*text == '\0')) | |
4735 sensitive = FALSE; | |
4736 } | |
4737 } | |
4738 | |
4739 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
4740 } | |
4741 | |
7620 | 4742 static void |
4743 rebuild_addchat_entries(GaimGtkAddChatData *data) | |
4744 { | |
4745 GaimConnection *gc; | |
9959 | 4746 GList *list = NULL, *tmp = NULL; |
9754 | 4747 GHashTable *defaults = NULL; |
7620 | 4748 struct proto_chat_entry *pce; |
4749 gboolean focus = TRUE; | |
4750 | |
10127 | 4751 g_return_if_fail(data->account != NULL); |
4752 | |
7620 | 4753 gc = gaim_account_get_connection(data->account); |
4754 | |
4755 while (GTK_BOX(data->entries_box)->children) | |
4756 { | |
4757 gtk_container_remove(GTK_CONTAINER(data->entries_box), | |
10475 | 4758 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
7620 | 4759 } |
4760 | |
4761 if (data->entries != NULL) | |
4762 g_list_free(data->entries); | |
4763 | |
4764 data->entries = NULL; | |
4765 | |
9959 | 4766 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4767 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | |
7620 | 4768 |
9754 | 4769 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
10475 | 4770 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, data->default_chat_name); |
9754 | 4771 |
7620 | 4772 for (tmp = list; tmp; tmp = tmp->next) |
4773 { | |
4774 GtkWidget *label; | |
4775 GtkWidget *rowbox; | |
10475 | 4776 GtkWidget *input; |
7620 | 4777 |
4778 pce = tmp->data; | |
4779 | |
4780 rowbox = gtk_hbox_new(FALSE, 5); | |
4781 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); | |
4782 | |
7889 | 4783 label = gtk_label_new_with_mnemonic(pce->label); |
7620 | 4784 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4785 gtk_size_group_add_widget(data->sg, label); | |
4786 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4787 | |
4788 if (pce->is_int) | |
4789 { | |
4790 GtkObject *adjust; | |
4791 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, | |
4792 1, 10, 10); | |
10475 | 4793 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
4794 gtk_widget_set_size_request(input, 50, -1); | |
4795 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
7620 | 4796 } |
4797 else | |
4798 { | |
9754 | 4799 char *value; |
10475 | 4800 input = gtk_entry_new(); |
4801 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9754 | 4802 value = g_hash_table_lookup(defaults, pce->identifier); |
4803 if (value != NULL) | |
10475 | 4804 gtk_entry_set_text(GTK_ENTRY(input), value); |
7620 | 4805 if (pce->secret) |
11986 | 4806 { |
10475 | 4807 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 4808 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
4809 } | |
10475 | 4810 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
4811 g_signal_connect(G_OBJECT(input), "changed", | |
4812 G_CALLBACK(addchat_set_sensitive_if_input_cb), data); | |
7620 | 4813 } |
4814 | |
10475 | 4815 /* Do the following for any type of input widget */ |
4816 if (focus) | |
4817 { | |
4818 gtk_widget_grab_focus(input); | |
4819 focus = FALSE; | |
4820 } | |
4821 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
4822 gaim_set_accessible_label(input, label); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4823 g_object_set_data(G_OBJECT(input), "identifier", (gpointer)pce->identifier); |
10475 | 4824 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); |
4825 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
4826 data->entries = g_list_append(data->entries, input); | |
4827 | |
7620 | 4828 g_free(pce); |
4829 } | |
4830 | |
4831 g_list_free(list); | |
9754 | 4832 g_hash_table_destroy(defaults); |
7620 | 4833 |
10475 | 4834 /* Set whether the "OK" button should be clickable initially */ |
4835 addchat_set_sensitive_if_input_cb(NULL, data); | |
4836 | |
7620 | 4837 gtk_widget_show_all(data->entries_box); |
4838 } | |
4839 | |
4840 static void | |
10475 | 4841 addchat_select_account_cb(GObject *w, GaimAccount *account, |
7620 | 4842 GaimGtkAddChatData *data) |
4843 { | |
9460 | 4844 if (strcmp(gaim_account_get_protocol_id(data->account), |
4845 gaim_account_get_protocol_id(account)) == 0) | |
7620 | 4846 { |
4847 data->account = account; | |
4848 } | |
4849 else | |
4850 { | |
4851 data->account = account; | |
4852 rebuild_addchat_entries(data); | |
4853 } | |
4854 } | |
4855 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
4856 static void |
7859 | 4857 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
9754 | 4858 const char *alias, const char *name) |
7620 | 4859 { |
4860 GaimGtkAddChatData *data; | |
8975 | 4861 GaimGtkBuddyList *gtkblist; |
4862 GList *l; | |
4863 GaimConnection *gc; | |
7620 | 4864 GtkWidget *label; |
4865 GtkWidget *rowbox; | |
4866 GtkWidget *hbox; | |
4867 GtkWidget *vbox; | |
4868 GtkWidget *img; | |
4869 | |
9812 | 4870 if (account != NULL) { |
4871 gc = gaim_account_get_connection(account); | |
4872 | |
4873 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | |
4874 gaim_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | |
4875 return; | |
4876 } | |
4877 } else { | |
4878 /* Find an account with chat capabilities */ | |
4879 for (l = gaim_connections_get_all(); l != NULL; l = l->next) { | |
4880 gc = (GaimConnection *)l->data; | |
4881 | |
4882 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | |
4883 account = gaim_connection_get_account(gc); | |
4884 break; | |
4885 } | |
4886 } | |
4887 | |
4888 if (account == NULL) { | |
4889 gaim_notify_error(NULL, NULL, | |
4890 _("You are not currently signed on with any " | |
4891 "protocols that have the ability to chat."), NULL); | |
4892 return; | |
4893 } | |
4894 } | |
4895 | |
7620 | 4896 data = g_new0(GaimGtkAddChatData, 1); |
9812 | 4897 data->account = account; |
4898 data->default_chat_name = g_strdup(name); | |
7620 | 4899 |
4900 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4901 GTK_ICON_SIZE_DIALOG); | |
4902 | |
8975 | 4903 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4904 | |
7620 | 4905 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4906 | |
8975 | 4907 data->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
4908 NULL, GTK_DIALOG_NO_SEPARATOR, | |
4909 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
4910 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4911 NULL); | |
4912 | |
4913 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4914 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8975 | 4915 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4916 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4917 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4918 gtk_window_set_role(GTK_WINDOW(data->window), "add_chat"); |
8975 | 4919 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4920 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4921 |
11243 | 4922 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4923 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4924 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4925 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4926 | |
4927 vbox = gtk_vbox_new(FALSE, 5); | |
4928 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4929 | |
4930 label = gtk_label_new( | |
4931 _("Please enter an alias, and the appropriate information " | |
4932 "about the chat you would like to add to your buddy list.\n")); | |
4933 gtk_widget_set_size_request(label, 400, -1); | |
4934 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4935 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4936 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4937 | |
4938 rowbox = gtk_hbox_new(FALSE, 5); | |
4939 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4940 | |
4941 label = gtk_label_new(_("Account:")); | |
4942 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4943 gtk_size_group_add_widget(data->sg, label); | |
4944 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4945 | |
4946 data->account_menu = gaim_gtk_account_option_menu_new(account, FALSE, | |
10475 | 4947 G_CALLBACK(addchat_select_account_cb), |
9987 | 4948 chat_account_filter_func, data); |
7620 | 4949 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
8137 | 4950 gaim_set_accessible_label (data->account_menu, label); |
7620 | 4951 |
4952 data->entries_box = gtk_vbox_new(FALSE, 5); | |
9811 | 4953 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
7620 | 4954 gtk_box_pack_start(GTK_BOX(vbox), data->entries_box, TRUE, TRUE, 0); |
4955 | |
4956 rebuild_addchat_entries(data); | |
4957 | |
4958 rowbox = gtk_hbox_new(FALSE, 5); | |
4959 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4960 | |
4961 label = gtk_label_new(_("Alias:")); | |
4962 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4963 gtk_size_group_add_widget(data->sg, label); | |
4964 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4965 | |
4966 data->alias_entry = gtk_entry_new(); | |
7859 | 4967 if (alias != NULL) |
4968 gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias); | |
7620 | 4969 gtk_box_pack_end(GTK_BOX(rowbox), data->alias_entry, TRUE, TRUE, 0); |
10311 | 4970 gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE); |
8137 | 4971 gaim_set_accessible_label (data->alias_entry, label); |
7620 | 4972 |
4973 rowbox = gtk_hbox_new(FALSE, 5); | |
4974 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4975 | |
9811 | 4976 label = gtk_label_new(_("Group:")); |
7620 | 4977 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4978 gtk_size_group_add_widget(data->sg, label); | |
4979 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4980 | |
9811 | 4981 data->group_combo = gtk_combo_new(); |
4982 gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree()); | |
7620 | 4983 gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0); |
4984 | |
4985 if (group) | |
4986 { | |
4987 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry), | |
4988 group->name); | |
4989 } | |
8137 | 4990 gaim_set_accessible_label (data->group_combo, label); |
7620 | 4991 |
4992 g_signal_connect(G_OBJECT(data->window), "response", | |
4993 G_CALLBACK(add_chat_resp_cb), data); | |
4994 | |
4995 gtk_widget_show_all(data->window); | |
4996 } | |
4997 | |
4998 static void | |
4999 add_group_cb(GaimConnection *gc, const char *group_name) | |
5000 { | |
9285 | 5001 GaimGroup *group; |
5002 | |
12458 | 5003 if ((group_name == NULL) || (*group_name == '\0')) |
5004 return; | |
5005 | |
9285 | 5006 group = gaim_group_new(group_name); |
5007 gaim_blist_add_group(group, NULL); | |
7620 | 5008 } |
5009 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5010 static void |
7620 | 5011 gaim_gtk_blist_request_add_group(void) |
5012 { | |
7853 | 5013 gaim_request_input(NULL, _("Add Group"), NULL, |
7620 | 5014 _("Please enter the name of the group to be added."), |
8697 | 5015 NULL, FALSE, FALSE, NULL, |
7620 | 5016 _("Add"), G_CALLBACK(add_group_cb), |
5017 _("Cancel"), NULL, NULL); | |
5018 } | |
5019 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5020 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5021 gaim_gtk_blist_toggle_visibility() |
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 if (gtkblist && gtkblist->window) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5024 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5025 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
|
5026 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5027 gaim_blist_set_visible(TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5028 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5029 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5030 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5031 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5032 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5033 gaim_gtk_blist_visibility_manager_add() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5034 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5035 visibility_manager_count++; |
12479
53e2dc07d9e2
[gaim-migrate @ 14790]
Richard Laager <rlaager@wiktel.com>
parents:
12478
diff
changeset
|
5036 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
|
5037 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5038 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5039 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5040 gaim_gtk_blist_visibility_manager_remove() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5041 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5042 if (visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5043 visibility_manager_count--; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5044 if (!visibility_manager_count) |
12115
e9790eb93216
[gaim-migrate @ 14415]
Luke Schierer <lschiere@pidgin.im>
parents:
12113
diff
changeset
|
5045 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
|
5046 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
|
5047 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5048 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5049 |
7620 | 5050 static GaimBlistUiOps blist_ui_ops = |
5228 | 5051 { |
5052 gaim_gtk_blist_new_list, | |
5256 | 5053 gaim_gtk_blist_new_node, |
5228 | 5054 gaim_gtk_blist_show, |
5055 gaim_gtk_blist_update, | |
5056 gaim_gtk_blist_remove, | |
5057 gaim_gtk_blist_destroy, | |
7620 | 5058 gaim_gtk_blist_set_visible, |
5059 gaim_gtk_blist_request_add_buddy, | |
5060 gaim_gtk_blist_request_add_chat, | |
10012 | 5061 gaim_gtk_blist_request_add_group |
5228 | 5062 }; |
5063 | |
5064 | |
7620 | 5065 GaimBlistUiOps * |
5066 gaim_gtk_blist_get_ui_ops(void) | |
5228 | 5067 { |
5068 return &blist_ui_ops; | |
5069 } | |
5070 | |
10643 | 5071 GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() |
5072 { | |
5073 return gtkblist; | |
5074 } | |
5075 | |
7620 | 5076 static void account_signon_cb(GaimConnection *gc, gpointer z) |
5077 { | |
5078 GaimAccount *account = gaim_connection_get_account(gc); | |
5079 GaimBlistNode *gnode, *cnode; | |
5080 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) | |
5081 { | |
5082 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5083 continue; | |
5084 for(cnode = gnode->child; cnode; cnode = cnode->next) | |
5085 { | |
5086 GaimChat *chat; | |
5087 | |
5088 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
5089 continue; | |
5090 | |
5091 chat = (GaimChat *)cnode; | |
5092 | |
5093 if(chat->account != account) | |
5094 continue; | |
5095 | |
8197 | 5096 if(gaim_blist_node_get_bool((GaimBlistNode*)chat, "gtk-autojoin") || |
8198 | 5097 (gaim_blist_node_get_string((GaimBlistNode*)chat, |
5098 "gtk-autojoin") != NULL)) | |
7620 | 5099 serv_join_chat(gc, chat->components); |
5100 } | |
5101 } | |
5102 } | |
5103 | |
8815 | 5104 void * |
5105 gaim_gtk_blist_get_handle() { | |
5106 static int handle; | |
5107 | |
5108 return &handle; | |
5109 } | |
5110 | |
11910 | 5111 static gboolean buddy_signonoff_timeout_cb(GaimBuddy *buddy) |
5112 { | |
5113 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
5114 | |
5115 gtknode->recent_signonoff = FALSE; | |
5116 gtknode->recent_signonoff_timer = 0; | |
5117 | |
5118 gaim_gtk_blist_update(NULL, (GaimBlistNode*)buddy); | |
5119 | |
5120 return FALSE; | |
5121 } | |
5122 | |
5123 static void buddy_signonoff_cb(GaimBuddy *buddy) | |
5124 { | |
11915 | 5125 struct _gaim_gtk_blist_node *gtknode; |
5126 | |
5127 if(!((GaimBlistNode*)buddy)->ui_data) { | |
5128 gaim_gtk_blist_new_node((GaimBlistNode*)buddy); | |
5129 } | |
5130 | |
5131 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
11910 | 5132 |
5133 gtknode->recent_signonoff = TRUE; | |
5134 | |
5135 if(gtknode->recent_signonoff_timer > 0) | |
5136 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
5137 gtknode->recent_signonoff_timer = gaim_timeout_add(10000, | |
5138 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); | |
5139 } | |
5140 | |
7620 | 5141 void gaim_gtk_blist_init(void) |
5142 { | |
8815 | 5143 void *gtk_blist_handle = gaim_gtk_blist_get_handle(); |
7620 | 5144 |
5145 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
8815 | 5146 gtk_blist_handle, GAIM_CALLBACK(account_signon_cb), |
7620 | 5147 NULL); |
7731 | 5148 |
5149 /* Initialize prefs */ | |
8819 | 5150 gaim_prefs_add_none("/gaim/gtk/blist"); |
5151 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); | |
5152 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); | |
12656 | 5153 gaim_prefs_add_bool("/gaim/gtk/blist/show_idle_time", TRUE); |
8819 | 5154 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); |
10282 | 5155 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); |
12279 | 5156 gaim_prefs_add_bool("/gaim/gtk/blist/list_maximized", FALSE); |
9711 | 5157 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); |
8819 | 5158 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
5159 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | |
9778 | 5160 gaim_prefs_add_int("/gaim/gtk/blist/width", 309); /* Golden ratio, baby */ |
5161 gaim_prefs_add_int("/gaim/gtk/blist/height", 500); /* Golden ratio, baby */ | |
8819 | 5162 gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500); |
7731 | 5163 |
8815 | 5164 /* Register our signals */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5165 gaim_signal_register(gtk_blist_handle, "gtkblist-hiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5166 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5167 gaim_value_new(GAIM_TYPE_POINTER)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5168 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5169 gaim_signal_register(gtk_blist_handle, "gtkblist-unhiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5170 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5171 gaim_value_new(GAIM_TYPE_SUBTYPE)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
5172 |
8815 | 5173 gaim_signal_register(gtk_blist_handle, "gtkblist-created", |
9811 | 5174 gaim_marshal_VOID__POINTER, NULL, 1, |
5175 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
5176 GAIM_SUBTYPE_BLIST)); | |
8819 | 5177 |
5178 gaim_signal_register(gtk_blist_handle, "drawing-tooltip", | |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5179 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
9811 | 5180 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_BLIST_NODE), |
12713
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5181 gaim_value_new_outgoing(GAIM_TYPE_BOXED, "GString *"), |
d7043c3c793d
[gaim-migrate @ 15057]
Richard Laager <rlaager@wiktel.com>
parents:
12679
diff
changeset
|
5182 gaim_value_new(GAIM_TYPE_BOOLEAN)); |
11910 | 5183 |
5184 | |
5185 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
5186 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
7620 | 5187 } |
5188 | |
8815 | 5189 void |
5190 gaim_gtk_blist_uninit(void) { | |
5191 gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle()); | |
5192 } | |
5228 | 5193 |
5194 /********************************************************************* | |
9811 | 5195 * Buddy List sorting functions * |
5422 | 5196 *********************************************************************/ |
5197 | |
11796 | 5198 GList *gaim_gtk_blist_get_sort_methods() |
5199 { | |
5200 return gaim_gtk_blist_sort_methods; | |
5201 } | |
5202 | |
7620 | 5203 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
5422 | 5204 { |
5205 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | |
7620 | 5206 method->id = g_strdup(id); |
5422 | 5207 method->name = g_strdup(name); |
9775 | 5208 method->func = func; |
11796 | 5209 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
5210 gaim_gtk_blist_update_sort_methods(); | |
5422 | 5211 } |
5212 | |
7620 | 5213 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
11796 | 5214 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5215 |
5216 while(l) { | |
5217 struct gaim_gtk_blist_sort_method *method = l->data; | |
5218 if(!strcmp(method->id, id)) { | |
11796 | 5219 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
7620 | 5220 g_free(method->id); |
5221 g_free(method->name); | |
5222 g_free(method); | |
5223 break; | |
5224 } | |
5225 } | |
11796 | 5226 gaim_gtk_blist_update_sort_methods(); |
5422 | 5227 } |
5228 | |
7620 | 5229 void gaim_gtk_blist_sort_method_set(const char *id){ |
11796 | 5230 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 5231 |
5232 if(!id) | |
5233 id = "none"; | |
5234 | |
5235 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | |
5422 | 5236 l = l->next; |
7620 | 5237 |
5422 | 5238 if (l) { |
5239 current_sort_method = l->data; | |
5240 } else if (!current_sort_method) { | |
7620 | 5241 gaim_gtk_blist_sort_method_set("none"); |
5422 | 5242 return; |
5243 } | |
5244 redo_buddy_list(gaim_get_blist(), TRUE); | |
5245 | |
5246 } | |
5247 | |
5248 /****************************************** | |
5249 ** Sort Methods | |
5250 ******************************************/ | |
5251 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5252 static void sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter parent_iter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5253 { |
7620 | 5254 GaimBlistNode *sibling = node->prev; |
5255 GtkTreeIter sibling_iter; | |
5256 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5257 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5258 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5259 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5260 } |
7620 | 5261 |
5262 while (sibling && !get_iter_from_node(sibling, &sibling_iter)) { | |
5263 sibling = sibling->prev; | |
5422 | 5264 } |
7620 | 5265 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5266 gtk_tree_store_insert_after(gtkblist->treemodel, iter, |
7620 | 5267 node->parent ? &parent_iter : NULL, |
5268 sibling ? &sibling_iter : NULL); | |
5422 | 5269 } |
5270 | |
7620 | 5271 #if GTK_CHECK_VERSION(2,2,1) |
5272 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5273 static void sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5274 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5275 GtkTreeIter more_z; |
7620 | 5276 |
5277 const char *my_name; | |
5278 | |
5279 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5280 my_name = gaim_contact_get_alias((GaimContact*)node); | |
5281 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5282 my_name = gaim_chat_get_name((GaimChat*)node); | |
5283 } else { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5284 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5285 return; |
7620 | 5286 } |
5287 | |
5422 | 5288 |
5289 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
|
5290 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5291 return; |
7620 | 5292 } |
5293 | |
5294 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5295 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5296 GaimBlistNode *n; |
7620 | 5297 const char *this_name; |
5298 int cmp; | |
5299 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5300 val.g_type = 0; |
7620 | 5301 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5302 n = g_value_get_pointer(&val); | |
5303 | |
5304 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5305 this_name = gaim_contact_get_alias((GaimContact*)n); | |
5306 } else if(GAIM_BLIST_NODE_IS_CHAT(n)) { | |
5307 this_name = gaim_chat_get_name((GaimChat*)n); | |
5308 } else { | |
5309 this_name = NULL; | |
5310 } | |
5311 | |
5312 cmp = gaim_utf8_strcasecmp(my_name, this_name); | |
5313 | |
5314 if(this_name && (cmp < 0 || (cmp == 0 && node < n))) { | |
5315 if(cur) { | |
5316 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5317 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5318 return; |
7620 | 5319 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5320 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5321 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5322 return; |
7620 | 5323 } |
5324 } | |
5325 g_value_unset(&val); | |
5326 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
5327 | |
5328 if(cur) { | |
5329 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5330 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5331 return; |
7620 | 5332 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5333 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5334 return; |
7620 | 5335 } |
5336 } | |
5337 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5338 static void sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
7620 | 5339 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5340 GtkTreeIter more_z; |
7620 | 5341 |
5342 GaimBuddy *my_buddy, *this_buddy; | |
5343 | |
5344 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5345 my_buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
5346 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5347 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5348 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5349 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5350 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5351 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5352 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5353 return; |
7620 | 5354 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5355 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5356 return; |
7620 | 5357 } |
5358 | |
5359 | |
5360 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
|
5361 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5362 return; |
5422 | 5363 } |
5364 | |
5365 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5366 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5367 GaimBlistNode *n; |
9944 | 5368 gint name_cmp; |
5369 gint presence_cmp; | |
7620 | 5370 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5371 val.g_type = 0; |
5422 | 5372 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5373 n = g_value_get_pointer(&val); | |
7620 | 5374 |
5375 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5376 this_buddy = gaim_contact_get_priority_buddy((GaimContact*)n); | |
5377 } else { | |
5378 this_buddy = NULL; | |
5379 } | |
5380 | |
9944 | 5381 name_cmp = gaim_utf8_strcasecmp( |
5382 (my_buddy | |
5383 ? gaim_contact_get_alias(gaim_buddy_get_contact(my_buddy)) | |
5384 : NULL), | |
5385 (this_buddy | |
5386 ? gaim_contact_get_alias(gaim_buddy_get_contact(this_buddy)) | |
5387 : NULL)); | |
5388 | |
5389 presence_cmp = gaim_presence_compare( | |
5390 gaim_buddy_get_presence(my_buddy), | |
5391 gaim_buddy_get_presence(this_buddy)); | |
5392 | |
5393 if (this_buddy == NULL || | |
10860 | 5394 (presence_cmp < 0 || |
9944 | 5395 (presence_cmp == 0 && |
5396 (name_cmp < 0 || (name_cmp == 0 && node < n))))) | |
5397 { | |
5398 if (cur != NULL) | |
5399 { | |
7620 | 5400 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5401 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5402 return; |
9944 | 5403 } |
5404 else | |
5405 { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5406 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
9944 | 5407 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5408 return; |
7620 | 5409 } |
5422 | 5410 } |
9944 | 5411 |
5422 | 5412 g_value_unset(&val); |
9944 | 5413 } |
5414 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), | |
5415 &more_z)); | |
7620 | 5416 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5417 if (cur) { |
7620 | 5418 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5419 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5420 return; |
7620 | 5421 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5422 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5423 return; |
7620 | 5424 } |
5422 | 5425 } |
5426 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5427 static void sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter) |
5422 | 5428 { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5429 GtkTreeIter more_z; |
7620 | 5430 |
5431 int log_size = 0, this_log_size = 0; | |
5432 const char *buddy_name, *this_buddy_name; | |
5433 | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5434 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
|
5435 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5436 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5437 } |
7620 | 5438 |
5439 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5440 GaimBlistNode *n; |
7620 | 5441 for (n = node->child; n; n = n->next) |
8898 | 5442 log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n))->name, ((GaimBuddy*)(n))->account); |
7620 | 5443 buddy_name = gaim_contact_get_alias((GaimContact*)node); |
5444 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5445 /* we don't have a reliable way of getting the log filename | |
5446 * from the chat info in the blist, yet */ | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5447 if (cur != NULL) { |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5448 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5449 return; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5450 } |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5451 |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5452 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5453 return; |
7620 | 5454 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5455 sort_method_none(node, blist, groupiter, cur, iter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5456 return; |
7620 | 5457 } |
5458 | |
5459 | |
5422 | 5460 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
|
5461 gtk_tree_store_insert(gtkblist->treemodel, iter, &groupiter, 0); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5462 return; |
5422 | 5463 } |
5464 | |
5465 do { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5466 GValue val; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5467 GaimBlistNode *n; |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5468 GaimBlistNode *n2; |
7620 | 5469 int cmp; |
5470 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12592
diff
changeset
|
5471 val.g_type = 0; |
5422 | 5472 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5473 n = g_value_get_pointer(&val); | |
7620 | 5474 this_log_size = 0; |
5475 | |
5476 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5477 for (n2 = n->child; n2; n2 = n2->next) | |
8898 | 5478 this_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n2))->name, ((GaimBuddy*)(n2))->account); |
7620 | 5479 this_buddy_name = gaim_contact_get_alias((GaimContact*)n); |
5480 } else { | |
5481 this_buddy_name = NULL; | |
5422 | 5482 } |
7620 | 5483 |
5484 cmp = gaim_utf8_strcasecmp(buddy_name, this_buddy_name); | |
5485 | |
5486 if (!GAIM_BLIST_NODE_IS_CONTACT(n) || log_size > this_log_size || | |
5487 ((log_size == this_log_size) && | |
5488 (cmp < 0 || (cmp == 0 && node < n)))) { | |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5489 if (cur != NULL) { |
7620 | 5490 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5491 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5492 return; |
7620 | 5493 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5494 gtk_tree_store_insert_before(gtkblist->treemodel, iter, |
7620 | 5495 &groupiter, &more_z); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5496 return; |
7620 | 5497 } |
5422 | 5498 } |
5499 g_value_unset(&val); | |
5500 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
7620 | 5501 |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5502 if (cur != NULL) { |
7620 | 5503 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5504 *iter = *cur; |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5505 return; |
7620 | 5506 } else { |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5507 gtk_tree_store_append(gtkblist->treemodel, iter, &groupiter); |
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5508 return; |
7620 | 5509 } |
5510 } | |
5511 | |
5512 #endif | |
5513 | |
5514 static void | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5515 plugin_act(GtkObject *obj, GaimPluginAction *pam) |
7620 | 5516 { |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5517 if (pam && pam->callback) |
10352 | 5518 pam->callback(pam); |
5422 | 5519 } |
7620 | 5520 |
8986 | 5521 static void |
12333 | 5522 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin) |
8986 | 5523 { |
12333 | 5524 GtkWidget *menuitem; |
9015 | 5525 GaimPluginAction *action = NULL; |
12333 | 5526 GList *actions, *l; |
5527 | |
5528 actions = GAIM_PLUGIN_ACTIONS(plugin, NULL); | |
5529 | |
5530 for (l = actions; l != NULL; l = l->next) | |
5531 { | |
5532 if (l->data) | |
5533 { | |
9015 | 5534 action = (GaimPluginAction *) l->data; |
5535 action->plugin = plugin; | |
12333 | 5536 action->context = NULL; |
9015 | 5537 |
5538 menuitem = gtk_menu_item_new_with_label(action->label); | |
12333 | 5539 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
5540 | |
9015 | 5541 g_signal_connect(G_OBJECT(menuitem), "activate", |
5542 G_CALLBACK(plugin_act), action); | |
13196
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5543 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5544 action, |
f04dffe22957
[gaim-migrate @ 15559]
Gary Kramlich <grim@reaperworld.com>
parents:
13195
diff
changeset
|
5545 (GDestroyNotify)gaim_plugin_action_free); |
9015 | 5546 gtk_widget_show(menuitem); |
5547 } | |
5548 else | |
5549 gaim_separator(menu); | |
5550 } | |
5551 | |
12333 | 5552 g_list_free(actions); |
8986 | 5553 } |
5554 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5555 static void |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5556 modify_account_cb(GtkWidget *widget, gpointer data) |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5557 { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5558 gaim_gtk_account_dialog_show(GAIM_GTK_MODIFY_ACCOUNT_DIALOG, data); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5559 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5560 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5561 static void |
12330 | 5562 enable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5563 { |
12330 | 5564 GaimAccount *account = data; |
5565 const GaimSavedStatus *saved_status; | |
5566 | |
5567 saved_status = gaim_savedstatus_get_current(); | |
5568 gaim_savedstatus_activate_for_account(saved_status, account); | |
5569 | |
5570 gaim_account_set_enabled(account, GAIM_GTK_UI, TRUE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5571 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5572 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5573 static void |
12330 | 5574 disable_account_cb(GtkCheckMenuItem *widget, gpointer data) |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5575 { |
12330 | 5576 GaimAccount *account = data; |
5577 | |
5578 gaim_account_set_enabled(account, GAIM_GTK_UI, FALSE); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5579 } |
8986 | 5580 |
7620 | 5581 void |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5582 gaim_gtk_blist_update_accounts_menu(void) |
7620 | 5583 { |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5584 GtkWidget *menuitem = NULL, *submenu = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5585 GList *l = NULL, *accounts = NULL; |
12330 | 5586 gboolean disabled_accounts = FALSE; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5587 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5588 if (accountmenu == NULL) |
7620 | 5589 return; |
5590 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5591 /* Clear the old Accounts menu */ |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5592 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
|
5593 menuitem = l->data; |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5594 |
4f7797a3024b
[gaim-migrate @ 14652]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12341
diff
changeset
|
5595 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
|
5596 gtk_container_remove(GTK_CONTAINER(accountmenu), |
13132
ba82cc4d1abd
[gaim-migrate @ 15494]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
5597 menuitem); |
7620 | 5598 } |
5599 | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5600 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5601 char *buf = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5602 GtkWidget *image = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5603 GaimConnection *gc = NULL; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5604 GaimAccount *account = NULL; |
12300
6487e68dcef9
[gaim-migrate @ 14604]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12298
diff
changeset
|
5605 GaimStatus *status = NULL; |
13090 | 5606 GdkPixbuf *pixbuf = NULL; |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5607 |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5608 account = accounts->data; |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5609 |
12330 | 5610 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5611 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5612 gaim_account_get_protocol_name(account), ")", NULL); | |
5613 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5614 g_free(buf); | |
5615 status = gaim_account_get_active_status(account); | |
13090 | 5616 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status), 0.5); |
5617 if (pixbuf != NULL) | |
5618 { | |
12330 | 5619 if (!gaim_account_is_connected(account)) |
13090 | 5620 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, |
12330 | 5621 0.0, FALSE); |
13090 | 5622 image = gtk_image_new_from_pixbuf(pixbuf); |
12330 | 5623 g_object_unref(G_OBJECT(pixbuf)); |
5624 gtk_widget_show(image); | |
5625 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5626 } | |
5627 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); | |
5628 gtk_widget_show(menuitem); | |
5629 | |
5630 submenu = gtk_menu_new(); | |
5631 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5632 gtk_widget_show(submenu); | |
5633 | |
5634 | |
12334 | 5635 menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit Account")); |
12330 | 5636 g_signal_connect(G_OBJECT(menuitem), "activate", |
5637 G_CALLBACK(modify_account_cb), account); | |
5638 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5639 gtk_widget_show(menuitem); | |
5640 | |
5641 gaim_separator(submenu); | |
5642 | |
5643 gc = gaim_account_get_connection(account); | |
5644 if (gc && GAIM_CONNECTION_IS_CONNECTED(gc)) { | |
5645 GaimPlugin *plugin = NULL; | |
5646 | |
5647 plugin = gc->prpl; | |
5648 if (GAIM_PLUGIN_HAS_ACTIONS(plugin)) { | |
5649 GList *l, *ll = NULL; | |
5650 GaimPluginAction *action = NULL; | |
5651 | |
5652 for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, gc); l; l = l->next) { | |
5653 if (l->data) { | |
5654 action = (GaimPluginAction *)l->data; | |
5655 action->plugin = plugin; | |
5656 action->context = gc; | |
5657 | |
5658 menuitem = gtk_menu_item_new_with_label(action->label); | |
5659 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5660 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5661 G_CALLBACK(plugin_act), action); | |
5662 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | |
5663 gtk_widget_show(menuitem); | |
5664 } else | |
5665 gaim_separator(submenu); | |
5666 } | |
5667 } else { | |
5668 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | |
5669 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5670 gtk_widget_set_sensitive(menuitem, FALSE); | |
5671 gtk_widget_show(menuitem); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5672 } |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5673 } else { |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5674 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5675 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5676 gtk_widget_set_sensitive(menuitem, FALSE); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5677 gtk_widget_show(menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5678 } |
12330 | 5679 |
5680 gaim_separator(submenu); | |
5681 | |
5682 menuitem = gtk_menu_item_new_with_mnemonic(_("_Disable")); | |
5683 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5684 G_CALLBACK(disable_account_cb), account); | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5685 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5686 gtk_widget_show(menuitem); |
12330 | 5687 } else { |
5688 disabled_accounts = TRUE; | |
12296
2f4577ae3810
[gaim-migrate @ 14600]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12279
diff
changeset
|
5689 } |
7620 | 5690 } |
9019 | 5691 |
12330 | 5692 if(disabled_accounts) { |
5693 gaim_separator(accountmenu); | |
12338 | 5694 menuitem = gtk_menu_item_new_with_label(_("Enable Account")); |
12330 | 5695 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); |
5696 gtk_widget_show(menuitem); | |
5697 | |
5698 submenu = gtk_menu_new(); | |
5699 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5700 gtk_widget_show(submenu); | |
5701 | |
5702 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { | |
5703 char *buf = NULL; | |
5704 GtkWidget *image = NULL; | |
5705 GaimAccount *account = NULL; | |
13090 | 5706 GdkPixbuf *pixbuf = NULL; |
12330 | 5707 |
5708 account = accounts->data; | |
5709 | |
5710 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { | |
5711 | |
5712 disabled_accounts = TRUE; | |
5713 | |
5714 buf = g_strconcat(gaim_account_get_username(account), " (", | |
5715 gaim_account_get_protocol_name(account), ")", NULL); | |
5716 menuitem = gtk_image_menu_item_new_with_label(buf); | |
5717 g_free(buf); | |
13090 | 5718 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
5719 if (pixbuf != NULL) | |
5720 { | |
5721 if (!gaim_account_is_connected(account)) | |
5722 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); | |
5723 image = gtk_image_new_from_pixbuf(pixbuf); | |
12330 | 5724 g_object_unref(G_OBJECT(pixbuf)); |
5725 gtk_widget_show(image); | |
5726 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5727 } | |
5728 g_signal_connect(G_OBJECT(menuitem), "activate", | |
5729 G_CALLBACK(enable_account_cb), account); | |
5730 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); | |
5731 gtk_widget_show(menuitem); | |
5732 } | |
9019 | 5733 } |
7620 | 5734 } |
5735 } | |
8986 | 5736 |
12333 | 5737 static GList *plugin_submenus = NULL; |
5738 | |
8986 | 5739 void |
5740 gaim_gtk_blist_update_plugin_actions(void) | |
5741 { | |
12333 | 5742 GtkWidget *menuitem, *submenu; |
9015 | 5743 GaimPlugin *plugin = NULL; |
8986 | 5744 GList *l; |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5745 GtkAccelGroup *accel_group; |
8986 | 5746 |
11742 | 5747 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); |
5748 | |
12333 | 5749 g_return_if_fail(pluginmenu != NULL); |
5750 | |
5751 /* Remove old plugin action submenus from the Tools menu */ | |
5752 for (l = plugin_submenus; l; l = l->next) | |
5753 { | |
5754 GList *menuitems; | |
5755 | |
5756 submenu = l->data; | |
5757 | |
5758 menuitems = gtk_container_get_children(GTK_CONTAINER(submenu)); | |
5759 while (menuitems != NULL) | |
5760 { | |
5761 GaimPluginAction *action; | |
5762 menuitem = menuitems->data; | |
5763 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | |
5764 g_free(action); | |
5765 menuitems = g_list_delete_link(menuitems, menuitems); | |
5766 } | |
5767 | |
5768 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(submenu)); | |
8986 | 5769 } |
12333 | 5770 g_list_free(plugin_submenus); |
5771 plugin_submenus = NULL; | |
5772 | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5773 accel_group = gtk_menu_get_accel_group(GTK_MENU(pluginmenu)); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5774 |
12333 | 5775 /* Add a submenu for each plugin with custom actions */ |
11742 | 5776 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5777 char *path; |
11923 | 5778 |
11742 | 5779 plugin = (GaimPlugin *) l->data; |
11923 | 5780 |
11742 | 5781 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5782 continue; | |
5783 | |
5784 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5785 continue; | |
9019 | 5786 |
13336
999571d910ed
[gaim-migrate @ 15706]
Richard Laager <rlaager@wiktel.com>
parents:
13315
diff
changeset
|
5787 menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name)); |
12333 | 5788 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); |
5789 gtk_widget_show(menuitem); | |
5790 | |
5791 plugin_submenus = g_list_append(plugin_submenus, menuitem); | |
5792 | |
5793 submenu = gtk_menu_new(); | |
5794 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5795 gtk_widget_show(submenu); | |
12464
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5796 |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5797 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5798 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
|
5799 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
2b08a27c2342
[gaim-migrate @ 14774]
Richard Laager <rlaager@wiktel.com>
parents:
12461
diff
changeset
|
5800 g_free(path); |
12333 | 5801 |
5802 build_plugin_actions(submenu, plugin); | |
8986 | 5803 } |
5804 } | |
11796 | 5805 |
12246 | 5806 static void |
5807 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
11796 | 5808 { |
5809 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
11923 | 5810 { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5811 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5812 |
11796 | 5813 gaim_gtk_blist_sort_method_set(id); |
11923 | 5814 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); |
12413
0332daad85ae
[gaim-migrate @ 14720]
Richard Laager <rlaager@wiktel.com>
parents:
12368
diff
changeset
|
5815 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13375
diff
changeset
|
5816 gaim_gtk_clear_cursor(gtkblist->window); |
11923 | 5817 } |
11796 | 5818 } |
5819 | |
5820 void | |
5821 gaim_gtk_blist_update_sort_methods(void) | |
5822 { | |
5823 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5824 GaimGtkBlistSortMethod *method = NULL; | |
5825 GList *l; | |
5826 GSList *sl = NULL; | |
5827 GtkWidget *sortmenu; | |
11797 | 5828 const char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); |
11796 | 5829 |
5830 if (gtkblist == NULL) | |
5831 return; | |
5832 | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
5833 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies")); |
11796 | 5834 |
5835 if (sortmenu == NULL) | |
5836 return; | |
5837 | |
5838 /* Clear the old menu */ | |
5839 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5840 menuitem = l->data; | |
5841 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5842 } | |
11923 | 5843 |
11796 | 5844 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { |
5845 method = (GaimGtkBlistSortMethod *) l->data; | |
5846 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5847 if (!strcmp(m, method->id)) | |
5848 activeitem = menuitem; | |
5849 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5850 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5851 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5852 G_CALLBACK(sortmethod_act), method->id); | |
11923 | 5853 gtk_widget_show(menuitem); |
11796 | 5854 } |
5855 if (activeitem) | |
5856 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5857 } |