summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2016-03-02 00:55:42 -0300
committerCarlos Soriano <csoriano@gnome.org>2018-03-25 23:18:09 +0200
commite79dfe003a6cd553243f1ef9297cc2af4fb01bfa (patch)
tree9f76930d209ab9ac25b8e47ea12381671c8151b2
parent816673a953c0f456d76466a4da514a98afb89fda (diff)
downloadnautilus-e79dfe003a6cd553243f1ef9297cc2af4fb01bfa.tar.gz
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.
-rw-r--r--src/nautilus-files-view.c41
-rw-r--r--src/nautilus-places-view.c11
-rw-r--r--src/nautilus-trash-bar.c5
-rw-r--r--src/nautilus-view.c11
4 files changed, 48 insertions, 20 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index fe276e277..8eed98e89 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -131,7 +131,6 @@ enum
FILE_CHANGED,
MOVE_COPY_ITEMS,
REMOVE_FILE,
- SELECTION_CHANGED,
TRASH,
DELETE,
LAST_SIGNAL
@@ -146,6 +145,7 @@ enum
PROP_IS_LOADING,
PROP_LOCATION,
PROP_SEARCH_QUERY,
+ PROP_SELECTION,
NUM_PROPERTIES
};
@@ -3044,6 +3044,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
{
@@ -3398,12 +3399,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)
{
@@ -3539,6 +3534,12 @@ done_loading (NautilusFilesView *view,
do_reveal = TRUE;
}
+ if (selection)
+ {
+ g_list_free_full (selection, g_object_unref);
+ g_object_notify (G_OBJECT (view), "selection");
+ }
+
if (pending_selection)
{
g_list_free_full (pending_selection, g_object_unref);
@@ -4110,7 +4111,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);
@@ -4157,7 +4158,7 @@ display_selection_info_idle_callback (gpointer data)
priv->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));
@@ -8852,6 +8853,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 ();
}
@@ -8906,6 +8913,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);
@@ -9340,15 +9353,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->get_window = nautilus_files_view_get_window;
klass->update_context_menus = real_update_context_menus;
@@ -9378,6 +9382,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 981d2de15..63300b063 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 1256963a4..621421641 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)
{
g_autolist (NautilusFile) selection = NULL;
@@ -72,11 +73,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 7b3a3c973..d14682d6c 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));
}
/**