[nautilus/wip/gbsneto/actionbar: 517/522] 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: 517/522] view: add NautilusView::selection property
- Date: Sun, 27 Nov 2016 16:37:30 +0000 (UTC)
commit 2686ff876bc8b1d66923a54d19847bf0dc7f6e71
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 | 36 ++++++++++++++++++------------------
src/nautilus-places-view.c | 11 +++++++++++
src/nautilus-trash-bar.c | 5 +++--
src/nautilus-view.c | 11 +++++++++++
4 files changed, 43 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 6f0c2d2..1d0c12d 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -142,7 +142,6 @@ enum
FILE_CHANGED,
MOVE_COPY_ITEMS,
REMOVE_FILE,
- SELECTION_CHANGED,
TRASH,
DELETE,
LAST_SIGNAL
@@ -157,6 +156,7 @@ enum
PROP_IS_LOADING,
PROP_LOCATION,
PROP_SEARCH_QUERY,
+ PROP_SELECTION,
NUM_PROPERTIES
};
@@ -2915,6 +2915,7 @@ 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
{
@@ -3276,12 +3277,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)
{
@@ -3407,6 +3402,7 @@ done_loading (NautilusFilesView *view,
if (selection)
{
g_list_free_full (selection, g_object_unref);
+ g_object_notify (G_OBJECT (view), "selection");
}
if (pending_selection)
@@ -3955,7 +3951,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");
}
g_signal_emit (view, signals[END_FILE_CHANGES], 0);
@@ -4000,7 +3996,7 @@ 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));
@@ -8509,6 +8505,12 @@ nautilus_files_view_get_property (GObject *object,
}
break;
+ case PROP_SELECTION:
+ {
+ g_value_set_pointer (value, nautilus_view_get_selection (NAUTILUS_VIEW (view)));
+ }
+ break;
+
default:
g_assert_not_reached ();
}
@@ -8561,6 +8563,12 @@ nautilus_files_view_set_property (GObject *object,
}
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);
@@ -8985,15 +8993,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_backing_uri = real_get_backing_uri;
klass->using_manual_layout = real_using_manual_layout;
klass->get_window = nautilus_files_view_get_window;
@@ -9024,6 +9023,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 981d2de..63300b0 100644
--- a/src/nautilus-places-view.c
+++ b/src/nautilus-places-view.c
@@ -50,6 +50,7 @@ enum
PROP_SEARCH_QUERY,
PROP_IS_LOADING,
PROP_IS_SEARCHING,
+ PROP_SELECTION,
LAST_PROP
};
@@ -170,6 +171,12 @@ nautilus_places_view_get_property (GObject *object,
}
break;
+ case PROP_SELECTION:
+ {
+ g_value_set_pointer (value, NULL);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -197,6 +204,9 @@ nautilus_places_view_set_property (GObject *object,
}
break;
+ case PROP_SELECTION:
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -348,6 +358,7 @@ nautilus_places_view_class_init (NautilusPlacesViewClass *klass)
g_object_class_override_property (object_class, PROP_IS_LOADING, "is-loading");
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_SELECTION, "selection");
g_object_class_override_property (object_class, PROP_SEARCH_QUERY, "search-query");
}
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index 9f8dfc3..743af67 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,11 +75,11 @@ static void
connect_view_and_update_button (NautilusTrashBar *bar)
{
bar->selection_handler_id = g_signal_connect (bar->view,
- "selection-changed",
+ "notify::selection",
G_CALLBACK (selection_changed_cb),
bar);
- selection_changed_cb (bar->view, bar);
+ selection_changed_cb (bar->view, NULL, bar);
}
static void
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 7b3a3c9..d14682d 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -72,6 +72,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]