--- a/pidgin/pidginaccountchooser.c Fri Dec 20 02:44:13 2019 +0000
+++ b/pidgin/pidginaccountchooser.c Sun Dec 22 18:42:12 2019 -0500
@@ -36,6 +36,14 @@
/******************************************************************************
*****************************************************************************/
@@ -52,6 +60,8 @@
/******************************************************************************
*****************************************************************************/
+static GParamSpec *properties[PROP_LAST] = {NULL}; G_DEFINE_TYPE(PidginAccountChooser, pidgin_account_chooser, GTK_TYPE_COMBO_BOX)
@@ -192,14 +202,78 @@
+pidgin_account_chooser_changed_cb(GtkComboBox *widget, gpointer user_data) + g_object_notify_by_pspec(G_OBJECT(widget), properties[PROP_ACCOUNT]); /******************************************************************************
*****************************************************************************/
+pidgin_account_chooser_get_property(GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) + PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(object); + g_value_set_object(value, account_chooser_get_selected(chooser)); + g_value_set_boolean(value, chooser->show_all); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +pidgin_account_chooser_set_property(GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) + PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(object); + account_chooser_select_by_data(GTK_WIDGET(chooser), + g_value_get_object(value)); + chooser->show_all = g_value_get_boolean(value); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); pidgin_account_chooser_class_init(PidginAccountChooserClass *klass)
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ obj_class->get_property = pidgin_account_chooser_get_property; + obj_class->set_property = pidgin_account_chooser_set_property; + properties[PROP_ACCOUNT] = g_param_spec_object( + "account", "Account", "The account that is currently selected.", + PURPLE_TYPE_ACCOUNT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + properties[PROP_SHOW_ALL] = g_param_spec_boolean( + "show-all", "Show all", + "Whether to show all accounts, or just online ones.", FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(obj_class, PROP_LAST, properties); gtk_widget_class_set_template_from_resource(
widget_class, "/im/pidgin/Pidgin/Accounts/chooser.ui");
@@ -215,6 +289,9 @@
gtk_widget_init_template(GTK_WIDGET(chooser));
+ g_signal_connect(chooser, "changed", pidgin_account_chooser_changed_cb, /* Register the purple sign on/off event callbacks. */
purple_connections_get_handle(), "signed-on", chooser,
@@ -238,8 +315,8 @@
PidginAccountChooser *chooser = NULL;
- chooser = g_object_new(PIDGIN_TYPE_ACCOUNT_CHOOSER, NULL);
- chooser->show_all = show_all;
+ chooser = g_object_new(PIDGIN_TYPE_ACCOUNT_CHOOSER, "account", + default_account, "show-all", show_all, NULL); set_account_menu(PIDGIN_ACCOUNT_CHOOSER(chooser), default_account);
return GTK_WIDGET(chooser);
@@ -270,4 +347,14 @@
g_return_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser));
account_chooser_select_by_data(chooser, account);
+ /* NOTE: Property notification occurs in 'changed' signal callback. */ +pidgin_account_chooser_get_show_all(GtkWidget *chooser) + g_return_val_if_fail(PIDGIN_IS_ACCOUNT_CHOOSER(chooser), FALSE); + return PIDGIN_ACCOUNT_CHOOSER(chooser)->show_all; --- a/pidgin/pidginaccountchooser.h Fri Dec 20 02:44:13 2019 +0000
+++ b/pidgin/pidginaccountchooser.h Sun Dec 22 18:42:12 2019 -0500
@@ -93,6 +93,18 @@
void pidgin_account_chooser_set_selected(GtkWidget *chooser,
+ * pidgin_account_chooser_get_show_all: + * @chooser: The chooser created by pidgin_account_chooser_new(). + * Returns whether to show all accounts. + * Returns: Whether or not to show all accounts, or just active accounts. +gboolean pidgin_account_chooser_get_show_all(GtkWidget *chooser); #endif /* PIDGIN_ACCOUNT_CHOOSER_H */