[gnome-photos/wip/rishi/flowbox: 3/3] Port to GdMainBox
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/flowbox: 3/3] Port to GdMainBox
- Date: Sun, 11 Dec 2016 14:54:39 +0000 (UTC)
commit 0895cb271f247e6e24254ecbf2a7e9f595815e8d
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/photos-utils.c | 16 +++----
src/photos-utils.h | 2 +-
src/photos-view-container.c | 100 +++++++++++++++++++++++--------------------
4 files changed, 60 insertions(+), 59 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 226d73b..8f16d52 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/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..3d56579 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -50,10 +50,11 @@
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 +88,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 +105,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 +147,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 +172,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 +185,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 +197,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 +246,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);
@@ -267,11 +273,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 +295,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);
@@ -501,18 +513,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]