[nautilus/wip/gbsneto/cleanups: 2/5] view: manage the floating bar
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/gbsneto/cleanups: 2/5] view: manage the floating bar
- Date: Thu, 30 Jul 2015 17:30:06 +0000 (UTC)
commit 886ae7b0d16bd962e752dd7a8bde49d4d92871bb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jul 28 19:21:31 2015 -0300
view: manage the floating bar
NautilusWindowSlot currently manages the floating bar,
requiring access to the underlying model of NautilusView
and making the code even more coupled and adding more
complexity to the codebase.
Fix that by delegating the management of the floating
bar to NautilusView itself.
src/nautilus-view.c | 306 +++++++++++++++++++++++++++++++++++++++-----
src/nautilus-view.h | 5 +-
src/nautilus-window-slot.c | 285 +----------------------------------------
src/nautilus-window-slot.h | 3 -
4 files changed, 284 insertions(+), 315 deletions(-)
---
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index cf20d42..4237436 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -32,6 +32,7 @@
#include "nautilus-application.h"
#include "nautilus-desktop-canvas-view.h"
#include "nautilus-error-reporting.h"
+#include "nautilus-floating-bar.h"
#include "nautilus-list-view.h"
#include "nautilus-mime-actions.h"
#include "nautilus-previewer.h"
@@ -227,10 +228,16 @@ struct NautilusViewDetails
GActionGroup *view_action_group;
+ GtkWidget *scrolled_window;
+
/* Empty states */
- GtkWidget *overlay;
GtkWidget *folder_is_empty_widget;
GtkWidget *no_search_results_widget;
+
+ /* Floating bar */
+ guint floating_bar_set_status_timeout_id;
+ guint floating_bar_loading_timeout_id;
+ GtkWidget *floating_bar;
};
typedef struct {
@@ -275,7 +282,7 @@ static void check_empty_states (NautilusView *vi
static void unschedule_pop_up_pathbar_context_menu (NautilusView *view);
-G_DEFINE_TYPE (NautilusView, nautilus_view, GTK_TYPE_SCROLLED_WINDOW);
+G_DEFINE_TYPE (NautilusView, nautilus_view, GTK_TYPE_OVERLAY);
static void
check_empty_states (NautilusView *view)
@@ -305,6 +312,210 @@ check_empty_states (NautilusView *view)
}
}
+/*
+ * Floating Bar code
+ */
+static void
+remove_loading_floating_bar (NautilusView *view)
+{
+ if (view->details->floating_bar_loading_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_loading_timeout_id);
+ view->details->floating_bar_loading_timeout_id = 0;
+ }
+
+ gtk_widget_hide (view->details->floating_bar);
+ nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (view->details->floating_bar));
+}
+
+static void
+real_setup_loading_floating_bar (NautilusView *view)
+{
+ gboolean disable_chrome;
+
+ g_object_get (nautilus_view_get_window (view),
+ "disable-chrome", &disable_chrome,
+ NULL);
+
+ if (disable_chrome) {
+ gtk_widget_hide (view->details->floating_bar);
+ return;
+ }
+
+ nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (view->details->floating_bar));
+ nautilus_floating_bar_set_primary_label (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
+ NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model) ?
_("Searching…") : _("Loading…"));
+ nautilus_floating_bar_set_details_label (NAUTILUS_FLOATING_BAR (view->details->floating_bar), NULL);
+ nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
view->details->loading);
+ nautilus_floating_bar_add_action (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
+ "process-stop-symbolic",
+ NAUTILUS_FLOATING_BAR_ACTION_ID_STOP);
+
+ gtk_widget_set_halign (view->details->floating_bar, GTK_ALIGN_END);
+ gtk_widget_show (view->details->floating_bar);
+}
+
+static gboolean
+setup_loading_floating_bar_timeout_cb (gpointer user_data)
+{
+ NautilusView *view = user_data;
+
+ view->details->floating_bar_loading_timeout_id = 0;
+ real_setup_loading_floating_bar (view);
+
+ return FALSE;
+}
+
+static void
+setup_loading_floating_bar (NautilusView *view)
+{
+ /* setup loading overlay */
+ if (view->details->floating_bar_set_status_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_set_status_timeout_id);
+ view->details->floating_bar_set_status_timeout_id = 0;
+ }
+
+ if (view->details->floating_bar_loading_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_loading_timeout_id);
+ view->details->floating_bar_loading_timeout_id = 0;
+ }
+
+ view->details->floating_bar_loading_timeout_id =
+ g_timeout_add (500, setup_loading_floating_bar_timeout_cb, view);
+}
+
+static void
+floating_bar_action_cb (NautilusFloatingBar *floating_bar,
+ gint action,
+ NautilusView *view)
+{
+ if (action == NAUTILUS_FLOATING_BAR_ACTION_ID_STOP) {
+ remove_loading_floating_bar (view);
+ nautilus_window_slot_stop_loading (view->details->slot);
+ }
+}
+
+static void
+real_view_set_short_status (NautilusView *view,
+ const gchar *primary_status,
+ const gchar *detail_status)
+{
+ gboolean disable_chrome;
+
+ nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (view->details->floating_bar));
+ nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
view->details->loading);
+
+ g_object_get (nautilus_view_get_window (view),
+ "disable-chrome", &disable_chrome,
+ NULL);
+
+ if ((primary_status == NULL && detail_status == NULL) || disable_chrome) {
+ gtk_widget_hide (view->details->floating_bar);
+ return;
+ }
+
+ nautilus_floating_bar_set_labels (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
+ primary_status,
+ detail_status);
+
+ gtk_widget_show (view->details->floating_bar);
+}
+
+typedef struct {
+ gchar *primary_status;
+ gchar *detail_status;
+ NautilusView *view;
+} SetStatusData;
+
+static void
+set_status_data_free (gpointer data)
+{
+ SetStatusData *status_data = data;
+
+ g_free (status_data->primary_status);
+ g_free (status_data->detail_status);
+
+ g_slice_free (SetStatusData, data);
+}
+
+static gboolean
+set_status_timeout_cb (gpointer data)
+{
+ SetStatusData *status_data = data;
+
+ status_data->view->details->floating_bar_set_status_timeout_id = 0;
+ real_view_set_short_status (status_data->view,
+ status_data->primary_status,
+ status_data->detail_status);
+
+ return FALSE;
+}
+
+static void
+set_floating_bar_status (NautilusView *view,
+ const gchar *primary_status,
+ const gchar *detail_status)
+{
+ GtkSettings *settings;
+ gint double_click_time;
+ SetStatusData *status_data;
+
+ if (view->details->floating_bar_set_status_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_set_status_timeout_id);
+ view->details->floating_bar_set_status_timeout_id = 0;
+ }
+
+ settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (view)));
+ g_object_get (settings,
+ "gtk-double-click-time", &double_click_time,
+ NULL);
+
+ status_data = g_slice_new0 (SetStatusData);
+ status_data->primary_status = g_strdup (primary_status);
+ status_data->detail_status = g_strdup (detail_status);
+ status_data->view = view;
+
+ /* waiting for half of the double-click-time before setting
+ * the status seems to be a good approximation of not setting it
+ * too often and not delaying the statusbar too much.
+ */
+ view->details->floating_bar_set_status_timeout_id =
+ g_timeout_add_full (G_PRIORITY_DEFAULT,
+ (guint) (double_click_time / 2),
+ set_status_timeout_cb,
+ status_data,
+ set_status_data_free);
+}
+
+static void
+on_done_loading (NautilusView *view)
+{
+ remove_loading_floating_bar (view);
+}
+
+
+static void
+connect_directory_signals (NautilusView *view,
+ NautilusDirectory *directory)
+{
+ if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ g_signal_connect_swapped (directory,
+ "done-loading",
+ G_CALLBACK (on_done_loading),
+ view);
+ }
+}
+
+static void
+disconnect_directory_signals (NautilusView *view,
+ NautilusDirectory *directory)
+{
+ if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ g_signal_handlers_disconnect_by_func (directory,
+ G_CALLBACK (on_done_loading),
+ view);
+ }
+}
+
static char *
real_get_backing_uri (NautilusView *view)
{
@@ -579,6 +790,15 @@ nautilus_view_restore_default_zoom_level (NautilusView *view)
NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->restore_default_zoom_level (view);
}
+gboolean
+nautilus_view_is_search_directory (NautilusView *view)
+{
+ if (!view->details->model)
+ return FALSE;
+
+ return NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model);
+}
+
const char *
nautilus_view_get_view_id (NautilusView *view)
{
@@ -2509,7 +2729,7 @@ nautilus_view_grab_focus (NautilusView *view)
{
/* focus the child of the scrolled window if it exists */
GtkWidget *child;
- child = gtk_bin_get_child (GTK_BIN (view));
+ child = gtk_bin_get_child (GTK_BIN (view->details->scrolled_window));
if (child) {
gtk_widget_grab_focus (GTK_WIDGET (child));
}
@@ -2611,6 +2831,16 @@ nautilus_view_destroy (GtkWidget *object)
view->details->reveal_selection_idle_id = 0;
}
+ if (view->details->floating_bar_set_status_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_set_status_timeout_id);
+ view->details->floating_bar_set_status_timeout_id = 0;
+ }
+
+ if (view->details->floating_bar_loading_timeout_id != 0) {
+ g_source_remove (view->details->floating_bar_loading_timeout_id);
+ view->details->floating_bar_loading_timeout_id = 0;
+ }
+
if (view->details->directory_as_file) {
nautilus_file_unref (view->details->directory_as_file);
@@ -2823,8 +3053,7 @@ nautilus_view_display_selection_info (NautilusView *view)
g_free (non_folder_count_str);
g_free (non_folder_item_count_str);
- nautilus_window_slot_set_status (view->details->slot,
- primary_status, detail_status);
+ set_floating_bar_status (view, primary_status, detail_status);
g_free (primary_status);
g_free (detail_status);
@@ -2841,12 +3070,10 @@ nautilus_view_load_location (NautilusView *nautilus_view,
GFile *location)
{
NautilusDirectory *directory;
- NautilusView *directory_view;
- directory_view = NAUTILUS_VIEW (nautilus_view);
nautilus_profile_start (NULL);
directory = nautilus_directory_get (location);
- load_directory (directory_view, directory);
+ load_directory (nautilus_view, directory);
nautilus_directory_unref (directory);
nautilus_profile_end (NULL);
}
@@ -2881,6 +3108,7 @@ done_loading (NautilusView *view,
* as NULL. */
if (view->details->model != NULL) {
nautilus_view_update_toolbar_menus (view);
+ remove_loading_floating_bar (view);
schedule_update_context_menus (view);
schedule_update_status (view);
reset_update_interval (view);
@@ -6916,6 +7144,8 @@ load_directory (NautilusView *view,
view->details->loading = TRUE;
+ connect_directory_signals (view, directory);
+
/* Update menus when directory is empty, before going to new
* location, so they won't have any false lingering knowledge
* of old selection.
@@ -6929,6 +7159,11 @@ load_directory (NautilusView *view,
old_directory = view->details->model;
+ /* Disconnect search signals from the old directory if it was a search directory */
+ if (old_directory) {
+ disconnect_directory_signals (view, old_directory);
+ }
+
nautilus_directory_ref (directory);
view->details->model = directory;
nautilus_directory_unref (old_directory);
@@ -6989,6 +7224,7 @@ finish_loading (NautilusView *view)
g_signal_emit (view, signals[BEGIN_LOADING], 0);
nautilus_profile_end ("BEGIN_LOADING");
+ setup_loading_floating_bar (view);
check_empty_states (view);
/* Assume we have now all information to show window */
@@ -7167,6 +7403,7 @@ nautilus_view_stop_loading (NautilusView *view)
disconnect_model_handlers (view);
if (view->details->model) {
+ disconnect_directory_signals (view, view->details->model);
nautilus_directory_unref (view->details->model);
view->details->model = NULL;
}
@@ -7487,7 +7724,7 @@ nautilus_view_scroll_event (GtkWidget *widget,
return TRUE;
}
- return GTK_WIDGET_CLASS (nautilus_view_parent_class)->scroll_event (widget, event);
+ return FALSE;
}
static void
@@ -7524,7 +7761,7 @@ nautilus_view_container_add (GtkContainer *container,
{
NautilusView *view = NAUTILUS_VIEW (container);
- gtk_container_add (GTK_CONTAINER (view->details->overlay), widget);
+ gtk_container_add (GTK_CONTAINER (view->details->scrolled_window), widget);
}
static void
@@ -7533,10 +7770,8 @@ nautilus_view_class_init (NautilusViewClass *klass)
GObjectClass *oclass;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
- GtkScrolledWindowClass *scrolled_window_class;
widget_class = GTK_WIDGET_CLASS (klass);
- scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass);
container_class = GTK_CONTAINER_CLASS (klass);
oclass = G_OBJECT_CLASS (klass);
@@ -7551,11 +7786,6 @@ nautilus_view_class_init (NautilusViewClass *klass)
g_type_class_add_private (klass, sizeof (NautilusViewDetails));
- /* Get rid of the strange 3-pixel gap that GtkScrolledWindow
- * uses by default. It does us no good.
- */
- scrolled_window_class->scrollbar_spacing = 0;
-
signals[ADD_FILE] =
g_signal_new ("add-file",
G_TYPE_FROM_CLASS (klass),
@@ -7678,28 +7908,48 @@ nautilus_view_init (NautilusView *view)
view->details = G_TYPE_INSTANCE_GET_PRIVATE (view, NAUTILUS_TYPE_VIEW,
NautilusViewDetails);
- /* Overlay */
- view->details->overlay = gtk_overlay_new ();
- gtk_widget_show (view->details->overlay);
+ gtk_widget_add_events (GTK_WIDGET (view),
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
+
+ /* Scrolled Window */
+ view->details->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->details->scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_widget_show (view->details->scrolled_window);
+
+ g_signal_connect_swapped (view->details->scrolled_window,
+ "scroll-event",
+ G_CALLBACK (nautilus_view_scroll_event),
+ view);
/* Since the GtkContainer::add method was already overriden by the time
* _init is called, we have to manually use the parent's ::add method.
*/
- GTK_CONTAINER_CLASS (nautilus_view_parent_class)->add (GTK_CONTAINER (view), view->details->overlay);
+ GTK_CONTAINER_CLASS (nautilus_view_parent_class)->add (GTK_CONTAINER (view),
view->details->scrolled_window);
/* Empty states */
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-no-search-results.ui");
view->details->no_search_results_widget = GTK_WIDGET (gtk_builder_get_object (builder,
"no_search_results"));
- gtk_overlay_add_overlay (GTK_OVERLAY (view->details->overlay),
- view->details->no_search_results_widget);
+ gtk_overlay_add_overlay (GTK_OVERLAY (view), view->details->no_search_results_widget);
g_object_unref (builder);
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-folder-is-empty.ui");
view->details->folder_is_empty_widget = GTK_WIDGET (gtk_builder_get_object (builder,
"folder_is_empty"));
- gtk_overlay_add_overlay (GTK_OVERLAY (view->details->overlay),
- view->details->folder_is_empty_widget);
+ gtk_overlay_add_overlay (GTK_OVERLAY (view), view->details->folder_is_empty_widget);
g_object_unref (builder);
+ /* Floating bar */
+ view->details->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
+ gtk_widget_set_halign (view->details->floating_bar, GTK_ALIGN_END);
+ gtk_widget_set_valign (view->details->floating_bar, GTK_ALIGN_END);
+ gtk_overlay_add_overlay (GTK_OVERLAY (view), view->details->floating_bar);
+
+ g_signal_connect (view->details->floating_bar,
+ "action",
+ G_CALLBACK (floating_bar_action_cb),
+ view);
+
/* Default to true; desktop-icon-view sets to false */
view->details->show_foreign_files = TRUE;
@@ -7709,12 +7959,6 @@ nautilus_view_init (NautilusView *view)
(GDestroyNotify)file_and_directory_free,
NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (view), NULL);
- gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (view), NULL);
-
gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (view)),
GTK_JUNCTION_TOP | GTK_JUNCTION_LEFT);
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 78218cf..6ad1ff7 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -62,13 +62,13 @@ typedef struct NautilusViewClass NautilusViewClass;
typedef struct NautilusViewDetails NautilusViewDetails;
struct NautilusView {
- GtkScrolledWindow parent;
+ GtkOverlay parent;
NautilusViewDetails *details;
};
struct NautilusViewClass {
- GtkScrolledWindowClass parent_class;
+ GtkOverlayClass parent_class;
/* The 'clear' signal is emitted to empty the view of its contents.
* It must be replaced by each subclass.
@@ -391,5 +391,6 @@ void nautilus_view_action_show_hidden_files (NautilusView *view,
gboolean show_hidden);
GActionGroup * nautilus_view_get_action_group (NautilusView *view);
+gboolean nautilus_view_is_search_directory (NautilusView *view);
#endif /* NAUTILUS_VIEW_H */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 43f9884..4b7574b 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -27,7 +27,6 @@
#include "nautilus-application.h"
#include "nautilus-canvas-view.h"
#include "nautilus-desktop-window.h"
-#include "nautilus-floating-bar.h"
#include "nautilus-list-view.h"
#include "nautilus-special-location-bar.h"
#include "nautilus-trash-bar.h"
@@ -62,12 +61,6 @@ enum {
struct NautilusWindowSlotDetails {
NautilusWindow *window;
- /* floating bar */
- guint set_status_timeout_id;
- guint loading_timeout_id;
- GtkWidget *floating_bar;
- GtkWidget *view_overlay;
-
/* slot contains
* 1) an vbox containing extra_location_widgets
* 2) the view
@@ -131,12 +124,10 @@ static void location_has_really_changed (NautilusWindowSlot *slot);
static void nautilus_window_slot_connect_new_content_view (NautilusWindowSlot *slot);
static void nautilus_window_slot_disconnect_content_view (NautilusWindowSlot *slot);
static void nautilus_window_slot_emit_location_change (NautilusWindowSlot *slot, GFile *from, GFile *to);
-static void setup_loading_floating_bar (NautilusWindowSlot *slot);
static void
nautilus_window_slot_sync_search_widgets (NautilusWindowSlot *slot)
{
- NautilusDirectory *directory;
gboolean toggle;
if (slot != nautilus_window_get_active_slot (slot->details->window)) {
@@ -146,8 +137,7 @@ nautilus_window_slot_sync_search_widgets (NautilusWindowSlot *slot)
toggle = slot->details->search_visible;
if (slot->details->content_view != NULL) {
- directory = nautilus_view_get_model (slot->details->content_view);
- if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ if (nautilus_view_is_search_directory (slot->details->content_view)) {
toggle = TRUE;
}
}
@@ -190,49 +180,6 @@ nautilus_window_slot_sync_view_mode (NautilusWindowSlot *slot)
}
static void
-remove_loading_floating_bar (NautilusWindowSlot *slot)
-{
- if (slot->details->loading_timeout_id != 0) {
- g_source_remove (slot->details->loading_timeout_id);
- slot->details->loading_timeout_id = 0;
- }
-
- gtk_widget_hide (slot->details->floating_bar);
- nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (slot->details->floating_bar));
-}
-
-static void
-nautilus_window_slot_on_done_loading (NautilusDirectory *directory,
- NautilusWindowSlot *slot)
-{
-
- remove_loading_floating_bar (slot);
- nautilus_window_slot_set_allow_stop (slot, FALSE);
-}
-
-static void
-connect_directory_signals (NautilusWindowSlot *slot,
- NautilusDirectory *directory)
-{
- if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
- g_signal_connect_object (directory, "done-loading",
- G_CALLBACK (nautilus_window_slot_on_done_loading),
- slot, 0);
- }
-}
-
-static void
-disconnect_directory_signals (NautilusWindowSlot *slot,
- NautilusDirectory *directory)
-{
- if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
- g_signal_handlers_disconnect_by_func (directory,
- G_CALLBACK (nautilus_window_slot_on_done_loading),
- slot);
- }
-}
-
-static void
sync_search_directory (NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
@@ -526,16 +473,6 @@ real_inactive (NautilusWindowSlot *slot)
}
static void
-floating_bar_action_cb (NautilusFloatingBar *floating_bar,
- gint action,
- NautilusWindowSlot *slot)
-{
- if (action == NAUTILUS_FLOATING_BAR_ACTION_ID_STOP) {
- nautilus_window_slot_stop_loading (slot);
- }
-}
-
-static void
remove_all_extra_location_widgets (GtkWidget *widget,
gpointer data)
{
@@ -627,22 +564,6 @@ nautilus_window_slot_constructed (GObject *object)
gtk_widget_show_all (slot->details->query_editor_revealer);
nautilus_window_slot_add_extra_location_widget (slot, slot->details->query_editor_revealer);
- slot->details->view_overlay = gtk_overlay_new ();
- gtk_widget_add_events (slot->details->view_overlay,
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
- gtk_box_pack_start (GTK_BOX (slot), slot->details->view_overlay, TRUE, TRUE, 0);
- gtk_widget_show (slot->details->view_overlay);
-
- slot->details->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
- gtk_widget_set_halign (slot->details->floating_bar, GTK_ALIGN_END);
- gtk_widget_set_valign (slot->details->floating_bar, GTK_ALIGN_END);
- gtk_overlay_add_overlay (GTK_OVERLAY (slot->details->view_overlay),
- slot->details->floating_bar);
-
- g_signal_connect (slot->details->floating_bar, "action",
- G_CALLBACK (floating_bar_action_cb), slot);
-
slot->details->title = g_strdup (_("Loading…"));
}
@@ -889,7 +810,6 @@ begin_location_change (NautilusWindowSlot *slot,
NautilusWindowGoToCallback callback,
gpointer user_data)
{
- NautilusDirectory *previous_directory;
NautilusDirectory *directory;
NautilusFile *file;
gboolean force_reload;
@@ -905,12 +825,8 @@ begin_location_change (NautilusWindowSlot *slot,
nautilus_profile_start (NULL);
- previous_directory = nautilus_directory_get (previous_location);
directory = nautilus_directory_get (location);
- /* Disconnect search signals from the old directory if it was a search directory */
- disconnect_directory_signals (slot, previous_directory);
- nautilus_directory_unref (previous_directory);
/* Avoid to update status from the current view in our async calls */
nautilus_window_slot_disconnect_content_view (slot);
@@ -945,7 +861,6 @@ begin_location_change (NautilusWindowSlot *slot,
end_location_change (slot);
nautilus_window_slot_set_allow_stop (slot, TRUE);
- nautilus_window_slot_set_status (slot, NULL, NULL);
g_assert (slot->details->pending_location == NULL);
g_assert (slot->details->pending_selection == NULL);
@@ -1466,10 +1381,6 @@ create_content_view (NautilusWindowSlot *slot,
old_directory = nautilus_directory_get (old_location);
new_directory = nautilus_directory_get (slot->details->pending_location);
- /* Connect to the done loading signal if it is a search directory to update
- * the no results widget */
- connect_directory_signals (slot, new_directory);
-
if (NAUTILUS_IS_SEARCH_DIRECTORY (new_directory) &&
!NAUTILUS_IS_SEARCH_DIRECTORY (old_directory)) {
nautilus_search_directory_set_base_model (NAUTILUS_SEARCH_DIRECTORY (new_directory),
old_directory);
@@ -1629,7 +1540,6 @@ cancel_location_change (NautilusWindowSlot *slot)
location = nautilus_window_slot_get_location (slot);
directory = nautilus_directory_get (slot->details->location);
- disconnect_directory_signals (slot, directory);
/* Stops current loading or search if any, so we are not slow */
nautilus_view_stop_loading (slot->details->content_view);
nautilus_directory_unref (directory);
@@ -2237,70 +2147,7 @@ view_end_loading_cb (NautilusView *view,
slot->details->needs_reload = FALSE;
}
- /* If it is a search directory, it will hide the toolbar when the search engine
- * finishes, not every time the view end loading the new files */
- if (!NAUTILUS_IS_SEARCH_DIRECTORY (nautilus_view_get_model (slot->details->content_view))) {
- remove_loading_floating_bar (slot);
- nautilus_window_slot_set_allow_stop (slot, FALSE);
- }
-}
-
-static void
-real_setup_loading_floating_bar (NautilusWindowSlot *slot)
-{
- gboolean disable_chrome;
-
- g_object_get (nautilus_window_slot_get_window (slot),
- "disable-chrome", &disable_chrome,
- NULL);
-
- if (disable_chrome) {
- gtk_widget_hide (slot->details->floating_bar);
- return;
- }
-
- nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (slot->details->floating_bar));
- nautilus_floating_bar_set_primary_label (NAUTILUS_FLOATING_BAR (slot->details->floating_bar),
- NAUTILUS_IS_SEARCH_DIRECTORY (nautilus_view_get_model
(slot->details->content_view)) ?
- _("Searching…") : _("Loading…"));
- nautilus_floating_bar_set_details_label (NAUTILUS_FLOATING_BAR (slot->details->floating_bar), NULL);
- nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (slot->details->floating_bar),
- slot->details->allow_stop);
- nautilus_floating_bar_add_action (NAUTILUS_FLOATING_BAR (slot->details->floating_bar),
- "process-stop-symbolic",
- NAUTILUS_FLOATING_BAR_ACTION_ID_STOP);
-
- gtk_widget_set_halign (slot->details->floating_bar, GTK_ALIGN_END);
- gtk_widget_show (slot->details->floating_bar);
-}
-
-static gboolean
-setup_loading_floating_bar_timeout_cb (gpointer user_data)
-{
- NautilusWindowSlot *slot = user_data;
-
- slot->details->loading_timeout_id = 0;
- real_setup_loading_floating_bar (slot);
-
- return FALSE;
-}
-
-static void
-setup_loading_floating_bar (NautilusWindowSlot *slot)
-{
- /* setup loading overlay */
- if (slot->details->set_status_timeout_id != 0) {
- g_source_remove (slot->details->set_status_timeout_id);
- slot->details->set_status_timeout_id = 0;
- }
-
- if (slot->details->loading_timeout_id != 0) {
- g_source_remove (slot->details->loading_timeout_id);
- slot->details->loading_timeout_id = 0;
- }
-
- slot->details->loading_timeout_id =
- g_timeout_add (500, setup_loading_floating_bar_timeout_cb, slot);
+ nautilus_window_slot_set_allow_stop (slot, FALSE);
}
static void
@@ -2315,9 +2162,7 @@ view_begin_loading_cb (NautilusView *view,
nautilus_window_slot_set_allow_stop (slot, TRUE);
}
- setup_loading_floating_bar (slot);
-
- nautilus_profile_end (NULL);
+ nautilus_profile_end (NULL);
}
static void
@@ -2422,7 +2267,8 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *slot)
slot->details->new_content_view = NULL;
widget = GTK_WIDGET (slot->details->content_view);
- gtk_container_add (GTK_CONTAINER (slot->details->view_overlay), widget);
+ gtk_container_add (GTK_CONTAINER (slot), widget);
+ gtk_widget_set_vexpand (widget, TRUE);
gtk_widget_show (widget);
}
}
@@ -2476,7 +2322,6 @@ static void
nautilus_window_slot_dispose (GObject *object)
{
NautilusWindowSlot *slot;
- NautilusDirectory *directory;
GtkWidget *widget;
slot = NAUTILUS_WINDOW_SLOT (object);
@@ -2500,16 +2345,6 @@ nautilus_window_slot_dispose (GObject *object)
slot->details->new_content_view = NULL;
}
- if (slot->details->set_status_timeout_id != 0) {
- g_source_remove (slot->details->set_status_timeout_id);
- slot->details->set_status_timeout_id = 0;
- }
-
- if (slot->details->loading_timeout_id != 0) {
- g_source_remove (slot->details->loading_timeout_id);
- slot->details->loading_timeout_id = 0;
- }
-
nautilus_window_slot_set_viewed_file (slot, NULL);
/* TODO? why do we unref here? the file is NULL.
* It was already here before the slot move, though */
@@ -2519,10 +2354,6 @@ nautilus_window_slot_dispose (GObject *object)
/* TODO? why do we ref here, instead of unreffing?
* It was already here before the slot migration, though */
g_object_ref (slot->details->location);
-
- directory = nautilus_directory_get (slot->details->location);
- disconnect_directory_signals (slot, directory);
- g_object_unref (directory);
}
if (slot->details->view_mode_before_search) {
@@ -2715,113 +2546,9 @@ nautilus_window_slot_set_allow_stop (NautilusWindowSlot *slot,
void
nautilus_window_slot_stop_loading (NautilusWindowSlot *slot)
{
- remove_loading_floating_bar (slot);
cancel_location_change (slot);
}
-static void
-real_slot_set_short_status (NautilusWindowSlot *slot,
- const gchar *primary_status,
- const gchar *detail_status)
-{
- gboolean disable_chrome;
-
- nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (slot->details->floating_bar));
- nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (slot->details->floating_bar),
- slot->details->allow_stop);
-
- g_object_get (nautilus_window_slot_get_window (slot),
- "disable-chrome", &disable_chrome,
- NULL);
-
- if ((primary_status == NULL && detail_status == NULL) || disable_chrome) {
- gtk_widget_hide (slot->details->floating_bar);
- return;
- }
-
- nautilus_floating_bar_set_labels (NAUTILUS_FLOATING_BAR (slot->details->floating_bar),
- primary_status, detail_status);
- gtk_widget_show (slot->details->floating_bar);
-}
-
-typedef struct {
- gchar *primary_status;
- gchar *detail_status;
- NautilusWindowSlot *slot;
-} SetStatusData;
-
-static void
-set_status_data_free (gpointer data)
-{
- SetStatusData *status_data = data;
-
- g_free (status_data->primary_status);
- g_free (status_data->detail_status);
-
- g_slice_free (SetStatusData, data);
-}
-
-static gboolean
-set_status_timeout_cb (gpointer data)
-{
- SetStatusData *status_data = data;
-
- status_data->slot->details->set_status_timeout_id = 0;
- real_slot_set_short_status (status_data->slot,
- status_data->primary_status,
- status_data->detail_status);
-
- return FALSE;
-}
-
-static void
-set_floating_bar_status (NautilusWindowSlot *slot,
- const gchar *primary_status,
- const gchar *detail_status)
-{
- GtkSettings *settings;
- gint double_click_time;
- SetStatusData *status_data;
-
- if (slot->details->set_status_timeout_id != 0) {
- g_source_remove (slot->details->set_status_timeout_id);
- slot->details->set_status_timeout_id = 0;
- }
-
- settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET
(slot->details->content_view)));
- g_object_get (settings,
- "gtk-double-click-time", &double_click_time,
- NULL);
-
- status_data = g_slice_new0 (SetStatusData);
- status_data->primary_status = g_strdup (primary_status);
- status_data->detail_status = g_strdup (detail_status);
- status_data->slot = slot;
-
- /* waiting for half of the double-click-time before setting
- * the status seems to be a good approximation of not setting it
- * too often and not delaying the statusbar too much.
- */
- slot->details->set_status_timeout_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT,
- (guint) (double_click_time / 2),
- set_status_timeout_cb,
- status_data,
- set_status_data_free);
-}
-
-void
-nautilus_window_slot_set_status (NautilusWindowSlot *slot,
- const char *primary_status,
- const char *detail_status)
-{
- g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
-
- if (slot->details->content_view != NULL) {
- set_floating_bar_status (slot, primary_status, detail_status);
- }
-}
-
/* returns either the pending or the actual current uri */
char *
nautilus_window_slot_get_current_uri (NautilusWindowSlot *slot)
@@ -2851,7 +2578,7 @@ nautilus_window_slot_get_current_view (NautilusWindowSlot *slot)
void
nautilus_window_slot_go_home (NautilusWindowSlot *slot,
NautilusWindowOpenFlags flags)
-{
+{
GFile *home;
g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index ed7e780..97ff788 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -120,9 +120,6 @@ void nautilus_window_slot_go_home (NautilusWindowSlot *slot,
void nautilus_window_slot_go_up (NautilusWindowSlot *slot,
NautilusWindowOpenFlags flags);
-void nautilus_window_slot_set_status (NautilusWindowSlot *slot,
- const char *primary_status,
- const char *detail_status);
void nautilus_window_slot_sync_view_mode (NautilusWindowSlot *slot);
void nautilus_window_slot_display_view_selection_failure (NautilusWindow *window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]