[nautilus/wip/gbsneto/actionbar: 5/10] view: add NautilusView::selection property
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/gbsneto/actionbar: 5/10] view: add NautilusView::selection property
- Date: Tue, 29 Mar 2016 15:13:19 +0000 (UTC)
commit 969b8cab025734a30ab4400709b8b9ed7fbd42b4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Mar 2 00:55:42 2016 -0300
view: add NautilusView::selection property
Currently we don't have any way to track selection
changes, although NautilusView exposes selection. This
is an inconsistency in code, and should be avoided.
Fix that by adding a NautilusView::selection property
and deprecating the NautilusFilesView::selection-changed
signal.
src/nautilus-files-view.c | 34 +++++++++++++++++-----------------
src/nautilus-places-view.c | 9 +++++++++
src/nautilus-trash-bar.c | 5 +++--
src/nautilus-view.c | 11 +++++++++++
4 files changed, 40 insertions(+), 19 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 5643226..cc86b53 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -139,7 +139,6 @@ enum {
FILE_CHANGED,
MOVE_COPY_ITEMS,
REMOVE_FILE,
- SELECTION_CHANGED,
TRASH,
DELETE,
LAST_SIGNAL
@@ -154,6 +153,7 @@ enum {
PROP_IS_LOADING,
PROP_LOCATION,
PROP_SEARCH_QUERY,
+ PROP_SELECTION,
NUM_PROPERTIES
};
@@ -2773,6 +2773,8 @@ nautilus_files_view_set_selection (NautilusView *nautilus_files_view,
*/
nautilus_files_view_call_set_selection (view, selection);
nautilus_files_view_reveal_selection (view);
+
+ g_object_notify (G_OBJECT (view), "selection");
} else {
/* If we are still loading, set the list of pending URIs instead.
* done_loading() will eventually select the pending URIs and reveal them.
@@ -3084,12 +3086,6 @@ nautilus_files_view_display_selection_info (NautilusFilesView *view)
}
static void
-nautilus_files_view_send_selection_change (NautilusFilesView *view)
-{
- g_signal_emit (view, signals[SELECTION_CHANGED], 0);
-}
-
-static void
nautilus_files_view_set_location (NautilusView *view,
GFile *location)
{
@@ -3210,6 +3206,8 @@ done_loading (NautilusFilesView *view,
}
}
nautilus_files_view_display_selection_info (view);
+
+ g_object_notify (G_OBJECT (view), "selection");
}
view->details->loading = FALSE;
@@ -3641,7 +3639,7 @@ process_old_files (NautilusFilesView *view)
/* Send a selection change since some file names could
* have changed.
*/
- nautilus_files_view_send_selection_change (view);
+ g_object_notify (G_OBJECT (view), "selection");
}
}
@@ -3675,7 +3673,8 @@ display_selection_info_idle_callback (gpointer data)
view->details->display_selection_idle_id = 0;
nautilus_files_view_display_selection_info (view);
- nautilus_files_view_send_selection_change (view);
+
+ g_object_notify (G_OBJECT (view), "selection");
g_object_unref (G_OBJECT (view));
@@ -7604,6 +7603,10 @@ nautilus_files_view_get_property (GObject *object,
g_value_set_object (value, view->details->search_query);
break;
+ case PROP_SELECTION:
+ g_value_set_pointer (value, nautilus_view_get_selection (NAUTILUS_VIEW (view)));
+ break;
+
default:
g_assert_not_reached ();
@@ -7647,6 +7650,10 @@ nautilus_files_view_set_property (GObject *object,
nautilus_view_set_search_query (NAUTILUS_VIEW (directory_view), g_value_get_object (value));
break;
+ case PROP_SELECTION:
+ nautilus_view_set_selection (NAUTILUS_VIEW (directory_view), g_value_get_pointer (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -8025,14 +8032,6 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 2, NAUTILUS_TYPE_FILE, NAUTILUS_TYPE_DIRECTORY);
- signals[SELECTION_CHANGED] =
- g_signal_new ("selection-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
klass->get_selected_icon_locations = real_get_selected_icon_locations;
klass->is_read_only = real_is_read_only;
@@ -8070,6 +8069,7 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
g_object_class_override_property (oclass, PROP_IS_SEARCH, "is-searching");
g_object_class_override_property (oclass, PROP_LOCATION, "location");
g_object_class_override_property (oclass, PROP_SEARCH_QUERY, "search-query");
+ g_object_class_override_property (oclass, PROP_SELECTION, "selection");
}
static void
diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c
index 1a01495..613703e 100644
--- a/src/nautilus-places-view.c
+++ b/src/nautilus-places-view.c
@@ -50,6 +50,7 @@ enum {
PROP_VIEW_WIDGET,
PROP_IS_LOADING,
PROP_IS_SEARCHING,
+ PROP_SELECTION,
LAST_PROP
};
@@ -141,6 +142,10 @@ nautilus_places_view_get_property (GObject *object,
g_value_set_object (value, nautilus_view_get_view_widget (view));
break;
+ case PROP_SELECTION:
+ g_value_set_pointer (value, NULL);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -163,6 +168,9 @@ nautilus_places_view_set_property (GObject *object,
nautilus_view_set_search_query (view, g_value_get_object (value));
break;
+ case PROP_SELECTION:
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -313,6 +321,7 @@ nautilus_places_view_class_init (NautilusPlacesViewClass *klass)
g_object_class_override_property (object_class, PROP_IS_SEARCHING, "is-searching");
g_object_class_override_property (object_class, PROP_LOCATION, "location");
g_object_class_override_property (object_class, PROP_SEARCH_QUERY, "search-query");
+ g_object_class_override_property (object_class, PROP_SELECTION, "selection");
g_object_class_override_property (object_class, PROP_VIEW_WIDGET, "view-widget");
}
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index d7c62f5..0b85065 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -55,6 +55,7 @@ G_DEFINE_TYPE (NautilusTrashBar, nautilus_trash_bar, GTK_TYPE_INFO_BAR);
static void
selection_changed_cb (NautilusFilesView *view,
+ GParamSpec *pspec,
NautilusTrashBar *bar)
{
GList *selection;
@@ -74,10 +75,10 @@ static void
connect_view_and_update_button (NautilusTrashBar *bar)
{
bar->priv->selection_handler_id =
- g_signal_connect (bar->priv->view, "selection-changed",
+ g_signal_connect (bar->priv->view, "notify::selection",
G_CALLBACK (selection_changed_cb), bar);
- selection_changed_cb (bar->priv->view, bar);
+ selection_changed_cb (bar->priv->view, NULL, bar);
}
static void
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index f14b9f0..30f72f9 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -96,6 +96,17 @@ nautilus_view_default_init (NautilusViewInterface *iface)
"The search query being performed on the
view",
NAUTILUS_TYPE_QUERY,
G_PARAM_READWRITE));
+
+ /**
+ * NautilusView::selection:
+ *
+ * The current selection of the view.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_pointer ("selection",
+ "Selection of the view",
+ "The selection of the view",
+ G_PARAM_READWRITE));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]