[gnome-photos/wip/search: 19/22] application: Implement PhotosSearchContext
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/search: 19/22] application: Implement PhotosSearchContext
- Date: Wed, 19 Feb 2014 12:33:24 +0000 (UTC)
commit a83494e75437c808dc07b9e74ecf5b2b60a168e5
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Feb 18 17:14:11 2014 +0100
application: Implement PhotosSearchContext
src/photos-application.c | 48 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 82f01a7..527b84d 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -45,6 +45,7 @@
#include "photos-properties-dialog.h"
#include "photos-query.h"
#include "photos-resources.h"
+#include "photos-search-context.h"
#include "photos-search-controller.h"
#include "photos-search-provider.h"
#include "photos-single-item-job.h"
@@ -70,16 +71,20 @@ struct _PhotosApplicationPrivate
GomMiner *flickr_miner;
GtkWidget *main_window;
PhotosBaseManager *item_mngr;
- PhotosBaseManager *src_mngr;
PhotosCameraCache *camera_cache;
PhotosModeController *mode_cntrlr;
- PhotosSearchController *srch_cntrlr;
+ PhotosSearchContextState *state;
PhotosSearchProvider *search_provider;
guint32 activation_timestamp;
};
+static void photos_application_search_context_iface_init (PhotosSearchContextInterface *iface);
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosApplication, photos_application, GTK_TYPE_APPLICATION)
+
+G_DEFINE_TYPE_WITH_CODE (PhotosApplication, photos_application, GTK_TYPE_APPLICATION,
+ G_ADD_PRIVATE (PhotosApplication)
+ G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_SEARCH_CONTEXT,
+ photos_application_search_context_iface_init));
enum
@@ -232,6 +237,7 @@ photos_application_activate_result (PhotosApplication *self,
job = photos_single_item_job_new (identifier);
photos_single_item_job_run (job,
+ priv->state,
PHOTOS_QUERY_FLAGS_UNFILTERED,
photos_application_activate_query_executed,
g_object_ref (self));
@@ -260,6 +266,14 @@ photos_application_fullscreen (PhotosApplication *self, GVariant *parameter)
}
+static PhotosSearchContextState *
+photos_application_get_state (PhotosSearchContext *context)
+{
+ PhotosApplication *self = PHOTOS_APPLICATION (context);
+ return self->priv->state;
+}
+
+
static void
photos_application_init_app_menu (PhotosApplication *self)
{
@@ -286,7 +300,7 @@ photos_application_launch_search (PhotosApplication *self, const gchar* const *t
photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_OVERVIEW);
str = g_strjoinv (" ", (gchar **) terms);
- photos_search_controller_set_string (priv->srch_cntrlr, str);
+ photos_search_controller_set_string (priv->state->srch_cntrlr, str);
g_free (str);
state = g_variant_new ("b", TRUE);
@@ -414,10 +428,10 @@ photos_application_refresh_miners (PhotosApplication *self)
{
PhotosApplicationPrivate *priv = self->priv;
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->src_mngr), "facebook"))
+ if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr), "facebook"))
photos_application_refresh_miner_now (self, priv->facebook_miner);
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->src_mngr), "flickr"))
+ if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr), "flickr"))
photos_application_refresh_miner_now (self, priv->flickr_miner);
}
@@ -501,12 +515,12 @@ photos_application_start_miners (PhotosApplication *self)
photos_application_refresh_miners (self);
- g_signal_connect_object (priv->src_mngr,
+ g_signal_connect_object (priv->state->src_mngr,
"object-added",
G_CALLBACK (photos_application_refresh_miners),
self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (priv->src_mngr,
+ g_signal_connect_object (priv->state->src_mngr,
"object-removed",
G_CALLBACK (photos_application_refresh_miners),
self,
@@ -662,7 +676,6 @@ photos_application_startup (GApplication *application)
NULL);
priv->item_mngr = photos_item_manager_dup_singleton ();
- priv->src_mngr = photos_source_manager_dup_singleton ();
/* A dummy reference to keep it alive during the lifetime of the
* application.
@@ -670,7 +683,6 @@ photos_application_startup (GApplication *application)
priv->camera_cache = photos_camera_cache_dup_singleton ();
priv->mode_cntrlr = photos_mode_controller_dup_singleton ();
- priv->srch_cntrlr = photos_search_controller_dup_singleton ();
action = g_simple_action_new ("about", NULL);
g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_application_about), self);
@@ -787,12 +799,16 @@ photos_application_dispose (GObject *object)
g_clear_object (&priv->facebook_miner);
g_clear_object (&priv->flickr_miner);
g_clear_object (&priv->item_mngr);
- g_clear_object (&priv->src_mngr);
g_clear_object (&priv->camera_cache);
g_clear_object (&priv->mode_cntrlr);
- g_clear_object (&priv->srch_cntrlr);
g_clear_object (&priv->search_provider);
+ if (priv->state != NULL)
+ {
+ photos_search_context_state_free (priv->state);
+ priv->state = NULL;
+ }
+
G_OBJECT_CLASS (photos_application_parent_class)->dispose (object);
}
@@ -817,6 +833,7 @@ photos_application_init (PhotosApplication *self)
G_CALLBACK (photos_application_launch_search),
self);
+ priv->state = photos_search_context_state_new (PHOTOS_SEARCH_CONTEXT (self));
priv->activation_timestamp = GDK_CURRENT_TIME;
}
@@ -838,6 +855,13 @@ photos_application_class_init (PhotosApplicationClass *class)
}
+static void
+photos_application_search_context_iface_init (PhotosSearchContextInterface *iface)
+{
+ iface->get_state = photos_application_get_state;
+}
+
+
GtkApplication *
photos_application_new (void)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]