[gnome-control-center/wip/feborges/avatar-chooser: 87/90] user-accounts: Turn UmPhotoDialog in a full GObject



commit 5cbe2763c1e3635dfb4549c4e45b8212ead31c67
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jan 9 16:00:41 2018 +0100

    user-accounts: Turn UmPhotoDialog in a full GObject
    
    For the new avatar-chooser implementation we will use Gtk+ widget
    composite templates.

 panels/user-accounts/um-photo-dialog.c |   32 ++++++++++++++++++++++----------
 panels/user-accounts/um-photo-dialog.h |    4 ++++
 panels/user-accounts/um-user-panel.c   |    4 ----
 3 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/panels/user-accounts/um-photo-dialog.c b/panels/user-accounts/um-photo-dialog.c
index 600c583..d8819f6 100644
--- a/panels/user-accounts/um-photo-dialog.c
+++ b/panels/user-accounts/um-photo-dialog.c
@@ -58,6 +58,8 @@ struct _UmPhotoDialog {
         ActUser *user;
 };
 
+G_DEFINE_TYPE (UmPhotoDialog, um_photo_dialog, GTK_TYPE_POPOVER)
+
 static void
 crop_dialog_response (GtkWidget     *dialog,
                       gint           response_id,
@@ -591,21 +593,31 @@ um_photo_dialog_new (GtkWidget *button)
         return um;
 }
 
-void
-um_photo_dialog_free (UmPhotoDialog *um)
+static void
+um_photo_dialog_dispose (GObject *object)
 {
-        gtk_widget_destroy (um->photo_popup);
+        UmPhotoDialog *um = UM_PHOTO_DIALOG (object);
 
-        if (um->thumb_factory)
-                g_object_unref (um->thumb_factory);
+        g_clear_object (&um->thumb_factory);
 #ifdef HAVE_CHEESE
-        if (um->monitor)
-                g_object_unref (um->monitor);
+        g_clear_object (&um->monitor);
 #endif
-        if (um->user)
-                g_object_unref (um->user);
+        g_clear_object (&um->user);
+
+        G_OBJECT_CLASS (um_photo_dialog_parent_class)->dispose (object);
+}
+
+static void
+um_photo_dialog_init (UmPhotoDialog *um)
+{
+}
+
+static void
+um_photo_dialog_class_init (UmPhotoDialogClass *klass)
+{
+        GObjectClass *oclass = G_OBJECT_CLASS (klass);
 
-        g_free (um);
+        oclass->dispose = um_photo_dialog_dispose;
 }
 
 static void
diff --git a/panels/user-accounts/um-photo-dialog.h b/panels/user-accounts/um-photo-dialog.h
index 4555c6a..fc74a2e 100644
--- a/panels/user-accounts/um-photo-dialog.h
+++ b/panels/user-accounts/um-photo-dialog.h
@@ -26,6 +26,10 @@
 
 G_BEGIN_DECLS
 
+#define UM_TYPE_PHOTO_DIALOG (um_photo_dialog_get_type())
+
+G_DECLARE_FINAL_TYPE (UmPhotoDialog, um_photo_dialog, UM, PHOTO_DIALOG, GtkPopover)
+
 typedef struct _UmPhotoDialog UmPhotoDialog;
 
 UmPhotoDialog *um_photo_dialog_new      (GtkWidget     *button);
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index c1875cb..bd571af 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -1511,10 +1511,6 @@ cc_user_panel_dispose (GObject *object)
                 um_password_dialog_free (priv->password_dialog);
                 priv->password_dialog = NULL;
         }
-        if (priv->photo_dialog) {
-                um_photo_dialog_free (priv->photo_dialog);
-                priv->photo_dialog = NULL;
-        }
         if (priv->history_dialog) {
                 um_history_dialog_free (priv->history_dialog);
                 priv->history_dialog = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]