[gnome-photos/wip/rishi/flowbox: 4/4] Port to GdMainBox
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/flowbox: 4/4] Port to GdMainBox
- Date: Wed, 21 Dec 2016 08:35:52 +0000 (UTC)
commit 0f3308f0b8967c3a1a0c7a030782571047570548
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Dec 7 11:46:37 2016 +0100
Port to GdMainBox
https://bugzilla.gnome.org/show_bug.cgi?id=690623
configure.ac | 1 -
src/Makefile.am | 2 -
src/photos-utils.c | 16 +-
src/photos-utils.h | 2 +-
src/photos-view-container.c | 105 +++++-----
src/photos-view-model.c | 463 -------------------------------------------
src/photos-view-model.h | 58 ------
7 files changed, 60 insertions(+), 587 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3f08ff7..8af5b14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,7 +112,6 @@ LIBGD_INIT([
gtk-hacks
main-box
main-icon-view
- main-view
static
tagged-entry
])
diff --git a/src/Makefile.am b/src/Makefile.am
index 5aba849..6ddd49d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -254,8 +254,6 @@ gnome_photos_SOURCES = \
photos-utils.h \
photos-view-container.c \
photos-view-container.h \
- photos-view-model.c \
- photos-view-model.h \
photos-widget-shader.c \
photos-widget-shader.h \
photos-main.c \
diff --git a/src/photos-utils.c b/src/photos-utils.c
index bf8c0b9..58e6535 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1275,22 +1275,18 @@ photos_utils_get_thumbnail_frame_border (void)
GList *
-photos_utils_get_urns_from_paths (GList *paths, GtkTreeModel *model)
+photos_utils_get_urns_from_items (GList *items)
{
GList *l;
GList *urns = NULL;
- for (l = paths; l != NULL; l = l->next)
+ for (l = items; l != NULL; l = l->next)
{
- GtkTreeIter iter;
- GtkTreePath *path = (GtkTreePath *) l->data;
- gchar *id;
+ GdMainBoxItem *box_item = GD_MAIN_BOX_ITEM (l->data);
+ const gchar *id;
- if (!gtk_tree_model_get_iter (model, &iter, path))
- continue;
-
- gtk_tree_model_get (model, &iter, GD_MAIN_COLUMN_ID, &id, -1);
- urns = g_list_prepend (urns, id);
+ id = gd_main_box_item_get_id (box_item);
+ urns = g_list_prepend (urns, g_strdup (id));
}
return g_list_reverse (urns);
diff --git a/src/photos-utils.h b/src/photos-utils.h
index f161e17..769248d 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -159,7 +159,7 @@ const gchar *photos_utils_get_provider_name (PhotosBaseManager *sr
GtkBorder *photos_utils_get_thumbnail_frame_border (void);
-GList *photos_utils_get_urns_from_paths (GList *paths, GtkTreeModel *model);
+GList *photos_utils_get_urns_from_items (GList *items);
GIcon *photos_utils_icon_from_rdf_type (const gchar *type);
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index e1993e2..523ceba 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -44,16 +44,15 @@
#include "photos-tracker-search-controller.h"
#include "photos-utils.h"
#include "photos-view-container.h"
-#include "photos-view-model.h"
struct _PhotosViewContainer
{
GtkStack parent_instance;
- GdMainView *view;
- GtkListStore *model;
GtkWidget *error_box;
GtkWidget *no_results;
+ GtkWidget *sw;
+ GtkWidget *view;
PhotosBaseManager *item_mngr;
PhotosModeController *mode_cntrlr;
PhotosOffsetController *offset_cntrlr;
@@ -87,7 +86,7 @@ photos_view_container_edge_reached (PhotosViewContainer *self, GtkPositionType p
static void
photos_view_container_connect_view (PhotosViewContainer *self)
{
- g_signal_connect_swapped (self->view, "edge-reached", G_CALLBACK (photos_view_container_edge_reached),
self);
+ g_signal_connect_swapped (self->sw, "edge-reached", G_CALLBACK (photos_view_container_edge_reached), self);
}
@@ -104,22 +103,25 @@ photos_view_container_count_changed (PhotosViewContainer *self, gint count)
static void
photos_view_container_disconnect_view (PhotosViewContainer *self)
{
- g_signal_handlers_disconnect_by_func (self->view, photos_view_container_edge_reached, self);
+ g_signal_handlers_disconnect_by_func (self->sw, photos_view_container_edge_reached, self);
}
static void
-photos_view_container_item_activated (PhotosViewContainer *self, const gchar * id)
+photos_view_container_item_activated (PhotosViewContainer *self, GdMainBoxItem *box_item)
{
- GObject *object;
+ PhotosBaseItem *item;
+ const gchar *id;
- object = photos_base_manager_get_object_by_id (self->item_mngr, id);
+ id = gd_main_box_item_get_id (box_item);
+ item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (self->item_mngr, id));
+ g_return_if_fail ((gpointer) box_item == (gpointer) item);
- if (!photos_base_item_is_collection (PHOTOS_BASE_ITEM (object)) &&
+ if (!photos_base_item_is_collection (item) &&
photos_remote_display_manager_is_active (self->remote_mngr))
- photos_remote_display_manager_render (self->remote_mngr, PHOTOS_BASE_ITEM (object));
+ photos_remote_display_manager_render (self->remote_mngr, item);
else
- photos_base_manager_set_active_object (self->item_mngr, object);
+ photos_base_manager_set_active_object (self->item_mngr, G_OBJECT (item));
}
@@ -143,14 +145,17 @@ photos_view_container_query_status_changed (PhotosViewContainer *self, gboolean
{
if (!query_status)
{
- gd_main_view_set_model (self->view, GTK_TREE_MODEL (self->model));
+ PhotosBaseManager *item_mngr_chld;
+
+ item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->item_mngr), self->mode);
+ gd_main_box_set_model (GD_MAIN_BOX (self->view), G_LIST_MODEL (item_mngr_chld));
photos_selection_controller_freeze_selection (self->sel_cntrlr, FALSE);
/* TODO: update selection */
}
else
{
photos_selection_controller_freeze_selection (self->sel_cntrlr, TRUE);
- gd_main_view_set_model (self->view, NULL);
+ gd_main_box_set_model (GD_MAIN_BOX (self->view), NULL);
}
}
@@ -165,7 +170,7 @@ photos_view_container_select_all (PhotosViewContainer *self)
return;
photos_selection_controller_set_selection_mode (self->sel_cntrlr, TRUE);
- gd_main_view_select_all (self->view);
+ gd_main_box_select_all (GD_MAIN_BOX (self->view));
}
@@ -178,7 +183,7 @@ photos_view_container_select_none (PhotosViewContainer *self)
if (self->mode != mode)
return;
- gd_main_view_unselect_all (self->view);
+ gd_main_box_unselect_all (GD_MAIN_BOX (self->view));
}
@@ -190,30 +195,30 @@ photos_view_container_selection_mode_request (PhotosViewContainer *self)
static void
-photos_view_container_set_selection_mode (PhotosViewContainer *self, gboolean selection_mode)
+photos_view_container_selection_changed (PhotosViewContainer *self)
{
- PhotosWindowMode window_mode;
+ GList *selected_urns;
+ GList *selection;
- window_mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
- if (self->mode != window_mode)
- return;
+ selection = gd_main_box_get_selection (GD_MAIN_BOX (self->view));
+ selected_urns = photos_utils_get_urns_from_items (selection);
+ photos_selection_controller_set_selection (self->sel_cntrlr, selected_urns);
- gd_main_view_set_selection_mode (self->view, selection_mode);
+ g_list_free_full (selected_urns, g_free);
+ g_list_free_full (selection, g_object_unref);
}
static void
-photos_view_container_view_selection_changed (PhotosViewContainer *self)
+photos_view_container_set_selection_mode (PhotosViewContainer *self, gboolean selection_mode)
{
- GList *selected_urns;
- GList *selection;
+ PhotosWindowMode window_mode;
- selection = gd_main_view_get_selection (self->view);
- selected_urns = photos_utils_get_urns_from_paths (selection, GTK_TREE_MODEL (self->model));
- photos_selection_controller_set_selection (self->sel_cntrlr, selected_urns);
+ window_mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
+ if (self->mode != window_mode)
+ return;
- g_list_free_full (selected_urns, g_free);
- g_list_free_full (selection, (GDestroyNotify) gtk_tree_path_free);
+ gd_main_box_set_selection_mode (GD_MAIN_BOX (self->view), selection_mode);
}
@@ -239,12 +244,11 @@ photos_view_container_constructed (GObject *object)
AtkObject *accessible;
GAction *action;
GApplication *app;
- GtkWidget *generic_view;
+ GtkStyleContext *context;
GtkWidget *grid;
PhotosSearchContextState *state;
gboolean selection_mode;
gboolean status;
- gint size;
G_OBJECT_CLASS (photos_view_container_parent_class)->constructed (object);
@@ -255,8 +259,6 @@ photos_view_container_constructed (GObject *object)
if (accessible != NULL)
atk_object_set_name (accessible, self->name);
- self->model = photos_view_model_new (self->mode);
-
grid = gtk_grid_new ();
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
gtk_stack_add_named (GTK_STACK (self), grid, "view");
@@ -267,11 +269,17 @@ photos_view_container_constructed (GObject *object)
self->error_box = photos_error_box_new ();
gtk_stack_add_named (GTK_STACK (self), self->error_box, "error");
- self->view = gd_main_view_new (GD_MAIN_VIEW_ICON);
- generic_view = gd_main_view_get_generic_view (self->view);
- size = photos_utils_get_icon_size_unscaled ();
- gtk_icon_view_set_item_width (GTK_ICON_VIEW (generic_view), size + 24);
- gtk_container_add (GTK_CONTAINER (grid), GTK_WIDGET (self->view));
+ self->sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_hexpand (self->sw, TRUE);
+ gtk_widget_set_vexpand (self->sw, TRUE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (self->sw), GTK_SHADOW_IN);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self->sw));
+ gtk_style_context_add_class (context, "documents-scrolledwin");
+ gtk_container_add (GTK_CONTAINER (grid), self->sw);
+
+ self->view = gd_main_box_new (GD_MAIN_BOX_ICON);
+ gtk_container_add (GTK_CONTAINER (self->sw), self->view);
gtk_widget_show_all (GTK_WIDGET (self));
@@ -283,8 +291,8 @@ photos_view_container_constructed (GObject *object)
G_CALLBACK (photos_view_container_selection_mode_request),
self);
g_signal_connect_swapped (self->view,
- "view-selection-changed",
- G_CALLBACK (photos_view_container_view_selection_changed),
+ "selection-changed",
+ G_CALLBACK (photos_view_container_selection_changed),
self);
self->item_mngr = g_object_ref (state->item_mngr);
@@ -387,7 +395,6 @@ photos_view_container_dispose (GObject *object)
self->disposed = TRUE;
}
- g_clear_object (&self->model);
g_clear_object (&self->item_mngr);
g_clear_object (&self->mode_cntrlr);
g_clear_object (&self->offset_cntrlr);
@@ -501,18 +508,12 @@ photos_view_container_new (PhotosWindowMode mode, const gchar *name)
void
photos_view_container_activate_result (PhotosViewContainer *self)
{
- GtkTreeIter iter;
+ PhotosBaseItem *item;
+ PhotosBaseManager *item_mngr_chld;
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->model), &iter))
- {
- GtkTreePath *path;
- GtkWidget *generic_view;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->model), &iter);
- generic_view = gd_main_view_get_generic_view (self->view);
- gtk_icon_view_item_activated (GTK_ICON_VIEW (generic_view), path);
- gtk_tree_path_free (path);
- }
+ item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->item_mngr), self->mode);
+ item = PHOTOS_BASE_ITEM (g_list_model_get_object (G_LIST_MODEL (item_mngr_chld), 0));
+ photos_base_manager_set_active_object (self->item_mngr, G_OBJECT (item));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]