pidgin/plugins/disco/gtkdisco.c

Thu, 09 Jul 2009 17:20:08 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Thu, 09 Jul 2009 17:20:08 +0000
changeset 27699
8f6edef17bf5
parent 27399
7f99a7d1f249
child 27733
3e20246d57f2
permissions
-rw-r--r--

Use purple_markup_escape_text instead of the glib version.

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

mercurial