pidgin/pidginaccountchooser.c

Sun, 03 Nov 2024 00:05:44 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 03 Nov 2024 00:05:44 -0500
changeset 43045
308e8d0ce68c
parent 42649
6986f5428d30
child 43072
a59a119b74f5
permissions
-rw-r--r--

remove purple3-url-handler.desktop.in.in

The application that did the launching was removed long ago. Also this should
be implemented by the user interfaces and they might provide separate files to
groups schemas as well.

Testing Done:
Called in the turtles.

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

40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
1 /*
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
2 * Pidgin - Internet Messenger
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 *
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 * source distribution.
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
8 *
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
12 * (at your option) any later version.
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
13 *
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 * GNU General Public License for more details.
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
18 *
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
22 */
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
23 #include <glib/gi18n-lib.h>
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
24
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25 #include <gtk/gtk.h>
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
27 #include "pidginaccountchooser.h"
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
28
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
29 struct _PidginAccountChooser {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
30 AdwBin parent;
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
31
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
32 GtkDropDown *chooser;
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
33 GtkFilterListModel *filter;
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
34 };
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
35
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
36 enum
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
37 {
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
38 PROP_0,
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
39 PROP_ACCOUNT,
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
40 PROP_FILTER,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42575
diff changeset
41 N_PROPERTIES,
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
42 };
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
43
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42575
diff changeset
44 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
45
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
46 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
47 * Callbacks
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
48 *****************************************************************************/
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
49 static void
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
50 pidgin_account_chooser_changed_cb(G_GNUC_UNUSED GObject *obj,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
51 G_GNUC_UNUSED GParamSpec *pspec,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
52 gpointer data)
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
53 {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
54 g_object_notify_by_pspec(G_OBJECT(data), properties[PROP_ACCOUNT]);
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
55 }
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
56
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
57 /******************************************************************************
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
58 * GObject implementation
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
59 *****************************************************************************/
42575
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42165
diff changeset
60 G_DEFINE_FINAL_TYPE(PidginAccountChooser, pidgin_account_chooser, ADW_TYPE_BIN)
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
61
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
62 static void
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
63 pidgin_account_chooser_get_property(GObject *object, guint prop_id,
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
64 GValue *value, GParamSpec *pspec)
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
65 {
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
66 PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(object);
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
67
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
68 switch (prop_id) {
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
69 case PROP_ACCOUNT:
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
70 g_value_set_object(value, pidgin_account_chooser_get_selected(chooser));
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
71 break;
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
72 case PROP_FILTER:
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
73 g_value_set_object(value, pidgin_account_chooser_get_filter(chooser));
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
74 break;
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
75 default:
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
76 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
77 break;
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
78 }
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
79 }
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
80
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
81 static void
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
82 pidgin_account_chooser_set_property(GObject *object, guint prop_id,
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
83 const GValue *value, GParamSpec *pspec)
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
84 {
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
85 PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(object);
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
86
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
87 switch (prop_id) {
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
88 case PROP_ACCOUNT:
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
89 pidgin_account_chooser_set_selected(chooser,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
90 g_value_get_object(value));
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
91 break;
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
92 case PROP_FILTER:
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
93 pidgin_account_chooser_set_filter(chooser,
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
94 g_value_get_object(value));
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
95 break;
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
96 default:
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
97 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
98 break;
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
99 }
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
100 }
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
101
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
102 static void
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
103 pidgin_account_chooser_class_init(PidginAccountChooserClass *klass)
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
104 {
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
105 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
106 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
107
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
108 /* Properties */
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
109 obj_class->get_property = pidgin_account_chooser_get_property;
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
110 obj_class->set_property = pidgin_account_chooser_set_property;
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
111
42649
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
112 /**
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
113 * PidginAccountChooser:account:
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
114 *
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
115 * The account that is currently selected.
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
116 *
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
117 * Since: 3.0
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
118 */
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
119 properties[PROP_ACCOUNT] = g_param_spec_object(
42649
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
120 "account", "Account",
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
121 "The account that is currently selected.",
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
122 PURPLE_TYPE_ACCOUNT,
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
123 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
124
42649
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
125 /**
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
126 * PidginAccountChooser:filter:
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
127 *
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
128 * A filter to be applied to the list of accounts.
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
129 *
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
130 * Since: 3.0
6986f5428d30 Add a doc check unit test to Pidgin and fix the issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
131 */
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
132 properties[PROP_FILTER] = g_param_spec_object(
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
133 "filter", "filter",
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
134 "The filter to be applied on the list of accounts.",
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
135 GTK_TYPE_FILTER,
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
136 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
137
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42575
diff changeset
138 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
139
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
140 /* Widget template */
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
141 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: 40534
diff changeset
142 widget_class, "/im/pidgin/Pidgin3/Accounts/chooser.ui");
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
143
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
144 gtk_widget_class_bind_template_child(widget_class, PidginAccountChooser,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
145 chooser);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
146 gtk_widget_class_bind_template_child(widget_class, PidginAccountChooser,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
147 filter);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
148
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
149 gtk_widget_class_bind_template_callback(widget_class,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
150 pidgin_account_chooser_changed_cb);
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
151 }
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
152
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
153 static void
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
154 pidgin_account_chooser_init(PidginAccountChooser *chooser) {
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
155 GListModel *model = NULL;
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
156
39788
6e86cff44a34 Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39787
diff changeset
157 gtk_widget_init_template(GTK_WIDGET(chooser));
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
158
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
159 model = purple_account_manager_get_default_as_model();
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
160 gtk_filter_list_model_set_model(chooser->filter, model);
39785
aa7e3b71802d Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
161 }
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
162
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
163 /******************************************************************************
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
164 * Public API
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
165 *****************************************************************************/
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
166 GtkWidget *
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
167 pidgin_account_chooser_new(void) {
39790
dd3fd44f3abb Move account chooser data into its struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39789
diff changeset
168 PidginAccountChooser *chooser = NULL;
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
169
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
170 chooser = g_object_new(PIDGIN_TYPE_ACCOUNT_CHOOSER, NULL);
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
171
39790
dd3fd44f3abb Move account chooser data into its struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39789
diff changeset
172 return GTK_WIDGET(chooser);
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
173 }
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
174
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
175 GtkFilter *
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
176 pidgin_account_chooser_get_filter(PidginAccountChooser *chooser) {
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
177 g_return_val_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser), NULL);
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
178
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
179 return gtk_filter_list_model_get_filter(chooser->filter);
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
180 }
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
181
39793
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
182 void
41857
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
183 pidgin_account_chooser_set_filter(PidginAccountChooser *chooser,
ff94f8ff8a70 Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41030
diff changeset
184 GtkFilter *filter)
39793
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
185 {
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
186 g_return_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser));
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
187
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
188 gtk_filter_list_model_set_filter(chooser->filter, filter);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
189 g_object_notify_by_pspec(G_OBJECT(chooser), properties[PROP_FILTER]);
39793
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
190 }
2a29bc06910b Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39792
diff changeset
191
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
192 PurpleAccount *
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
193 pidgin_account_chooser_get_selected(PidginAccountChooser *chooser) {
39792
23eb94ca54bd Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39791
diff changeset
194 g_return_val_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser), NULL);
23eb94ca54bd Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39791
diff changeset
195
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
196 return gtk_drop_down_get_selected_item(chooser->chooser);
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
197 }
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
198
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
199 void
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
200 pidgin_account_chooser_set_selected(PidginAccountChooser *chooser,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
201 PurpleAccount *account)
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
202 {
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
203 GListModel *model = NULL;
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
204 guint n_items = 0;
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
205
39792
23eb94ca54bd Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39791
diff changeset
206 g_return_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser));
23eb94ca54bd Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39791
diff changeset
207
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
208 model = gtk_drop_down_get_model(chooser->chooser);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
209 g_return_if_fail(G_IS_LIST_MODEL(model));
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
210
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
211 n_items = g_list_model_get_n_items(model);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
212 for(guint position = 0; position < n_items; position++) {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
213 PurpleAccount *acc = g_list_model_get_item(model, position);
40248
0d975f80d020 Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39793
diff changeset
214
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
215 if(acc == account) {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
216 /* NOTE: Property notification occurs in 'changed' signal
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
217 * callback.
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
218 */
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
219 gtk_drop_down_set_selected(chooser->chooser, position);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
220
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
221 g_object_unref(acc);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
222
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
223 return;
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
224 }
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
225
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41857
diff changeset
226 g_object_unref(acc);
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents: 40496
diff changeset
227 }
39789
7d58eccb27de Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39788
diff changeset
228 }

mercurial