[gnome-photos/wip/search: 15/22] application: Rearrange the window creation and destruction code
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/search: 15/22] application: Rearrange the window creation and destruction code
- Date: Wed, 19 Feb 2014 12:33:04 +0000 (UTC)
commit 67ff4b8176bdebe0fb556613f020ad6e9e81df2a
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Feb 18 14:18:21 2014 +0100
application: Rearrange the window creation and destruction code
This keeps the code in sync with gnome-documents.
src/photos-application.c | 50 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index b8ed612..9fb9b6d 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -91,6 +91,8 @@ struct _PhotosApplicationRefreshData
};
static gboolean photos_application_refresh_miner_now (PhotosApplication *self, GomMiner *miner);
+static void photos_application_start_miners (PhotosApplication *self);
+static void photos_application_stop_miners (PhotosApplication *self);
static PhotosApplicationRefreshData *
@@ -138,6 +140,36 @@ photos_application_action_toggle (GSimpleAction *simple, GVariant *parameter, gp
static void
+photos_application_destroy (PhotosApplication *self)
+{
+ PhotosApplicationPrivate *priv = self->priv;
+
+ priv->main_window = NULL;
+
+ if (priv->miners_running != NULL)
+ {
+ photos_application_stop_miners (self);
+ g_list_free_full (priv->miners_running, g_object_unref);
+ priv->miners_running = NULL;
+ }
+}
+
+
+static void
+photos_application_create_window (PhotosApplication *self)
+{
+ PhotosApplicationPrivate *priv = self->priv;
+
+ if (priv->main_window != NULL)
+ return;
+
+ priv->main_window = photos_main_window_new (GTK_APPLICATION (self));
+ g_signal_connect_swapped (priv->main_window, "destroy", G_CALLBACK (photos_application_destroy), self);
+ photos_application_start_miners (self);
+}
+
+
+static void
photos_application_activate_result (PhotosApplication *self,
const gchar *identifier,
const gchar *const *terms,
@@ -448,6 +480,12 @@ photos_application_activate (GApplication *application)
PhotosApplication *self = PHOTOS_APPLICATION (application);
PhotosApplicationPrivate *priv = self->priv;
+ if (priv->main_window == NULL)
+ {
+ photos_application_create_window (self);
+ photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
+ }
+
gtk_window_present (GTK_WINDOW (priv->main_window));
}
@@ -622,11 +660,6 @@ photos_application_startup (GApplication *application)
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>p", "app.print-current", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>f", "app.search", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>a", "app.select-all", NULL);
-
- priv->main_window = photos_main_window_new (GTK_APPLICATION (self));
- photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
-
- photos_application_start_miners (self);
}
@@ -654,13 +687,6 @@ photos_application_dispose (GObject *object)
PhotosApplication *self = PHOTOS_APPLICATION (object);
PhotosApplicationPrivate *priv = self->priv;
- if (priv->miners_running != NULL)
- {
- photos_application_stop_miners (self);
- g_list_free_full (priv->miners_running, g_object_unref);
- priv->miners_running = NULL;
- }
-
if (priv->resource != NULL)
{
g_resources_unregister (priv->resource);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]