[nautilus/wip/csoriano/flow] f
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/flow] f
- Date: Wed, 11 Jan 2017 17:12:25 +0000 (UTC)
commit 7cb5d77d258f9ba95825a7db41eaa43809ef2a40
Author: Carlos Soriano <csoriano gnome org>
Date: Wed Jan 11 18:12:03 2017 +0100
f
src/nautilus-view-icon-controller.c | 12 +++++++---
src/nautilus-view-icon-controller.h | 3 +-
src/nautilus-view-icon-ui.c | 38 +++++++++++++++++++++++++++++-----
src/nautilus-view-model.c | 25 ++++++++++++++++++----
4 files changed, 62 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index d5d23ce..d9b8051 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -336,11 +336,15 @@ real_set_selection (NautilusFilesView *files_view,
NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
g_autoptr (GQueue) selection_files;
g_autoptr (GQueue) selection_item_models;
+ g_autoptr (GQueue) dummy_empty_queue;
- g_print ("TYPE %s\n", G_OBJECT_TYPE_NAME (selection->data));
+ g_print ("List length %d\n", g_list_length (selection));
selection_files = convert_glist_to_queue (selection);
selection_item_models = nautilus_view_model_get_item_models_from_files (self->model, selection_files);
- nautilus_view_model_set_selected (self->model, NULL);
+ dummy_empty_queue = g_queue_new ();
+ g_print ("~~~~~~~~~~~~~selection set to null\n");
+ nautilus_view_model_set_selected (self->model, dummy_empty_queue);
+ g_print ("######### selection set to something\n");
nautilus_view_model_set_selected (self->model, selection_item_models);
nautilus_files_view_notify_selection_changed (files_view);
}
@@ -788,10 +792,10 @@ nautilus_view_icon_controller_new (NautilusWindowSlot *slot)
NULL);
}
-GListStore *
+NautilusViewModel *
nautilus_view_icon_controller_get_model (NautilusViewIconController *self)
{
g_return_val_if_fail (NAUTILUS_IS_VIEW_ICON_CONTROLLER (self), NULL);
- return nautilus_view_model_get_g_model (self->model);
+ return self->model;
}
diff --git a/src/nautilus-view-icon-controller.h b/src/nautilus-view-icon-controller.h
index 9a9f23d..814d6d6 100644
--- a/src/nautilus-view-icon-controller.h
+++ b/src/nautilus-view-icon-controller.h
@@ -6,6 +6,7 @@
#include "nautilus-files-view.h"
#include "nautilus-window-slot.h"
+#include "nautilus-view-model.h"
G_BEGIN_DECLS
@@ -15,7 +16,7 @@ G_DECLARE_FINAL_TYPE (NautilusViewIconController, nautilus_view_icon_controller,
NautilusViewIconController *nautilus_view_icon_controller_new (NautilusWindowSlot *slot);
-GListStore * nautilus_view_icon_controller_get_model (NautilusViewIconController *self);
+NautilusViewModel * nautilus_view_icon_controller_get_model (NautilusViewIconController *self);
G_END_DECLS
diff --git a/src/nautilus-view-icon-ui.c b/src/nautilus-view-icon-ui.c
index 5fff957..8d46093 100644
--- a/src/nautilus-view-icon-ui.c
+++ b/src/nautilus-view-icon-ui.c
@@ -102,13 +102,22 @@ on_view_item_model_selected_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
- NautilusViewIconItemUi *self = NAUTILUS_VIEW_ICON_ITEM_UI (user_data);
+ NautilusViewIconUi *self;
NautilusViewItemModel *item_model;
GtkFlowBoxChild *item_ui;
+ self = NAUTILUS_VIEW_ICON_UI (user_data);
item_model = NAUTILUS_VIEW_ITEM_MODEL (object);
item_ui = GTK_FLOW_BOX_CHILD (nautilus_view_item_model_get_item_ui (item_model));
- gtk_flow_box_select_child (GTK_FLOW_BOX (self), item_ui);
+ g_print ("selected? %s %d %d", nautilus_file_get_uri (nautilus_view_item_model_get_file (item_model)),
nautilus_view_item_model_get_is_selected (item_model), gtk_flow_box_child_is_selected (item_ui));
+ if (nautilus_view_item_model_get_is_selected (item_model) && !gtk_flow_box_child_is_selected (item_ui))
+ {
+ gtk_flow_box_select_child (GTK_FLOW_BOX (self), item_ui);
+ }
+ else if (gtk_flow_box_child_is_selected (item_ui))
+ {
+ gtk_flow_box_unselect_child (GTK_FLOW_BOX (self), item_ui);
+ }
}
@@ -152,11 +161,26 @@ on_ui_selected_children_changed (GtkFlowBox *box,
gpointer user_data)
{
NautilusViewIconUi *self;
+ GList *selected_children_ui;
+ GList *l;
+ GList *files_selection;
self = NAUTILUS_VIEW_ICON_UI (user_data);
+ files_selection = NULL;
+
+ selected_children_ui = gtk_flow_box_get_selected_children (GTK_FLOW_BOX (self));
+ for (l = selected_children_ui; l != NULL; l = l->next)
+ {
+ NautilusViewItemModel *item_model;
+ NautilusFile *file;
+
+ item_model = nautilus_view_icon_item_ui_get_model (NAUTILUS_VIEW_ICON_ITEM_UI (l->data));
+ file = nautilus_view_item_model_get_file (item_model);
+ files_selection = g_list_prepend (files_selection, file);
+ }
- nautilus_view_set_selection (NAUTILUS_VIEW (self->controller),
- gtk_flow_box_get_selected_children (GTK_FLOW_BOX (self)));
+ g_print ("changed\n");
+ nautilus_view_set_selection (NAUTILUS_VIEW (self->controller), files_selection);
}
static void
@@ -169,7 +193,8 @@ static void
constructed (GObject *object)
{
NautilusViewIconUi *self = NAUTILUS_VIEW_ICON_UI (object);
- GListStore *model;
+ NautilusViewModel *model;
+ GListStore *gmodel;
G_OBJECT_CLASS (nautilus_view_icon_ui_parent_class)->constructed (object);
@@ -186,8 +211,9 @@ constructed (GObject *object)
gtk_widget_set_margin_end (GTK_WIDGET (self), 10);
model = nautilus_view_icon_controller_get_model (self->controller);
+ gmodel = nautilus_view_model_get_g_model (model);
gtk_flow_box_bind_model (GTK_FLOW_BOX (self),
- G_LIST_MODEL (model),
+ G_LIST_MODEL (gmodel),
create_widget_func, self, NULL);
g_signal_connect (self, "child-activated", (GCallback) on_child_activated, self);
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 15a75ff..e6df9a9 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -164,6 +164,7 @@ nautilus_view_model_get_item_models_from_files (NautilusViewModel *self,
NautilusFile *file1;
gint i = 0;
+ g_print ("Type %s\n", G_OBJECT_TYPE_NAME (l->data));
file1 = NAUTILUS_FILE (l->data);
while ((item_model = g_list_model_get_item (G_LIST_MODEL(self->internal_model), i)))
{
@@ -192,13 +193,27 @@ nautilus_view_model_set_selected (NautilusViewModel *self,
GQueue *item_models)
{
GList *l;
+ NautilusViewItemModel *item_model;
- g_print ("set selected\n");
- for (l = g_queue_peek_head_link (item_models); l != NULL; l = l->next)
+ gint i = 0;
+ while ((item_model = g_list_model_get_item (G_LIST_MODEL(self->internal_model), i)))
{
- NautilusViewItemModel *item_model;
+ gboolean selected;
+
+ selected = FALSE;
+ for (l = g_queue_peek_head_link (item_models); l != NULL; l = l->next)
+ {
+ NautilusViewItemModel *selected_item_model;
+
+ selected_item_model = NAUTILUS_VIEW_ITEM_MODEL (l->data);
+ if (item_model == selected_item_model)
+ {
+ selected = TRUE;
+ break;
+ }
+ }
+ i++;
- item_model = NAUTILUS_VIEW_ITEM_MODEL (l->data);
- nautilus_view_item_model_set_selected (item_model, TRUE);
+ nautilus_view_item_model_set_selected (item_model, selected);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]