Sat, 29 Oct 2022 00:52:04 -0500
Add a filter property to PidginAccountChooser
This replaces the old `pidgin_account_chooser_set_filter_func`.
It also currently does nothing, but neither did the old code.
Testing Done:
Compiled only.
Reviewed at https://reviews.imfreedom.org/r/1995/
|
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 | */ |
|
40496
6941fece679b
phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
23 | #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
|
24 | |
|
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
25 | #include "pidginaccountchooser.h" |
|
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
26 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
27 | #include "pidginaccountstore.h" |
|
39785
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
28 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
29 | struct _PidginAccountChooser { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
30 | GtkComboBox parent; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
31 | |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
32 | GtkFilter *filter; |
|
39785
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
33 | }; |
|
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
34 | |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
35 | enum |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
36 | { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
37 | PROP_0, |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
38 | PROP_ACCOUNT, |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
39 | PROP_FILTER, |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
40 | PROP_LAST |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
41 | }; |
|
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 | static GParamSpec *properties[PROP_LAST] = {NULL}; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
44 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
45 | /****************************************************************************** |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
46 | * Callbacks |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
47 | *****************************************************************************/ |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
48 | static void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
49 | pidgin_account_chooser_changed_cb(GtkComboBox *widget, gpointer user_data) { |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
50 | g_object_notify_by_pspec(G_OBJECT(widget), properties[PROP_ACCOUNT]); |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
51 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
52 | |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
53 | /****************************************************************************** |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
54 | * GObject implementation |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
55 | *****************************************************************************/ |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
56 | G_DEFINE_TYPE(PidginAccountChooser, pidgin_account_chooser, GTK_TYPE_COMBO_BOX) |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
57 | |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
58 | static void |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
59 | 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
|
60 | GValue *value, GParamSpec *pspec) |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
61 | { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
62 | 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
|
63 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
64 | switch (prop_id) { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
65 | 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
|
66 | 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
|
67 | break; |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
68 | case PROP_FILTER: |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
69 | 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
|
70 | break; |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
71 | default: |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
72 | 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
|
73 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
74 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
75 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
76 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
77 | static void |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
78 | 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
|
79 | const GValue *value, GParamSpec *pspec) |
|
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 | 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
|
82 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
83 | switch (prop_id) { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | break; |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
88 | case PROP_FILTER: |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
89 | 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
|
90 | g_value_get_object(value)); |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
91 | break; |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
92 | default: |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
93 | 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
|
94 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
95 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
96 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
97 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
98 | static void |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
99 | 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
|
100 | { |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
101 | 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
|
102 | 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
|
103 | |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
104 | /* Properties */ |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
105 | 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
|
106 | 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
|
107 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
108 | properties[PROP_ACCOUNT] = g_param_spec_object( |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
109 | "account", "Account", "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
|
110 | PURPLE_TYPE_ACCOUNT, |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
111 | 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
|
112 | |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
113 | 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
|
114 | "filter", "filter", |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
115 | "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
|
116 | GTK_TYPE_FILTER, |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
117 | 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
|
118 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
119 | g_object_class_install_properties(obj_class, PROP_LAST, properties); |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
120 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
121 | /* Widget template */ |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
122 | 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
|
123 | widget_class, "/im/pidgin/Pidgin3/Accounts/chooser.ui"); |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
124 | } |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
125 | |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
126 | static void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
127 | pidgin_account_chooser_init(PidginAccountChooser *chooser) { |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
128 | 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
|
129 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
130 | /* this callback emits the notify for the account property */ |
|
40249
a133a6fcc822
Fill PidginAccountChooser on init.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40248
diff
changeset
|
131 | g_signal_connect(chooser, "changed", |
|
a133a6fcc822
Fill PidginAccountChooser on init.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40248
diff
changeset
|
132 | G_CALLBACK(pidgin_account_chooser_changed_cb), NULL); |
|
39785
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
133 | } |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
134 | |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
135 | /****************************************************************************** |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
136 | * Public API |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
137 | *****************************************************************************/ |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
138 | GtkWidget * |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
139 | 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
|
140 | PidginAccountChooser *chooser = NULL; |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
141 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
142 | 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
|
143 | |
|
39790
dd3fd44f3abb
Move account chooser data into its struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39789
diff
changeset
|
144 | return GTK_WIDGET(chooser); |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
145 | } |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
146 | |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
147 | GtkFilter * |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
148 | 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
|
149 | 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
|
150 | |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
151 | return chooser->filter; |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
152 | } |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
153 | |
|
39793
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
154 | void |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
155 | 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
|
156 | GtkFilter *filter) |
|
39793
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
157 | { |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
158 | 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
|
159 | |
|
41857
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
160 | if(g_set_object(&chooser->filter, filter)) { |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
161 | g_object_notify_by_pspec(G_OBJECT(chooser), properties[PROP_FILTER]); |
|
ff94f8ff8a70
Add a filter property to PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41030
diff
changeset
|
162 | } |
|
39793
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
163 | } |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
164 | |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
165 | PurpleAccount * |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
166 | pidgin_account_chooser_get_selected(PidginAccountChooser *chooser) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
167 | GtkTreeIter iter; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
168 | gpointer account = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
169 | |
|
39792
23eb94ca54bd
Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39791
diff
changeset
|
170 | 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
|
171 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
172 | if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(chooser), &iter)) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
173 | GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(chooser)); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
174 | gtk_tree_model_get(model, &iter, |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
175 | PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, &account, -1); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
176 | } |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
177 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
178 | return account; |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
179 | } |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
180 | |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
181 | void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
182 | 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
|
183 | PurpleAccount *account) |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
184 | { |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
185 | GtkTreeModel *model = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
186 | GtkTreeIter iter; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
187 | PurpleAccount *acc = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
188 | |
|
39792
23eb94ca54bd
Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39791
diff
changeset
|
189 | 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
|
190 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
191 | model = gtk_combo_box_get_model(GTK_COMBO_BOX(chooser)); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
192 | g_return_if_fail(GTK_IS_TREE_MODEL(model)); |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
193 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
194 | if(gtk_tree_model_get_iter_first(model, &iter)) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
195 | do { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
196 | gtk_tree_model_get(model, &iter, |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
197 | PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, &acc, -1); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
198 | if(acc == account) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
199 | /* NOTE: Property notification occurs in 'changed' signal |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
200 | * callback. |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
201 | */ |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
202 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(chooser), &iter); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
203 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
204 | g_object_unref(G_OBJECT(acc)); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
205 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
206 | return; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
207 | } |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
208 | g_object_unref(G_OBJECT(acc)); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
209 | } while(gtk_tree_model_iter_next(model, &iter)); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
210 | } |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
211 | } |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
212 |