[nautilus/wip/gbsneto/actionbar: 4/5] files-view: remove the floating bar



commit 1cfcec4a4378ee5a9f682f68bed295aec2d43fec
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Mar 22 13:49:49 2016 -0300

    files-view: remove the floating bar
    
    The floating bar was a bad choice since it's inception. Not
    only it hovers content, it's behavior is inconsistent and the
    usability of it is very poor.
    
    After the introduction of the actionbar, most of the data that
    we displayed through the floating bar was moved to the actionbar,
    making the floating bar obsolete.
    
    This commit follows up and completely removes the floating bar.

 src/Makefile.am             |    2 -
 src/nautilus-files-view.c   |  447 ------------------------------------
 src/nautilus-files-view.h   |    2 -
 src/nautilus-floating-bar.c |  525 -------------------------------------------
 src/nautilus-floating-bar.h |   79 -------
 5 files changed, 0 insertions(+), 1055 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6103c8b..9d2f34b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -165,8 +165,6 @@ nautilus_SOURCES = \
        nautilus-files-view.h                   \
        nautilus-files-view-dnd.c               \
        nautilus-files-view-dnd.h               \
-       nautilus-floating-bar.c                 \
-       nautilus-floating-bar.h                 \
        nautilus-freedesktop-dbus.c             \
        nautilus-freedesktop-dbus.h             \
        nautilus-image-properties-page.c        \
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index ed9d2c0..8f0c3bc 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -31,7 +31,6 @@
 #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"
@@ -127,9 +126,6 @@
 /* Delay to show the duplicated label when creating a folder */
 #define FILE_NAME_DUPLICATED_LABEL_TIMEOUT 500
 
-/* Delay to show the Loading... floating bar */
-#define FLOATING_BAR_LOADING_DELAY 200 /* ms */
-
 enum {
         ADD_FILE,
         BEGIN_FILE_CHANGES,
@@ -190,7 +186,6 @@ struct NautilusFilesViewDetails
 
         guint display_selection_idle_id;
         guint update_context_menus_timeout_id;
-        guint update_status_idle_id;
         guint reveal_selection_idle_id;
 
         guint display_pending_source_id;
@@ -258,11 +253,6 @@ struct NautilusFilesViewDetails
         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;
-
         /* View menu */
         GtkWidget *view_menu_widget;
         GtkWidget *view_icon;
@@ -301,8 +291,6 @@ static void     open_one_in_new_window                         (gpointer
                                                                 gpointer              callback_data);
 static void     schedule_update_context_menus                  (NautilusFilesView      *view);
 static void     remove_update_context_menus_timeout_callback   (NautilusFilesView      *view);
-static void     schedule_update_status                          (NautilusFilesView      *view);
-static void     remove_update_status_idle_callback             (NautilusFilesView *view);
 static void     reset_update_interval                          (NautilusFilesView      *view);
 static void     schedule_idle_display_of_pending_files         (NautilusFilesView      *view);
 static void     unschedule_display_of_pending_files            (NautilusFilesView      *view);
@@ -347,184 +335,6 @@ static const struct {
 #endif
 };
 
-/*
- * Floating Bar code
- */
-static void
-remove_loading_floating_bar (NautilusFilesView *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 (NautilusFilesView *view)
-{
-        gboolean disable_chrome;
-
-        g_object_get (nautilus_files_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_searching (NAUTILUS_VIEW (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)
-{
-        NautilusFilesView *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 (NautilusFilesView *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,
-                        NautilusFilesView   *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 (NautilusFilesView *view,
-                                    const gchar       *primary_status,
-                                    const gchar       *detail_status)
-{
-        gboolean disable_chrome;
-
-        if (view->details->loading)
-          return;
-
-        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),
-                                                FALSE);
-
-        g_object_get (nautilus_files_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;
-        NautilusFilesView *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 (NautilusFilesView *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 (NautilusFilesView *view)
 {
@@ -2840,7 +2650,6 @@ nautilus_files_view_destroy (GtkWidget *object)
         }
 
         remove_update_context_menus_timeout_callback (view);
-        remove_update_status_idle_callback (view);
 
         if (view->details->display_selection_idle_id != 0) {
                 g_source_remove (view->details->display_selection_idle_id);
@@ -2852,16 +2661,6 @@ nautilus_files_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;
-        }
-
         g_signal_handlers_disconnect_by_func (nautilus_preferences,
                                               schedule_update_context_menus, view);
         g_signal_handlers_disconnect_by_func (nautilus_preferences,
@@ -2870,8 +2669,6 @@ nautilus_files_view_destroy (GtkWidget *object)
                                               sort_directories_first_changed_callback, view);
         g_signal_handlers_disconnect_by_func (gtk_filechooser_preferences,
                                               show_hidden_files_changed_callback, view);
-        g_signal_handlers_disconnect_by_func (nautilus_window_state,
-                                              nautilus_files_view_display_selection_info, view);
         g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
                                               schedule_update_context_menus, view);
         g_signal_handlers_disconnect_by_func (nautilus_trash_monitor_get (),
@@ -2913,181 +2710,6 @@ nautilus_files_view_finalize (GObject *object)
         G_OBJECT_CLASS (nautilus_files_view_parent_class)->finalize (object);
 }
 
-/**
- * nautilus_files_view_display_selection_info:
- *
- * Display information about the current selection, and notify the view frame of the changed selection.
- * @view: NautilusFilesView for which to display selection info.
- *
- **/
-void
-nautilus_files_view_display_selection_info (NautilusFilesView *view)
-{
-        GList *selection;
-        goffset non_folder_size;
-        gboolean non_folder_size_known;
-        guint non_folder_count, folder_count, folder_item_count;
-        gboolean folder_item_count_known;
-        guint file_item_count;
-        GList *p;
-        char *first_item_name;
-        char *non_folder_count_str;
-        char *non_folder_item_count_str;
-        char *folder_count_str;
-        char *folder_item_count_str;
-        char *primary_status;
-        char *detail_status;
-        NautilusFile *file;
-
-        g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
-
-        selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
-
-        folder_item_count_known = TRUE;
-        folder_count = 0;
-        folder_item_count = 0;
-        non_folder_count = 0;
-        non_folder_size_known = FALSE;
-        non_folder_size = 0;
-        first_item_name = NULL;
-        folder_count_str = NULL;
-        folder_item_count_str = NULL;
-        non_folder_count_str = NULL;
-        non_folder_item_count_str = NULL;
-
-        for (p = selection; p != NULL; p = p->next) {
-                file = p->data;
-                if (nautilus_file_is_directory (file)) {
-                        folder_count++;
-                        if (nautilus_file_get_directory_item_count (file, &file_item_count, NULL)) {
-                                folder_item_count += file_item_count;
-                        } else {
-                                folder_item_count_known = FALSE;
-                        }
-                } else {
-                        non_folder_count++;
-                        if (!nautilus_file_can_get_size (file)) {
-                                non_folder_size_known = TRUE;
-                                non_folder_size += nautilus_file_get_size (file);
-                        }
-                }
-
-                if (first_item_name == NULL) {
-                        first_item_name = nautilus_file_get_display_name (file);
-                }
-        }
-
-        nautilus_file_list_free (selection);
-
-        /* Break out cases for localization's sake. But note that there are still pieces
-         * being assembled in a particular order, which may be a problem for some localizers.
-         */
-
-        if (folder_count != 0) {
-                if (folder_count == 1 && non_folder_count == 0) {
-                        folder_count_str = g_strdup_printf (_("“%s” selected"), first_item_name);
-                } else {
-                        folder_count_str = g_strdup_printf (ngettext("%'d folder selected",
-                                                                     "%'d folders selected",
-                                                                     folder_count),
-                                                            folder_count);
-                }
-
-                if (folder_count == 1) {
-                        if (!folder_item_count_known) {
-                                folder_item_count_str = g_strdup ("");
-                        } else {
-                                folder_item_count_str = g_strdup_printf (ngettext("(containing %'d item)",
-                                                                                  "(containing %'d items)",
-                                                                                  folder_item_count),
-                                                                         folder_item_count);
-                        }
-                }
-                else {
-                        if (!folder_item_count_known) {
-                                folder_item_count_str = g_strdup ("");
-                        } else {
-                                /* translators: this is preceded with a string of form 'N folders' (N more 
than 1) */
-                                folder_item_count_str = g_strdup_printf (ngettext("(containing a total of 
%'d item)",
-                                                                                  "(containing a total of 
%'d items)",
-                                                                                  folder_item_count),
-                                                                         folder_item_count);
-                        }
-
-                }
-        }
-
-        if (non_folder_count != 0) {
-                if (folder_count == 0) {
-                        if (non_folder_count == 1) {
-                                non_folder_count_str = g_strdup_printf (_("“%s” selected"),
-                                                                        first_item_name);
-                        } else {
-                                non_folder_count_str = g_strdup_printf (ngettext("%'d item selected",
-                                                                                 "%'d items selected",
-                                                                                 non_folder_count),
-                                                                        non_folder_count);
-                        }
-                } else {
-                        /* Folders selected also, use "other" terminology */
-                        non_folder_count_str = g_strdup_printf (ngettext("%'d other item selected",
-                                                                         "%'d other items selected",
-                                                                         non_folder_count),
-                                                                non_folder_count);
-                }
-
-                if (non_folder_size_known) {
-                        char *size_string;
-
-                        size_string = g_format_size (non_folder_size);
-                        /* This is marked for translation in case a localiser
-                         * needs to use something other than parentheses. The
-                         * the message in parentheses is the size of the selected items.
-                         */
-                        non_folder_item_count_str = g_strdup_printf (_("(%s)"), size_string);
-                        g_free (size_string);
-                } else {
-                        non_folder_item_count_str = g_strdup ("");
-                }
-        }
-
-        if (folder_count == 0 && non_folder_count == 0)        {
-                primary_status = NULL;
-                detail_status = NULL;
-        } else if (folder_count == 0) {
-                primary_status = g_strdup (non_folder_count_str);
-                detail_status = g_strdup (non_folder_item_count_str);
-        } else if (non_folder_count == 0) {
-                primary_status = g_strdup (folder_count_str);
-                detail_status  = g_strdup (folder_item_count_str);
-        } else {
-                /* This is marked for translation in case a localizer
-                 * needs to change ", " to something else. The comma
-                 * is between the message about the number of folders
-                 * and the number of items in those folders and the
-                 * message about the number of other items and the
-                 * total size of those items.
-                 */
-                primary_status = g_strdup_printf (_("%s %s, %s %s"),
-                                                  folder_count_str,
-                                                  folder_item_count_str,
-                                                  non_folder_count_str,
-                                                  non_folder_item_count_str);
-                detail_status = NULL;
-        }
-
-        g_free (first_item_name);
-        g_free (folder_count_str);
-        g_free (folder_item_count_str);
-        g_free (non_folder_count_str);
-        g_free (non_folder_item_count_str);
-
-        set_floating_bar_status (view, primary_status, detail_status);
-
-        g_free (primary_status);
-        g_free (detail_status);
-}
-
 static void
 nautilus_files_view_set_location (NautilusView *view,
                                   GFile        *location)
@@ -3164,9 +2786,7 @@ done_loading (NautilusFilesView *view,
         nautilus_profile_start (NULL);
 
         if (!view->details->in_destruction) {
-                remove_loading_floating_bar (view);
                 schedule_update_context_menus (view);
-                schedule_update_status (view);
                 nautilus_files_view_update_toolbar_menus (view);
                 reset_update_interval (view);
 
@@ -3208,7 +2828,6 @@ done_loading (NautilusFilesView *view,
                                 nautilus_files_view_reveal_selection (view);
                         }
                 }
-                nautilus_files_view_display_selection_info (view);
 
                 g_object_notify (G_OBJECT (view), "selection");
         }
@@ -3675,7 +3294,6 @@ display_selection_info_idle_callback (gpointer data)
         g_object_ref (G_OBJECT (view));
 
         view->details->display_selection_idle_id = 0;
-        nautilus_files_view_display_selection_info (view);
 
         g_object_notify (G_OBJECT (view), "selection");
 
@@ -3889,9 +3507,6 @@ files_added_callback (NautilusDirectory *directory,
 
         queue_pending_files (view, directory, files, &view->details->new_added_files);
 
-        /* The number of items could have changed */
-        schedule_update_status (view);
-
         nautilus_profile_end (NULL);
 }
 
@@ -3916,9 +3531,6 @@ files_changed_callback (NautilusDirectory *directory,
 
         queue_pending_files (view, directory, files, &view->details->new_changed_files);
 
-        /* The free space or the number of items could have changed */
-        schedule_update_status (view);
-
         /* A change in MIME type could affect the Open with menu, for
          * one thing, so we need to update menus when files change.
          */
@@ -3942,8 +3554,6 @@ 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);
 }
@@ -6979,48 +6589,6 @@ schedule_update_context_menus (NautilusFilesView *view)
         }
 }
 
-static void
-remove_update_status_idle_callback (NautilusFilesView *view)
-{
-        if (view->details->update_status_idle_id != 0) {
-                g_source_remove (view->details->update_status_idle_id);
-                view->details->update_status_idle_id = 0;
-        }
-}
-
-static gboolean
-update_status_idle_callback (gpointer data)
-{
-        NautilusFilesView *view;
-
-        view = NAUTILUS_FILES_VIEW (data);
-        nautilus_files_view_display_selection_info (view);
-        view->details->update_status_idle_id = 0;
-        return FALSE;
-}
-
-static void
-schedule_update_status (NautilusFilesView *view)
-{
-        g_assert (NAUTILUS_IS_FILES_VIEW (view));
-
-        /* Make sure we haven't already destroyed it */
-        if (view->details->slot == NULL) {
-                return;
-        }
-
-        if (view->details->loading) {
-                /* Don't update status bar while loading the dir */
-                return;
-        }
-
-        if (view->details->update_status_idle_id == 0) {
-                view->details->update_status_idle_id =
-                        g_idle_add_full (G_PRIORITY_DEFAULT_IDLE - 20,
-                                         update_status_idle_callback, view, NULL);
-        }
-}
-
 /**
  * nautilus_files_view_notify_selection_changed:
  *
@@ -7072,9 +6640,7 @@ file_changed_callback (NautilusFile *file,
         NautilusFilesView *view = NAUTILUS_FILES_VIEW (callback_data);
 
         schedule_changes (view);
-
         schedule_update_context_menus (view);
-        schedule_update_status (view);
 }
 
 /**
@@ -7102,8 +6668,6 @@ load_directory (NautilusFilesView *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.
@@ -8183,17 +7747,6 @@ nautilus_files_view_init (NautilusFilesView *view)
         gtk_overlay_add_overlay (GTK_OVERLAY (view->details->overlay), 
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->details->overlay), 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;
 
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index 4fb1c52..0090630 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -292,8 +292,6 @@ NautilusFilesView *      nautilus_files_view_new                         (guint
 NautilusWindowSlot *nautilus_files_view_get_nautilus_window_slot         (NautilusFilesView *view);
 char *              nautilus_files_view_get_uri                          (NautilusFilesView *view);
 
-void                nautilus_files_view_display_selection_info           (NautilusFilesView *view);
-
 GdkAtom                    nautilus_files_view_get_copied_files_atom     (NautilusFilesView *view);
 
 /* Wrappers for signal emitters. These are normally called


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]