diff options
author | Gabriel Ivascu <ivascu.gabriel59@gmail.com> | 2017-05-24 01:29:19 +0300 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2017-08-06 09:27:30 -0500 |
commit | 4e37cb12e172b7e8b4b911806735e891569bae7f (patch) | |
tree | e92d856a3dc9e2db4fd16b599774717cc7fd2662 /src/passwords-dialog.c | |
parent | a3048548b374cc2ecf553301584fcd4af0c34280 (diff) | |
download | epiphany-4e37cb12e172b7e8b4b911806735e891569bae7f.tar.gz |
passwords-dialog: Make the password manager an object property
Diffstat (limited to 'src/passwords-dialog.c')
-rw-r--r-- | src/passwords-dialog.c | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/src/passwords-dialog.c b/src/passwords-dialog.c index 3023dc2f6..ad5fb73dc 100644 --- a/src/passwords-dialog.c +++ b/src/passwords-dialog.c @@ -62,11 +62,57 @@ struct _EphyPasswordsDialog { G_DEFINE_TYPE (EphyPasswordsDialog, ephy_passwords_dialog, GTK_TYPE_DIALOG) +enum { + PROP_0, + PROP_PASSWORD_MANAGER, + LAST_PROP +}; + +static GParamSpec *obj_properties[LAST_PROP]; + +static void +ephy_passwords_dialog_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (object); + + switch (prop_id) { + case PROP_PASSWORD_MANAGER: + g_clear_object (&dialog->manager); + dialog->manager = g_object_ref (g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +ephy_passwords_dialog_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (object); + + switch (prop_id) { + case PROP_PASSWORD_MANAGER: + g_value_set_object (value, dialog->manager); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + static void ephy_passwords_dialog_dispose (GObject *object) { EphyPasswordsDialog *dialog = EPHY_PASSWORDS_DIALOG (object); + g_clear_object (&dialog->manager); + g_free (dialog->search_text); dialog->search_text = NULL; @@ -313,8 +359,19 @@ ephy_passwords_dialog_class_init (EphyPasswordsDialogClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + object_class->set_property = ephy_passwords_dialog_set_property; + object_class->get_property = ephy_passwords_dialog_get_property; object_class->dispose = ephy_passwords_dialog_dispose; + obj_properties[PROP_PASSWORD_MANAGER] = + g_param_spec_object ("password-manager", + "Password manager", + "Password Manager", + EPHY_TYPE_PASSWORD_MANAGER, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, obj_properties); + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/passwords-dialog.ui"); @@ -462,12 +519,8 @@ ephy_passwords_dialog_init (EphyPasswordsDialog *dialog) EphyPasswordsDialog * ephy_passwords_dialog_new (EphyPasswordManager *manager) { - EphyPasswordsDialog *dialog; - - dialog = EPHY_PASSWORDS_DIALOG (g_object_new (EPHY_TYPE_PASSWORDS_DIALOG, - "use-header-bar", TRUE, - NULL)); - dialog->manager = manager; - - return dialog; + return EPHY_PASSWORDS_DIALOG (g_object_new (EPHY_TYPE_PASSWORDS_DIALOG, + "password-manager", manager, + "use-header-bar", TRUE, + NULL)); } |