Mercurial > pidgin.yaz
annotate pidgin/plugins/disco/gtkdisco.c @ 27163:22d73c75e546
Fix adding a chat to the buddy list.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 08 Jun 2009 03:35:14 +0000 |
parents | 7dbe7ae559d3 |
children | f7ef790f3a44 |
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" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
32 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
33 #include "gtkdisco.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
34 #include "xmppdisco.h" |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
35 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
36 GList *dialogs = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
37 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
38 enum { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
39 PIXBUF_COLUMN = 0, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
40 NAME_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
41 DESCRIPTION_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
42 SERVICE_COLUMN, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
43 NUM_OF_COLUMNS |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
44 }; |
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 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
47 pidgin_disco_list_destroy(PidginDiscoList *list) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
48 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
49 g_hash_table_destroy(list->services); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
50 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
|
51 list->dialog->discolist = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
52 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
53 if (list->tree) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
54 gtk_widget_destroy(list->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
55 list->tree = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
56 } |
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 g_free((gchar*)list->server); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
59 g_free(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
60 } |
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 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
|
63 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
64 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
|
65 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
66 ++list->ref; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
67 purple_debug_misc("xmppdisco", "reffing 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
|
68 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
69 return list; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
70 } |
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 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
|
73 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
74 g_return_if_fail(list != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
75 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
76 --list->ref; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
77 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
78 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
|
79 if (list->ref == 0) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
80 pidgin_disco_list_destroy(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
81 } |
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 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
|
84 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
85 PidginDiscoDialog *dialog = list->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
86 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
87 if (!dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
88 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
89 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
90 list->in_progress = in_progress; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
91 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
92 if (in_progress) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
93 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
|
94 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
|
95 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
|
96 } else { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
97 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
|
98 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
99 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
|
100 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
101 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
|
102 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
|
103 /* |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
104 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
|
105 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
|
106 */ |
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 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
|
111 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
112 static void dialog_select_account_cb(GObject *w, PurpleAccount *account, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
113 PidginDiscoDialog *dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
114 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
115 dialog->account = account; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
116 gtk_widget_set_sensitive(dialog->browse_button, account != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
117 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
118 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
119 static void register_button_cb(GtkButton *button, PidginDiscoDialog *dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
120 { |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
121 XmppDiscoService *service = g_object_get_data(G_OBJECT(button), "service"); |
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
122 xmpp_disco_service_register(service); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
123 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
124 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
125 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
|
126 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
127 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
|
128 pidgin_disco_list_unref(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
129 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
130 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
131 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
|
132 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
133 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
|
134 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
135 if (!server || !*server) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
136 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
|
137 NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
138 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
139 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
|
140 pidgin_disco_list_unref(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
141 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
142 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
143 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
144 pdl->server = g_strdup(server); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
145 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
|
146 xmpp_disco_start(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
147 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
148 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
149 static void browse_button_cb(GtkButton *button, PidginDiscoDialog *dialog) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
150 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
151 PurpleConnection *pc; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 char *server = NULL; |
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 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
|
158 if (!pc) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
159 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
160 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 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
|
169 } |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
170 pidgin_disco_list_unref(dialog->discolist); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
171 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
172 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
173 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
|
174 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
|
175 (GDestroyNotify)gtk_tree_row_reference_free); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
176 pdl->pc = pc; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
177 /* We keep a copy... */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
178 pidgin_disco_list_ref(pdl); |
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 pdl->dialog = dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
181 pidgin_disco_create_tree(pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
182 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
183 if (dialog->account_widget) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
184 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
|
185 |
27059
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 } 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
|
192 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
|
193 } |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
194 |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
195 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
|
196 /* 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
|
197 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
|
198 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
199 purple_request_input(my_plugin, _("Server name request"), _("Enter an XMPP Server"), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
200 _("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
|
201 server, FALSE, FALSE, NULL, |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
202 _("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
|
203 _("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
204 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
|
205 |
9639747bb98c
Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents:
27058
diff
changeset
|
206 g_free(server); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
207 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
208 |
27163
22d73c75e546
Fix adding a chat to the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
27162
diff
changeset
|
209 static void add_to_blist_cb(GtkButton *button, PidginDiscoDialog *dialog) |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
210 { |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
211 XmppDiscoService *service = g_object_get_data(G_OBJECT(button), "service"); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
212 PurpleAccount *account; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
213 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
214 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
|
215 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
216 account = purple_connection_get_account(service->list->pc); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
217 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
218 if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT) |
27163
22d73c75e546
Fix adding a chat to the buddy list.
Paul Aurich <paul@darkrain42.org>
parents:
27162
diff
changeset
|
219 purple_blist_request_add_chat(account, NULL, NULL, service->jid); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
220 else |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
221 purple_blist_request_add_buddy(account, service->name, NULL, NULL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
222 } |
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 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
225 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
|
226 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
227 XmppDiscoService *service; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
228 GtkTreeIter iter; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
229 GValue val; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
230 PidginDiscoDialog *dialog = pdl->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
231 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
232 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
|
233 val.g_type = 0; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
234 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN, &val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
235 service = g_value_get_pointer(&val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
236 if (!service) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
237 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
|
238 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
|
239 return; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
240 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
241 |
27162
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
242 g_object_set_data(G_OBJECT(dialog->add_button), "service", service); |
7dbe7ae559d3
Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <paul@darkrain42.org>
parents:
27128
diff
changeset
|
243 g_object_set_data(G_OBJECT(dialog->register_button), "service", service); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
244 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
245 gtk_widget_set_sensitive(dialog->add_button, service->flags & XMPP_DISCO_ADD); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
246 gtk_widget_set_sensitive(dialog->register_button, service->flags & XMPP_DISCO_REGISTER); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
247 } else { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
248 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
|
249 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
|
250 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
251 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
252 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
253 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
254 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
|
255 gpointer user_data) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
256 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
257 PidginDiscoList *pdl; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
258 XmppDiscoService *service; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
259 GValue val; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
260 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
261 pdl = user_data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
262 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
263 val.g_type = 0; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
264 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
|
265 &val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
266 service = g_value_get_pointer(&val); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
267 xmpp_disco_service_expand(service); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
268 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
269 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
270 static void |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
271 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
|
272 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
273 PidginDiscoDialog *dialog = d; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
274 PidginDiscoList *list = dialog->discolist; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
275 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
276 if (list) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
277 list->dialog = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
278 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
279 if (list->in_progress) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
280 list->in_progress = FALSE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
281 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
282 pidgin_disco_list_unref(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
283 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
284 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
285 dialogs = g_list_remove(dialogs, d); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
286 g_free(dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
287 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
288 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
289 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
|
290 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
291 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
|
292 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
293 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
294 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
|
295 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
296 GtkWidget *window = dialog->window; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
297 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
298 gtk_widget_destroy(window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
299 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
300 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
301 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
|
302 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
303 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
|
304 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
305 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
306 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
|
307 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
308 GtkCellRenderer *text_renderer, *pixbuf_renderer; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
309 GtkTreeViewColumn *column; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
310 GtkTreeSelection *selection; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
311 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
312 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
|
313 GDK_TYPE_PIXBUF, /* PIXBUF_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
314 G_TYPE_STRING, /* NAME_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
315 G_TYPE_STRING, /* DESCRIPTION_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
316 G_TYPE_POINTER /* SERVICE_COLUMN */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
317 ); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
318 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
319 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
|
320 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
|
321 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
322 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
|
323 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
|
324 G_CALLBACK(selection_changed_cb), pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
325 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
326 g_object_unref(pdl->model); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
327 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
328 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
|
329 gtk_widget_show(pdl->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
330 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
331 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
|
332 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
|
333 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
334 column = gtk_tree_view_column_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
335 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
|
336 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
337 gtk_tree_view_column_pack_start(column, pixbuf_renderer, FALSE); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
338 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
|
339 "pixbuf", PIXBUF_COLUMN, NULL); |
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 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
|
342 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
|
343 "text", NAME_COLUMN, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
344 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
345 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
|
346 GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 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
|
351 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
352 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
|
353 "text", DESCRIPTION_COLUMN, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
354 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
|
355 GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
356 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
|
357 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
|
358 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
|
359 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
|
360 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
361 g_signal_connect(G_OBJECT(pdl->tree), "row-expanded", G_CALLBACK(row_expanded_cb), pdl); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
362 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
363 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
364 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
|
365 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
366 GList *node; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
367 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
368 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
|
369 PidginDiscoDialog *dialog = node->data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
370 PidginDiscoList *list = dialog->discolist; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
371 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
372 if (list && list->pc == pc) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
373 if (list->in_progress) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
374 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
|
375 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
376 if (list->tree) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
377 gtk_widget_destroy(list->tree); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
378 list->tree = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
379 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
380 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
381 pidgin_disco_list_unref(list); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
382 dialog->discolist = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
383 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
384 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
|
385 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
|
386 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
387 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
|
388 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
|
389 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
390 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
391 } |
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 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
|
394 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
395 while (dialogs) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
396 PidginDiscoDialog *dialog = dialogs->data; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
397 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
398 gtk_widget_destroy(dialog->window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
399 /* 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
|
400 } |
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 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
403 PidginDiscoDialog *pidgin_disco_dialog_new(void) |
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 PidginDiscoDialog *dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
406 GtkWidget *window, *vbox, *vbox2, *bbox; |
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 dialog = g_new0(PidginDiscoDialog, 1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
409 dialogs = g_list_prepend(dialogs, 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 /* Create the window. */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
412 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
|
413 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
414 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
|
415 G_CALLBACK(destroy_win_cb), dialog); |
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 /* Create the parent vbox for everything. */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
418 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
|
419 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
420 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
|
421 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
|
422 gtk_widget_show(vbox2); |
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 /* accounts dropdown list */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 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
|
429 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
430 /* scrolled window */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
431 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
|
432 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
|
433 GTK_SHADOW_IN); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
434 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
|
435 GTK_POLICY_AUTOMATIC, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
436 GTK_POLICY_AUTOMATIC); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
437 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
|
438 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
|
439 gtk_widget_show(dialog->sw); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
440 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
441 /* progress bar */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
442 dialog->progress = gtk_progress_bar_new(); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
443 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
|
444 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
|
445 gtk_widget_show(dialog->progress); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
446 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
447 /* button box */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
452 /* stop button */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
453 dialog->stop_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
454 G_CALLBACK(stop_button_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
455 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
|
456 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
457 /* browse button */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
458 dialog->browse_button = pidgin_pixbuf_button_from_stock(_("_Browse"), GTK_STOCK_REFRESH, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
459 PIDGIN_BUTTON_HORIZONTAL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
460 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
|
461 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
|
462 G_CALLBACK(browse_button_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
463 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
|
464 gtk_widget_show(dialog->browse_button); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
465 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
466 /* register button */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
467 dialog->register_button = pidgin_dialog_add_button(GTK_DIALOG(dialog->window), _("Register"), |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
468 G_CALLBACK(register_button_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
469 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
|
470 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
471 /* add button */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
472 dialog->add_button = pidgin_pixbuf_button_from_stock(_("_Add"), GTK_STOCK_ADD, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
473 PIDGIN_BUTTON_HORIZONTAL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
474 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
|
475 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
|
476 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
|
477 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
|
478 gtk_widget_show(dialog->add_button); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
479 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
480 /* close button */ |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
481 dialog->close_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
482 G_CALLBACK(close_button_cb), dialog); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
483 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
484 /* 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
|
485 gtk_widget_show(dialog->window); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
486 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
487 return dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
488 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
489 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
490 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
|
491 { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
492 PidginDiscoDialog *dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
493 GtkTreeIter iter, parent_iter, child; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
494 char *filename = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
495 GdkPixbuf *pixbuf = NULL; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
496 gboolean append = TRUE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
497 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
498 dialog = pdl->dialog; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
499 g_return_if_fail(dialog != NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
500 |
27085
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
501 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
|
502 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
|
503 else |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
504 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
|
505 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
506 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
|
507 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
508 if (parent) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
509 GtkTreeRowReference *rr; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
510 GtkTreePath *path; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
511 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
512 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
|
513 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
|
514 if (path) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
515 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
|
516 gtk_tree_path_free(path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
517 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
518 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
|
519 &parent_iter)) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
520 PidginDiscoList *tmp; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
521 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
|
522 SERVICE_COLUMN, &tmp, -1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
523 if (!tmp) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
524 append = FALSE; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
525 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
526 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
527 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
528 |
27085
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 return; |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
533 } |
61d817c4c935
Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents:
27059
diff
changeset
|
534 |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
535 if (append) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
536 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
|
537 else |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
538 iter = child; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
539 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
540 if (service->flags & XMPP_DISCO_BROWSE) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
541 GtkTreeRowReference *rr; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
542 GtkTreePath *path; |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
543 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
544 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
|
545 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
546 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
|
547 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
|
548 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
|
549 gtk_tree_path_free(path); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
550 } |
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 if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY && service->gateway_type) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
553 char *tmp = g_strconcat(service->gateway_type, ".png", NULL); |
27128
a4574f513be5
Use 16px icons in the XMPP disco browser as 22px seems a bit weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27085
diff
changeset
|
554 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", "16", tmp, NULL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
555 g_free(tmp); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
556 #if 0 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
557 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) { |
27128
a4574f513be5
Use 16px icons in the XMPP disco browser as 22px seems a bit weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27085
diff
changeset
|
558 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "16", "person.png", NULL); |
27058
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
559 #endif |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
560 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT) |
27128
a4574f513be5
Use 16px icons in the XMPP disco browser as 22px seems a bit weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27085
diff
changeset
|
561 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "16", "chat.png", NULL); |
27058
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 if (filename) { |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
564 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
565 g_free(filename); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
566 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
567 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
568 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
|
569 PIXBUF_COLUMN, pixbuf, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
570 NAME_COLUMN, service->name, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
571 DESCRIPTION_COLUMN, service->description, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
572 SERVICE_COLUMN, service, |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
573 -1); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
574 |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
575 if (pixbuf) |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
576 g_object_unref(pixbuf); |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
577 } |
08964b4b2fe4
Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
578 |