[gnome-photos/wip/search: 14/15] main-toolbar: Use PhotosOverviewSearchbar
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/search: 14/15] main-toolbar: Use PhotosOverviewSearchbar
- Date: Thu, 23 Jan 2014 09:43:57 +0000 (UTC)
commit 0b348fed3c03ab61d8741fed354084af25fd0d4c
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 21 11:24:07 2014 +0100
main-toolbar: Use PhotosOverviewSearchbar
src/photos-embed.c | 2 +-
src/photos-main-toolbar.c | 86 ++++++++++++++++++++++++++++++++++++++++++---
src/photos-main-toolbar.h | 4 +-
3 files changed, 84 insertions(+), 8 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index e9ff756..e159573 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -492,7 +492,7 @@ photos_embed_init (PhotosEmbed *self)
gtk_widget_show (priv->stack);
gtk_container_add (GTK_CONTAINER (priv->stack_overlay), priv->stack);
- priv->toolbar = photos_main_toolbar_new ();
+ priv->toolbar = photos_main_toolbar_new (GTK_OVERLAY (priv->stack_overlay));
photos_main_toolbar_set_stack (PHOTOS_MAIN_TOOLBAR (priv->toolbar), GTK_STACK (priv->stack));
priv->ntfctn_mngr = g_object_ref_sink (photos_notification_manager_dup_singleton ());
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index c0c86a8..3fb4ee0 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -33,10 +33,12 @@
#include "photos-application.h"
#include "photos-collection-manager.h"
#include "photos-dlna-renderers-manager.h"
+#include "photos-dropdown.h"
#include "photos-header-bar.h"
#include "photos-item-manager.h"
#include "photos-main-toolbar.h"
#include "photos-mode-controller.h"
+#include "photos-overview-searchbar.h"
#include "photos-remote-display-manager.h"
#include "photos-selection-controller.h"
#include "photos-source-manager.h"
@@ -46,7 +48,9 @@ struct _PhotosMainToolbarPrivate
{
GSimpleAction *gear_menu;
GtkWidget *coll_back_button;
+ GtkWidget *overlay;
GtkWidget *remote_display_button;
+ GtkWidget *searchbar;
GtkWidget *selection_menu;
GtkWidget *toolbar;
PhotosBaseManager *col_mngr;
@@ -58,6 +62,12 @@ struct _PhotosMainToolbarPrivate
PhotosWindowMode old_mode;
};
+enum
+{
+ PROP_0,
+ PROP_OVERLAY
+};
+
G_DEFINE_TYPE_WITH_PRIVATE (PhotosMainToolbar, photos_main_toolbar, GTK_TYPE_BOX);
@@ -309,6 +319,12 @@ photos_main_toolbar_clear_state_data (PhotosMainToolbar *self)
priv->remote_display_button = NULL;
}
+ if (priv->searchbar != NULL)
+ {
+ gtk_widget_destroy (priv->searchbar);
+ priv->searchbar = NULL;
+ }
+
if (priv->col_mngr != NULL)
g_signal_handlers_disconnect_by_func (priv->col_mngr, photos_main_toolbar_col_active_changed, self);
@@ -332,6 +348,20 @@ photos_main_toolbar_clear_toolbar (PhotosMainToolbar *self)
}
+static GtkWidget *
+photos_main_toolbar_create_overview_searchbar (PhotosMainToolbar *self)
+{
+ GtkWidget *dropdown;
+ GtkWidget *searchbar;
+
+ dropdown = photos_dropdown_new ();
+ gtk_overlay_add_overlay (GTK_OVERLAY (self->priv->overlay), dropdown);
+ searchbar = photos_overview_searchbar_new (PHOTOS_DROPDOWN (dropdown));
+
+ return searchbar;
+}
+
+
static GMenu *
photos_main_toolbar_create_preview_menu (PhotosMainToolbar *self)
{
@@ -386,6 +416,9 @@ photos_main_toolbar_populate_for_collections (PhotosMainToolbar *self)
photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_NORMAL);
photos_main_toolbar_add_selection_button (self);
+ priv->searchbar = photos_main_toolbar_create_overview_searchbar (self);
+ gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
+
object = photos_base_manager_get_active_object (priv->col_mngr);
photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
}
@@ -419,6 +452,9 @@ photos_main_toolbar_populate_for_favorites (PhotosMainToolbar *self)
photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_NORMAL);
photos_main_toolbar_add_selection_button (self);
+ priv->searchbar = photos_main_toolbar_create_overview_searchbar (self);
+ gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
+
object = photos_base_manager_get_active_object (priv->col_mngr);
photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
}
@@ -434,6 +470,9 @@ photos_main_toolbar_populate_for_overview (PhotosMainToolbar *self)
photos_header_bar_set_mode (PHOTOS_HEADER_BAR (priv->toolbar), PHOTOS_HEADER_BAR_MODE_NORMAL);
photos_main_toolbar_add_selection_button (self);
+ priv->searchbar = photos_main_toolbar_create_overview_searchbar (self);
+ gtk_container_add (GTK_CONTAINER (self), priv->searchbar);
+
object = photos_base_manager_get_active_object (priv->col_mngr);
photos_main_toolbar_col_active_changed (priv->col_mngr, object, self);
}
@@ -536,6 +575,17 @@ photos_main_toolbar_window_mode_changed (PhotosMainToolbar *self, PhotosWindowMo
static void
+photos_main_toolbar_constructed (GObject *object)
+{
+ PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (object);
+
+ G_OBJECT_CLASS (photos_main_toolbar_parent_class)->constructed (object);
+
+ photos_main_toolbar_reset_toolbar_mode (self);
+}
+
+
+static void
photos_main_toolbar_dispose (GObject *object)
{
PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (object);
@@ -555,6 +605,24 @@ photos_main_toolbar_dispose (GObject *object)
static void
+photos_main_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_OVERLAY:
+ self->priv->overlay = GTK_WIDGET (g_value_dup_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
photos_main_toolbar_share_changed_cb (PhotosMainToolbar *self,
PhotosDlnaRenderer *renderer,
PhotosBaseItem *item,
@@ -652,8 +720,6 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
G_CALLBACK (photos_main_toolbar_share_error_cb),
self,
G_CONNECT_SWAPPED);
-
- photos_main_toolbar_reset_toolbar_mode (self);
}
@@ -662,14 +728,24 @@ photos_main_toolbar_class_init (PhotosMainToolbarClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ object_class->constructed = photos_main_toolbar_constructed;
object_class->dispose = photos_main_toolbar_dispose;
+ object_class->set_property = photos_main_toolbar_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_OVERLAY,
+ g_param_spec_object ("overlay",
+ "GtkOverlay object",
+ "The stack overlay widget",
+ GTK_TYPE_OVERLAY,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
}
GtkWidget *
-photos_main_toolbar_new (void)
+photos_main_toolbar_new (GtkOverlay *overlay)
{
- return g_object_new (PHOTOS_TYPE_MAIN_TOOLBAR, NULL);
+ return g_object_new (PHOTOS_TYPE_MAIN_TOOLBAR, "overlay", overlay, NULL);
}
diff --git a/src/photos-main-toolbar.h b/src/photos-main-toolbar.h
index f563c3f..d64ed78 100644
--- a/src/photos-main-toolbar.h
+++ b/src/photos-main-toolbar.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -68,7 +68,7 @@ struct _PhotosMainToolbarClass
GType photos_main_toolbar_get_type (void) G_GNUC_CONST;
-GtkWidget *photos_main_toolbar_new (void);
+GtkWidget *photos_main_toolbar_new (GtkOverlay *overlay);
void photos_main_toolbar_set_stack (PhotosMainToolbar *self, GtkStack *stack);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]