Fri, 05 Mar 2021 03:31:29 -0600
Create a PidginAvatar widget.
This does everything the existing code does, but trying to integrate right now
is kind of difficult. The plan is to use this in a new PidginInfoPane I have
started, but that change got very large so I just packed it into the end of
the existing info pane.
The only things that are not implement right now, are making menu items
insensitive and that's because we need to figure out a better want to handle
custom avatars for users.
Testing Done:
Ran locally.
Reviewed at https://reviews.imfreedom.org/r/528/
|
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 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
32 | PurpleFilterAccountFunc filter_func; |
|
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, |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
39 | PROP_LAST |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
40 | }; |
|
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 | 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
|
43 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
44 | /****************************************************************************** |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
45 | * Callbacks |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
46 | *****************************************************************************/ |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
47 | static void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
48 | 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
|
49 | 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
|
50 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
51 | |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
52 | /****************************************************************************** |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
53 | * GObject implementation |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
54 | *****************************************************************************/ |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
55 | 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
|
56 | |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
57 | static void |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
58 | 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
|
59 | GValue *value, GParamSpec *pspec) |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
60 | { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
61 | 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
|
62 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
63 | switch (prop_id) { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
64 | 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
|
65 | 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
|
66 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
67 | default: |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
68 | 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
|
69 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
70 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
71 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
72 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
73 | static void |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
74 | 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
|
75 | const GValue *value, GParamSpec *pspec) |
|
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 | 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
|
78 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
79 | switch (prop_id) { |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
80 | 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
|
81 | 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
|
82 | 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
|
83 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
84 | default: |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
85 | 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
|
86 | break; |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
87 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
88 | } |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
89 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
90 | static void |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
91 | 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
|
92 | { |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
93 | 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
|
94 | 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
|
95 | |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
96 | /* Properties */ |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
97 | 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
|
98 | 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
|
99 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
100 | 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
|
101 | "account", "Account", "The account that is currently selected.", |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
102 | PURPLE_TYPE_ACCOUNT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
103 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
104 | 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
|
105 | |
|
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
106 | /* Widget template */ |
|
39788
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
107 | gtk_widget_class_set_template_from_resource( |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
108 | widget_class, "/im/pidgin/Pidgin/Accounts/chooser.ui"); |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
109 | } |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
110 | |
|
6e86cff44a34
Convert account chooser to a GObject.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39787
diff
changeset
|
111 | static void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
112 | 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
|
113 | 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
|
114 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
115 | /* 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
|
116 | g_signal_connect(chooser, "changed", |
|
a133a6fcc822
Fill PidginAccountChooser on init.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40248
diff
changeset
|
117 | 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
|
118 | } |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
119 | |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
120 | /****************************************************************************** |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
121 | * Public API |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
122 | *****************************************************************************/ |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
123 | GtkWidget * |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
124 | 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
|
125 | PidginAccountChooser *chooser = NULL; |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
126 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
127 | 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
|
128 | |
|
39790
dd3fd44f3abb
Move account chooser data into its struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39789
diff
changeset
|
129 | return GTK_WIDGET(chooser); |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
130 | } |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
131 | |
|
39793
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
132 | void |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
133 | pidgin_account_chooser_set_filter_func(PidginAccountChooser *chooser, |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
134 | PurpleFilterAccountFunc filter_func) |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
135 | { |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
136 | 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
|
137 | |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
138 | chooser->filter_func = filter_func; |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
139 | } |
|
2a29bc06910b
Move account chooser filter in a separate setter.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39792
diff
changeset
|
140 | |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
141 | PurpleAccount * |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
142 | 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
|
143 | GtkTreeIter iter; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
144 | gpointer account = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
145 | |
|
39792
23eb94ca54bd
Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39791
diff
changeset
|
146 | 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
|
147 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | } |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
153 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
154 | return account; |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
155 | } |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
156 | |
|
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
157 | void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
158 | 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
|
159 | PurpleAccount *account) |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
160 | { |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
161 | GtkTreeModel *model = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
162 | GtkTreeIter iter; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
163 | PurpleAccount *acc = NULL; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
164 | |
|
39792
23eb94ca54bd
Add proper asserts in account chooser API.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39791
diff
changeset
|
165 | 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
|
166 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
167 | 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
|
168 | 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
|
169 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
170 | 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
|
171 | do { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
172 | 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
|
173 | 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
|
174 | if(acc == account) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
175 | /* 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
|
176 | * callback. |
|
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 | 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
|
179 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
180 | 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
|
181 | |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
182 | return; |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
183 | } |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
184 | 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
|
185 | } 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
|
186 | } |
|
39789
7d58eccb27de
Group public API for account chooser together.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39788
diff
changeset
|
187 | } |
|
40248
0d975f80d020
Add account/show-all properties to PidginAccountChooser.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39793
diff
changeset
|
188 |