pidgin/plugins/disco/gtkdisco.c

Wed, 02 Oct 2019 19:04:34 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 02 Oct 2019 19:04:34 -0400
changeset 39918
1c8e11f9274f
parent 39801
2bbed8148402
child 40197
75ffd76260fc
permissions
-rw-r--r--

Fix several memory leaks.

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"
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39040
diff changeset
32 #include "pidginaccountchooser.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
33 #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
34
35526
ed1be305c985 Fix gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
35 #include "gtk3compat.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 #include "gtkdisco.h"
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
37 #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
38
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
39 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
40
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
41 enum {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
42 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
43 NAME_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
44 DESCRIPTION_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
45 SERVICE_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
46 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
47 };
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
48
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
49 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
50 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
51 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
52 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
53 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
54 list->dialog->discolist = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
55
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
56 g_free((gchar*)list->server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
57 g_free(list);
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
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
60 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
61 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
62 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
63
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
64 ++list->ref;
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27265
diff changeset
65 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
66
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
67 return list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
68 }
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 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
71 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
72 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
73
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
74 --list->ref;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
75
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
76 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
77 if (list->ref == 0)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
78 pidgin_disco_list_destroy(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
79 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
80
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
81 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
82 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
83 PidginDiscoDialog *dialog = list->dialog;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
84
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
85 if (!dialog)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
86 return;
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 list->in_progress = in_progress;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
89
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
90 if (in_progress) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
91 gtk_widget_set_sensitive(dialog->account_chooser, FALSE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
92 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
93 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
94 } else {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
95 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
96
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
97 gtk_widget_set_sensitive(dialog->account_chooser, TRUE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
98
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
99 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
100 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
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->register_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->add_button, FALSE);
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 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
106 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
107
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
108 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
109 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
110 {
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 GdkPixbuf *pixbuf = NULL;
27733
3e20246d57f2 Avoid a potentially uninitialized variable
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27399
diff changeset
112 char *filename = NULL;
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
113 gchar *tmp_size;
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
114
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 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
116 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
117
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
118 tmp_size = g_strdup_printf("%sx%s", size, size);
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
119
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
120 if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY && service->gateway_type) {
39040
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
121 char *tmp = g_strconcat("im-", service->gateway_type,
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
122 ".png", NULL);
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
123
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
124 filename = g_build_filename(PURPLE_DATADIR,
39040
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
125 "pidgin", "icons", "hicolor", tmp_size, "apps",
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
126 tmp, NULL);
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
127 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
128 #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
129 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) {
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
130 filename = g_build_filename(PURPLE_DATADIR,
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
131 "pixmaps", "pidgin", "status", size, "person.png", NULL);
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
132 #endif
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
133 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT) {
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
134 filename = g_build_filename(PURPLE_DATADIR,
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
135 "pidgin", "icons", "hicolor", tmp_size, "status",
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
136 "chat.png", NULL);
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
137 }
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
138
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
139 g_free(tmp_size);
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
140
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
141 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
142 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
143 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
144 }
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
145
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
146 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
147 }
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
148
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
149 static void
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
150 dialog_select_account_cb(GtkWidget *chooser, 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
151 {
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
152 PurpleAccount *account = pidgin_account_chooser_get_selected(chooser);
28704
0c1d6f63740f When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <darkrain42@pidgin.im>
parents: 28304
diff changeset
153 gboolean change = (account != dialog->account);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
154 dialog->account = account;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
155 gtk_widget_set_sensitive(dialog->browse_button, account != NULL);
28704
0c1d6f63740f When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <darkrain42@pidgin.im>
parents: 28304
diff changeset
156
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
157 if (change) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
158 g_clear_pointer(&dialog->discolist, pidgin_disco_list_unref);
28704
0c1d6f63740f When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <darkrain42@pidgin.im>
parents: 28304
diff changeset
159 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
160 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
161
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
162 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
163 {
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
164 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
165 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
166
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
167 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
168 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
169 pdl->dialog->prompt_handle = NULL;
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
170
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
171 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
172 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
173 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
174
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
175 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
176 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
177 pdl->dialog->prompt_handle = NULL;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
178 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
179
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
180 if (!server || !*server) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
181 purple_notify_error(my_plugin, _("Invalid Server"), _("Invalid Server"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34329
diff changeset
182 NULL, purple_request_cpar_from_connection(pdl->pc));
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
183
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
184 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
185 pidgin_disco_list_unref(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
186 return;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
187 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
188
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
189 pdl->server = g_strdup(server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
190 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
191 xmpp_disco_start(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
192 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
193
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
194 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
195 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
196 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
197 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
198 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
199 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
200 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
201
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
202 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
203 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
204 return;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
205
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
206 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
207 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
208 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
209
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
210 g_clear_pointer(&dialog->discolist, pidgin_disco_list_unref);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
211 gtk_tree_store_clear(dialog->model);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
212
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
213 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
214 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
215 (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
216 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
217 /* We keep a copy... */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
218 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
219
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
220 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
221
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
222 gtk_widget_set_sensitive(dialog->account_chooser, FALSE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
223
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
224 username = purple_account_get_username(dialog->account);
29066
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
225 at = strchr(username, '@');
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
226 slash = strchr(username, '/');
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
227 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
228 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
229 } 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
230 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
231 }
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
232
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
233 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
234 /* 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
235 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
236
36135
b46d29bc9b35 Standardize the formatting we use to document hints for translators.
Mark Doliner <mark@kingant.net>
parents: 35850
diff changeset
237 /* Translators: The string "Enter an XMPP Server" is asking the user to
b46d29bc9b35 Standardize the formatting we use to document hints for translators.
Mark Doliner <mark@kingant.net>
parents: 35850
diff changeset
238 type the name of an XMPP server which will then be queried */
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
239 dialog->prompt_handle = purple_request_input(my_plugin, _("Server name request"), _("Enter an XMPP Server"),
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
240 _("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
241 server, FALSE, FALSE, NULL,
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
242 _("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
243 _("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb),
34329
ddbc1337332c Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33271
diff changeset
244 purple_request_cpar_from_connection(pc), 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
245
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
246 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
247 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
248
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
249 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
250 {
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
251 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
252 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
253 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
254
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
255 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
256
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
257 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
258 jid = service->jid;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
259
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
260 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
261 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
262 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
263 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
264 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
265
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
266 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
267 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
268 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
269 PidginDiscoDialog *dialog = user_data;
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
270 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
271 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
272
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
273 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
274 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
275 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
276
38705
62a7a975251a Use gdk_event_triggers_context_menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38583
diff changeset
277 if (!gdk_event_triggers_context_menu((GdkEvent *)event))
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
278 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
279
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
280 /* 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
281 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
282 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
283 return FALSE;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
284 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, path);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
285 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
286 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
287 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
288 SERVICE_COLUMN, &val);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
289 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
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)
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
292 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
293
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
294 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
295
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
296 if (service->flags & XMPP_DISCO_ADD) {
39008
a705bd1673dd gtkdisco: Port off of GtkStock
Mike Ruprecht <cmaiku@gmail.com>
parents: 38707
diff changeset
297 pidgin_new_menu_item(menu, _("Add to Buddy List"), NULL,
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
298 G_CALLBACK(add_to_blist_cb), dialog);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
299 }
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
300
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
301 if (service->flags & XMPP_DISCO_REGISTER) {
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
302 GtkWidget *item = pidgin_new_menu_item(menu, _("Register"),
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
303 NULL, NULL, NULL);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
304 g_signal_connect(G_OBJECT(item), "activate",
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
305 G_CALLBACK(register_button_cb), dialog);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
306 }
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
307
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
308 gtk_widget_show_all(menu);
38707
6f4d3ab2f2ed Use gtk_menu_popup_at_pointer instead of gtk_menu_popup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38705
diff changeset
309 gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *)event);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
310 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
311 }
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
312
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
313 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
314 selection_changed_cb(GtkTreeSelection *selection, 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
315 {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
316 GtkTreeIter iter;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
317 GValue val;
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 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
320 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
321 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
322 SERVICE_COLUMN, &val);
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
323 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
324 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
325 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
326 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
327 return;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
328 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
329
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
330 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
331 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
332 } else {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
333 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
334 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
335 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
336 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
337
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
338 static void
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
339 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
340 gpointer user_data)
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
341 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
342 PidginDiscoDialog *dialog = user_data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
343 XmppDiscoService *service;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
344 GValue val;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
345
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
346 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
347 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), arg1,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
348 SERVICE_COLUMN, &val);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
349 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
350 xmpp_disco_service_expand(service);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
351 }
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
352
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
353 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
354 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
355 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
356 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
357 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
358 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
359 PidginDiscoDialog *dialog = user_data;
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
360 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
361 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
362 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
363
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
364 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
365 path)) {
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
366 return;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
367 }
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
368
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
369 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
370 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
371 SERVICE_COLUMN, &val);
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
372 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
373
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
374 if (service->flags & XMPP_DISCO_BROWSE) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
375 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(dialog->tree),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
376 path)) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
377 gtk_tree_view_collapse_row(GTK_TREE_VIEW(dialog->tree),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
378 path);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
379 } else {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
380 gtk_tree_view_expand_row(GTK_TREE_VIEW(dialog->tree),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
381 path, FALSE);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
382 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
383 } else if (service->flags & XMPP_DISCO_REGISTER) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
384 register_button_cb(NULL, dialog);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
385 } else if (service->flags & XMPP_DISCO_ADD) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
386 add_to_blist_cb(NULL, dialog);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
387 }
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
388 }
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
389
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
390 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
391 destroy_win_cb(GtkWidget *window, G_GNUC_UNUSED gpointer data)
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
392 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
393 PidginDiscoDialog *dialog = PIDGIN_DISCO_DIALOG(window);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
394 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
395
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
396 if (dialog->prompt_handle)
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
397 purple_request_close(PURPLE_REQUEST_INPUT, dialog->prompt_handle);
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
398
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
399 if (list) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
400 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
401
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
402 if (list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
403 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
404
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
405 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
406 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
407
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
408 dialogs = g_list_remove(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
409 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
410
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
411 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
412 {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
413 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
414 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
415
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
416 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
417 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
418 gtk_widget_destroy(GTK_WIDGET(dialog));
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
419 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
420
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
421 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
422 {
36754
8250d6be8c02 Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34329
diff changeset
423 return purple_strequal(purple_account_get_protocol_id(account), XMPP_PROTOCOL_ID);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
424 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
425
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
426 static gboolean
33166
e97c8ef10fd2 Fix tooltip paint function parameters in gtkdisco plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33128
diff changeset
427 disco_paint_tooltip(GtkWidget *tipwindow, cairo_t *cr, gpointer data)
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
428 {
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 PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin");
33271
53bf180b9eb1 Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33170
diff changeset
430 GtkStyleContext *context = gtk_widget_get_style_context(tipwindow);
53bf180b9eb1 Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33170
diff changeset
431 gtk_style_context_add_class(context, GTK_STYLE_CLASS_TOOLTIP);
53bf180b9eb1 Use GtkStyleContext instead of GtkStyle on GTK+3.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33170
diff changeset
432 gtk_render_layout(context, cr, 6, 6, layout);
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
433 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
434 }
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
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 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
437 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
438 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
439 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
440 PidginDiscoDialog *dialog = data;
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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
449 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
450 path)) {
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
451 return FALSE;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
452 }
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
453
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 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
455 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model), &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
456 SERVICE_COLUMN, &val);
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
457 service = g_value_get_pointer(&val);
32081
49f0be55b564 gtkdisco: Prevent a NULL dereference crash
Paul Aurich <darkrain42@pidgin.im>
parents: 31321
diff changeset
458 if (!service)
49f0be55b564 gtkdisco: Prevent a NULL dereference crash
Paul Aurich <darkrain42@pidgin.im>
parents: 31321
diff changeset
459 return FALSE;
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
460
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 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
462 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
463 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
464 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
465
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 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
467 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
468 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
469
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 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
471 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
472 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
473
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 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
475 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
476 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
477
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 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
479 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
480 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
481
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 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
483 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
484 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
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 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
487 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
488 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
489 }
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 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
492 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
493 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
494 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
495 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
496 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
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 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
499 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
500 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
501 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
502 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
503 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
504
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
505 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
506 *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
507 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
508 *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
509
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
510 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
511 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
512 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
513 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
514
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
515 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
516 }
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
517
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
518 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
519 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
520 GList *node;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
521
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
522 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
523 PidginDiscoDialog *dialog = node->data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
524 PidginDiscoList *list = dialog->discolist;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
525
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
526 if (list && list->pc == pc) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
527 if (list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
528 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
529
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
530 gtk_tree_store_clear(dialog->model);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
531
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
532 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
533 dialog->discolist = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
534
39786
7800f52d0ae6 Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
535 gtk_widget_set_sensitive(
7800f52d0ae6 Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
536 dialog->browse_button,
7800f52d0ae6 Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
537 pidgin_account_chooser_get_selected(
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
538 dialog->account_chooser) != NULL);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
539
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
540 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
541 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
542 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
543 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
544 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
545
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
546 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
547 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
548 while (dialogs) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
549 GtkWidget *dialog = dialogs->data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
550
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
551 gtk_widget_destroy(dialog);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
552 /* 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
553 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
554 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
555
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
556 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
557 * GObject implementation
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
558 *****************************************************************************/
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
559
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
560 G_DEFINE_DYNAMIC_TYPE(PidginDiscoDialog, pidgin_disco_dialog, GTK_TYPE_DIALOG)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
561
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
562 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
563 pidgin_disco_dialog_class_init(PidginDiscoDialogClass *klass)
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
564 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
565 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
566
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
567 gtk_widget_class_set_template_from_resource(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
568 widget_class, "/im/pidgin/Pidgin/Plugin/XMPPDisco/disco.ui");
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
569
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
570 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
571 account_chooser);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
572 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
573 progress);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
574 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
575 stop_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
576 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
577 browse_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
578 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
579 register_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
580 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
581 add_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
582 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
583 tree);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
584 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
585 model);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
586
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
587 gtk_widget_class_bind_template_callback(widget_class, destroy_win_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
588 gtk_widget_class_bind_template_callback(widget_class, stop_button_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
589 gtk_widget_class_bind_template_callback(widget_class, browse_button_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
590 gtk_widget_class_bind_template_callback(widget_class,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
591 register_button_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
592 gtk_widget_class_bind_template_callback(widget_class, add_to_blist_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
593 gtk_widget_class_bind_template_callback(widget_class, close_button_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
594 gtk_widget_class_bind_template_callback(widget_class,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
595 dialog_select_account_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
596 gtk_widget_class_bind_template_callback(widget_class, row_activated_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
597 gtk_widget_class_bind_template_callback(widget_class, row_expanded_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
598 gtk_widget_class_bind_template_callback(widget_class, service_click_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
599 gtk_widget_class_bind_template_callback(widget_class,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
600 selection_changed_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
601 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
602
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
603 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
604 pidgin_disco_dialog_class_finalize(PidginDiscoDialogClass *klass)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
605 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
606 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
607
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
608 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
609 pidgin_disco_dialog_init(PidginDiscoDialog *dialog)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
610 {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
611 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
612
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
613 gtk_widget_init_template(GTK_WIDGET(dialog));
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
614
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
615 /* accounts dropdown list */
39793
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
616 pidgin_account_chooser_set_filter_func(
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
617 PIDGIN_ACCOUNT_CHOOSER(dialog->account_chooser),
39793
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
618 account_filter_func);
39786
7800f52d0ae6 Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
619 dialog->account =
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
620 pidgin_account_chooser_get_selected(dialog->account_chooser);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
621
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
622 /* browse button */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
623 gtk_widget_set_sensitive(dialog->browse_button, dialog->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
624
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
625 pidgin_tooltip_setup_for_treeview(GTK_WIDGET(dialog->tree), dialog,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
626 disco_create_tooltip,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
627 disco_paint_tooltip);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
628 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
629
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
630 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
631 * Public API
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
632 *****************************************************************************/
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
633
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
634 void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
635 pidgin_disco_dialog_register(PurplePlugin *plugin)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
636 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
637 pidgin_disco_dialog_register_type(G_TYPE_MODULE(plugin));
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
638 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
639
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
640 PidginDiscoDialog *
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
641 pidgin_disco_dialog_new(void)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
642 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
643 PidginDiscoDialog *dialog =
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
644 g_object_new(PIDGIN_TYPE_DISCO_DIALOG, NULL);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
645 gtk_widget_show_all(GTK_WIDGET(dialog));
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
646 return dialog;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
647 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
648
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
649 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
650 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
651 PidginDiscoDialog *dialog;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
652 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
653 GdkPixbuf *pixbuf = NULL;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
654 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
655
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
656 dialog = pdl->dialog;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
657 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
658
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
659 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
660 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
661 else
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
662 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
663
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
664 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
665
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
666 if (parent) {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
667 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
668 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
669
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
670 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
671 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
672 if (path) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
673 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
674 &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
675 gtk_tree_path_free(path);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
676
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
677 if (gtk_tree_model_iter_children(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
678 GTK_TREE_MODEL(dialog->model), &child,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
679 &parent_iter)) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
680 PidginDiscoList *tmp;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
681 gtk_tree_model_get(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
682 GTK_TREE_MODEL(dialog->model), &child,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
683 SERVICE_COLUMN, &tmp, -1);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
684 if (!tmp)
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
685 append = FALSE;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
686 }
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 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
689
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
690 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
691 if (parent != NULL && !append)
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
692 gtk_tree_store_remove(dialog->model, &child);
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
693 return;
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
694 }
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
695
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
696 if (append) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
697 gtk_tree_store_append(dialog->model, &iter,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
698 (parent ? &parent_iter : NULL));
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
699 } else {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
700 iter = child;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
701 }
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
702
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
703 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
704 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
705 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
706
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
707 gtk_tree_store_append(dialog->model, &child, &iter);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
708
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
709 path = gtk_tree_model_get_path(GTK_TREE_MODEL(dialog->model),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
710 &iter);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
711 rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(dialog->model),
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
712 path);
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
713 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
714 gtk_tree_path_free(path);
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
715 }
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
716
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
717 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
718
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
719 gtk_tree_store_set(dialog->model, &iter, PIXBUF_COLUMN, pixbuf,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
720 NAME_COLUMN, service->name, DESCRIPTION_COLUMN,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
721 service->description, SERVICE_COLUMN, service, -1);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
722
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
723 if (pixbuf)
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
724 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
725 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
726

mercurial