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