annotate pidgin/plugins/disco/gtkdisco.c @ 27159:0baf79f7a58d

Add a row-activated callback for the XMPP Disco browser that provides a default action for each row. Browseable services expand/collapse, services with ADD flag open the add dialog, and services with the REGISTER flag will open the register dialog (in that order).
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 07 Jun 2009 22:12:26 +0000
parents abab554140b5
children 0d01bd0c19ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 struct _menu_cb_info {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
39 PidginDiscoList *list;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
40 XmppDiscoService *service;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
41 };
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
42
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
43 enum {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
44 PIXBUF_COLUMN = 0,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
45 NAME_COLUMN,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
46 DESCRIPTION_COLUMN,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
47 SERVICE_COLUMN,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
48 NUM_OF_COLUMNS
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
49 };
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
50
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
51 static void
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
52 pidgin_disco_list_destroy(PidginDiscoList *list)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
53 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
54 g_hash_table_destroy(list->services);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
55 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
56 list->dialog->discolist = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
57
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
58 if (list->tree) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
59 gtk_widget_destroy(list->tree);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
60 list->tree = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
61 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
62
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
63 g_free((gchar*)list->server);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
64 g_free(list);
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
67 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
68 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
69 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
70
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
71 ++list->ref;
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
72 purple_debug_misc("xmppdisco", "reffing list, ref count now %d\n", list->ref);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
73
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
74 return list;
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
77 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
78 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
79 g_return_if_fail(list != NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
80
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
81 --list->ref;
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 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
84 if (list->ref == 0)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
85 pidgin_disco_list_destroy(list);
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
88 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
89 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
90 PidginDiscoDialog *dialog = list->dialog;
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 (!dialog)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
93 return;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
94
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
95 list->in_progress = in_progress;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
96
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
97 if (in_progress) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
98 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
99 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
100 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
101 } else {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
102 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
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->account_widget, TRUE);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
105
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
106 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
107 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
108 /*
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
109 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
110 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
111 */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
112 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
113 }
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 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
116
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
117 static void dialog_select_account_cb(GObject *w, PurpleAccount *account,
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
118 PidginDiscoDialog *dialog)
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
119 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
120 dialog->account = account;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
121 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
122 }
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 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
125 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
126 struct _menu_cb_info *info = g_object_get_data(G_OBJECT(button), "disco-info");
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
127
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
128 xmpp_disco_service_register(info->service);
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_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
132 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
133 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
134 pidgin_disco_list_unref(pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
135 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
136
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
137 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
138 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
139 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
140
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
141 if (!server || !*server) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
142 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
143 NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
144
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, FALSE);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
146 pidgin_disco_list_unref(pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
147 return;
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
150 pdl->server = g_strdup(server);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
151 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
152 xmpp_disco_start(pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
153 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
154
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
155 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
156 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
157 PurpleConnection *pc;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
158 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
159 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
160 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
161 char *server = NULL;
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
162
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
163 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
164 if (!pc)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
165 return;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
166
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
167 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
168 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
169 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
170
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
171 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
172 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
173 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
174 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
175 }
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
176 pidgin_disco_list_unref(dialog->discolist);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
177 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
178
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
179 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
180 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
181 (GDestroyNotify)gtk_tree_row_reference_free);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
182 pdl->pc = pc;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
183 /* We keep a copy... */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
184 pidgin_disco_list_ref(pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
185
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
186 pdl->dialog = dialog;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
187 pidgin_disco_create_tree(pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
188
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
189 if (dialog->account_widget)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
190 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
191
27059
9639747bb98c Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents: 27058
diff changeset
192 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
193 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
194 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
195 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
196 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
197 } 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
198 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
199 }
9639747bb98c Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents: 27058
diff changeset
200
9639747bb98c Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents: 27058
diff changeset
201 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
202 /* 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
203 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
204
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
205 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
206 _("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
207 server, FALSE, FALSE, NULL,
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
208 _("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
209 _("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb),
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
210 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
211
9639747bb98c Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <paul@darkrain42.org>
parents: 27058
diff changeset
212 g_free(server);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
213 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
214
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
215 static void add_room_to_blist_cb(GtkButton *button, PidginDiscoDialog *dialog)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
216 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
217 struct _menu_cb_info *info = g_object_get_data(G_OBJECT(button), "disco-info");
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
218 PurpleAccount *account;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
219 const char *name;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
220
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
221 g_return_if_fail(info != NULL);
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 account = purple_connection_get_account(info->list->pc);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
224 name = info->service->name;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
225
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
226 if (info->service->type == XMPP_DISCO_SERVICE_TYPE_CHAT)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
227 purple_blist_request_add_chat(account, NULL, NULL, name);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
228 else
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
229 purple_blist_request_add_buddy(account, name, NULL, NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
230 }
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 static void
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
233 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
234 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
235 XmppDiscoService *service;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
236 GtkTreeIter iter;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
237 GValue val;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
238 static struct _menu_cb_info *info;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
239 PidginDiscoDialog *dialog = pdl->dialog;
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 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
242 val.g_type = 0;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
243 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
244 service = g_value_get_pointer(&val);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
245 if (!service) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
246 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
247 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
248 return;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
249 }
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 info = g_new0(struct _menu_cb_info, 1);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
252 info->list = dialog->discolist;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
253 info->service = service;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
254
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
255 g_object_set_data_full(G_OBJECT(dialog->add_button), "disco-info",
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
256 info, g_free);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
257 g_object_set_data(G_OBJECT(dialog->register_button), "disco-info", info);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
258
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
259 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
260 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
261 } else {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
262 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
263 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
264 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
265 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
266
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
267 static void
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
268 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
269 gpointer user_data)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
270 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
271 PidginDiscoList *pdl;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
272 XmppDiscoService *service;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
273 GValue val;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
274
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
275 pdl = user_data;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
276
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
277 val.g_type = 0;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
278 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
279 &val);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
280 service = g_value_get_pointer(&val);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
281 xmpp_disco_service_expand(service);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
282 }
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 static void
27159
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
285 row_activated_cb(GtkTreeView *tree_view,
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
286 GtkTreePath *path,
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
287 GtkTreeViewColumn *column,
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
288 gpointer user_data)
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
289 {
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
290 PidginDiscoList *pdl = user_data;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
291 GtkTreeIter iter;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
292 XmppDiscoService *service;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
293 GValue val;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
294
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
295 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(pdl->model), &iter, path))
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
296 return;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
297
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
298 val.g_type = 0;
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
299 gtk_tree_model_get_value(GTK_TREE_MODEL(pdl->model), &iter, SERVICE_COLUMN,
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
300 &val);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
301 service = g_value_get_pointer(&val);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
302
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
303 if (service->flags & XMPP_DISCO_BROWSE)
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
304 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(pdl->tree), path))
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
305 gtk_tree_view_collapse_row(GTK_TREE_VIEW(pdl->tree), path);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
306 else
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
307 gtk_tree_view_expand_row(GTK_TREE_VIEW(pdl->tree), path, FALSE);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
308 else if (service->flags & XMPP_DISCO_ADD)
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
309 add_room_to_blist_cb(GTK_BUTTON(pdl->dialog->add_button), pdl->dialog);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
310 else if (service->flags & XMPP_DISCO_REGISTER)
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
311 register_button_cb(GTK_BUTTON(pdl->dialog->register_button), pdl->dialog);
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
312 }
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
313
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
314 static void
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
315 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
316 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
317 PidginDiscoDialog *dialog = d;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
318 PidginDiscoList *list = dialog->discolist;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
319
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
320 if (list) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
321 list->dialog = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
322
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
323 if (list->in_progress)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
324 list->in_progress = FALSE;
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 pidgin_disco_list_unref(list);
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
329 dialogs = g_list_remove(dialogs, d);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
330 g_free(dialog);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
331 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
332
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
333 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
334 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
335 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
336 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
337
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
338 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
339 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
340 GtkWidget *window = dialog->window;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
341
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
342 gtk_widget_destroy(window);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
343 }
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 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
346 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
347 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
348 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
349
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
350 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
351 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
352 GtkCellRenderer *text_renderer, *pixbuf_renderer;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
353 GtkTreeViewColumn *column;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
354 GtkTreeSelection *selection;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
355
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
356 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
357 GDK_TYPE_PIXBUF, /* PIXBUF_COLUMN */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
358 G_TYPE_STRING, /* NAME_COLUMN */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
359 G_TYPE_STRING, /* DESCRIPTION_COLUMN */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
360 G_TYPE_POINTER /* SERVICE_COLUMN */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
361 );
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 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
364 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
365
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
366 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
367 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
368 G_CALLBACK(selection_changed_cb), pdl);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
369
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
370 g_object_unref(pdl->model);
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 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
373 gtk_widget_show(pdl->tree);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
374
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
375 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
376 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
377
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
378 column = gtk_tree_view_column_new();
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
379 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
380
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
381 gtk_tree_view_column_pack_start(column, pixbuf_renderer, FALSE);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
382 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
383 "pixbuf", PIXBUF_COLUMN, NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
384
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
385 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
386 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
387 "text", NAME_COLUMN, NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
388
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
389 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
390 GTK_TREE_VIEW_COLUMN_GROW_ONLY);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
391 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
392 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
393 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
394 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
395
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
396 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
397 "text", DESCRIPTION_COLUMN, NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
398 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
399 GTK_TREE_VIEW_COLUMN_GROW_ONLY);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
400 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
401 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
402 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
403 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
404
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
405 g_signal_connect(G_OBJECT(pdl->tree), "row-expanded", G_CALLBACK(row_expanded_cb), pdl);
27159
0baf79f7a58d Add a row-activated callback for the XMPP Disco browser that provides a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27158
diff changeset
406 g_signal_connect(G_OBJECT(pdl->tree), "row-activated", G_CALLBACK(row_activated_cb), pdl);
27058
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
409 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
410 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
411 GList *node;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
412
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
413 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
414 PidginDiscoDialog *dialog = node->data;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
415 PidginDiscoList *list = dialog->discolist;
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 if (list && list->pc == pc) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
418 if (list->in_progress)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
419 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
420
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
421 if (list->tree) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
422 gtk_widget_destroy(list->tree);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
423 list->tree = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
424 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
425
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
426 pidgin_disco_list_unref(list);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
427 dialog->discolist = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
428
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
429 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
430 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
431
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
432 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
433 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
434 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
435 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
436 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
437
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
438 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
439 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
440 while (dialogs) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
441 PidginDiscoDialog *dialog = dialogs->data;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
442
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
443 gtk_widget_destroy(dialog->window);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
444 /* 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
445 }
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
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
448 PidginDiscoDialog *pidgin_disco_dialog_new(void)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
449 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
450 PidginDiscoDialog *dialog;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
451 GtkWidget *window, *vbox, *vbox2, *bbox;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
452
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
453 dialog = g_new0(PidginDiscoDialog, 1);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
454 dialogs = g_list_prepend(dialogs, dialog);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
455
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
456 /* Create the window. */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
457 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
458
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
459 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
460 G_CALLBACK(destroy_win_cb), dialog);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
461
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
462 /* Create the parent vbox for everything. */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
463 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
464
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
465 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
466 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
467 gtk_widget_show(vbox2);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
468
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
469 /* accounts dropdown list */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
470 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
471 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
472 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
473 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
474
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
475 /* scrolled window */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
476 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
477 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
478 GTK_SHADOW_IN);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
479 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
480 GTK_POLICY_AUTOMATIC,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
481 GTK_POLICY_AUTOMATIC);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
482 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
483 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
484 gtk_widget_show(dialog->sw);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
485
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
486 /* progress bar */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
487 dialog->progress = gtk_progress_bar_new();
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
488 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
489 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
490 gtk_widget_show(dialog->progress);
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 /* button box */
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
493 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
494 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
495 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
496
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
497 /* stop button */
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
498 dialog->stop_button =
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
499 pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP,
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
500 G_CALLBACK(stop_button_cb), dialog);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
501 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
502
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
503 /* browse button */
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
504 dialog->browse_button =
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
505 pidgin_pixbuf_button_from_stock(_("_Browse"), GTK_STOCK_REFRESH,
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
506 PIDGIN_BUTTON_HORIZONTAL);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
507 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
508 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
509 G_CALLBACK(browse_button_cb), dialog);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
510 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
511 gtk_widget_show(dialog->browse_button);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
512
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
513 /* register button */
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
514 dialog->register_button =
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
515 pidgin_dialog_add_button(GTK_DIALOG(dialog->window), _("Register"),
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
516 G_CALLBACK(register_button_cb), dialog);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
517 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
518
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
519 /* add button */
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
520 dialog->add_button =
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
521 pidgin_pixbuf_button_from_stock(_("_Add"), GTK_STOCK_ADD,
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
522 PIDGIN_BUTTON_HORIZONTAL);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
523 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
524 g_signal_connect(G_OBJECT(dialog->add_button), "clicked",
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
525 G_CALLBACK(add_room_to_blist_cb), dialog);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
526 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
527 gtk_widget_show(dialog->add_button);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
528
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
529 /* close button */
27158
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
530 dialog->close_button =
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
531 pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE,
abab554140b5 Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27128
diff changeset
532 G_CALLBACK(close_button_cb), dialog);
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
533
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
534 /* 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
535 gtk_widget_show(dialog->window);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
536
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
537 return dialog;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
538 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
539
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
540 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
541 {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
542 PidginDiscoDialog *dialog;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
543 GtkTreeIter iter, parent_iter, child;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
544 char *filename = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
545 GdkPixbuf *pixbuf = NULL;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
546 gboolean append = TRUE;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
547
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
548 dialog = pdl->dialog;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
549 g_return_if_fail(dialog != NULL);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
550
27085
61d817c4c935 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents: 27059
diff changeset
551 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
552 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
553 else
61d817c4c935 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents: 27059
diff changeset
554 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
555
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
556 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
557
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
558 if (parent) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
559 GtkTreeRowReference *rr;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
560 GtkTreePath *path;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
561
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
562 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
563 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
564 if (path) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
565 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
566 gtk_tree_path_free(path);
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 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
569 &parent_iter)) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
570 PidginDiscoList *tmp;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
571 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
572 SERVICE_COLUMN, &tmp, -1);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
573 if (!tmp)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
574 append = FALSE;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
575 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
576 }
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
27085
61d817c4c935 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents: 27059
diff changeset
579 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
580 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
581 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
582 return;
61d817c4c935 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents: 27059
diff changeset
583 }
61d817c4c935 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <paul@darkrain42.org>
parents: 27059
diff changeset
584
27058
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
585 if (append)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
586 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
587 else
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
588 iter = child;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
589
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
590 if (service->flags & XMPP_DISCO_BROWSE) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
591 GtkTreeRowReference *rr;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
592 GtkTreePath *path;
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
593
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
594 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
595
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
596 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
597 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
598 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
599 gtk_tree_path_free(path);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
600 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
601
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
602 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
603 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
604 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
605 g_free(tmp);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
606 #if 0
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
607 } 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
608 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
609 #endif
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
610 } 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
611 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
612
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
613 if (filename) {
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
614 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
615 g_free(filename);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
616 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
617
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
618 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
619 PIXBUF_COLUMN, pixbuf,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
620 NAME_COLUMN, service->name,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
621 DESCRIPTION_COLUMN, service->description,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
622 SERVICE_COLUMN, service,
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
623 -1);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
624
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
625 if (pixbuf)
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
626 g_object_unref(pixbuf);
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
627 }
08964b4b2fe4 Convert the disco browser to a plugin. Refs #556
Paul Aurich <paul@darkrain42.org>
parents:
diff changeset
628