user-accounts: Turn UmPhotoDialog in a full GObject

For the new avatar-chooser implementation we will use Gtk+ widget
composite templates.

https://bugzilla.gnome.org/show_bug.cgi?id=766670
This commit is contained in:
Felipe Borges 2018-01-09 16:00:41 +01:00
parent 0f893b7cff
commit 3fb1c1dca1
3 changed files with 31 additions and 15 deletions

View file

@ -43,6 +43,8 @@
#define AVATAR_PIXEL_SIZE 72
struct _UmPhotoDialog {
GtkPopover parent;
GtkWidget *photo_popup;
GtkWidget *popup_button;
GtkWidget *crop_area;
@ -58,6 +60,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,
@ -569,7 +573,9 @@ um_photo_dialog_new (GtkWidget *button)
{
UmPhotoDialog *um;
um = g_new0 (UmPhotoDialog, 1);
um = g_object_new (UM_TYPE_PHOTO_DIALOG,
"relative-to", button,
NULL);
um->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
@ -591,21 +597,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_free (um);
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);
oclass->dispose = um_photo_dialog_dispose;
}
static void

View file

@ -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);

View file

@ -1498,10 +1498,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;