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