Mercurial > pidgin.yaz
annotate pidgin/plugins/disco/gtkdisco.c @ 28900:6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 07 Nov 2009 03:45:13 +0000 |
parents | 0486e2a9b48f |
children | 3d471a4bafac |
rev | line source |
---|---|
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
1 /** |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
2 * @file gtkdisco.c GTK+ Service Discovery UI |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
3 * @ingroup pidgin |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
4 */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
5 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
6 /* pidgin |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
7 * |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
8 * Pidgin is the legal property of its developers, whose names are too numerous |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
10 * source distribution. |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
11 * |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
15 * (at your option) any later version. |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
16 * |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
21 * |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
25 */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
26 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
27 #include "internal.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
28 #include "debug.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
29 #include "gtkutils.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
30 #include "pidgin.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
31 #include "request.h" |
27161
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
32 #include "pidgintooltip.h" |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
33 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
34 #include "gtkdisco.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
35 #include "xmppdisco.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
36 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
37 GList *dialogs = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
38 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
39 enum { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
40 PIXBUF_COLUMN = 0, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
41 NAME_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
42 DESCRIPTION_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
43 SERVICE_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
44 NUM_OF_COLUMNS |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
45 }; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
46 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
47 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
48 pidgin_disco_list_destroy(PidginDiscoList *list) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
49 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
50 g_hash_table_destroy(list->services); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
51 if (list->dialog && list->dialog->discolist == list) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
52 list->dialog->discolist = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
53 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
54 if (list->tree) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
55 gtk_widget_destroy(list->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
56 list->tree = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
57 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
58 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
59 g_free((gchar*)list->server); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
60 g_free(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
61 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
62 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
63 PidginDiscoList *pidgin_disco_list_ref(PidginDiscoList *list) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
64 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
65 g_return_val_if_fail(list != NULL, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
66 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
67 ++list->ref; |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
68 purple_debug_misc("xmppdisco", "reffing list, ref count now %d\n", list->ref); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
69 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
70 return list; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
71 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
72 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
73 void pidgin_disco_list_unref(PidginDiscoList *list) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
74 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
75 g_return_if_fail(list != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
76 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
77 --list->ref; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
78 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
79 purple_debug_misc("xmppdisco", "unreffing list, ref count now %d\n", list->ref); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
80 if (list->ref == 0) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
81 pidgin_disco_list_destroy(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
82 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
83 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
84 void pidgin_disco_list_set_in_progress(PidginDiscoList *list, gboolean in_progress) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
85 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
86 PidginDiscoDialog *dialog = list->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
87 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
88 if (!dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
89 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
90 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
91 list->in_progress = in_progress; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
92 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
93 if (in_progress) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
94 gtk_widget_set_sensitive(dialog->account_widget, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
95 gtk_widget_set_sensitive(dialog->stop_button, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
96 gtk_widget_set_sensitive(dialog->browse_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
97 } else { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
98 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dialog->progress), 0.0); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
99 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
100 gtk_widget_set_sensitive(dialog->account_widget, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
101 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
102 gtk_widget_set_sensitive(dialog->stop_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
103 gtk_widget_set_sensitive(dialog->browse_button, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
104 /* |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
105 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
106 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
107 */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
108 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
109 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
110 |
27257
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
111 static GdkPixbuf * |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
112 pidgin_disco_load_icon(XmppDiscoService *service, const char *size) |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
113 { |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
114 GdkPixbuf *pixbuf = NULL; |
27550
319b09e2590f
Avoid a potentially uninitialized variable
Stu Tomlinson <stu@nosnilmot.com>
parents:
27257
diff
changeset
|
115 char *filename = NULL; |
27257
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
116 |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
117 g_return_val_if_fail(service != NULL, NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
118 g_return_val_if_fail(size != NULL, NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
119 |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
120 if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY && service->gateway_type) { |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
121 char *tmp = g_strconcat(service->gateway_type, ".png", NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
122 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", size, tmp, NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
123 g_free(tmp); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
124 #if 0 |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
125 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) { |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
126 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", size, "person.png", NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
127 #endif |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
128 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT) |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
129 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", size, "chat.png", NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
130 |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
131 if (filename) { |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
132 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
133 g_free(filename); |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
134 } |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
135 |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
136 return pixbuf; |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
137 } |
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
138 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
139 static void pidgin_disco_create_tree(PidginDiscoList *pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
140 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
141 static void dialog_select_account_cb(GObject *w, PurpleAccount *account, |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
142 PidginDiscoDialog *dialog) |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
143 { |
28776
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
144 gboolean change = (account != dialog->account); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
145 dialog->account = account; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
146 gtk_widget_set_sensitive(dialog->browse_button, account != NULL); |
28776
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
147 |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
148 if (change && dialog->discolist) { |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
149 if (dialog->discolist->tree) { |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
150 gtk_widget_destroy(dialog->discolist->tree); |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
151 dialog->discolist->tree = NULL; |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
152 } |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
153 pidgin_disco_list_unref(dialog->discolist); |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
154 dialog->discolist = NULL; |
0486e2a9b48f
When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <paul@darkrain42.org>
parents:
28373
diff
changeset
|
155 } |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
156 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
157 |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
158 static void register_button_cb(GtkWidget *unused, PidginDiscoDialog *dialog) |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
159 { |
27166
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
160 xmpp_disco_service_register(dialog->selected); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
161 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
162 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
163 static void discolist_cancel_cb(PidginDiscoList *pdl, const char *server) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
164 { |
28900
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
165 pdl->dialog->prompt_handle = NULL; |
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
166 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
167 pidgin_disco_list_set_in_progress(pdl, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
168 pidgin_disco_list_unref(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
169 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
170 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
171 static void discolist_ok_cb(PidginDiscoList *pdl, const char *server) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
172 { |
28900
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
173 pdl->dialog->prompt_handle = NULL; |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
174 gtk_widget_set_sensitive(pdl->dialog->browse_button, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
175 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
176 if (!server || !*server) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
177 purple_notify_error(my_plugin, _("Invalid Server"), _("Invalid Server"), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
178 NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
179 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
180 pidgin_disco_list_set_in_progress(pdl, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
181 pidgin_disco_list_unref(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
182 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
183 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
184 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
185 pdl->server = g_strdup(server); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
186 pidgin_disco_list_set_in_progress(pdl, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
187 xmpp_disco_start(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
188 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
189 |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
190 static void browse_button_cb(GtkWidget *button, PidginDiscoDialog *dialog) |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
191 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
192 PurpleConnection *pc; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
193 PidginDiscoList *pdl; |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
194 const char *username; |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
195 const char *at, *slash; |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
196 char *server = NULL; |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
197 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
198 pc = purple_account_get_connection(dialog->account); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
199 if (!pc) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
200 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
201 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
202 gtk_widget_set_sensitive(dialog->browse_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
203 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
204 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
205 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
206 if (dialog->discolist != NULL) { |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
207 if (dialog->discolist->tree) { |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
208 gtk_widget_destroy(dialog->discolist->tree); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
209 dialog->discolist->tree = NULL; |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
210 } |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
211 pidgin_disco_list_unref(dialog->discolist); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
212 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
213 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
214 pdl = dialog->discolist = g_new0(PidginDiscoList, 1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
215 pdl->services = g_hash_table_new_full(NULL, NULL, NULL, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
216 (GDestroyNotify)gtk_tree_row_reference_free); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
217 pdl->pc = pc; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
218 /* We keep a copy... */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
219 pidgin_disco_list_ref(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
220 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
221 pdl->dialog = dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
222 pidgin_disco_create_tree(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
223 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
224 if (dialog->account_widget) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
225 gtk_widget_set_sensitive(dialog->account_widget, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
226 |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
227 username = purple_account_get_username(dialog->account); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
228 at = g_utf8_strchr(username, -1, '@'); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
229 slash = g_utf8_strchr(username, -1, '/'); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
230 if (at && !slash) { |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
231 server = g_strdup_printf("%s", at + 1); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
232 } else if (at && slash && at + 1 < slash) { |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
233 server = g_strdup_printf("%.*s", (int)(slash - (at + 1)), at + 1); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
234 } |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
235 |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
236 if (server == NULL) |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
237 /* This shouldn't ever happen since the account is connected */ |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
238 server = g_strdup("jabber.org"); |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
239 |
28373
8d408dff1bff
Add a bunch of comments for translators that might make some of these
Mark Doliner <mark@kingant.net>
parents:
27550
diff
changeset
|
240 /* Note to translators: The string "Enter an XMPP Server" is asking the |
8d408dff1bff
Add a bunch of comments for translators that might make some of these
Mark Doliner <mark@kingant.net>
parents:
27550
diff
changeset
|
241 user to type the name of an XMPP server which will then be queried */ |
28900
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
242 dialog->prompt_handle = purple_request_input(my_plugin, _("Server name request"), _("Enter an XMPP Server"), |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
243 _("Select an XMPP server to query"), |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
244 server, FALSE, FALSE, NULL, |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
245 _("Find Services"), PURPLE_CALLBACK(discolist_ok_cb), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
246 _("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
247 purple_connection_get_account(pc), NULL, NULL, pdl); |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
248 |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
249 g_free(server); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
250 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
251 |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
252 static void add_to_blist_cb(GtkWidget *unused, PidginDiscoDialog *dialog) |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
253 { |
27166
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
254 XmppDiscoService *service = dialog->selected; |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
255 PurpleAccount *account; |
27160
0d01bd0c19ba
Use the JID for adding a chat/buddy because the name is for descriptive
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27159
diff
changeset
|
256 const char *jid; |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
257 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
258 g_return_if_fail(service != NULL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
259 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
260 account = purple_connection_get_account(service->list->pc); |
27164
f7ef790f3a44
merge of '43b8c66366c5dc03c717fa9d938446752df53293'
Elliott Sales de Andrade <qulogic@pidgin.im>
diff
changeset
|
261 jid = service->jid; |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
262 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
263 if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT) |
27160
0d01bd0c19ba
Use the JID for adding a chat/buddy because the name is for descriptive
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27159
diff
changeset
|
264 purple_blist_request_add_chat(account, NULL, NULL, jid); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
265 else |
27160
0d01bd0c19ba
Use the JID for adding a chat/buddy because the name is for descriptive
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27159
diff
changeset
|
266 purple_blist_request_add_buddy(account, jid, NULL, NULL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
267 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
268 |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
269 static gboolean |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
270 service_click_cb(GtkTreeView *tree, GdkEventButton *event, gpointer user_data) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
271 { |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
272 PidginDiscoList *pdl; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
273 XmppDiscoService *service; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
274 GtkWidget *menu; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
275 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
276 GtkTreePath *path; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
277 GtkTreeIter iter; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
278 GValue val; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
279 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
280 if (event->button != 3 || event->type != GDK_BUTTON_PRESS) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
281 return FALSE; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
282 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
283 pdl = user_data; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
284 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
285 /* Figure out what was clicked */ |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
286 if (!gtk_tree_view_get_path_at_pos(tree, event->x, event->y, &path, |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
287 NULL, NULL, NULL)) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
288 return FALSE; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
289 gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &iter, path); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
290 gtk_tree_path_free(path); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
291 val.g_type = 0; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
292 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN, |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
293 &val); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
294 service = g_value_get_pointer(&val); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
295 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
296 if (!service) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
297 return FALSE; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
298 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
299 menu = gtk_menu_new(); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
300 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
301 if (service->flags & XMPP_DISCO_ADD) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
302 pidgin_new_item_from_stock(menu, _("Add to Buddy List"), GTK_STOCK_ADD, |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
303 G_CALLBACK(add_to_blist_cb), pdl->dialog, |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
304 0, 0, NULL); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
305 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
306 if (service->flags & XMPP_DISCO_REGISTER) { |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
307 GtkWidget *item = pidgin_new_item(menu, _("Register")); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
308 g_signal_connect(G_OBJECT(item), "activate", |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
309 G_CALLBACK(register_button_cb), pdl->dialog); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
310 } |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
311 |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
312 gtk_widget_show_all(menu); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
313 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
314 event->time); |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
315 return FALSE; |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
316 } |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
317 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
318 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
319 selection_changed_cb(GtkTreeSelection *selection, PidginDiscoList *pdl) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
320 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
321 GtkTreeIter iter; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
322 GValue val; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
323 PidginDiscoDialog *dialog = pdl->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
324 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
325 if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
326 val.g_type = 0; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
327 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN, &val); |
27166
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
328 dialog->selected = g_value_get_pointer(&val); |
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
329 if (!dialog->selected) { |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
330 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
331 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
332 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
333 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
334 |
27166
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
335 gtk_widget_set_sensitive(dialog->add_button, dialog->selected->flags & XMPP_DISCO_ADD); |
abf989278782
Store the currently selected service in the Dialog structure
Paul Aurich <paul@darkrain42.org>
parents:
27165
diff
changeset
|
336 gtk_widget_set_sensitive(dialog->register_button, dialog->selected->flags & XMPP_DISCO_REGISTER); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
337 } else { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
338 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
339 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
340 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
341 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
342 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
343 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
344 row_expanded_cb(GtkTreeView *tree, GtkTreeIter *arg1, GtkTreePath *rg2, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
345 gpointer user_data) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
346 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
347 PidginDiscoList *pdl; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
348 XmppDiscoService *service; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
349 GValue val; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
350 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
351 pdl = user_data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
352 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
353 val.g_type = 0; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
354 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), arg1, SERVICE_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
355 &val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
356 service = g_value_get_pointer(&val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
357 xmpp_disco_service_expand(service); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
358 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
359 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
360 static void |
27159
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
361 row_activated_cb(GtkTreeView *tree_view, |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
362 GtkTreePath *path, |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
363 GtkTreeViewColumn *column, |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
364 gpointer user_data) |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
365 { |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
366 PidginDiscoList *pdl = user_data; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
367 GtkTreeIter iter; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
368 XmppDiscoService *service; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
369 GValue val; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
370 |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
371 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &iter, path)) |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
372 return; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
373 |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
374 val.g_type = 0; |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
375 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN, |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
376 &val); |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
377 service = g_value_get_pointer(&val); |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
378 |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
379 if (service->flags & XMPP_DISCO_BROWSE) |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
380 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(pdl->tree), path)) |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
381 gtk_tree_view_collapse_row(GTK_TREE_VIEW(pdl->tree), path); |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
382 else |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
383 gtk_tree_view_expand_row(GTK_TREE_VIEW(pdl->tree), path, FALSE); |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
384 else if (service->flags & XMPP_DISCO_REGISTER) |
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
385 register_button_cb(NULL, pdl->dialog); |
27159
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
386 else if (service->flags & XMPP_DISCO_ADD) |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
387 add_to_blist_cb(NULL, pdl->dialog); |
27159
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
388 } |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
389 |
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
390 static void |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
391 destroy_win_cb(GtkWidget *window, gpointer d) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
392 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
393 PidginDiscoDialog *dialog = d; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
394 PidginDiscoList *list = dialog->discolist; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
395 |
28900
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
396 if (dialog->prompt_handle) |
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
397 purple_request_close(PURPLE_REQUEST_INPUT, dialog->prompt_handle); |
6126436715e8
xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <paul@darkrain42.org>
parents:
28776
diff
changeset
|
398 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
399 if (list) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
400 list->dialog = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
401 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
402 if (list->in_progress) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
403 list->in_progress = FALSE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
404 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
405 pidgin_disco_list_unref(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
406 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
407 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
408 dialogs = g_list_remove(dialogs, d); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
409 g_free(dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
410 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
411 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
412 static void stop_button_cb(GtkButton *button, PidginDiscoDialog *dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
413 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
414 pidgin_disco_list_set_in_progress(dialog->discolist, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
415 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
416 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
417 static void close_button_cb(GtkButton *button, PidginDiscoDialog *dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
418 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
419 GtkWidget *window = dialog->window; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
420 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
421 gtk_widget_destroy(window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
422 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
423 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
424 static gboolean account_filter_func(PurpleAccount *account) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
425 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
426 return purple_strequal(purple_account_get_protocol_id(account), XMPP_PLUGIN_ID); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
427 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
428 |
27161
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
429 static gboolean |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
430 disco_paint_tooltip(GtkWidget *tipwindow, gpointer data) |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
431 { |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
432 PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
433 gtk_paint_layout(tipwindow->style, tipwindow->window, GTK_STATE_NORMAL, FALSE, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
434 NULL, tipwindow, "tooltip", |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
435 6, 6, layout); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
436 return TRUE; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
437 } |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
438 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
439 static gboolean |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
440 disco_create_tooltip(GtkWidget *tipwindow, GtkTreePath *path, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
441 gpointer data, int *w, int *h) |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
442 { |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
443 PidginDiscoList *pdl = data; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
444 GtkTreeIter iter; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
445 PangoLayout *layout; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
446 int width, height; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
447 XmppDiscoService *service; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
448 GValue val; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
449 const char *type = NULL; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
450 char *markup, *jid, *name, *desc = NULL; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
451 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
452 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &iter, path)) |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
453 return FALSE; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
454 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
455 val.g_type = 0; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
456 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
457 &val); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
458 service = g_value_get_pointer(&val); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
459 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
460 switch (service->type) { |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
461 case XMPP_DISCO_SERVICE_TYPE_UNSET: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
462 type = _("Unknown"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
463 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
464 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
465 case XMPP_DISCO_SERVICE_TYPE_GATEWAY: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
466 type = _("Gateway"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
467 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
468 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
469 case XMPP_DISCO_SERVICE_TYPE_DIRECTORY: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
470 type = _("Directory"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
471 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
472 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
473 case XMPP_DISCO_SERVICE_TYPE_CHAT: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
474 type = _("Chat"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
475 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
476 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
477 case XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
478 type = _("PubSub Collection"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
479 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
480 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
481 case XMPP_DISCO_SERVICE_TYPE_PUBSUB_LEAF: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
482 type = _("PubSub Leaf"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
483 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
484 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
485 case XMPP_DISCO_SERVICE_TYPE_OTHER: |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
486 type = _("Other"); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
487 break; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
488 } |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
489 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
490 markup = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>\n<b>%s:</b> %s%s%s", |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
491 name = g_markup_escape_text(service->name, -1), |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
492 type, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
493 jid = g_markup_escape_text(service->jid, -1), |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
494 service->description ? _("\n<b>Description:</b> ") : "", |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
495 service->description ? desc = g_markup_escape_text(service->description, -1) : ""); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
496 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
497 layout = gtk_widget_create_pango_layout(tipwindow, NULL); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
498 pango_layout_set_markup(layout, markup, -1); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
499 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
500 pango_layout_set_width(layout, 500000); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
501 pango_layout_get_size(layout, &width, &height); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
502 g_object_set_data_full(G_OBJECT(tipwindow), "tooltip-plugin", layout, g_object_unref); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
503 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
504 if (w) |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
505 *w = PANGO_PIXELS(width) + 12; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
506 if (h) |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
507 *h = PANGO_PIXELS(height) + 12; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
508 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
509 g_free(markup); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
510 g_free(jid); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
511 g_free(name); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
512 g_free(desc); |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
513 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
514 return TRUE; |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
515 } |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
516 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
517 static void pidgin_disco_create_tree(PidginDiscoList *pdl) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
518 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
519 GtkCellRenderer *text_renderer, *pixbuf_renderer; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
520 GtkTreeViewColumn *column; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
521 GtkTreeSelection *selection; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
522 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
523 pdl->model = gtk_tree_store_new(NUM_OF_COLUMNS, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
524 GDK_TYPE_PIXBUF, /* PIXBUF_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
525 G_TYPE_STRING, /* NAME_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
526 G_TYPE_STRING, /* DESCRIPTION_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
527 G_TYPE_POINTER /* SERVICE_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
528 ); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
529 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
530 pdl->tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdl->model)); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
531 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(pdl->tree), TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
532 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
533 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pdl->tree)); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
534 g_signal_connect(G_OBJECT(selection), "changed", |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
535 G_CALLBACK(selection_changed_cb), pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
536 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
537 g_object_unref(pdl->model); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
538 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
539 gtk_container_add(GTK_CONTAINER(pdl->dialog->sw), pdl->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
540 gtk_widget_show(pdl->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
541 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
542 text_renderer = gtk_cell_renderer_text_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
543 pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
544 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
545 column = gtk_tree_view_column_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
546 gtk_tree_view_column_set_title(column, _("Name")); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
547 |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
548 gtk_tree_view_column_pack_start(column, pixbuf_renderer, FALSE); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
549 gtk_tree_view_column_set_attributes(column, pixbuf_renderer, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
550 "pixbuf", PIXBUF_COLUMN, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
551 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
552 gtk_tree_view_column_pack_start(column, text_renderer, TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
553 gtk_tree_view_column_set_attributes(column, text_renderer, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
554 "text", NAME_COLUMN, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
555 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
556 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
557 GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
558 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
559 gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), NAME_COLUMN); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
560 gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
561 gtk_tree_view_append_column(GTK_TREE_VIEW(pdl->tree), column); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
562 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
563 column = gtk_tree_view_column_new_with_attributes(_("Description"), text_renderer, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
564 "text", DESCRIPTION_COLUMN, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
565 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
566 GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
567 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
568 gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), DESCRIPTION_COLUMN); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
569 gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
570 gtk_tree_view_append_column(GTK_TREE_VIEW(pdl->tree), column); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
571 |
27167
fc7b9ca819c3
Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <paul@darkrain42.org>
parents:
27166
diff
changeset
|
572 g_signal_connect(G_OBJECT(pdl->tree), "button-press-event", G_CALLBACK(service_click_cb), pdl); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
573 g_signal_connect(G_OBJECT(pdl->tree), "row-expanded", G_CALLBACK(row_expanded_cb), pdl); |
27159
0baf79f7a58d
Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27158
diff
changeset
|
574 g_signal_connect(G_OBJECT(pdl->tree), "row-activated", G_CALLBACK(row_activated_cb), pdl); |
27161
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
575 |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
576 pidgin_tooltip_setup_for_treeview(pdl->tree, pdl, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
577 disco_create_tooltip, |
dda65a7151a2
Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27160
diff
changeset
|
578 disco_paint_tooltip); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
579 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
580 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
581 void pidgin_disco_signed_off_cb(PurpleConnection *pc) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
582 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
583 GList *node; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
584 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
585 for (node = dialogs; node; node = node->next) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
586 PidginDiscoDialog *dialog = node->data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
587 PidginDiscoList *list = dialog->discolist; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
588 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
589 if (list && list->pc == pc) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
590 if (list->in_progress) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
591 pidgin_disco_list_set_in_progress(list, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
592 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
593 if (list->tree) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
594 gtk_widget_destroy(list->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
595 list->tree = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
596 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
597 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
598 pidgin_disco_list_unref(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
599 dialog->discolist = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
600 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
601 gtk_widget_set_sensitive(dialog->browse_button, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
602 pidgin_account_option_menu_get_selected(dialog->account_widget) != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
603 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
604 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
605 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
606 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
607 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
608 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
609 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
610 void pidgin_disco_dialogs_destroy_all(void) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
611 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
612 while (dialogs) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
613 PidginDiscoDialog *dialog = dialogs->data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
614 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
615 gtk_widget_destroy(dialog->window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
616 /* destroy_win_cb removes the dialog from the list */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
617 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
618 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
619 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
620 PidginDiscoDialog *pidgin_disco_dialog_new(void) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
621 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
622 PidginDiscoDialog *dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
623 GtkWidget *window, *vbox, *vbox2, *bbox; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
624 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
625 dialog = g_new0(PidginDiscoDialog, 1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
626 dialogs = g_list_prepend(dialogs, dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
627 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
628 /* Create the window. */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
629 dialog->window = window = pidgin_create_dialog(_("Service Discovery"), PIDGIN_HIG_BORDER, "service discovery", TRUE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
630 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
631 g_signal_connect(G_OBJECT(window), "destroy", |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
632 G_CALLBACK(destroy_win_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
633 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
634 /* Create the parent vbox for everything. */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
635 vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(window), FALSE, PIDGIN_HIG_BORDER); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
636 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
637 vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
638 gtk_container_add(GTK_CONTAINER(vbox), vbox2); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
639 gtk_widget_show(vbox2); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
640 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
641 /* accounts dropdown list */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
642 dialog->account_widget = pidgin_account_option_menu_new(NULL, FALSE, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
643 G_CALLBACK(dialog_select_account_cb), account_filter_func, dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
644 dialog->account = pidgin_account_option_menu_get_selected(dialog->account_widget); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
645 pidgin_add_widget_to_vbox(GTK_BOX(vbox2), _("_Account:"), NULL, dialog->account_widget, TRUE, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
646 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
647 /* scrolled window */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
648 dialog->sw = gtk_scrolled_window_new(NULL, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
649 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dialog->sw), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
650 GTK_SHADOW_IN); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
651 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dialog->sw), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
652 GTK_POLICY_AUTOMATIC, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
653 GTK_POLICY_AUTOMATIC); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
654 gtk_box_pack_start(GTK_BOX(vbox2), dialog->sw, TRUE, TRUE, 0); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
655 gtk_widget_set_size_request(dialog->sw, -1, 250); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
656 gtk_widget_show(dialog->sw); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
657 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
658 /* progress bar */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
659 dialog->progress = gtk_progress_bar_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
660 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
661 gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
662 gtk_widget_show(dialog->progress); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
663 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
664 /* button box */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
665 bbox = pidgin_dialog_get_action_area(GTK_DIALOG(window)); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
666 gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
667 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
668 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
669 /* stop button */ |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
670 dialog->stop_button = |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
671 pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP, |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
672 G_CALLBACK(stop_button_cb), dialog); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
673 gtk_widget_set_sensitive(dialog->stop_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
674 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
675 /* browse button */ |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
676 dialog->browse_button = |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
677 pidgin_pixbuf_button_from_stock(_("_Browse"), GTK_STOCK_REFRESH, |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
678 PIDGIN_BUTTON_HORIZONTAL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
679 gtk_box_pack_start(GTK_BOX(bbox), dialog->browse_button, FALSE, FALSE, 0); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
680 g_signal_connect(G_OBJECT(dialog->browse_button), "clicked", |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
681 G_CALLBACK(browse_button_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
682 gtk_widget_set_sensitive(dialog->browse_button, dialog->account != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
683 gtk_widget_show(dialog->browse_button); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
684 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
685 /* register button */ |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
686 dialog->register_button = |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
687 pidgin_dialog_add_button(GTK_DIALOG(dialog->window), _("Register"), |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
688 G_CALLBACK(register_button_cb), dialog); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
689 gtk_widget_set_sensitive(dialog->register_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
690 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
691 /* add button */ |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
692 dialog->add_button = |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
693 pidgin_pixbuf_button_from_stock(_("_Add"), GTK_STOCK_ADD, |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
694 PIDGIN_BUTTON_HORIZONTAL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
695 gtk_box_pack_start(GTK_BOX(bbox), dialog->add_button, FALSE, FALSE, 0); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
696 g_signal_connect(G_OBJECT(dialog->add_button), "clicked", |
27163
22d73c75e546
Fix adding a chat to the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
27162
diff
changeset
|
697 G_CALLBACK(add_to_blist_cb), dialog); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
698 gtk_widget_set_sensitive(dialog->add_button, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
699 gtk_widget_show(dialog->add_button); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
700 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
701 /* close button */ |
27158
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
702 dialog->close_button = |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
703 pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, |
abab554140b5
Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27128
diff
changeset
|
704 G_CALLBACK(close_button_cb), dialog); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
705 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
706 /* show the dialog window and return the dialog */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
707 gtk_widget_show(dialog->window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
708 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
709 return dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
710 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
711 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
712 void pidgin_disco_add_service(PidginDiscoList *pdl, XmppDiscoService *service, XmppDiscoService *parent) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
713 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
714 PidginDiscoDialog *dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
715 GtkTreeIter iter, parent_iter, child; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
716 GdkPixbuf *pixbuf = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
717 gboolean append = TRUE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
718 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
719 dialog = pdl->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
720 g_return_if_fail(dialog != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
721 |
27085
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
722 if (service != NULL) |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
723 purple_debug_info("xmppdisco", "Adding service \"%s\"\n", service->name); |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
724 else |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
725 purple_debug_info("xmppdisco", "Service \"%s\" has no childrens\n", parent->name); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
726 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
727 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress)); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
728 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
729 if (parent) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
730 GtkTreeRowReference *rr; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
731 GtkTreePath *path; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
732 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
733 rr = g_hash_table_lookup(pdl->services, parent); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
734 path = gtk_tree_row_reference_get_path(rr); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
735 if (path) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
736 gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &parent_iter, path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
737 gtk_tree_path_free(path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
738 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
739 if (gtk_tree_model_iter_children(GTK_TREE_MODEL(pdl->model), &child, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
740 &parent_iter)) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
741 PidginDiscoList *tmp; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
742 gtk_tree_model_get(GTK_TREE_MODEL(pdl->model), &child, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
743 SERVICE_COLUMN, &tmp, -1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
744 if (!tmp) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
745 append = FALSE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
746 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
747 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
748 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
749 |
27085
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
750 if (service == NULL) { |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
751 if (parent != NULL && !append) |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
752 gtk_tree_store_remove(pdl->model, &child); |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
753 return; |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
754 } |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
755 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
756 if (append) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
757 gtk_tree_store_append(pdl->model, &iter, (parent ? &parent_iter : NULL)); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
758 else |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
759 iter = child; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
760 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
761 if (service->flags & XMPP_DISCO_BROWSE) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
762 GtkTreeRowReference *rr; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
763 GtkTreePath *path; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
764 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
765 gtk_tree_store_append(pdl->model, &child, &iter); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
766 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
767 path = gtk_tree_model_get_path(GTK_TREE_MODEL(pdl->model), &iter); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
768 rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(pdl->model), path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
769 g_hash_table_insert(pdl->services, service, rr); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
770 gtk_tree_path_free(path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
771 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
772 |
27257
afcb1d41e557
Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <paul@darkrain42.org>
parents:
27167
diff
changeset
|
773 pixbuf = pidgin_disco_load_icon(service, "16"); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
774 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
775 gtk_tree_store_set(pdl->model, &iter, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
776 PIXBUF_COLUMN, pixbuf, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
777 NAME_COLUMN, service->name, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
778 DESCRIPTION_COLUMN, service->description, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
779 SERVICE_COLUMN, service, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
780 -1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
781 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
782 if (pixbuf) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
783 g_object_unref(pixbuf); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
784 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
785 |