[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: Fri, 31 Jul 2015 13:22:33 +0000 (UTC)
commit c816ee68416f2175171b17e6da23a624519406ac
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-canvas-view.c | 4 +-
src/nautilus-list-view.c | 4 +-
src/nautilus-view.c | 318 +++++++++++++++++++++++++++++++++++--------
src/nautilus-view.h | 6 +-
src/nautilus-window-slot.c | 298 ++----------------------------------------
src/nautilus-window-slot.h | 3 -
6 files changed, 278 insertions(+), 355 deletions(-)
---
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 953c7b5..53e37d9 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1640,7 +1640,9 @@ static NautilusCanvasContainer *
create_canvas_container (NautilusCanvasView *canvas_view)
{
NautilusCanvasContainer *canvas_container;
+ GtkWidget *content_widget;
+ content_widget = nautilus_view_get_content_widget (NAUTILUS_VIEW (canvas_view));
canvas_container = nautilus_canvas_view_container_new (canvas_view);
canvas_view->details->canvas_container = GTK_WIDGET (canvas_container);
g_object_add_weak_pointer (G_OBJECT (canvas_container),
@@ -1695,7 +1697,7 @@ create_canvas_container (NautilusCanvasView *canvas_view)
g_signal_connect_object (canvas_container, "store-layout-timestamp",
G_CALLBACK (store_layout_timestamp), canvas_view, 0);
- gtk_container_add (GTK_CONTAINER (canvas_view),
+ gtk_container_add (GTK_CONTAINER (content_widget),
GTK_WIDGET (canvas_container));
nautilus_canvas_view_update_click_mode (canvas_view);
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index ac4bf80..20a4882 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1793,7 +1793,9 @@ create_and_set_up_tree_view (NautilusListView *view)
GList *nautilus_columns;
GList *l;
gchar **default_column_order, **default_visible_columns;
+ GtkWidget *content_widget;
+ content_widget = nautilus_view_get_content_widget (NAUTILUS_VIEW (view));
view->details->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
view->details->columns = g_hash_table_new_full (g_str_hash,
g_str_equal,
@@ -2025,7 +2027,7 @@ create_and_set_up_tree_view (NautilusListView *view)
default_visible_columns);
gtk_widget_show (GTK_WIDGET (view->details->tree_view));
- gtk_container_add (GTK_CONTAINER (view), GTK_WIDGET (view->details->tree_view));
+ gtk_container_add (GTK_CONTAINER (content_widget), GTK_WIDGET (view->details->tree_view));
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (view->details->tree_view));
atk_object_set_name (atk_obj, _("List View"));
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index cf20d42..b1f7b82 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"
@@ -118,6 +119,9 @@
/* Time to show the duplicated folder label */
#define DIALOG_DUPLICATED_NAME_ERROR_LABEL_TIMEOUT 500
+/* Delay to show the Loading... floating bar */
+#define FLOATING_BAR_LOADING_DELAY 500 /* ms */
+
enum {
ADD_FILE,
BEGIN_FILE_CHANGES,
@@ -227,10 +231,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,26 +285,24 @@ 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)
{
GList *files;
GList *filtered;
- NautilusDirectory *directory;
gboolean show_hidden_files;
gtk_widget_hide (view->details->no_search_results_widget);
gtk_widget_hide (view->details->folder_is_empty_widget);
- directory = view->details->model;
- if (!view->details->loading && directory != NULL) {
- files = nautilus_directory_get_file_list (directory);
+ if (!view->details->loading && view->details->model) {
+ files = nautilus_directory_get_file_list (view->details->model);
show_hidden_files = g_settings_get_boolean (gtk_filechooser_preferences,
NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
filtered = nautilus_file_list_filter_hidden (files, show_hidden_files);
if (g_list_length (filtered) == 0) {
- if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ if (nautilus_view_is_search (view)) {
gtk_widget_show (view->details->no_search_results_widget);
} else {
gtk_widget_show (view->details->folder_is_empty_widget);
@@ -305,26 +313,200 @@ 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_view_is_search (view) ? _("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 (FLOATING_BAR_LOADING_DELAY, 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_floating_bar_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;
+} FloatingBarSetStatusData;
+
+static void
+floating_bar_set_status_data_free (gpointer data)
+{
+ FloatingBarSetStatusData *status_data = data;
+
+ g_free (status_data->primary_status);
+ g_free (status_data->detail_status);
+
+ g_slice_free (FloatingBarSetStatusData, data);
+}
+
+static gboolean
+floating_bar_set_status_timeout_cb (gpointer data)
+{
+ FloatingBarSetStatusData *status_data = data;
+
+ status_data->view->details->floating_bar_set_status_timeout_id = 0;
+ real_floating_bar_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;
+ FloatingBarSetStatusData *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 (FloatingBarSetStatusData);
+ 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),
+ floating_bar_set_status_timeout_cb,
+ status_data,
+ floating_bar_set_status_data_free);
+}
+
static char *
real_get_backing_uri (NautilusView *view)
{
NautilusDirectory *directory;
char *uri;
-
+
g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
if (view->details->model == NULL) {
return NULL;
}
-
+
directory = view->details->model;
-
+
if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
directory = nautilus_desktop_directory_get_real_directory (NAUTILUS_DESKTOP_DIRECTORY
(directory));
} else {
nautilus_directory_ref (directory);
}
-
+
uri = nautilus_directory_get_uri (directory);
nautilus_directory_unref (directory);
@@ -579,6 +761,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 (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 +2700,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 +2802,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 +3024,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 +3041,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,14 +3079,14 @@ 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);
selection = view->details->pending_selection;
- if (NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model)
- && all_files_seen) {
+ if (nautilus_view_is_search (view) && all_files_seen) {
nautilus_view_select_first (view);
do_reveal = TRUE;
} else if (selection != NULL && all_files_seen) {
@@ -3618,6 +3816,8 @@ done_loading_callback (NautilusDirectory *directory,
*/
unschedule_display_of_pending_files (view);
schedule_timeout_display_of_pending_files (view, UPDATE_INTERVAL_MIN);
+
+ remove_loading_floating_bar (view);
}
nautilus_profile_end (NULL);
}
@@ -3730,6 +3930,14 @@ nautilus_view_get_model (NautilusView *view)
return view->details->model;
}
+GtkWidget*
+nautilus_view_get_content_widget (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
+
+ return view->details->scrolled_window;
+}
+
GdkAtom
nautilus_view_get_copied_files_atom (NautilusView *view)
{
@@ -6068,8 +6276,7 @@ real_update_actions_state (NautilusView *view)
selection_contains_special_link = special_link_in_selection (selection);
selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (selection);
selection_contains_recent = showing_recent_directory (view);
- selection_contains_search = view->details->model &&
- NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model);
+ selection_contains_search = nautilus_view_is_search (view);
selection_is_read_only = selection_count == 1 &&
(!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
!nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
@@ -6916,6 +7123,8 @@ load_directory (NautilusView *view,
view->details->loading = TRUE;
+ setup_loading_floating_bar (view);
+
/* Update menus when directory is empty, before going to new
* location, so they won't have any false lingering knowledge
* of old selection.
@@ -7487,7 +7696,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
@@ -7519,25 +7728,12 @@ nautilus_view_parent_set (GtkWidget *widget,
}
static void
-nautilus_view_container_add (GtkContainer *container,
- GtkWidget *widget)
-{
- NautilusView *view = NAUTILUS_VIEW (container);
-
- gtk_container_add (GTK_CONTAINER (view->details->overlay), widget);
-}
-
-static void
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);
oclass->finalize = nautilus_view_finalize;
@@ -7547,15 +7743,8 @@ nautilus_view_class_init (NautilusViewClass *klass)
widget_class->scroll_event = nautilus_view_scroll_event;
widget_class->parent_set = nautilus_view_parent_set;
- container_class->add = nautilus_view_container_add;
-
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 +7867,45 @@ 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_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 +7915,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..e8557a5 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,7 @@ 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 (NautilusView *view);
+GtkWidget* nautilus_view_get_content_widget (NautilusView *view);
#endif /* NAUTILUS_VIEW_H */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 43f9884..2bc4bee 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,28 +124,18 @@ 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)) {
return;
}
- 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)) {
- toggle = TRUE;
- }
- }
-
- nautilus_window_slot_set_search_visible (slot, toggle);
+ nautilus_window_slot_set_search_visible (slot,
+ slot->details->search_visible ||
+ (slot->details->content_view &&
+ nautilus_view_is_search (slot->details->content_view)));
}
static gboolean
@@ -190,49 +173,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 +466,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 +557,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 +803,6 @@ begin_location_change (NautilusWindowSlot *slot,
NautilusWindowGoToCallback callback,
gpointer user_data)
{
- NautilusDirectory *previous_directory;
NautilusDirectory *directory;
NautilusFile *file;
gboolean force_reload;
@@ -905,12 +818,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 +854,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 +1374,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 +1533,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 +2140,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 +2155,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 +2260,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 +2315,6 @@ static void
nautilus_window_slot_dispose (GObject *object)
{
NautilusWindowSlot *slot;
- NautilusDirectory *directory;
GtkWidget *widget;
slot = NAUTILUS_WINDOW_SLOT (object);
@@ -2500,16 +2338,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 +2347,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 +2539,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 +2571,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]