[gnome-photos/wip/flowbox: 2/2] Try to use a GtkFlowBox
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/flowbox: 2/2] Try to use a GtkFlowBox
- Date: Mon, 21 Oct 2013 14:45:12 +0000 (UTC)
commit 7b749d16a604bd7f21df328b14f7a3ef14e158ff
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Oct 18 18:33:14 2013 +0200
Try to use a GtkFlowBox
configure.ac | 2 +-
src/Makefile.am | 2 +
src/photos-base-item.c | 2 -
src/photos-flow-box.c | 419 +++++++++++++++++++++++++++++++++++++++++++
src/photos-flow-box.h | 73 ++++++++
src/photos-view-container.c | 131 ++++++++------
6 files changed, 566 insertions(+), 63 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2af074d..253b846 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ EXEMPI_MIN_VERSION=1.99.5
GLIB_MIN_VERSION=2.35.1
GOA_MIN_VERSION=3.8.0
GRILO_MIN_VERSION=0.2.6
-GTK_MIN_VERSION=3.9.11
+GTK_MIN_VERSION=3.11.0
LIBEXIF_MIN_VERSION=0.6.14
LIBRSVG_MIN_VERSION=2.26.0
diff --git a/src/Makefile.am b/src/Makefile.am
index 2cc64a3..4534fc3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,6 +98,8 @@ gnome_photos_SOURCES = \
photos-filterable.h \
photos-flickr-item.c \
photos-flickr-item.h \
+ photos-flow-box.c \
+ photos-flow-box.h \
photos-header-bar.c \
photos-header-bar.h \
photos-indexing-notification.c \
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 8f3a40a..b695a49 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -359,8 +359,6 @@ photos_base_item_download_in_thread_func (GTask *task,
static void
photos_base_item_icon_updated (PhotosBaseItem *self, GIcon *icon)
{
- PhotosBaseItemPrivate *priv = self->priv;
-
if (icon == NULL)
return;
diff --git a/src/photos-flow-box.c b/src/photos-flow-box.c
new file mode 100644
index 0000000..d12359f
--- /dev/null
+++ b/src/photos-flow-box.c
@@ -0,0 +1,419 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2013 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "photos-collection-manager.h"
+#include "photos-enums.h"
+#include "photos-flow-box.h"
+#include "photos-item-manager.h"
+#include "photos-view-model.h"
+
+
+struct _PhotosFlowBoxPrivate
+{
+ GtkTreeModel *model;
+ PhotosBaseManager *col_mngr;
+ PhotosBaseManager *item_mngr;
+ PhotosWindowMode mode;
+ gchar *is_present_key;
+};
+
+enum
+{
+ PROP_0,
+ PROP_MODE
+};
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (PhotosFlowBox, photos_flow_box, GTK_TYPE_FLOW_BOX);
+
+
+/* static gboolean */
+/* photos_flow_box_configure_event (GtkWidget *widget, GdkEventConfigure *event) */
+/* { */
+/* PhotosFlowBox *self = PHOTOS_FLOW_BOX (widget); */
+/* PhotosFlowBoxPrivate *priv = self->priv; */
+/* gboolean ret_val; */
+
+/* ret_val = GTK_WIDGET_CLASS (photos_flow_box_parent_class)->configure_event (widget, event); */
+
+/* if (photos_mode_controller_get_fullscreen (priv->controller)) */
+/* return ret_val; */
+
+/* if (priv->configure_id != 0) */
+/* { */
+/* g_source_remove (priv->configure_id); */
+/* priv->configure_id = 0; */
+/* } */
+
+/* priv->configure_id = g_timeout_add (CONFIGURE_ID_TIMEOUT, photos_flow_box_configure_id_timeout, self);
*/
+/* return ret_val; */
+/* } */
+
+
+/* static void */
+/* photos_flow_box_fullscreen_changed (PhotosModeController *controller, gboolean fullscreen, gpointer
user_data) */
+/* { */
+/* PhotosFlowBox *self = PHOTOS_FLOW_BOX (user_data); */
+
+/* if (fullscreen) */
+/* gtk_window_fullscreen (GTK_WINDOW (self)); */
+/* else */
+/* gtk_window_unfullscreen (GTK_WINDOW (self)); */
+/* } */
+
+
+/* static gboolean */
+/* photos_flow_box_handle_key_overview (PhotosFlowBox *self, GdkEventKey *event) */
+/* { */
+/* return GDK_EVENT_PROPAGATE; */
+/* } */
+
+
+/* static gboolean */
+/* photos_flow_box_handle_key_preview (PhotosFlowBox *self, GdkEventKey *event) */
+/* { */
+/* PhotosFlowBoxPrivate *priv = self->priv; */
+/* GtkTextDirection direction; */
+/* gboolean fullscreen; */
+
+/* direction = gtk_widget_get_direction (GTK_WIDGET (self)); */
+/* fullscreen = photos_mode_controller_get_fullscreen (priv->controller); */
+
+/* if ((fullscreen && event->keyval == GDK_KEY_Escape) */
+/* || ((event->state & GDK_MOD1_MASK) != 0 */
+/* && ((direction == GTK_TEXT_DIR_LTR && event->keyval == GDK_KEY_Left) */
+/* || (direction == GTK_TEXT_DIR_RTL && event->keyval == GDK_KEY_Right))) */
+/* || event->keyval == GDK_KEY_BackSpace */
+/* || event->keyval == GDK_KEY_Back) */
+/* { */
+/* photos_base_manager_set_active_object (priv->item_mngr, NULL); */
+/* return GDK_EVENT_STOP; */
+/* } */
+
+/* return GDK_EVENT_PROPAGATE; */
+/* } */
+
+
+/* static gboolean */
+/* photos_flow_box_key_press_event (GtkWidget *widget, GdkEventKey *event) */
+/* { */
+/* PhotosFlowBox *self = PHOTOS_FLOW_BOX (widget); */
+/* PhotosFlowBoxPrivate *priv = self->priv; */
+/* PhotosWindowMode mode; */
+/* gboolean handled; */
+
+/* mode = photos_mode_controller_get_window_mode (priv->controller); */
+/* if (mode == PHOTOS_WINDOW_MODE_PREVIEW) */
+/* handled = photos_flow_box_handle_key_preview (self, event); */
+/* else */
+/* handled = photos_flow_box_handle_key_overview (self, event); */
+
+/* if (!handled) */
+/* handled = GTK_WIDGET_CLASS (photos_flow_box_parent_class)->key_press_event (widget, event); */
+
+/* return handled; */
+/* } */
+
+
+static void
+photos_flow_box_add_item (PhotosFlowBox *self, PhotosBaseItem *item)
+{
+ GdkPixbuf *icon;
+ GtkWidget *child;
+ GtkWidget *image;
+
+ g_object_set_data (G_OBJECT (item), self->priv->is_present_key, GINT_TO_POINTER (TRUE));
+
+ child = gtk_flow_box_child_new ();
+ g_object_set_data_full (G_OBJECT (child), "item", g_object_ref (item), g_object_unref);
+ gtk_container_add (GTK_CONTAINER (self), child);
+
+ icon = photos_base_item_get_icon (item);
+ image = gtk_image_new_from_pixbuf (icon);
+ g_object_bind_property (item, "icon", image, "pixbuf", G_BINDING_DEFAULT);
+ gtk_container_add (GTK_CONTAINER (child), image);
+
+ gtk_widget_show_all (child);
+}
+
+
+static void
+photos_flow_box_remove_item (PhotosFlowBox *self, PhotosBaseItem *item)
+{
+ GList *children = NULL;
+ GList *l;
+
+ g_object_set_data (G_OBJECT (item), self->priv->is_present_key, NULL);
+
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ for (l = children; l != NULL; l = l->next)
+ {
+ GtkWidget *child = GTK_WIDGET (l->data);
+ GObject *object;
+
+ object = G_OBJECT (g_object_get_data (G_OBJECT (child), "item"));
+ if ((gpointer) object == (gpointer) item)
+ {
+ gtk_container_remove (GTK_CONTAINER (self), child);
+ break;
+ }
+ }
+
+ g_list_free (children);
+}
+
+
+static void
+photos_flow_box_clear (PhotosFlowBox *self)
+{
+ GList *children = NULL;
+ GList *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ for (l = children; l != NULL; l = l->next)
+ {
+ GtkWidget *child = GTK_WIDGET (l->data);
+ GObject *object;
+
+ object = G_OBJECT (g_object_get_data (G_OBJECT (child), "item"));
+ g_object_set_data (object, self->priv->is_present_key, NULL);
+ gtk_container_remove (GTK_CONTAINER (self), child);
+ }
+
+ g_list_free (children);
+}
+
+
+static void
+photos_flow_box_info_updated (PhotosBaseItem *item, gpointer user_data)
+{
+ PhotosFlowBox *self = PHOTOS_FLOW_BOX (user_data);
+ PhotosFlowBoxPrivate *priv = self->priv;
+ GObject *collection;
+ gboolean is_collection;
+ gboolean is_favorite;
+ gboolean is_present;
+
+ collection = photos_base_manager_get_active_object (priv->col_mngr);
+ is_collection = photos_base_item_is_collection (item);
+ is_favorite = photos_base_item_is_favorite (item);
+ is_present = (g_object_get_data (G_OBJECT (item), priv->is_present_key) != NULL);
+
+ if (priv->mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
+ {
+ if (!is_collection && is_present && collection == NULL)
+ photos_flow_box_remove_item (self, item);
+ else if (is_collection && !is_present)
+ photos_flow_box_add_item (self, item);
+ }
+ else if (priv->mode == PHOTOS_WINDOW_MODE_FAVORITES)
+ {
+ if (!is_favorite && is_present && collection == NULL)
+ photos_flow_box_remove_item (self, item);
+ else if (is_favorite && !is_present && collection == NULL)
+ photos_flow_box_add_item (self, item);
+ }
+ else if (priv->mode == PHOTOS_WINDOW_MODE_OVERVIEW)
+ {
+ if (is_collection && is_present)
+ photos_flow_box_remove_item (self, item);
+ else if (!is_collection && !is_present)
+ photos_flow_box_add_item (self, item);
+ }
+}
+
+
+static void
+photos_flow_box_object_added (PhotosFlowBox *self, GObject *object)
+{
+ PhotosBaseItem *item = PHOTOS_BASE_ITEM (object);
+ PhotosFlowBoxPrivate *priv = self->priv;
+ GObject *collection;
+ gboolean is_collection;
+ gboolean is_favorite;
+
+ collection = photos_base_manager_get_active_object (priv->col_mngr);
+ is_collection = photos_base_item_is_collection (item);
+ is_favorite = photos_base_item_is_favorite (item);
+
+ if (collection == NULL)
+ {
+ if ((priv->mode == PHOTOS_WINDOW_MODE_COLLECTIONS && !is_collection)
+ || (priv->mode == PHOTOS_WINDOW_MODE_FAVORITES && !is_favorite)
+ || (priv->mode == PHOTOS_WINDOW_MODE_OVERVIEW && is_collection))
+ goto out;
+ }
+
+ photos_flow_box_add_item (self, item);
+
+ out:
+ g_signal_connect (item, "info-updated", G_CALLBACK (photos_flow_box_info_updated), self);
+}
+
+
+static void
+photos_flow_box_object_removed (PhotosFlowBox *self, GObject *object)
+{
+ photos_flow_box_remove_item (self, PHOTOS_BASE_ITEM (object));
+}
+
+
+static gint
+photos_flow_box_sort_func (GtkFlowBoxChild *child1, GtkFlowBoxChild *child2, gpointer user_data)
+{
+ PhotosBaseItem *item;
+ gint64 mtime1;
+ gint64 mtime2;
+
+ item = PHOTOS_BASE_ITEM (g_object_get_data (G_OBJECT (child1), "item"));
+ mtime1 = photos_base_item_get_mtime (item);
+
+ item = PHOTOS_BASE_ITEM (g_object_get_data (G_OBJECT (child2), "item"));
+ mtime2 = photos_base_item_get_mtime (item);
+
+ return mtime2 - mtime1; /* descending order */
+}
+
+
+static void
+photos_flow_box_constructed (GObject *object)
+{
+ PhotosFlowBox *self = PHOTOS_FLOW_BOX (object);
+ GHashTable *items_hash;
+ GList *items;
+ GList *l;
+
+ G_OBJECT_CLASS (photos_flow_box_parent_class)->constructed (object);
+
+ items_hash = photos_base_manager_get_objects (self->priv->item_mngr);
+ items = g_hash_table_get_values (items_hash);
+ for (l = items; l != NULL; l = l->next)
+ {
+ GObject *object = G_OBJECT (l->data);
+ photos_flow_box_object_added (self, object);
+ }
+
+ g_list_free (items);
+}
+
+
+static void
+photos_flow_box_dispose (GObject *object)
+{
+ PhotosFlowBox *self = PHOTOS_FLOW_BOX (object);
+ PhotosFlowBoxPrivate *priv = self->priv;
+
+ g_clear_object (&priv->model);
+ g_clear_object (&priv->col_mngr);
+ g_clear_object (&priv->item_mngr);
+
+ G_OBJECT_CLASS (photos_flow_box_parent_class)->dispose (object);
+}
+
+
+static void
+photos_flow_box_finalize (GObject *object)
+{
+ PhotosFlowBox *self = PHOTOS_FLOW_BOX (object);
+
+ g_free (self->priv->is_present_key);
+
+ G_OBJECT_CLASS (photos_flow_box_parent_class)->finalize (object);
+}
+
+
+static void
+photos_flow_box_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ PhotosFlowBox *self = PHOTOS_FLOW_BOX (object);
+ PhotosFlowBoxPrivate *priv = self->priv;
+
+ switch (prop_id)
+ {
+ case PROP_MODE:
+ priv->mode = (PhotosWindowMode) g_value_get_enum (value);
+ priv->is_present_key = g_strdup_printf ("is-present-%d", priv->mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+static void
+photos_flow_box_init (PhotosFlowBox *self)
+{
+ PhotosFlowBoxPrivate *priv;
+
+ self->priv = photos_flow_box_get_instance_private (self);
+ priv = self->priv;
+
+ gtk_flow_box_set_sort_func (GTK_FLOW_BOX (self), photos_flow_box_sort_func, NULL, NULL);
+
+ priv->col_mngr = photos_collection_manager_dup_singleton ();
+
+ priv->item_mngr = photos_item_manager_dup_singleton ();
+ g_signal_connect_swapped (priv->item_mngr, "object-added", G_CALLBACK (photos_flow_box_object_added),
self);
+ g_signal_connect_swapped (priv->item_mngr, "object-removed", G_CALLBACK (photos_flow_box_object_removed),
self);
+ g_signal_connect_swapped (priv->item_mngr, "clear", G_CALLBACK (photos_flow_box_clear), self);
+}
+
+
+static void
+photos_flow_box_class_init (PhotosFlowBoxClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ object_class->constructed = photos_flow_box_constructed;
+ object_class->dispose = photos_flow_box_dispose;
+ object_class->finalize = photos_flow_box_finalize;
+ object_class->set_property = photos_flow_box_set_property;
+ /* widget_class->configure_event = photos_flow_box_configure_event; */
+ /* widget_class->delete_event = photos_flow_box_delete_event; */
+ /* widget_class->key_press_event = photos_flow_box_key_press_event; */
+
+ g_object_class_install_property (object_class,
+ PROP_MODE,
+ g_param_spec_enum ("mode",
+ "PhotosWindowMode enum",
+ "The mode for the flow box",
+ PHOTOS_TYPE_WINDOW_MODE,
+ PHOTOS_WINDOW_MODE_NONE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+}
+
+
+GtkWidget *
+photos_flow_box_new (PhotosWindowMode mode)
+{
+ return g_object_new (PHOTOS_TYPE_FLOW_BOX,
+ "homogeneous", TRUE,
+ "min-children-per-line", 2,
+ "mode", mode,
+ NULL);
+}
diff --git a/src/photos-flow-box.h b/src/photos-flow-box.h
new file mode 100644
index 0000000..f1e5d24
--- /dev/null
+++ b/src/photos-flow-box.h
@@ -0,0 +1,73 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2013 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_FLOW_BOX_H
+#define PHOTOS_FLOW_BOX_H
+
+#include <gtk/gtk.h>
+
+#include "photos-mode-controller.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_FLOW_BOX (photos_flow_box_get_type ())
+
+#define PHOTOS_FLOW_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PHOTOS_TYPE_FLOW_BOX, PhotosFlowBox))
+
+#define PHOTOS_FLOW_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PHOTOS_TYPE_FLOW_BOX, PhotosFlowBoxClass))
+
+#define PHOTOS_IS_FLOW_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ PHOTOS_TYPE_FLOW_BOX))
+
+#define PHOTOS_IS_FLOW_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ PHOTOS_TYPE_FLOW_BOX))
+
+#define PHOTOS_FLOW_BOX_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PHOTOS_TYPE_FLOW_BOX, PhotosFlowBoxClass))
+
+typedef struct _PhotosFlowBox PhotosFlowBox;
+typedef struct _PhotosFlowBoxClass PhotosFlowBoxClass;
+typedef struct _PhotosFlowBoxPrivate PhotosFlowBoxPrivate;
+
+struct _PhotosFlowBox
+{
+ GtkFlowBox parent_instance;
+ PhotosFlowBoxPrivate *priv;
+};
+
+struct _PhotosFlowBoxClass
+{
+ GtkFlowBoxClass parent_class;
+};
+
+GType photos_flow_box_get_type (void) G_GNUC_CONST;
+
+GtkWidget *photos_flow_box_new (PhotosWindowMode mode);
+
+G_END_DECLS
+
+#endif /* PHOTOS_FLOW_BOX_H */
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index c398c91..c79b6fe 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -24,10 +24,10 @@
#include "config.h"
-#include <libgd/gd.h>
#include "photos-application.h"
#include "photos-enums.h"
+#include "photos-flow-box.h"
#include "photos-item-manager.h"
#include "photos-load-more-button.h"
#include "photos-remote-display-manager.h"
@@ -42,10 +42,11 @@
struct _PhotosViewContainerPrivate
{
- GdMainView *view;
GtkListStore *model;
GtkTreePath *current_path;
GtkWidget *load_more;
+ GtkWidget *sw;
+ GtkWidget *view;
PhotosBaseManager *item_mngr;
PhotosModeController *mode_cntrlr;
PhotosRemoteDisplayManager *remote_mngr;
@@ -77,14 +78,14 @@ photos_view_container_view_changed (PhotosViewContainer *self)
gdouble value;
gint reveal_area_height = 32;
- vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->view));
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->sw));
if (vscrollbar == NULL || !gtk_widget_get_visible (GTK_WIDGET (vscrollbar)))
{
photos_load_more_button_set_block (PHOTOS_LOAD_MORE_BUTTON (priv->load_more), TRUE);
return;
}
- vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->view));
+ vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->sw));
page_size = gtk_adjustment_get_page_size (vadjustment);
upper = gtk_adjustment_get_upper (vadjustment);
value = gtk_adjustment_get_value (vadjustment);
@@ -106,7 +107,7 @@ photos_view_container_connect_view (PhotosViewContainer *self)
GtkAdjustment *vadjustment;
GtkWidget *vscrollbar;
- vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->view));
+ vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->sw));
g_signal_connect_object (vadjustment,
"changed",
G_CALLBACK (photos_view_container_view_changed),
@@ -118,7 +119,7 @@ photos_view_container_connect_view (PhotosViewContainer *self)
self,
G_CONNECT_SWAPPED);
- vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->view));
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->sw));
g_signal_connect_object (vscrollbar,
"notify::visible",
G_CALLBACK (photos_view_container_view_changed),
@@ -136,33 +137,33 @@ photos_view_container_disconnect_view (PhotosViewContainer *self)
GtkAdjustment *vadjustment;
GtkWidget *vscrollbar;
- vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->view));
- vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->view));
+ vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->sw));
+ vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->sw));
g_signal_handlers_disconnect_by_func (vadjustment, photos_view_container_view_changed, self);
g_signal_handlers_disconnect_by_func (vscrollbar, photos_view_container_view_changed, self);
}
-static void
-photos_view_container_item_activated (GdMainView *main_view,
- const gchar * id,
- const GtkTreePath *path,
- gpointer user_data)
-{
- PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data);
- PhotosViewContainerPrivate *priv = self->priv;
- GObject *object;
+/* static void */
+/* photos_view_container_item_activated (GdMainView *main_view, */
+/* const gchar * id, */
+/* const GtkTreePath *path, */
+/* gpointer user_data) */
+/* { */
+/* PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data); */
+/* PhotosViewContainerPrivate *priv = self->priv; */
+/* GObject *object; */
- priv->current_path = gtk_tree_path_copy (path);
- object = photos_base_manager_get_object_by_id (priv->item_mngr, id);
+/* priv->current_path = gtk_tree_path_copy (path); */
+/* object = photos_base_manager_get_object_by_id (priv->item_mngr, id); */
- if (!photos_base_item_is_collection (PHOTOS_BASE_ITEM (object)) &&
- photos_remote_display_manager_is_active (priv->remote_mngr))
- photos_remote_display_manager_render (priv->remote_mngr, PHOTOS_BASE_ITEM (object));
- else
- photos_base_manager_set_active_object (priv->item_mngr, object);
-}
+/* if (!photos_base_item_is_collection (PHOTOS_BASE_ITEM (object)) && */
+/* photos_remote_display_manager_is_active (priv->remote_mngr)) */
+/* photos_remote_display_manager_render (priv->remote_mngr, PHOTOS_BASE_ITEM (object)); */
+/* else */
+/* photos_base_manager_set_active_object (priv->item_mngr, object); */
+/* } */
static void
@@ -175,14 +176,14 @@ photos_view_container_query_status_changed (PhotosTrackerController *trk_cntrlr,
if (!query_status)
{
- gd_main_view_set_model (priv->view, GTK_TREE_MODEL (priv->model));
+ /* photos_flow_box_set_model (PHOTOS_FLOW_BOX (priv->view), GTK_TREE_MODEL (priv->model)); */
photos_selection_controller_freeze_selection (priv->sel_cntrlr, FALSE);
/* TODO: update selection */
}
else
{
photos_selection_controller_freeze_selection (priv->sel_cntrlr, TRUE);
- gd_main_view_set_model (priv->view, NULL);
+ /* photos_flow_box_set_model (PHOTOS_FLOW_BOX (priv->view), NULL); */
}
}
@@ -193,33 +194,33 @@ photos_view_container_selection_mode_changed (PhotosSelectionController *sel_cnt
gpointer user_data)
{
PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data);
- gd_main_view_set_selection_mode (self->priv->view, mode);
+ /* gd_main_view_set_selection_mode (self->priv->view, mode); */
}
-static void
-photos_view_container_selection_mode_request (GdMainView *main_view, gpointer user_data)
-{
- PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data);
- photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, TRUE);
-}
+/* static void */
+/* photos_view_container_selection_mode_request (GdMainView *main_view, gpointer user_data) */
+/* { */
+/* PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data); */
+/* photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, TRUE); */
+/* } */
-static void
-photos_view_container_view_selection_changed (GdMainView *main_view, gpointer user_data)
-{
- PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data);
- PhotosViewContainerPrivate *priv = self->priv;
- GList *selected_urns;
- GList *selection;
+/* static void */
+/* photos_view_container_view_selection_changed (GdMainView *main_view, gpointer user_data) */
+/* { */
+/* PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (user_data); */
+/* PhotosViewContainerPrivate *priv = self->priv; */
+/* GList *selected_urns; */
+/* GList *selection; */
- selection = gd_main_view_get_selection (main_view);
- selected_urns = photos_utils_get_urns_from_paths (selection, GTK_TREE_MODEL (priv->model));
- photos_selection_controller_set_selection (priv->sel_cntrlr, selected_urns);
+/* selection = gd_main_view_get_selection (main_view); */
+/* selected_urns = photos_utils_get_urns_from_paths (selection, GTK_TREE_MODEL (priv->model)); */
+/* photos_selection_controller_set_selection (priv->sel_cntrlr, selected_urns); */
- if (selection != NULL)
- g_list_free_full (selection, (GDestroyNotify) gtk_tree_path_free);
-}
+/* if (selection != NULL) */
+/* g_list_free_full (selection, (GDestroyNotify) gtk_tree_path_free); */
+/* } */
static void
@@ -246,6 +247,7 @@ photos_view_container_constructed (GObject *object)
PhotosViewContainerPrivate *priv = self->priv;
GAction *action;
GtkApplication *app;
+ GtkStyleContext *context;
gboolean status;
G_OBJECT_CLASS (photos_view_container_parent_class)->constructed (object);
@@ -254,23 +256,32 @@ photos_view_container_constructed (GObject *object)
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
- priv->view = gd_main_view_new (GD_MAIN_VIEW_ICON);
- gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->view));
+ priv->sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_hexpand (priv->sw, TRUE);
+ gtk_widget_set_vexpand (priv->sw, TRUE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->sw), GTK_SHADOW_IN);
+ context = gtk_widget_get_style_context (priv->sw);
+ gtk_style_context_add_class (context, "documents-scrolledwin");
+ gtk_container_add (GTK_CONTAINER (self), priv->sw);
+
+ priv->view = photos_flow_box_new (priv->mode);
+ gtk_container_add (GTK_CONTAINER (priv->sw), priv->view);
priv->load_more = photos_load_more_button_new (priv->mode);
gtk_container_add (GTK_CONTAINER (self), priv->load_more);
gtk_widget_show_all (GTK_WIDGET (self));
- g_signal_connect (priv->view, "item-activated", G_CALLBACK (photos_view_container_item_activated), self);
- g_signal_connect (priv->view,
- "selection-mode-request",
- G_CALLBACK (photos_view_container_selection_mode_request),
- self);
- g_signal_connect (priv->view,
- "view-selection-changed",
- G_CALLBACK (photos_view_container_view_selection_changed),
- self);
+ /* g_signal_connect (priv->view, "item-activated", G_CALLBACK (photos_view_container_item_activated),
self); */
+ /* g_signal_connect (priv->view, */
+ /* "selection-mode-request", */
+ /* G_CALLBACK (photos_view_container_selection_mode_request), */
+ /* self); */
+ /* g_signal_connect (priv->view, */
+ /* "view-selection-changed", */
+ /* G_CALLBACK (photos_view_container_view_selection_changed), */
+ /* self); */
priv->item_mngr = photos_item_manager_dup_singleton ();
@@ -313,10 +324,10 @@ photos_view_container_constructed (GObject *object)
app = photos_application_new ();
action = g_action_map_lookup_action (G_ACTION_MAP (app), "select-all");
- g_signal_connect_swapped (action, "activate", G_CALLBACK (gd_main_view_select_all), priv->view);
+ g_signal_connect_swapped (action, "activate", G_CALLBACK (gtk_flow_box_select_all), priv->view);
action = g_action_map_lookup_action (G_ACTION_MAP (app), "select-none");
- g_signal_connect_swapped (action, "activate", G_CALLBACK (gd_main_view_unselect_all), priv->view);
+ g_signal_connect_swapped (action, "activate", G_CALLBACK (gtk_flow_box_unselect_all), priv->view);
g_object_unref (app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]