Commit d4926ac5 authored by Debarshi Ray's avatar Debarshi Ray

application: Make it a singleton

parent 85eb9907
......@@ -156,6 +156,24 @@ photos_application_startup (GApplication *application)
}
static GObject *
photos_application_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params)
{
static GObject *self = NULL;
if (self == NULL)
{
self = G_OBJECT_CLASS (photos_application_parent_class)->constructor (type,
n_construct_params,
construct_params);
g_object_add_weak_pointer (self, (gpointer) &self);
return self;
}
return g_object_ref (self);
}
static void
photos_application_dispose (GObject *object)
{
......@@ -200,6 +218,7 @@ photos_application_class_init (PhotosApplicationClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
GApplicationClass *application_class = G_APPLICATION_CLASS (class);
object_class->constructor = photos_application_constructor;
object_class->dispose = photos_application_dispose;
application_class->activate = photos_application_activate;
application_class->startup = photos_application_startup;
......@@ -209,14 +228,11 @@ photos_application_class_init (PhotosApplicationClass *class)
GtkApplication *
photos_application_new (const gchar *application_id,
GApplicationFlags flags)
photos_application_new (void)
{
g_return_val_if_fail (g_application_id_is_valid (application_id), NULL);
g_type_init ();
return g_object_new (PHOTOS_TYPE_APPLICATION,
"application-id", application_id,
"flags", flags,
"application-id", "org.gnome." PACKAGE_NAME,
"flags", G_APPLICATION_FLAGS_NONE,
NULL);
}
......@@ -49,8 +49,7 @@ struct _PhotosApplicationClass
GType photos_application_get_type (void) G_GNUC_CONST;
GtkApplication *photos_application_new (const gchar *application_id,
GApplicationFlags flags);
GtkApplication *photos_application_new (void);
G_END_DECLS
......
......@@ -39,7 +39,7 @@ main (gint argc, gchar *argv[])
g_set_prgname (PACKAGE_TARNAME);
app = photos_application_new ("org.gnome." PACKAGE_NAME, G_APPLICATION_FLAGS_NONE);
app = photos_application_new ();
exit_status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment