pidgin/plugins/disco/gtkdisco.c

Thu, 18 Aug 2022 23:16:24 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 18 Aug 2022 23:16:24 -0500
changeset 41506
fff3a446f76d
parent 41499
a80a41434f44
child 41562
bfd0330f09fb
permissions
-rw-r--r--

Remove the refresh timer, visible preference, and delete-event from gtkblist.

The refresh timer is a polling method of every buddy in the blist and needs to
be fixed regardless.

The visible preference doesn't make sense in a world where there will be no
buddy list window.

The delete event doesn't make sense as it quit the program which is handled
differently now.

Testing Done:
Ran the program, made sure the contact list showed up and that it didn't close the program when closing the window.

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

41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
1 /*
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
2 * Pidgin - Internet Messenger
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
4 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
5 * 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
6 * 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
7 * source distribution.
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
8 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * (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
13 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
14 * 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
15 * 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
16 * 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
17 * 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
18 *
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
21 */
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
22
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
23 #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
24 # 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
25 #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
26
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 #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
28
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
29 #include <purple.h>
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
30
40502
875489636847 pidgin.h phase3: create pidgin.h and force its usage
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
31 #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
32
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
33 #include "gtkdisco.h"
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
34 #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
35
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
36 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
37
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
38 enum {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
39 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
40 NAME_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
41 DESCRIPTION_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
42 SERVICE_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
43 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
44 };
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
45
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
46 static PidginDiscoList *
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
47 pidgin_disco_list_new(void) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
48 return g_rc_box_new0(PidginDiscoList);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
49 }
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
50
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
51 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
52 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
53 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
54 g_hash_table_destroy(list->services);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
55 if (list->dialog && list->dialog->discolist == list) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
56 list->dialog->discolist = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
57 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
58
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
59 g_free((gchar*)list->server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
60 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
61
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
62 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
63 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
64 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
65
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
66 purple_debug_misc("xmppdisco", "reffing list");
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
67 return g_rc_box_acquire(list);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
68 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
69
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
70 void pidgin_disco_list_unref(PidginDiscoList *list)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
71 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
72 g_return_if_fail(list != NULL);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
73
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
74 purple_debug_misc("xmppdisco", "unreffing list");
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
75 g_rc_box_release_full(list, (GDestroyNotify)pidgin_disco_list_destroy);
27217
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
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
78 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
79 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
80 PidginDiscoDialog *dialog = list->dialog;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
81
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
82 if (!dialog) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
83 return;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
84 }
27217
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 list->in_progress = in_progress;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
87
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
88 if (in_progress) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
89 gtk_widget_set_sensitive(dialog->account_chooser, FALSE);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
90 g_simple_action_set_enabled(dialog->stop_action, TRUE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
91 g_simple_action_set_enabled(dialog->browse_action, FALSE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
92 } else {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
93 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
94
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
95 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
96
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
97 g_simple_action_set_enabled(dialog->stop_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
98 g_simple_action_set_enabled(dialog->browse_action, TRUE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
99 /*
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
100 g_simple_action_set_enabled(dialog->register_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
101 g_simple_action_set_enabled(dialog->add_action, FALSE);
27217
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 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
104 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
105
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
106 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
107 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
108 {
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
109 GdkPixbuf *pixbuf = NULL;
27733
3e20246d57f2 Avoid a potentially uninitialized variable
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 27399
diff changeset
110 char *filename = NULL;
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
111 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
112
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 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
114 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
115
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
116 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
117
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
118 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
119 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
120 ".png", NULL);
65ed0e8e8229 Move protocol icons to the apps icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39037
diff changeset
121
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
122 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
123 "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
124 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
125 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
126 #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
127 } 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
128 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
129 "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
130 #endif
35850
1abeda205d6c cross-win32: make dirs more flexible, add them to the config.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35526
diff changeset
131 } 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
132 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
133 "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
134 "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
135 }
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
136
39037
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
137 g_free(tmp_size);
5014cd8d58e3 Move status icons to the status icon theme specification directory
Mike Ruprecht <cmaiku@gmail.com>
parents: 39008
diff changeset
138
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
139 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
140 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
141 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
142 }
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 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
145 }
7f99a7d1f249 Abstract an "image loading function" (will be used for the tooltip in a sec)
Paul Aurich <darkrain42@pidgin.im>
parents: 27319
diff changeset
146
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
147 static void
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
148 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
149 {
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
150 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
151 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
152 dialog->account = account;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
153 g_simple_action_set_enabled(dialog->browse_action, 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
154
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
155 if (change) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
156 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
157 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
158 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
159
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
160 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
161 activate_register(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
162 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
163 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
164 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
165 PidginDiscoDialog *dialog = data;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
166 XmppDiscoService *service = dialog->selected;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
167
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
168 g_return_if_fail(service != NULL);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
169
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
170 xmpp_disco_service_register(service);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
171 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
172
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
173 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
174 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
175 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
176
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
177 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
178 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
179 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
180
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
181 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
182 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
183 pdl->dialog->prompt_handle = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
184 g_simple_action_set_enabled(pdl->dialog->browse_action, TRUE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
185
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
186 if (!server || !*server) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
187 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
188 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
189
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
190 pidgin_disco_list_set_in_progress(pdl, FALSE);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
191 pidgin_disco_list_unref(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
192 return;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
193 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
194
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
195 pdl->server = g_strdup(server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
196 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
197 xmpp_disco_start(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
198 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
199
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
200 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
201 activate_browse(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
202 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
203 gpointer data)
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
204 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
205 PidginDiscoDialog *dialog = data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
206 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
207 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
208 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
209 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
210 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
211
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
212 pc = purple_account_get_connection(dialog->account);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
213 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
214 return;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
215 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
216
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
217 g_simple_action_set_enabled(dialog->browse_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
218 g_simple_action_set_enabled(dialog->add_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
219 g_simple_action_set_enabled(dialog->register_action, 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
220
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
221 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
222 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
223
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
224 pdl = dialog->discolist = pidgin_disco_list_new();
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
225 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
226 (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
227 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
228 /* We keep a copy... */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
229 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
230
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
231 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
232
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
233 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
234
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
235 username = purple_account_get_username(dialog->account);
29066
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
236 at = strchr(username, '@');
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
237 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
238 if (at && !slash) {
40700
4c3ee00e6107 Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40534
diff changeset
239 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
240 } 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
241 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
242 }
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
243
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
244 if (server == NULL) {
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
245 /* 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
246 server = g_strdup("jabber.org");
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
247 }
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
248
36135
b46d29bc9b35 Standardize the formatting we use to document hints for translators.
Mark Doliner <mark@kingant.net>
parents: 35850
diff changeset
249 /* 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
250 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
251 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
252 _("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
253 server, FALSE, FALSE, NULL,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
254 _("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
255 _("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
256 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
257
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
258 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
259 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
260
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
261 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
262 activate_add_to_blist(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
263 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
264 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
265 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
266 PidginDiscoDialog *dialog = data;
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
267 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
268 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
269 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
270
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
271 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
272
27310
fd59f3923233 Get rid of _menu_cb_info; pass around the XmppDiscoService*
Paul Aurich <darkrain42@pidgin.im>
parents: 27265
diff changeset
273 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
274 jid = service->jid;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
275
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
276 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
277 purple_blist_request_add_chat(account, NULL, NULL, jid);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
278 } 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
279 purple_blist_request_add_buddy(account, jid, NULL, NULL);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
280 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
281 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
282
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
283 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
284 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
285 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
286 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
287 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
288
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
289 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
290 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
291 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
292
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
293 GdkRectangle rect;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
294
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
295 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
296 return FALSE;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
297 }
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
298
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
299 /* 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
300 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
301 NULL, NULL, NULL))
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
302 {
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
303 return FALSE;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
304 }
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
305 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
306 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
307 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
308 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
309 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
310 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
311
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
312 if (!service) {
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
313 return FALSE;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
314 }
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
315
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
316 gtk_tree_view_convert_bin_window_to_widget_coords(dialog->tree,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
317 (gint)event->x,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
318 (gint)event->y,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
319 &rect.x, &rect.y);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
320 rect.width = rect.height = 1;
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
321
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
322 gtk_popover_set_pointing_to(GTK_POPOVER(dialog->popover), &rect);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
323 gtk_popover_popup(GTK_POPOVER(dialog->popover));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
324
27319
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
325 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
326 }
f684f9ad6c79 Add a context menu with actions and re-arrange so registration takes preference
Paul Aurich <darkrain42@pidgin.im>
parents: 27318
diff changeset
327
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
328 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
329 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
330 {
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
331 GtkTreeIter iter;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
332 GValue val;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
333 gboolean allow_add = FALSE, allow_register = FALSE;
26585
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 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
336 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
337 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
338 SERVICE_COLUMN, &val);
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
339 dialog->selected = g_value_get_pointer(&val);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
340 if (dialog->selected != NULL) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
341 allow_add = (dialog->selected->flags & XMPP_DISCO_ADD);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
342 allow_register = (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
343 }
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
344 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
345
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
346 g_simple_action_set_enabled(dialog->add_action, allow_add);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
347 g_simple_action_set_enabled(dialog->register_action, allow_register);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
348 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
349
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
350 static void
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
351 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
352 gpointer user_data)
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
353 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
354 PidginDiscoDialog *dialog = user_data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
355 XmppDiscoService *service;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
356 GValue val;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
357
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
358 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
359 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
360 SERVICE_COLUMN, &val);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
361 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
362 xmpp_disco_service_expand(service);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
363 }
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
364
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
365 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
366 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
367 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
368 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
369 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
370 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
371 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
372 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
373 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
374 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
375
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
376 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, 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
377 return;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
378 }
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
379
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
380 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
381 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
382 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
383 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
384
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
385 if (service->flags & XMPP_DISCO_BROWSE) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
386 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(dialog->tree), path)) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
387 gtk_tree_view_collapse_row(GTK_TREE_VIEW(dialog->tree), path);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
388 } else {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
389 gtk_tree_view_expand_row(GTK_TREE_VIEW(dialog->tree), path, FALSE);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
390 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
391 } else if (service->flags & XMPP_DISCO_REGISTER) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
392 g_action_activate(G_ACTION(dialog->register_action), NULL);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
393 } else if (service->flags & XMPP_DISCO_ADD) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
394 g_action_activate(G_ACTION(dialog->add_action), NULL);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
395 }
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
396 }
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
397
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
398 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
399 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
400 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
401 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
402 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
403
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
404 if (dialog->prompt_handle) {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
405 purple_request_close(PURPLE_REQUEST_INPUT, dialog->prompt_handle);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
406 }
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
407
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
408 if (list) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
409 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
410
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
411 if (list->in_progress) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
412 list->in_progress = FALSE;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
413 }
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
414
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
415 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
416 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
417
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
418 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
419 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
420
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
421 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
422 activate_stop(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
423 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
424 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
425 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
426 PidginDiscoDialog *dialog = data;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
427
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
428 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
429 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
430
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
431 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
432 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
433 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
434 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
435
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
436 static gboolean
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
437 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
438 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
439 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
448 if (keyboard_mode) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
449 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
450 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
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 }
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
453 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
454 } else {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
455 gint bx, by;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
456
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
457 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
458 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
459 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
460 NULL, NULL, NULL);
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
461 if (path == NULL) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
462 return FALSE;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
463 }
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
464
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
465 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
466 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
467 return FALSE;
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
468 }
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
469 }
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
470
898c56e61aa1 Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27314
diff changeset
471 val.g_type = 0;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
472 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
473 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
474 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
475 if (!service) {
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
476 gtk_tree_path_free(path);
32081
49f0be55b564 gtkdisco: Prevent a NULL dereference crash
Paul Aurich <darkrain42@pidgin.im>
parents: 31321
diff changeset
477 return FALSE;
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
478 }
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
479
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 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
481 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
482 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
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_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
486 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
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_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
490 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
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 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
494 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
495 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
496
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 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
498 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
499 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
500
898c56e61aa1 Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27314
diff changeset
501 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
502 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
503 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
504
898c56e61aa1 Add a tooltip to the XMPP Disco browser. Someone should probably fill this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27314
diff changeset
505 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
506 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
507 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
508 }
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
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
510 name = g_markup_escape_text(service->name, -1);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
511 jid = g_markup_escape_text(service->jid, -1);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
512 if (service->description != NULL) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
513 desc = g_markup_escape_text(service->description, -1);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
514 }
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
515
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
516 markup = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>\n<b>%s:</b> %s%s%s",
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
517 name, type, jid,
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
518 service->description ? _("\n<b>Description:</b> ") : "",
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
519 service->description ? desc : "");
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
520
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
521 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
522 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
523
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
524 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
525 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
526 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
527 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
528 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
529
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
530 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
531 }
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
532
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
533 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
534 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
535 GList *node;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
536
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
537 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
538 PidginDiscoDialog *dialog = node->data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
539 PidginDiscoList *list = dialog->discolist;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
540
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
541 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
542 PurpleAccount *account = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
543
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
544 if (list->in_progress) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
545 pidgin_disco_list_set_in_progress(list, FALSE);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
546 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
547
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
548 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
549
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
550 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
551 dialog->discolist = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
552
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
553 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
554 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
555
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
556 g_simple_action_set_enabled(dialog->browse_action, account != NULL);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
557 g_simple_action_set_enabled(dialog->add_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
558 g_simple_action_set_enabled(dialog->register_action, FALSE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
559 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
560 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
561 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
562
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
563 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
564 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
565 while (dialogs) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
566 GtkWidget *dialog = dialogs->data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
567
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
568 gtk_widget_destroy(dialog);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
569 /* 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
570 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
571 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
572
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
573 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
574 * GObject implementation
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
575 *****************************************************************************/
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
576
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
577 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
578
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
579 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
580 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
581 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
582 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
583
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
584 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
585 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
586
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
587 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
588 account_chooser);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
589 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
590 progress);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
591 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
592 tree);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
593 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
594 model);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
595 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
596 popover);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
597 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
598 popover_menu);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
599
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
600 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
601 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
602 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
603 dialog_select_account_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
604 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
605 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
606 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
607 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
608 selection_changed_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
609 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
610
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
611 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
612 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
613 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
614 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
615
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
616 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
617 pidgin_disco_dialog_init(PidginDiscoDialog *dialog)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
618 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
619 GActionEntry entries[] = {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
620 { .name = "stop", .activate = activate_stop },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
621 { .name = "browse", .activate = activate_browse },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
622 { .name = "register", .activate = activate_register },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
623 { .name = "add", .activate = activate_add_to_blist },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
624 };
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
625 GSimpleActionGroup *action_group = NULL;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
626 GActionMap *action_map = NULL;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
627
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
628 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
629
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
630 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
631
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
632 /* 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
633 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
634 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
635
40946
f3bb3efca77b Use standard tooltips in XMPP Service Discovery plugin.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40944
diff changeset
636 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
637 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
638 G_CALLBACK(disco_query_tooltip), dialog);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
639
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
640 action_group = g_simple_action_group_new();
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
641 action_map = G_ACTION_MAP(action_group);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
642 g_action_map_add_action_entries(action_map, entries, G_N_ELEMENTS(entries),
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
643 dialog);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
644
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
645 dialog->stop_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
646 g_action_map_lookup_action(action_map, "stop"));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
647 g_simple_action_set_enabled(dialog->stop_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
648
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
649 dialog->browse_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
650 g_action_map_lookup_action(action_map, "browse"));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
651 g_simple_action_set_enabled(dialog->browse_action, dialog->account != NULL);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
652
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
653 dialog->register_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
654 g_action_map_lookup_action(action_map, "register"));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
655 g_simple_action_set_enabled(dialog->register_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
656
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
657 dialog->add_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
658 g_action_map_lookup_action(action_map, "add"));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
659 g_simple_action_set_enabled(dialog->add_action, FALSE);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
660
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
661 gtk_widget_insert_action_group(GTK_WIDGET(dialog), "disco",
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
662 G_ACTION_GROUP(action_group));
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
663
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
664 gtk_popover_bind_model(GTK_POPOVER(dialog->popover), dialog->popover_menu,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
665 NULL);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
666 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
667
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
668 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
669 * Public API
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
670 *****************************************************************************/
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
671
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
672 void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
673 pidgin_disco_dialog_register(PurplePlugin *plugin)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
674 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
675 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
676 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
677
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
678 PidginDiscoDialog *
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
679 pidgin_disco_dialog_new(void)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
680 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
681 PidginDiscoDialog *dialog = g_object_new(PIDGIN_TYPE_DISCO_DIALOG, NULL);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
682 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
683 return dialog;
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
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
686 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
687 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
688 PidginDiscoDialog *dialog;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
689 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
690 GdkPixbuf *pixbuf = NULL;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
691 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
692
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
693 dialog = pdl->dialog;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
694 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
695
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
696 if (service != NULL) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
697 purple_debug_info("xmppdisco", "Adding service \"%s\"", service->name);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
698 } else {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
699 purple_debug_info("xmppdisco", "Service \"%s\" has no children",
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
700 parent->name);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
701 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
702
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
703 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
704
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
705 if (parent) {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
706 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
707 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
708
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
709 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
710 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
711 if (path) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
712 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
713 &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
714 gtk_tree_path_free(path);
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
715
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
716 if (gtk_tree_model_iter_children(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
717 GTK_TREE_MODEL(dialog->model), &child,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
718 &parent_iter)) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
719 PidginDiscoList *tmp;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
720 gtk_tree_model_get(
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
721 GTK_TREE_MODEL(dialog->model), &child,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
722 SERVICE_COLUMN, &tmp, -1);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
723 if (!tmp) {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
724 append = FALSE;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
725 }
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
726 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
727 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
728 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
729
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
730 if (service == NULL) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
731 if (parent != NULL && !append) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
732 gtk_tree_store_remove(dialog->model, &child);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
733 }
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
734 return;
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
735 }
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
736
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
737 if (append) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
738 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
739 (parent ? &parent_iter : NULL));
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
740 } else {
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
741 iter = child;
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
742 }
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
743
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
744 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
745 GtkTreeRowReference *rr;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
746 GtkTreePath *path;
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
747
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
748 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
749
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
750 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
751 &iter);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
752 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
753 path);
26925
c8a3e1885041 Rename pdl->cats to pdl->services, since these aren't roomlist categories
Paul Aurich <darkrain42@pidgin.im>
parents: 26919
diff changeset
754 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
755 gtk_tree_path_free(path);
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
756 }
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
757
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
758 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
759
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
760 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
761 NAME_COLUMN, service->name, DESCRIPTION_COLUMN,
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
762 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
763
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
764 if (pixbuf) {
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
765 g_object_unref(pixbuf);
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
766 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
767 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
768

mercurial