pidgin/plugins/disco/gtkdisco.c

Fri, 25 Mar 2022 02:51:58 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 25 Mar 2022 02:51:58 -0500
changeset 41314
0dc72eacd8bf
parent 41030
ec8b76f3bf0a
child 41499
a80a41434f44
permissions
-rw-r--r--

Replace PURPLE_CALLBACK by G_CALLBACK

Another straight search-and-replace for 'easy' review.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/1371/

26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
1 /* pidgin
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
2 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
3 * 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
4 * 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
5 * source distribution.
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
6 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * (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
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 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
13 * 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
14 * 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
15 * 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
16 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
17 * 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
18 * 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
19 * 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
20 */
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
21
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
22 #ifdef HAVE_CONFIG_H
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
23 # include <config.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
24 #endif
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
25
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
26 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
27
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
28 #include <purple.h>
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
29
40502
875489636847 pidgin.h phase3: create pidgin.h and force its usage
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
30 #include <pidgin.h>
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
31
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
32 #include "gtkdisco.h"
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
33 #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
34
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
35 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
36
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
37 enum {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
38 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
39 NAME_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
40 DESCRIPTION_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
41 SERVICE_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
42 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
43 };
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
44
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
45 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
46 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
47 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
48 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
49 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
50 list->dialog->discolist = NULL;
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_free((gchar*)list->server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
53 g_free(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
54 }
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 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
57 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
58 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
59
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
60 ++list->ref;
27312
07a772783c0f Make this whitespace a bit more consistent (I hope).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27265
diff changeset
61 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
62
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
63 return list;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
64 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
65
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
66 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
67 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
68 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
69
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
70 --list->ref;
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 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
73 if (list->ref == 0)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
74 pidgin_disco_list_destroy(list);
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
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
77 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
78 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
79 PidginDiscoDialog *dialog = list->dialog;
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 if (!dialog)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
82 return;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
83
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
84 list->in_progress = in_progress;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
85
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
86 if (in_progress) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
87 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
88 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
89 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
90 } else {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
91 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
92
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
93 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
94
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
95 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
96 gtk_widget_set_sensitive(dialog->browse_button, TRUE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
97 /*
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
98 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
99 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
100 */
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 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
103
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
104 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
105 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
106 {
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
107 GdkPixbuf *pixbuf = NULL;
27733
3e20246d57f2 Avoid a potentially uninitialized variable
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27399
diff changeset
108 char *filename = NULL;
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
109 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
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 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
112 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
113
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
114 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
115
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
116 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
117 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
118 ".png", NULL);
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
119
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
120 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
121 "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
122 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
123 g_free(tmp);
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
124 #if 0
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
125 } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) {
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
126 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
127 "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
128 #endif
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
129 } 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
130 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
131 "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
132 "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
133 }
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
134
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
135 g_free(tmp_size);
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
136
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
137 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
138 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
139 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
140 }
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
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 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
143 }
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
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
145 static void
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
146 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
147 {
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
148 PurpleAccount *account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(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
149 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
150 dialog->account = account;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
151 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
152
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
153 if (change) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
154 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
155 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
156 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
157
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
158 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
159 {
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
160 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
161 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
162
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
163 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
164 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
165 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
166
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
167 pidgin_disco_list_set_in_progress(pdl, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
168 pidgin_disco_list_unref(pdl);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
169 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
170
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
171 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
172 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
173 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
174 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
175
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
176 if (!server || !*server) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
177 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
178 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
179
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
180 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
181 pidgin_disco_list_unref(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
182 return;
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
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
185 pdl->server = g_strdup(server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
186 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
187 xmpp_disco_start(pdl);
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
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
190 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
191 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
192 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
193 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
194 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
195 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
196 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
197
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
198 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
199 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
200 return;
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 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
203 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
204 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
205
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
206 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
207 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
208
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
209 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
210 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
211 (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
212 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
213 /* We keep a copy... */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
214 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
215
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
216 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
217
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
218 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
219
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
220 username = purple_account_get_username(dialog->account);
29066
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
221 at = strchr(username, '@');
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
222 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
223 if (at && !slash) {
40700
4c3ee00e6107 Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40534
diff changeset
224 server = g_strdup(at + 1);
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
225 } 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
226 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
227 }
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
228
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
229 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
230 /* 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
231 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
232
36135
b46d29bc9b35 Standardize the formatting we use to document hints for translators.
Mark Doliner <mark@kingant.net>
parents: 35850
diff changeset
233 /* 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
234 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
235 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
236 _("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
237 server, FALSE, FALSE, NULL,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
238 _("Find Services"), G_CALLBACK(discolist_ok_cb),
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
239 _("Cancel"), G_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
240 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
241
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
242 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
243 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
244
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
245 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
246 {
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
247 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
248 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
249 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
250
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
251 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
252
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
253 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
254 jid = service->jid;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
255
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
256 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
257 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
258 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
259 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
260 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
261
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
262 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
263 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
264 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
265 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
266 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
267 GtkWidget *menu;
40944
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
268 GtkWidget *menuitem = 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
269
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
270 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
271 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
272 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
273
38705
62a7a975251a Use gdk_event_triggers_context_menu.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38583
diff changeset
274 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
275 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
276
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
277 /* 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
278 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
279 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
280 return FALSE;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
281 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
282 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
283 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
284 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
285 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
286 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
287
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
288 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
289 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
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 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
292
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
293 if (service->flags & XMPP_DISCO_ADD) {
40944
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
294 menuitem = gtk_menu_item_new_with_label(_("Add to Buddy List"));
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
295 g_signal_connect(G_OBJECT(menuitem), "activate",
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
296 G_CALLBACK(add_to_blist_cb), dialog);
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
297 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
298 }
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
299
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
300 if (service->flags & XMPP_DISCO_REGISTER) {
40944
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
301 menuitem = gtk_menu_item_new_with_label(_("Register"));
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
302 g_signal_connect(G_OBJECT(menuitem), "activate",
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
303 G_CALLBACK(register_button_cb), dialog);
40944
6e95a22ee02f Inline pidgin_menu_item_new in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40700
diff changeset
304 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
305 }
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 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
308 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
309 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
310 }
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
311
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
312 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
313 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
314 {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
315 GtkTreeIter iter;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
316 GValue val;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
317
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
318 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
319 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
320 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
321 SERVICE_COLUMN, &val);
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
322 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
323 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
324 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
325 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
326 return;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
327 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
328
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
329 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
330 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
331 } else {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
332 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
333 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
334 }
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
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
337 static void
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
338 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
339 gpointer user_data)
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
340 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
341 PidginDiscoDialog *dialog = user_data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
342 XmppDiscoService *service;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
343 GValue val;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
344
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
345 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
346 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
347 SERVICE_COLUMN, &val);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
348 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
349 xmpp_disco_service_expand(service);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
350 }
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
351
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
352 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
353 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
354 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
355 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
356 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
357 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
358 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
359 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
360 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
361 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
362
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
363 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
364 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
365 return;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
366 }
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
367
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 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
369 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
370 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
371 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
372
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
373 if (service->flags & XMPP_DISCO_BROWSE) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
374 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
375 path)) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
376 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
377 path);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
378 } else {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
379 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
380 path, FALSE);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
381 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
382 } 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
383 register_button_cb(NULL, dialog);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
384 } 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
385 add_to_blist_cb(NULL, dialog);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
386 }
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
387 }
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 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
390 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
391 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
392 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
393 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
394
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
395 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
396 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
397
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
398 if (list) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
399 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
400
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
401 if (list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
402 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
403
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
404 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
405 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
406
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
407 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
408 }
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 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
411 {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
412 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
413 }
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 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
416 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
417 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
418 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
419
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
420 static gboolean
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
421 disco_query_tooltip(GtkWidget *widget, int x, int y, gboolean keyboard_mode,
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
422 GtkTooltip *tooltip, 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
423 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
424 PidginDiscoDialog *dialog = data;
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
425 GtkTreePath *path = NULL;
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 GtkTreeIter iter;
898c56e61aa1 Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27314
diff changeset
427 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
428 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
429 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
430 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
431
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
432 if (keyboard_mode) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
433 GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
434 if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
435 return FALSE;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
436 }
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
437 path = gtk_tree_model_get_path(GTK_TREE_MODEL(dialog->model), &iter);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
438 } else {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
439 gint bx, by;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
440
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
441 gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget),
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
442 x, y, &bx, &by);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
443 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bx, by, &path,
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
444 NULL, NULL, NULL);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
445 if (path == NULL) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
446 return FALSE;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
447 }
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
448
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
449 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, path)) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
450 gtk_tree_path_free(path);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
451 return FALSE;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
452 }
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
453 }
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
454
898c56e61aa1 Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27314
diff changeset
455 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
456 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
457 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
458 service = g_value_get_pointer(&val);
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
459 if (!service) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
460 gtk_tree_path_free(path);
32081
49f0be55b564 gtkdisco: Prevent a NULL dereference crash
Paul Aurich <darkrain42@pidgin.im>
parents: 31321
diff changeset
461 return FALSE;
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
462 }
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
463
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 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
465 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
466 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
467 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
468
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 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
470 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
471 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
472
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 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
474 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
475 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
476
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 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
478 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
479 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
480
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 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
482 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
483 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
484
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 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
486 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
487 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
488
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 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
490 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
491 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
492 }
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
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 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
495 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
496 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
497 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
498 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
499 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
500
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
501 gtk_tooltip_set_markup(tooltip, markup);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
502 gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, 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
503
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 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
505 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
506 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
507 g_free(desc);
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
508 gtk_tree_path_free(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
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 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
511 }
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
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
513 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
514 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
515 GList *node;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
516
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
517 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
518 PidginDiscoDialog *dialog = node->data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
519 PidginDiscoList *list = dialog->discolist;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
520
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
521 if (list && list->pc == pc) {
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
522 PurpleAccount *account = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
523
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
524 if (list->in_progress)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
525 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
526
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
527 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
528
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
529 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
530 dialog->discolist = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
531
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
532 account = pidgin_account_chooser_get_selected(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
533 PIDGIN_ACCOUNT_CHOOSER(dialog->account_chooser));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
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,
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
537 account != NULL);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
538
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
539 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
540 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
541 }
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 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
546 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
547 while (dialogs) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
548 GtkWidget *dialog = dialogs->data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
549
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
550 gtk_widget_destroy(dialog);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
551 /* 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
552 }
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
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
555 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
556 * GObject implementation
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
557 *****************************************************************************/
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 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
560
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
561 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
562 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
563 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
564 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
565
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
566 gtk_widget_class_set_template_from_resource(
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40946
diff changeset
567 widget_class, "/im/pidgin/Pidgin3/Plugin/XMPPDisco/disco.ui");
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
568
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
569 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
570 account_chooser);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
571 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
572 progress);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
573 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
574 stop_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
575 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
576 browse_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
577 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
578 register_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
579 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
580 add_button);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
581 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
582 tree);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
583 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
584 model);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
585
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
586 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
587 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
588 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
589 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
590 register_button_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
591 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
592 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
593 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
594 dialog_select_account_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
595 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
596 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
597 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
598 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
599 selection_changed_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
600 }
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 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
603 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
604 {
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 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
608 pidgin_disco_dialog_init(PidginDiscoDialog *dialog)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
609 {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
610 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
611
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
612 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
613
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
614 /* accounts dropdown list */
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
615 dialog->account = pidgin_account_chooser_get_selected(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
616 PIDGIN_ACCOUNT_CHOOSER(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
617
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
618 /* browse button */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
619 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
620
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
621 gtk_widget_set_has_tooltip(GTK_WIDGET(dialog->tree), TRUE);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
622 g_signal_connect(G_OBJECT(dialog->tree), "query-tooltip",
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
623 G_CALLBACK(disco_query_tooltip), dialog);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
624 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
625
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
626 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
627 * Public API
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
628 *****************************************************************************/
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
629
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
630 void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
631 pidgin_disco_dialog_register(PurplePlugin *plugin)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
632 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
633 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
634 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
635
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
636 PidginDiscoDialog *
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
637 pidgin_disco_dialog_new(void)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
638 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
639 PidginDiscoDialog *dialog =
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
640 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
641 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
642 return dialog;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
643 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
644
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
645 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
646 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
647 PidginDiscoDialog *dialog;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
648 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
649 GdkPixbuf *pixbuf = NULL;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
650 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
651
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
652 dialog = pdl->dialog;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
653 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
654
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
655 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
656 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
657 else
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
658 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
659
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
660 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
661
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
662 if (parent) {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
663 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
664 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
665
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
666 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
667 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
668 if (path) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
669 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
670 &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
671 gtk_tree_path_free(path);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
672
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
673 if (gtk_tree_model_iter_children(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
674 GTK_TREE_MODEL(dialog->model), &child,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
675 &parent_iter)) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
676 PidginDiscoList *tmp;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
677 gtk_tree_model_get(
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 SERVICE_COLUMN, &tmp, -1);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
680 if (!tmp)
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
681 append = FALSE;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
682 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
683 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
684 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
685
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
686 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
687 if (parent != NULL && !append)
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
688 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
689 return;
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
690 }
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
691
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
692 if (append) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
693 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
694 (parent ? &parent_iter : NULL));
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
695 } else {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
696 iter = child;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
697 }
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
698
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
699 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
700 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
701 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
702
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
703 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
704
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
705 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
706 &iter);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
707 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
708 path);
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
709 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
710 gtk_tree_path_free(path);
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
711 }
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
712
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
713 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
714
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
715 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
716 NAME_COLUMN, service->name, DESCRIPTION_COLUMN,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
717 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
718
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
719 if (pixbuf)
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
720 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
721 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
722

mercurial