summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2016-03-22 13:49:49 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2016-11-27 17:36:59 +0100
commit0954a426232342f6a9e89647bd5639b99b1bc5f8 (patch)
tree1948998cf84caaabc4f0ad2d24f11a9b233c9d17
parent765eb7d38c3c464d28f3b88afcd9ec688b5da4b0 (diff)
downloadnautilus-wip/gbsneto/actionbar.tar.gz
files-view: remove the floating barwip/gbsneto/actionbar
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.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/nautilus-files-view.c501
-rw-r--r--src/nautilus-files-view.h2
-rw-r--r--src/nautilus-floating-bar.c605
-rw-r--r--src/nautilus-floating-bar.h80
5 files changed, 0 insertions, 1190 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a3a5e146b..113c4a41d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -164,8 +164,6 @@ nautilus_no_main_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 20aaca540..26685cf96 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -35,7 +35,6 @@
#endif
#include "nautilus-error-reporting.h"
#include "nautilus-file-undo-manager.h"
-#include "nautilus-floating-bar.h"
#include "nautilus-list-view.h"
#include "nautilus-canvas-view.h"
#include "nautilus-mime-actions.h"
@@ -126,9 +125,6 @@
#define SHORTCUTS_PATH "/nautilus/scripts-accels"
-/* Delay to show the Loading... floating bar */
-#define FLOATING_BAR_LOADING_DELAY 200 /* ms */
-
#define MIN_COMMON_FILENAME_PREFIX_LENGTH 4
@@ -192,7 +188,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;
@@ -262,11 +257,6 @@ struct NautilusFilesViewDetails
GtkWidget *trash_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;
-
/* Toolbar menu */
NautilusToolbarMenuSections *toolbar_menu_sections;
GtkWidget *sort_menu;
@@ -305,8 +295,6 @@ static void open_one_in_new_window (gpointer data,
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);
@@ -361,195 +349,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);
- nautilus_floating_bar_remove_hover_timeout (NAUTILUS_FLOATING_BAR (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)
{
@@ -2989,7 +2788,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)
{
@@ -3003,18 +2801,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,
@@ -3023,8 +2809,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 (),
@@ -3068,218 +2852,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)
@@ -3380,9 +2952,7 @@ done_loading (NautilusFilesView *view,
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);
@@ -3437,7 +3007,6 @@ done_loading (NautilusFilesView *view,
nautilus_files_view_reveal_selection (view);
}
}
- nautilus_files_view_display_selection_info (view);
}
view->details->loading = FALSE;
@@ -3999,7 +3568,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");
g_object_unref (G_OBJECT (view));
@@ -4224,9 +3792,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);
}
@@ -4251,9 +3816,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.
*/
@@ -4278,8 +3840,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);
}
@@ -7862,52 +7422,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:
*
@@ -7963,9 +7477,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);
}
/**
@@ -7993,8 +7505,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.
@@ -9160,17 +8670,6 @@ nautilus_files_view_init (NautilusFilesView *view)
TRUE);
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 70dcb2de8..3a986f27d 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -271,8 +271,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);
-
/* Wrappers for signal emitters. These are normally called
* only by NautilusFilesView itself. They have corresponding signals
* that observers might want to connect with.
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
deleted file mode 100644
index 2a6a2c5cc..000000000
--- a/src/nautilus-floating-bar.c
+++ /dev/null
@@ -1,605 +0,0 @@
-/* Nautilus - Floating status bar.
- *
- * Copyright (C) 2011 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cosimo Cecchi <cosimoc@redhat.com>
- *
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include "nautilus-floating-bar.h"
-
-#define HOVER_HIDE_TIMEOUT_INTERVAL 100
-
-struct _NautilusFloatingBarDetails
-{
- gchar *primary_label;
- gchar *details_label;
-
- GtkWidget *primary_label_widget;
- GtkWidget *details_label_widget;
- GtkWidget *spinner;
- gboolean show_spinner;
- gboolean is_interactive;
- guint hover_timeout_id;
-};
-
-enum
-{
- PROP_PRIMARY_LABEL = 1,
- PROP_DETAILS_LABEL,
- PROP_SHOW_SPINNER,
- NUM_PROPERTIES
-};
-
-enum
-{
- ACTION,
- NUM_SIGNALS
-};
-
-static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
-static guint signals[NUM_SIGNALS] = { 0, };
-
-G_DEFINE_TYPE (NautilusFloatingBar, nautilus_floating_bar,
- GTK_TYPE_BOX);
-
-static void
-action_button_clicked_cb (GtkButton *button,
- NautilusFloatingBar *self)
-{
- gint action_id;
-
- action_id = GPOINTER_TO_INT
- (g_object_get_data (G_OBJECT (button), "action-id"));
-
- g_signal_emit (self, signals[ACTION], 0, action_id);
-}
-
-static void
-nautilus_floating_bar_finalize (GObject *obj)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
-
- nautilus_floating_bar_remove_hover_timeout (self);
- g_free (self->priv->primary_label);
- g_free (self->priv->details_label);
-
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
-}
-
-static void
-nautilus_floating_bar_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id)
- {
- case PROP_PRIMARY_LABEL:
- {
- g_value_set_string (value, self->priv->primary_label);
- }
- break;
-
- case PROP_DETAILS_LABEL:
- {
- g_value_set_string (value, self->priv->details_label);
- }
- break;
-
- case PROP_SHOW_SPINNER:
- {
- g_value_set_boolean (value, self->priv->show_spinner);
- }
- break;
-
- default:
- {
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
- break;
- }
-}
-
-static void
-nautilus_floating_bar_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
-
- switch (property_id)
- {
- case PROP_PRIMARY_LABEL:
- {
- nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
- }
- break;
-
- case PROP_DETAILS_LABEL:
- {
- nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
- }
- break;
-
- case PROP_SHOW_SPINNER:
- {
- nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
- }
- break;
-
- default:
- {
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
- break;
- }
-}
-
-static void
-update_labels (NautilusFloatingBar *self)
-{
- gboolean primary_visible, details_visible;
-
- primary_visible = (self->priv->primary_label != NULL) &&
- (strlen (self->priv->primary_label) > 0);
- details_visible = (self->priv->details_label != NULL) &&
- (strlen (self->priv->details_label) > 0);
-
- gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
- self->priv->primary_label);
- gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
-
- gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
- self->priv->details_label);
- gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
-}
-
-void
-nautilus_floating_bar_remove_hover_timeout (NautilusFloatingBar *self)
-{
- if (self->priv->hover_timeout_id != 0)
- {
- g_source_remove (self->priv->hover_timeout_id);
- self->priv->hover_timeout_id = 0;
- }
-}
-
-typedef struct
-{
- GtkWidget *overlay;
- GtkWidget *floating_bar;
- GdkDevice *device;
- gint y_down_limit;
- gint y_upper_limit;
-} CheckPointerData;
-
-static void
-check_pointer_data_free (gpointer data)
-{
- g_slice_free (CheckPointerData, data);
-}
-
-static gboolean
-check_pointer_timeout (gpointer user_data)
-{
- CheckPointerData *data = user_data;
- gint pointer_y = -1;
-
- gdk_window_get_device_position (gtk_widget_get_window (data->overlay), data->device,
- NULL, &pointer_y, NULL);
-
- if (pointer_y == -1 || pointer_y < data->y_down_limit || pointer_y > data->y_upper_limit)
- {
- gtk_widget_show (data->floating_bar);
- NAUTILUS_FLOATING_BAR (data->floating_bar)->priv->hover_timeout_id = 0;
-
- return G_SOURCE_REMOVE;
- }
- else
- {
- gtk_widget_hide (data->floating_bar);
- }
-
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean
-overlay_enter_notify_cb (GtkWidget *parent,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- GtkWidget *widget = user_data;
- CheckPointerData *data;
- gint y_pos;
-
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
-
- if (self->priv->hover_timeout_id != 0)
- {
- g_source_remove (self->priv->hover_timeout_id);
- }
-
- if (event->window != gtk_widget_get_window (widget))
- {
- return GDK_EVENT_PROPAGATE;
- }
-
- if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive)
- {
- return GDK_EVENT_PROPAGATE;
- }
-
- gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);
-
- data = g_slice_new (CheckPointerData);
- data->overlay = parent;
- data->floating_bar = widget;
- data->device = gdk_event_get_device ((GdkEvent *) event);
- data->y_down_limit = y_pos;
- data->y_upper_limit = y_pos + gtk_widget_get_allocated_height (widget);
-
- self->priv->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, HOVER_HIDE_TIMEOUT_INTERVAL,
- check_pointer_timeout, data,
- check_pointer_data_free);
-
- g_source_set_name_by_id (self->priv->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");
-
- return GDK_EVENT_STOP;
-}
-
-static void
-nautilus_floating_bar_parent_set (GtkWidget *widget,
- GtkWidget *old_parent)
-{
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (widget);
-
- if (old_parent != NULL)
- {
- g_signal_handlers_disconnect_by_func (old_parent,
- overlay_enter_notify_cb, widget);
- }
-
- if (parent != NULL)
- {
- g_signal_connect (parent, "enter-notify-event",
- G_CALLBACK (overlay_enter_notify_cb), widget);
- }
-}
-
-static void
-get_padding_and_border (GtkWidget *widget,
- GtkBorder *border)
-{
- GtkStyleContext *context;
- GtkStateFlags state;
- GtkBorder tmp;
-
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
-
- gtk_style_context_get_padding (context, state, border);
- gtk_style_context_get_border (context, state, &tmp);
- border->top += tmp.top;
- border->right += tmp.right;
- border->bottom += tmp.bottom;
- border->left += tmp.left;
-}
-
-static void
-nautilus_floating_bar_get_preferred_width (GtkWidget *widget,
- gint *minimum_size,
- gint *natural_size)
-{
- GtkBorder border;
-
- get_padding_and_border (widget, &border);
-
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_width (widget,
- minimum_size,
- natural_size);
-
- *minimum_size += border.left + border.right;
- *natural_size += border.left + border.right;
-}
-
-static void
-nautilus_floating_bar_get_preferred_width_for_height (GtkWidget *widget,
- gint height,
- gint *minimum_size,
- gint *natural_size)
-{
- GtkBorder border;
-
- get_padding_and_border (widget, &border);
-
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_width_for_height (widget,
- height,
- minimum_size,
- natural_size);
-
- *minimum_size += border.left + border.right;
- *natural_size += border.left + border.right;
-}
-
-static void
-nautilus_floating_bar_get_preferred_height (GtkWidget *widget,
- gint *minimum_size,
- gint *natural_size)
-{
- GtkBorder border;
-
- get_padding_and_border (widget, &border);
-
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_height (widget,
- minimum_size,
- natural_size);
-
- *minimum_size += border.top + border.bottom;
- *natural_size += border.top + border.bottom;
-}
-
-static void
-nautilus_floating_bar_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum_size,
- gint *natural_size)
-{
- GtkBorder border;
-
- get_padding_and_border (widget, &border);
-
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->get_preferred_height_for_width (widget,
- width,
- minimum_size,
- natural_size);
-
- *minimum_size += border.top + border.bottom;
- *natural_size += border.top + border.bottom;
-}
-
-static void
-nautilus_floating_bar_constructed (GObject *obj)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
- GtkWidget *w, *box, *labels_box;
-
- G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
-
- box = GTK_WIDGET (obj);
-
- w = gtk_spinner_new ();
- gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
- gtk_widget_set_visible (w, self->priv->show_spinner);
- gtk_spinner_start (GTK_SPINNER (w));
- self->priv->spinner = w;
-
- gtk_widget_set_size_request (w, 16, 16);
- gtk_widget_set_margin_start (w, 8);
-
- labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
- g_object_set (labels_box,
- "margin-top", 2,
- "margin-bottom", 2,
- "margin-start", 12,
- "margin-end", 12,
- NULL);
- gtk_widget_show (labels_box);
-
- w = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->primary_label_widget = w;
- gtk_widget_show (w);
-
- w = gtk_label_new (NULL);
- gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
- gtk_container_add (GTK_CONTAINER (labels_box), w);
- self->priv->details_label_widget = w;
- gtk_widget_show (w);
-}
-
-static void
-nautilus_floating_bar_init (NautilusFloatingBar *self)
-{
- GtkStyleContext *context;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_FLOATING_BAR,
- NautilusFloatingBarDetails);
-
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "floating-bar");
-}
-
-static void
-nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
-{
- GObjectClass *oclass = G_OBJECT_CLASS (klass);
- GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
-
- oclass->constructed = nautilus_floating_bar_constructed;
- oclass->set_property = nautilus_floating_bar_set_property;
- oclass->get_property = nautilus_floating_bar_get_property;
- oclass->finalize = nautilus_floating_bar_finalize;
-
- wclass->get_preferred_width = nautilus_floating_bar_get_preferred_width;
- wclass->get_preferred_width_for_height = nautilus_floating_bar_get_preferred_width_for_height;
- wclass->get_preferred_height = nautilus_floating_bar_get_preferred_height;
- wclass->get_preferred_height_for_width = nautilus_floating_bar_get_preferred_height_for_width;
- wclass->parent_set = nautilus_floating_bar_parent_set;
-
- properties[PROP_PRIMARY_LABEL] =
- g_param_spec_string ("primary-label",
- "Bar's primary label",
- "Primary label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_DETAILS_LABEL] =
- g_param_spec_string ("details-label",
- "Bar's details label",
- "Details label displayed by the bar",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_SHOW_SPINNER] =
- g_param_spec_boolean ("show-spinner",
- "Show spinner",
- "Whether a spinner should be shown in the floating bar",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- signals[ACTION] =
- g_signal_new ("action",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- g_type_class_add_private (klass, sizeof (NautilusFloatingBarDetails));
- g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
-}
-
-void
-nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
- const gchar *label)
-{
- if (g_strcmp0 (self->priv->primary_label, label) != 0)
- {
- g_free (self->priv->primary_label);
- self->priv->primary_label = g_strdup (label);
-
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
-
- update_labels (self);
- }
-}
-
-void
-nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
- const gchar *label)
-{
- if (g_strcmp0 (self->priv->details_label, label) != 0)
- {
- g_free (self->priv->details_label);
- self->priv->details_label = g_strdup (label);
-
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
-
- update_labels (self);
- }
-}
-
-void
-nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
- const gchar *primary_label,
- const gchar *details_label)
-{
- nautilus_floating_bar_set_primary_label (self, primary_label);
- nautilus_floating_bar_set_details_label (self, details_label);
-}
-
-void
-nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
- gboolean show_spinner)
-{
- if (self->priv->show_spinner != show_spinner)
- {
- self->priv->show_spinner = show_spinner;
- gtk_widget_set_visible (self->priv->spinner,
- show_spinner);
-
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SPINNER]);
- }
-}
-
-GtkWidget *
-nautilus_floating_bar_new (const gchar *primary_label,
- const gchar *details_label,
- gboolean show_spinner)
-{
- return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
- "primary-label", primary_label,
- "details-label", details_label,
- "show-spinner", show_spinner,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "spacing", 8,
- NULL);
-}
-
-void
-nautilus_floating_bar_add_action (NautilusFloatingBar *self,
- const gchar *icon_name,
- gint action_id)
-{
- GtkWidget *button;
- GtkStyleContext *context;
-
- button = gtk_button_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- context = gtk_widget_get_style_context (button);
- gtk_style_context_add_class (context, "circular");
- gtk_style_context_add_class (context, "flat");
- gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- g_object_set_data (G_OBJECT (button), "action-id",
- GINT_TO_POINTER (action_id));
-
- g_signal_connect (button, "clicked",
- G_CALLBACK (action_button_clicked_cb), self);
-
- self->priv->is_interactive = TRUE;
-}
-
-void
-nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
-{
- GtkWidget *widget;
- GList *children, *l;
- gpointer data;
-
- children = gtk_container_get_children (GTK_CONTAINER (self));
- l = children;
-
- while (l != NULL)
- {
- widget = l->data;
- data = g_object_get_data (G_OBJECT (widget), "action-id");
- l = l->next;
-
- if (data != NULL)
- {
- /* destroy this */
- gtk_widget_destroy (widget);
- }
- }
-
- g_list_free (children);
-
- self->priv->is_interactive = FALSE;
-}
diff --git a/src/nautilus-floating-bar.h b/src/nautilus-floating-bar.h
deleted file mode 100644
index ebe8e14d5..000000000
--- a/src/nautilus-floating-bar.h
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/* Nautilus - Floating status bar.
- *
- * Copyright (C) 2011 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cosimo Cecchi <cosimoc@redhat.com>
- *
- */
-
-#ifndef __NAUTILUS_FLOATING_BAR_H__
-#define __NAUTILUS_FLOATING_BAR_H__
-
-#include <gtk/gtk.h>
-
-#define NAUTILUS_FLOATING_BAR_ACTION_ID_STOP 1
-
-#define NAUTILUS_TYPE_FLOATING_BAR nautilus_floating_bar_get_type()
-#define NAUTILUS_FLOATING_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_FLOATING_BAR, NautilusFloatingBar))
-#define NAUTILUS_FLOATING_BAR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_FLOATING_BAR, NautilusFloatingBarClass))
-#define NAUTILUS_IS_FLOATING_BAR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_FLOATING_BAR))
-#define NAUTILUS_IS_FLOATING_BAR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_FLOATING_BAR))
-#define NAUTILUS_FLOATING_BAR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_FLOATING_BAR, NautilusFloatingBarClass))
-
-typedef struct _NautilusFloatingBar NautilusFloatingBar;
-typedef struct _NautilusFloatingBarClass NautilusFloatingBarClass;
-typedef struct _NautilusFloatingBarDetails NautilusFloatingBarDetails;
-
-struct _NautilusFloatingBar {
- GtkBox parent;
- NautilusFloatingBarDetails *priv;
-};
-
-struct _NautilusFloatingBarClass {
- GtkBoxClass parent_class;
-};
-
-/* GObject */
-GType nautilus_floating_bar_get_type (void);
-
-GtkWidget * nautilus_floating_bar_new (const gchar *primary_label,
- const gchar *details_label,
- gboolean show_spinner);
-
-void nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
- const gchar *label);
-void nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
- const gchar *label);
-void nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
- const gchar *primary,
- const gchar *detail);
-void nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
- gboolean show_spinner);
-
-void nautilus_floating_bar_add_action (NautilusFloatingBar *self,
- const gchar *icon_name,
- gint action_id);
-void nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self);
-
-void nautilus_floating_bar_remove_hover_timeout (NautilusFloatingBar *self);
-
-#endif /* __NAUTILUS_FLOATING_BAR_H__ */
-