After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771481 - Let the reset zoom button be inactive when zoom is 100%
Let the reset zoom button be inactive when zoom is 100%
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Views: All
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-09-15 10:24 UTC by Mohammed Sadiq
Modified: 2017-06-24 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
files-view: disable the reset zoom button by default (2.45 KB, patch)
2017-05-13 09:47 UTC, Diana Grecu
none Details | Review
files-view: disable the reset zoom button by default (2.44 KB, patch)
2017-05-20 18:06 UTC, Diana Grecu
committed Details | Review
files-view: update vfunc comment (1.11 KB, patch)
2017-06-24 15:11 UTC, Ernestas Kulik
committed Details | Review

Description Mohammed Sadiq 2016-09-15 10:24:32 UTC
Let the reset zoom button (the button that shows zoom level, like 100%, in menu[F10]) be inactive, if the zoom level is already 100%.
Comment 1 Diana Grecu 2017-05-13 09:47:37 UTC
Created attachment 351770 [details] [review]
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%.

Bugzilla link:
Comment 2 Ernestas Kulik 2017-05-13 10:16:41 UTC
Review of attachment 351770 [details] [review]:

Thanks for the patch!

I’d do this differently, though, to avoid float comparisons like that. Not sure offhand how exactly.

::: src/nautilus-files-view.c
@@ +7410,3 @@
     selection_all_in_trash = all_in_trash (selection);
 
+    is_default_zoom_level = nautilus_files_view_get_zoom_level_percentage(view) == 1;

Equality comparison between a float and a constant is a bad idea.

@@ +7411,3 @@
 
+    is_default_zoom_level = nautilus_files_view_get_zoom_level_percentage(view) == 1;
+

Not sure if leaving empty space here is necessary.

@@ +7730,3 @@
     g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                 nautilus_files_view_supports_zooming (view) && ! is_default_zoom_level);
+                                 // nautilus_files_view_supports_zooming (view));

You’ve left a comment there.
Comment 3 Diana Grecu 2017-05-20 18:06:30 UTC
Created attachment 352237 [details] [review]
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%.

Bugzilla link:
Comment 4 Ernestas Kulik 2017-05-21 08:56:39 UTC
Review of attachment 352237 [details] [review]:

The “Bugzilla link: ” part in the commit message is unnecessary.

::: src/nautilus-files-view.c
@@ +2544,3 @@
 {
     nautilus_files_view_restore_standard_zoom_level (user_data);
+    g_simple_action_set_enabled (action, FALSE);

I cannot see why this would be needed. Can you explain?

@@ +7409,3 @@
                               !nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
     selection_all_in_trash = all_in_trash (selection);
+    is_default_zoom_level = nautilus_files_view_get_zoom_level_percentage (view) == 1.0;

Although this does not address my previous concerns, I think this should be fine, as, to my understanding, dividing two integers (which are exactly representable in binary) will be exactly representable in binary if the result is, in fact, integral (which it is, if the zoom level is standard).

Do have in mind that you are now promoting the return value to a double (which is arguably worse), so use the “f” suffix for the constant.

@@ +7728,3 @@
                                          "zoom-standard");
     g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                 nautilus_files_view_supports_zooming (view) && ! is_default_zoom_level);

The space after the negation operator is unnecessary.
Comment 5 Ernestas Kulik 2017-06-24 15:11:15 UTC
Created attachment 354391 [details] [review]
files-view: update vfunc comment

get_zoom_level_percentage() does not return a value in the specified
range, as there are zoom levels beyond 100%.
Comment 6 Ernestas Kulik 2017-06-24 16:06:50 UTC
Attachment 352237 [details] pushed as b295aa5 - files-view: disable the reset zoom button by default
Comment 7 Ernestas Kulik 2017-06-24 16:09:22 UTC
Attachment 354391 [details] pushed as 0119b67 - files-view: update vfunc comment