pidgin/plugins/disco/gtkdisco.c

Tue, 02 Jan 2024 00:36:32 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 02 Jan 2024 00:36:32 -0600
changeset 42562
f02878f30f91
parent 42410
563e7a17c220
child 42573
9dc369a7d7da
permissions
-rw-r--r--

Create a full widget for the new instant message window

This now uses AdwMessageDialog and is self contained but PidginApplication
manages a singleton of it.

Previously this used the request api. I'm not sure why, as the request fields
were created by the ui itself.

Testing Done:
Created an im with `Echo` on a `demo` account and was able to send and receive messages.

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

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
42410
563e7a17c220 Fix possible clash of config headers
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
23 #include <purpleconfig.h>
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
24
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 #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
26
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
27 #include <purple.h>
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
28
40502
875489636847 pidgin.h phase3: create pidgin.h and force its usage
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
29 #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
30
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
31 #include "gtkdisco.h"
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
32 #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
33
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
34 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
35
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
36 enum {
42034
f05baca349b3 Use icon-name to set up XMPP Discovery icons instead
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41962
diff changeset
37 ICON_NAME_COLUMN = 0,
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
38 NAME_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
39 DESCRIPTION_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
40 SERVICE_COLUMN,
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
41 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
42 };
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
43
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
44 static PidginDiscoList *
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
45 pidgin_disco_list_new(void) {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
46 return g_rc_box_new0(PidginDiscoList);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
47 }
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
48
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
49 static void
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
50 pidgin_disco_list_destroy(PidginDiscoList *list)
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
51 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
52 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
53 list->dialog->discolist = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
54 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
55
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
56 g_free((gchar*)list->server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
57 }
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 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
60 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
61 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
62
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
63 purple_debug_misc("xmppdisco", "reffing list");
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
64 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
65 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
66
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
67 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
68 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
69 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
70
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
71 purple_debug_misc("xmppdisco", "unreffing list");
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
72 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
73 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
74
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
75 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
76 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
77 PidginDiscoDialog *dialog = list->dialog;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
78
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
79 if (!dialog) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
80 return;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
81 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
82
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
83 list->in_progress = in_progress;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
84
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
85 if (in_progress) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
86 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
87 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
88 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
89 } else {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
90 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
91
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
92 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
93
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
94 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
95 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
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->register_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->add_action, FALSE);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
99 */
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
100 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
101 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
102
39787
af7ae86ee287 Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39786
diff changeset
103 static void
41854
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41562
diff changeset
104 dialog_select_account_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41562
diff changeset
105 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
106 {
41854
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41562
diff changeset
107 PidginDiscoDialog *dialog = data;
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41562
diff changeset
108 PurpleAccount *account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(obj));
28704
0c1d6f63740f When switching the account in the Disco / Room List dialogs, kill the visible
Paul Aurich <darkrain42@pidgin.im>
parents: 28304
diff changeset
109 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
110 dialog->account = account;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
111 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
112
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
113 if (change) {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
114 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
115 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
116 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
117
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
118 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
119 activate_register(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
120 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
121 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
122 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
123 PidginDiscoDialog *dialog = data;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
124 XmppDiscoService *service = dialog->selected;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
125
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
126 g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
127
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
128 xmpp_disco_register_service(service);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
129 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
130
42074
58ae70ad7f21 Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents: 42037
diff changeset
131 static void
58ae70ad7f21 Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents: 42037
diff changeset
132 discolist_cancel_cb(PidginDiscoList *pdl, G_GNUC_UNUSED const char *server) {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
133 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
134
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
135 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
136 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
137 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
138
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
139 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
140 {
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
141 pdl->dialog->prompt_handle = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
142 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
143
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
144 if (!server || !*server) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
145 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
146 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
147
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
148 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
149 pidgin_disco_list_unref(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
150 return;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
151 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
152
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
153 pdl->server = g_strdup(server);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
154 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
155 xmpp_disco_start(pdl);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
156 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
157
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
158 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
159 activate_browse(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
160 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
161 gpointer data)
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
162 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
163 PidginDiscoDialog *dialog = data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
164 PurpleConnection *pc;
41962
f802660eaef2 Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents: 41854
diff changeset
165 PurpleContactInfo *info = 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
166 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
167 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
168 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
169 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
170
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
171 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
172 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
173 return;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
174 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
175
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
176 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
177 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
178 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
179
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
180 g_clear_pointer(&dialog->discolist, pidgin_disco_list_unref);
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
181 g_list_store_remove_all(dialog->root);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
182
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
183 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
184 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
185 /* We keep a copy... */
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
186 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
187
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
188 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
189
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
190 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
191
41962
f802660eaef2 Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents: 41854
diff changeset
192 info = PURPLE_CONTACT_INFO(dialog->account);
f802660eaef2 Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents: 41854
diff changeset
193 username = purple_contact_info_get_username(info);
29066
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
194 at = strchr(username, '@');
Paul Aurich <darkrain42@pidgin.im>
parents: 29060
diff changeset
195 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
196 if (at && !slash) {
40700
4c3ee00e6107 Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40534
diff changeset
197 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
198 } 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
199 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
200 }
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
201
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
202 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
203 /* 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
204 server = g_strdup("jabber.org");
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
205 }
27218
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
206
36135
b46d29bc9b35 Standardize the formatting we use to document hints for translators.
Mark Doliner <mark@kingant.net>
parents: 35850
diff changeset
207 /* 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
208 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
209 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
210 _("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
211 server, FALSE, FALSE, NULL,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
212 _("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
213 _("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
214 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
215
36968b1cde87 Remove debugging, use user's server as default, and avoid a GTK+ assertion.
Paul Aurich <darkrain42@pidgin.im>
parents: 27217
diff changeset
216 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
217 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
218
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
219 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
220 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
221 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
222 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
223 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
224 PidginDiscoDialog *dialog = data;
27318
c3f7edff8506 Store the currently selected service in the Dialog structure
Paul Aurich <darkrain42@pidgin.im>
parents: 27317
diff changeset
225 XmppDiscoService *service = dialog->selected;
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
226 PidginDiscoList *list = NULL;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
227 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
228 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
229
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
230 g_return_if_fail(XMPP_DISCO_IS_SERVICE(service));
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
231
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
232 list = xmpp_disco_service_get_list(service);
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
233 account = purple_connection_get_account(list->pc);
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
234 jid = xmpp_disco_service_get_jid(service);
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
235
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
236 if(xmpp_disco_service_get_service_type(service) == 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
237 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
238 } 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
239 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
240 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
241 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
242
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
243 static void
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
244 selection_changed_cb(GtkSelectionModel *self, G_GNUC_UNUSED guint position,
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
245 G_GNUC_UNUSED guint n_items, gpointer 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
246 {
41562
bfd0330f09fb Port XMPP Service Discovery plugin to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41499
diff changeset
247 PidginDiscoDialog *dialog = data;
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
248 GtkTreeListRow *row = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
249 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
250
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
251 /* The passed in position and n_items gives the *range* of selections that
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
252 * have changed, so just re-query it since GtkSingleSelection has exactly
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
253 * one. */
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
254 row = gtk_single_selection_get_selected_item(GTK_SINGLE_SELECTION(self));
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
255 if(row != NULL) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
256 dialog->selected = gtk_tree_list_row_get_item(row);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
257 if(XMPP_DISCO_IS_SERVICE(dialog->selected)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
258 XmppDiscoServiceFlags flags;
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
259
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
260 flags = xmpp_disco_service_get_flags(dialog->selected);
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
261 allow_add = (flags & XMPP_DISCO_ADD) != 0;
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
262 allow_register = (flags & XMPP_DISCO_REGISTER) != 0;
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
263
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
264 /* gtk_tree_list_row_get_item returns a ref, but this struct isn't
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
265 * supposed to hold one, as the model holds on to it. */
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
266 g_object_unref(dialog->selected);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
267 }
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
268 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
269
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
270 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
271 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
272 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
273
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
274 static GListModel *
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
275 service_create_child_model_cb(GObject *item, G_GNUC_UNUSED gpointer data) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
276 XmppDiscoService *service = XMPP_DISCO_SERVICE(item);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
277 GListModel *model = NULL;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
278
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
279 model = xmpp_disco_service_get_child_model(service);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
280 if(G_IS_LIST_MODEL(model)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
281 /* Always return a new ref, as the caller takes ownership. */
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
282 g_object_ref(model);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
283 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
284
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
285 return model;
26919
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
286 }
1be739ada7cd Handle expanding disco lists on the UI side
Paul Aurich <darkrain42@pidgin.im>
parents: 26596
diff changeset
287
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
288 static void
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
289 row_expanded_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
290 G_GNUC_UNUSED gpointer 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
291 {
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
292 GtkTreeListRow *row = GTK_TREE_LIST_ROW(obj);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
293
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
294 if(gtk_tree_list_row_get_expanded(row)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
295 XmppDiscoService *service = gtk_tree_list_row_get_item(row);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
296 if(XMPP_DISCO_IS_SERVICE(service)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
297 xmpp_disco_service_expand(service);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
298 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
299 g_clear_object(&service);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
300 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
301 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
302
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
303 static void
42091
7e0d24e06ce2 Fix new warning in XMPP disco plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42090
diff changeset
304 list_row_notify_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
7e0d24e06ce2 Fix new warning in XMPP disco plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42090
diff changeset
305 G_GNUC_UNUSED gpointer data)
7e0d24e06ce2 Fix new warning in XMPP disco plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42090
diff changeset
306 {
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
307 GtkTreeListRow *row = NULL;
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
308
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
309 row = gtk_tree_expander_get_list_row(GTK_TREE_EXPANDER(obj));
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
310 if(GTK_IS_TREE_LIST_ROW(row)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
311 g_signal_connect(row, "notify::expanded", G_CALLBACK(row_expanded_cb),
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
312 NULL);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
313 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
314 }
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
315
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
316 static void
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
317 row_activated_cb(GtkColumnView *self, guint position, gpointer user_data) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
318 PidginDiscoDialog *dialog = user_data;
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
319 GtkSelectionModel *model = NULL;
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
320 GtkTreeListRow *row = NULL;
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
321 XmppDiscoService *service = NULL;
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
322 XmppDiscoServiceFlags flags;
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
323
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
324 model = gtk_column_view_get_model(self);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
325 row = g_list_model_get_item(G_LIST_MODEL(model), position);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
326 service = gtk_tree_list_row_get_item(row);
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
327
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
328 flags = xmpp_disco_service_get_flags(service);
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
329 if((flags & XMPP_DISCO_BROWSE) != 0) {
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
330 if(gtk_tree_list_row_get_expanded(row)) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
331 gtk_tree_list_row_set_expanded(row, FALSE);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
332 } else {
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
333 gtk_tree_list_row_set_expanded(row, TRUE);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
334 }
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
335 } else if((flags & XMPP_DISCO_REGISTER) != 0) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
336 g_action_activate(G_ACTION(dialog->register_action), NULL);
42037
af20db93f2c2 Convert XmppDiscoService into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42034
diff changeset
337 } else if((flags & XMPP_DISCO_ADD) != 0) {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
338 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
339 }
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
340
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
341 g_clear_object(&service);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
342 g_clear_object(&row);
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
343 }
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
344
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
345 static void
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
346 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
347 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
348 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
349 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
350
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
351 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
352 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
353 }
28839
16ed31feeabf xmppdisco: Close the input request when closing the dialog. Fixes a crash.
Paul Aurich <darkrain42@pidgin.im>
parents: 28704
diff changeset
354
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
355 if (list) {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
356 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
357
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
358 if (list->in_progress) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
359 list->in_progress = FALSE;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
360 }
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
361
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
362 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
363 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
364
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
365 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
366 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
367
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
368 static void
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
369 activate_stop(G_GNUC_UNUSED GSimpleAction *action,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
370 G_GNUC_UNUSED GVariant *parameter,
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
371 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
372 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
373 PidginDiscoDialog *dialog = data;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
374
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
375 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
376 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
377
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
378 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
379 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
380 GList *node;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
381
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
382 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
383 PidginDiscoDialog *dialog = node->data;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
384 PidginDiscoList *list = dialog->discolist;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
385
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
386 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
387 PurpleAccount *account = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
388
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
389 if (list->in_progress) {
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
390 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
391 }
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
392
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
393 g_list_store_remove_all(dialog->root);
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
394
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
395 pidgin_disco_list_unref(list);
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
396 dialog->discolist = NULL;
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
397
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
398 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
399 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
400
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
401 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
402 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
403 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
404 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
405 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
406 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
407
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
408 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
409 {
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
410 while (dialogs) {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
411 GtkWidget *dialog = dialogs->data;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
412
41562
bfd0330f09fb Port XMPP Service Discovery plugin to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41499
diff changeset
413 gtk_window_destroy(GTK_WINDOW(dialog));
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
414 /* 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
415 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
416 }
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
417
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
418 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
419 * GObject implementation
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
420 *****************************************************************************/
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
421
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
422 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
423
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
424 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
425 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
426 {
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
427 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
428
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
429 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
430 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
431
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
432 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
433 account_chooser);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
434 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
435 progress);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
436 gtk_widget_class_bind_template_child(widget_class, PidginDiscoDialog,
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
437 sorter);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
438
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
439 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
440 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
441 dialog_select_account_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
442 gtk_widget_class_bind_template_callback(widget_class, row_activated_cb);
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
443 gtk_widget_class_bind_template_callback(widget_class, list_row_notify_cb);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
444 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
445 selection_changed_cb);
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
446 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
447
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
448 static void
42074
58ae70ad7f21 Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents: 42037
diff changeset
449 pidgin_disco_dialog_class_finalize(G_GNUC_UNUSED PidginDiscoDialogClass *klass)
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
450 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
451 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
452
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
453 static void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
454 pidgin_disco_dialog_init(PidginDiscoDialog *dialog)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
455 {
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
456 GtkTreeListModel *model = NULL;
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
457 GActionEntry entries[] = {
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
458 { .name = "stop", .activate = activate_stop },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
459 { .name = "browse", .activate = activate_browse },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
460 { .name = "register", .activate = activate_register },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
461 { .name = "add", .activate = activate_add_to_blist },
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
462 };
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
463 GSimpleActionGroup *action_group = NULL;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
464 GActionMap *action_map = NULL;
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
465
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
466 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
467
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
468 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
469
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
470 /* 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
471 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
472 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
473
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
474 action_group = g_simple_action_group_new();
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
475 action_map = G_ACTION_MAP(action_group);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
476 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
477 dialog);
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
478
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
479 dialog->stop_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
480 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
481 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
482
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
483 dialog->browse_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
484 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
485 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
486
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
487 dialog->register_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
488 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
489 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
490
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
491 dialog->add_action = G_SIMPLE_ACTION(
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
492 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
493 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
494
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
495 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
496 G_ACTION_GROUP(action_group));
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
497
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
498 dialog->root = g_list_store_new(XMPP_DISCO_TYPE_SERVICE);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
499 model = gtk_tree_list_model_new(G_LIST_MODEL(dialog->root), FALSE, FALSE,
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
500 (GtkTreeListModelCreateModelFunc)service_create_child_model_cb,
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
501 NULL, NULL);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
502 gtk_sort_list_model_set_model(dialog->sorter, G_LIST_MODEL(model));
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
503 g_object_unref(model);
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
504 }
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
505
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
506 /******************************************************************************
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
507 * Public API
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
508 *****************************************************************************/
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
509
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
510 void
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
511 pidgin_disco_dialog_register(PurplePlugin *plugin)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
512 {
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
513 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
514 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
515
39801
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
516 PidginDiscoDialog *
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
517 pidgin_disco_dialog_new(void)
2bbed8148402 Convert Service Discovery plugin to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
518 {
41499
a80a41434f44 Modernize XMPP discovery plugin
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
519 PidginDiscoDialog *dialog = g_object_new(PIDGIN_TYPE_DISCO_DIALOG, NULL);
42202
2273647d24b0 Use gtk_widget_set_visible for everything
Gary Kramlich <grim@reaperworld.com>
parents: 42091
diff changeset
520 gtk_widget_set_visible(GTK_WIDGET(dialog), TRUE);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
521 return dialog;
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
522 }
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
523
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
524 void
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
525 pidgin_disco_add_service(PidginDiscoList *pdl, XmppDiscoService *service,
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
526 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
527 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26587
diff changeset
528 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
529
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26588
diff changeset
530 dialog = pdl->dialog;
27217
7509acac49de Convert the disco browser to a plugin. Refs #556
Paul Aurich <darkrain42@pidgin.im>
parents: 26926
diff changeset
531 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
532
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
533 purple_debug_info("xmppdisco", "Adding service \"%s\" to %p",
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
534 xmpp_disco_service_get_name(service), parent);
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
535
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
536 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
537
42090
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
538 if(parent != NULL) {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
539 xmpp_disco_service_add_child(parent, service);
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
540 } else {
a109a8cc8059 Convert XMPP Service Discovery to GtkColumnView
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42074
diff changeset
541 g_list_store_append(dialog->root, service);
27222
9daa676e9244 Remove the pseudo-row child of expandable services if there are no children.
Paul Aurich <darkrain42@pidgin.im>
parents: 27218
diff changeset
542 }
26585
11eaedca43b4 Add the files I forgot to `mtn add` earlier (also, alphabetized disco.h
Paul Aurich <darkrain42@pidgin.im>
parents:
diff changeset
543 }

mercurial