summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Grecu <dianagrecu07@gmail.com>2017-05-13 12:16:11 +0300
committerErnestas Kulik <ernestask@gnome.org>2017-06-24 19:05:59 +0300
commitb295aa54469d3fe8fa79c8e07041f20dfe324140 (patch)
tree8f8334dc40265d2705bd4875d1f495758d5a6d12
parentc472551b4f4722fa1b7ecc2c259eeff2d924766d (diff)
downloadnautilus-b295aa54469d3fe8fa79c8e07041f20dfe324140.tar.gz
files-view: disable the reset zoom button by default
The reset zoom button is sensitive even though the zoom percentage is already at 100%. Let the button be inactive if the zoom percentage is already at 100%. https://bugzilla.gnome.org/show_bug.cgi?id=771481
-rw-r--r--src/nautilus-canvas-view.c13
-rw-r--r--src/nautilus-files-view.c12
-rw-r--r--src/nautilus-files-view.h2
-rw-r--r--src/nautilus-list-view.c13
-rw-r--r--src/nautilus-view-icon-controller.c13
5 files changed, 52 insertions, 1 deletions
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 6bc726a75..5b2683b44 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -950,6 +950,18 @@ nautilus_canvas_view_get_zoom_level_percentage (NautilusFilesView *view)
}
static gboolean
+nautilus_canvas_view_is_zoom_level_default (NautilusFilesView *view)
+{
+ guint icon_size;
+ NautilusCanvasZoomLevel zoom_level;
+
+ zoom_level = nautilus_canvas_view_get_zoom_level (view);
+ icon_size = nautilus_canvas_container_get_icon_size_for_zoom_level (zoom_level);
+
+ return icon_size == NAUTILUS_CANVAS_ICON_SIZE_LARGE;
+}
+
+static gboolean
nautilus_canvas_view_is_empty (NautilusFilesView *view)
{
g_assert (NAUTILUS_IS_CANVAS_VIEW (view));
@@ -2015,6 +2027,7 @@ nautilus_canvas_view_class_init (NautilusCanvasViewClass *klass)
nautilus_files_view_class->can_zoom_in = nautilus_canvas_view_can_zoom_in;
nautilus_files_view_class->can_zoom_out = nautilus_canvas_view_can_zoom_out;
nautilus_files_view_class->get_zoom_level_percentage = nautilus_canvas_view_get_zoom_level_percentage;
+ nautilus_files_view_class->is_zoom_level_default = nautilus_canvas_view_is_zoom_level_default;
nautilus_files_view_class->clear = nautilus_canvas_view_clear;
nautilus_files_view_class->end_loading = nautilus_canvas_view_end_loading;
nautilus_files_view_class->file_changed = nautilus_canvas_view_file_changed;
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 89edede36..3d569131a 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -854,6 +854,14 @@ nautilus_files_view_get_zoom_level_percentage (NautilusFilesView *view)
return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_zoom_level_percentage (view);
}
+static gboolean
+nautilus_files_view_is_zoom_level_default (NautilusFilesView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), FALSE);
+
+ return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->is_zoom_level_default (view);
+}
+
gboolean
nautilus_files_view_is_searching (NautilusView *view)
{
@@ -7364,6 +7372,7 @@ real_update_actions_state (NautilusFilesView *view)
GList *selection, *l;
NautilusFile *file;
gint selection_count;
+ gboolean zoom_level_is_default;
gboolean selection_contains_special_link;
gboolean selection_contains_desktop_or_home_dir;
gboolean selection_contains_recent;
@@ -7407,6 +7416,7 @@ real_update_actions_state (NautilusFilesView *view)
(!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
!nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
selection_all_in_trash = all_in_trash (selection);
+ zoom_level_is_default = nautilus_files_view_is_zoom_level_default (view);
is_read_only = nautilus_files_view_is_read_only (view);
can_create_files = nautilus_files_view_supports_creating_files (view);
@@ -7725,7 +7735,7 @@ real_update_actions_state (NautilusFilesView *view)
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"zoom-standard");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- nautilus_files_view_supports_zooming (view));
+ nautilus_files_view_supports_zooming (view) && !zoom_level_is_default);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"zoom-to-level");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index aff0133a7..b38bb33ea 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -170,6 +170,8 @@ struct _NautilusFilesViewClass {
/* The current zoom level as a percentage of the default (0, 1] */
gfloat (* get_zoom_level_percentage) (NautilusFilesView *view);
+ gboolean (*is_zoom_level_default) (NautilusFilesView *view);
+
/* reveal_selection is a function pointer that subclasses may
* override to make sure the selected items are sufficiently
* apparent to the user (e.g., scrolled into view). By default,
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 14a074a05..36c0c08be 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3170,6 +3170,18 @@ nautilus_list_view_get_zoom_level_percentage (NautilusFilesView *view)
return (gfloat) icon_size / NAUTILUS_LIST_ICON_SIZE_STANDARD;
}
+static gboolean
+nautilus_list_view_is_zoom_level_default (NautilusFilesView *view)
+{
+ NautilusListView *list_view;
+ guint icon_size;
+
+ list_view = NAUTILUS_LIST_VIEW (view);
+ icon_size = nautilus_list_model_get_icon_size_for_zoom_level (list_view->details->zoom_level);
+
+ return icon_size == NAUTILUS_LIST_ICON_SIZE_STANDARD;
+}
+
static void
nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view)
{
@@ -3560,6 +3572,7 @@ nautilus_list_view_class_init (NautilusListViewClass *class)
nautilus_files_view_class->can_zoom_in = nautilus_list_view_can_zoom_in;
nautilus_files_view_class->can_zoom_out = nautilus_list_view_can_zoom_out;
nautilus_files_view_class->get_zoom_level_percentage = nautilus_list_view_get_zoom_level_percentage;
+ nautilus_files_view_class->is_zoom_level_default = nautilus_list_view_is_zoom_level_default;
nautilus_files_view_class->click_policy_changed = nautilus_list_view_click_policy_changed;
nautilus_files_view_class->clear = nautilus_list_view_clear;
nautilus_files_view_class->file_changed = nautilus_list_view_file_changed;
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index e7308a2dd..f6199ba13 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -570,6 +570,18 @@ real_get_zoom_level_percentage (NautilusFilesView *files_view)
}
static gboolean
+real_is_zoom_level_default (NautilusFilesView *files_view)
+{
+ NautilusViewIconController *self;
+ guint icon_size;
+
+ self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+ icon_size = get_icon_size_for_zoom_level (self->zoom_level);
+
+ return icon_size == NAUTILUS_CANVAS_ICON_SIZE_LARGE;
+}
+
+static gboolean
real_can_zoom_in (NautilusFilesView *files_view)
{
return TRUE;
@@ -909,6 +921,7 @@ nautilus_view_icon_controller_class_init (NautilusViewIconControllerClass *klass
files_view_class->select_first = real_select_first;
files_view_class->restore_standard_zoom_level = real_restore_standard_zoom_level;
files_view_class->get_zoom_level_percentage = real_get_zoom_level_percentage;
+ files_view_class->is_zoom_level_default = real_is_zoom_level_default;
files_view_class->compute_rename_popover_pointing_to = real_compute_rename_popover_pointing_to;
}