summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2018-04-05 23:05:48 +0200
committerCarlos Soriano <csoriano@gnome.org>2018-04-13 21:41:38 +0200
commit8a58c9d0308e37771b7f8cdd54f810639401e373 (patch)
tree458baa21d029470ef0ea80edf5f7c60fc3ad71dd
parentb7b5b5e2a74ac935bfdaf6d7f35943029475e55f (diff)
downloadnautilus-8a58c9d0308e37771b7f8cdd54f810639401e373.tar.gz
views: Proxy the view main values and states
So they can be accessed easily from outside the view or window-slot. This is useful for preventing layer violation, as we had in the past.
-rw-r--r--src/nautilus-files-view.c20
-rw-r--r--src/nautilus-places-view.c11
-rw-r--r--src/nautilus-view.c8
-rw-r--r--src/nautilus-window-slot.c88
-rw-r--r--src/nautilus-window-slot.h6
5 files changed, 111 insertions, 22 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index a1cd2c9cd..f6104bbe2 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -142,8 +142,8 @@ enum
PROP_WINDOW_SLOT = 1,
PROP_SUPPORTS_ZOOMING,
PROP_ICON,
- PROP_IS_SEARCH,
- PROP_IS_LOADING,
+ PROP_SEARCHING,
+ PROP_LOADING,
PROP_LOCATION,
PROP_SEARCH_QUERY,
NUM_PROPERTIES
@@ -3591,7 +3591,7 @@ done_loading (NautilusFilesView *view,
priv->loading = FALSE;
g_signal_emit (view, signals[END_LOADING], 0, all_files_seen);
- g_object_notify (G_OBJECT (view), "is-loading");
+ g_object_notify (G_OBJECT (view), "loading");
if (!priv->in_destruction)
{
@@ -8354,8 +8354,8 @@ load_directory (NautilusFilesView *view,
priv->location = nautilus_directory_get_location (directory);
g_object_notify (G_OBJECT (view), "location");
- g_object_notify (G_OBJECT (view), "is-loading");
- g_object_notify (G_OBJECT (view), "is-searching");
+ g_object_notify (G_OBJECT (view), "loading");
+ g_object_notify (G_OBJECT (view), "searching");
/* FIXME bugzilla.gnome.org 45062: In theory, we also need to monitor metadata here (as
* well as doing a call when ready), in case external forces
@@ -8847,13 +8847,13 @@ nautilus_files_view_get_property (GObject *object,
switch (prop_id)
{
- case PROP_IS_LOADING:
+ case PROP_LOADING:
{
g_value_set_boolean (value, nautilus_view_is_loading (NAUTILUS_VIEW (view)));
}
break;
- case PROP_IS_SEARCH:
+ case PROP_SEARCHING:
{
g_value_set_boolean (value, nautilus_view_is_searching (NAUTILUS_VIEW (view)));
}
@@ -9195,7 +9195,7 @@ set_search_query_internal (NautilusFilesView *files_view,
load_directory (files_view, directory);
- g_object_notify (G_OBJECT (files_view), "is-searching");
+ g_object_notify (G_OBJECT (files_view), "searching");
nautilus_directory_unref (directory);
g_free (uri);
@@ -9393,8 +9393,8 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
- g_object_class_override_property (oclass, PROP_IS_LOADING, "is-loading");
- g_object_class_override_property (oclass, PROP_IS_SEARCH, "is-searching");
+ g_object_class_override_property (oclass, PROP_LOADING, "loading");
+ g_object_class_override_property (oclass, PROP_SEARCHING, "searching");
g_object_class_override_property (oclass, PROP_LOCATION, "location");
g_object_class_override_property (oclass, PROP_SEARCH_QUERY, "search-query");
}
diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c
index 981d2de15..80134c9e3 100644
--- a/src/nautilus-places-view.c
+++ b/src/nautilus-places-view.c
@@ -48,8 +48,9 @@ enum
PROP_0,
PROP_LOCATION,
PROP_SEARCH_QUERY,
- PROP_IS_LOADING,
- PROP_IS_SEARCHING,
+ PROP_LOADING,
+ PROP_SEARCHING,
+ PROP_SELECTION,
LAST_PROP
};
@@ -108,7 +109,7 @@ open_location_cb (NautilusPlacesView *view,
static void
loading_cb (NautilusView *view)
{
- g_object_notify (G_OBJECT (view), "is-loading");
+ g_object_notify (G_OBJECT (view), "loading");
}
static void
@@ -345,8 +346,8 @@ nautilus_places_view_class_init (NautilusPlacesViewClass *klass)
object_class->get_property = nautilus_places_view_get_property;
object_class->set_property = nautilus_places_view_set_property;
- 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_LOADING, "loading");
+ g_object_class_override_property (object_class, PROP_SEARCHING, "searching");
g_object_class_override_property (object_class, PROP_LOCATION, "location");
g_object_class_override_property (object_class, PROP_SEARCH_QUERY, "search-query");
}
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 7b3a3c973..f4d928777 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -26,24 +26,24 @@ static void
nautilus_view_default_init (NautilusViewInterface *iface)
{
/**
- * NautilusView::is-loading:
+ * NautilusView::loading:
*
* %TRUE if the view is loading the location, %FALSE otherwise.
*/
g_object_interface_install_property (iface,
- g_param_spec_boolean ("is-loading",
+ g_param_spec_boolean ("loading",
"Current view is loading",
"Whether the current view is loading the location or not",
FALSE,
G_PARAM_READABLE));
/**
- * NautilusView::is-searching:
+ * NautilusView::searching:
*
* %TRUE if the view is searching, %FALSE otherwise.
*/
g_object_interface_install_property (iface,
- g_param_spec_boolean ("is-searching",
+ g_param_spec_boolean ("searching",
"Current view is searching",
"Whether the current view is searching or not",
FALSE,
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 2fa9c3339..f62c2ec5c 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -61,6 +61,8 @@ enum
PROP_ICON,
PROP_TOOLBAR_MENU_SECTIONS,
PROP_LOADING,
+ PROP_SEARCHING,
+ PROP_SELECTION,
PROP_LOCATION,
NUM_PROPERTIES
};
@@ -124,6 +126,12 @@ typedef struct
GError *mount_error;
gboolean tried_mount;
gint view_mode_before_search;
+
+ /* View bindings */
+ GBinding *searching_binding;
+ GBinding *selection_binding;
+ gboolean searching;
+ GList *selection;
} NautilusWindowSlotPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (NautilusWindowSlot, nautilus_window_slot, GTK_TYPE_BOX);
@@ -728,6 +736,29 @@ nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *self,
}
static void
+nautilus_window_slot_set_searching (NautilusWindowSlot *self,
+ gboolean searching)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ priv->searching = searching;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SEARCHING]);
+}
+
+static void
+nautilus_window_slot_set_selection (NautilusWindowSlot *self,
+ GList *selection)
+{
+ NautilusWindowSlotPrivate *priv;
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ priv->selection = selection;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTION]);
+}
+
+static void
nautilus_window_slot_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -755,6 +786,18 @@ nautilus_window_slot_set_property (GObject *object,
}
break;
+ case PROP_SEARCHING:
+ {
+ nautilus_window_slot_set_searching (self, g_value_get_boolean (value));
+ }
+ break;
+
+ case PROP_SELECTION:
+ {
+ nautilus_window_slot_set_selection (self, g_value_get_pointer (value));
+ }
+ break;
+
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -820,6 +863,26 @@ nautilus_window_slot_get_property (GObject *object,
}
}
+gboolean
+nautilus_window_slot_get_searching (NautilusWindowSlot *self)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ return priv->searching;
+}
+
+GList*
+nautilus_window_slot_get_selection (NautilusWindowSlot *self)
+{
+ NautilusWindowSlotPrivate *priv;
+
+ priv = nautilus_window_slot_get_instance_private (self);
+
+ return priv->selection;
+}
+
static void
nautilus_window_slot_constructed (GObject *object)
{
@@ -2702,7 +2765,7 @@ nautilus_window_slot_connect_new_content_view (NautilusWindowSlot *self)
if (priv->new_content_view)
{
g_signal_connect (priv->new_content_view,
- "notify::is-loading",
+ "notify::loading",
G_CALLBACK (view_is_loading_changed_cb),
self);
}
@@ -2742,6 +2805,8 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
if (priv->content_view != NULL)
{
+ g_binding_unbind (priv->searching_binding);
+ g_binding_unbind (priv->selection_binding);
widget = GTK_WIDGET (priv->content_view);
gtk_widget_destroy (widget);
g_object_unref (priv->content_view);
@@ -2757,7 +2822,12 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
gtk_container_add (GTK_CONTAINER (self), widget);
gtk_widget_set_vexpand (widget, TRUE);
gtk_widget_show (widget);
-
+ priv->searching_binding = g_object_bind_property (priv->content_view, "searching",
+ self, "searching",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+ priv->selection_binding = g_object_bind_property (priv->content_view, "selection",
+ self, "selection",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLBAR_MENU_SECTIONS]);
}
@@ -2922,6 +2992,7 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
"Whether the slot is the active slot of the window",
FALSE,
G_PARAM_READWRITE);
+
properties[PROP_LOADING] =
g_param_spec_boolean ("loading",
"Whether the slot loading",
@@ -2929,6 +3000,19 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
FALSE,
G_PARAM_READABLE);
+ properties[PROP_SEARCHING] =
+ g_param_spec_boolean ("searching",
+ "Whether the current view of the slot is searching",
+ "Whether the current view of the slot is searching. Proxy property from the view",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ properties[PROP_SELECTION] =
+ g_param_spec_pointer ("selection",
+ "Selection of the current view of the slot",
+ "The selection of the current view of the slot. Proxy property from the view",
+ G_PARAM_READWRITE);
+
properties[PROP_WINDOW] =
g_param_spec_object ("window",
"The NautilusWindow",
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index f62454e48..86b441fdc 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -110,6 +110,10 @@ void nautilus_window_slot_set_active (NautilusWindowSlot *
gboolean active);
gboolean nautilus_window_slot_get_loading (NautilusWindowSlot *slot);
+gboolean nautilus_window_slot_get_searching (NautilusWindowSlot *slot);
+
+GList* nautilus_window_slot_get_selection (NautilusWindowSlot *slot);
+
void nautilus_window_slot_search (NautilusWindowSlot *slot,
const gchar *text);
@@ -122,4 +126,4 @@ void nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
RestoreTabData* nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self);
/* Only used by slot-dnd */
-NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot); \ No newline at end of file
+NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot);