[PATCH] Use labels instead percentages for zoom levels



Now that Nautilus is using fixes sizes for zoom levels/icon sizes[1],
what about use strings instead percentage to describe the current zoom
level? Please also note the the percentages listed in Preferences dialog
don't respect actual sizes...

Here is a patch to perform this change:

        33%	-->	Extra small
        50%		Small
        67%		Medium
        100%		Normal
        150%		Large
        200%		Extra large
        400%		Enormous
        
Know issue: the width for button in explore toolbar is smaller then
neede. Try set "Extra large" and see

[1] From libnautilus-private/nautilus-icon-info.h

#define NAUTILUS_ICON_SIZE_SMALLEST     16
#define NAUTILUS_ICON_SIZE_SMALLER      24
#define NAUTILUS_ICON_SIZE_SMALL        32
#define NAUTILUS_ICON_SIZE_STANDARD     48
#define NAUTILUS_ICON_SIZE_LARGE        72
#define NAUTILUS_ICON_SIZE_LARGER       96
#define NAUTILUS_ICON_SIZE_LARGEST     192
Index: src/nautilus-zoom-control.c
===================================================================
--- src/nautilus-zoom-control.c	(revisione 13591)
+++ src/nautilus-zoom-control.c	(copia locale)
@@ -256,7 +256,8 @@
 	
 	text = gtk_label_get_text (GTK_LABEL (zoom_control->details->zoom_label));
 	layout = gtk_label_get_layout (GTK_LABEL (zoom_control->details->zoom_label));
-	pango_layout_set_text (layout, "100%", -1);
+	/* Translators, do not translate the part before the | */
+	pango_layout_set_text (layout, Q_("ZoomLevel|Normal"), -1);
 	pango_layout_get_pixel_size (layout, &width, &height);
 	gtk_widget_set_size_request (zoom_control->details->zoom_label, width, height);
 	gtk_label_set_text (GTK_LABEL (zoom_control->details->zoom_label), 
@@ -326,7 +327,8 @@
 			  "popup-menu", G_CALLBACK (zoom_popup_menu),
 			  zoom_control);
 
-	zoom_control->details->zoom_label = gtk_label_new ("100%");
+	/* Translators, do not translate the part before the | */
+	zoom_control->details->zoom_label = gtk_label_new (Q_("ZoomLevel|Normal"));
 	g_signal_connect (zoom_control->details->zoom_label,
 			  "style_set",
 			  G_CALLBACK (label_style_set_callback),
@@ -366,18 +368,16 @@
 static void
 nautilus_zoom_control_redraw (NautilusZoomControl *zoom_control)
 {
-	int percent;
-	char *num_str;
+	char *zoom_level;
 
 	gtk_widget_set_sensitive (zoom_control->details->zoom_in,
 				  nautilus_zoom_control_can_zoom_in (zoom_control));
 	gtk_widget_set_sensitive (zoom_control->details->zoom_out,
 				  nautilus_zoom_control_can_zoom_out (zoom_control));
 
-	percent = floor ((100.0 * nautilus_get_relative_icon_size_for_zoom_level (zoom_control->details->zoom_level)) + .5);
-	num_str = g_strdup_printf ("%d%%", percent);
-	gtk_label_set_text (GTK_LABEL (zoom_control->details->zoom_label), num_str);
-	g_free (num_str);
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (zoom_control->details->zoom_level);
+	gtk_label_set_text (GTK_LABEL (zoom_control->details->zoom_label), zoom_level);
+	g_free (zoom_level);
 }
 	
 /* routines to create and handle the zoom menu */
@@ -426,15 +426,13 @@
 	GtkWidget *menu_item;
 	char *item_text;
 	GSList *radio_item_group;
-	int percent;
 	
 	/* Set flag so that callback isn't activated when set_active called
 	 * to set toggle state of other radio items.
 	 */
 	zoom_control->details->marking_menu_items = TRUE;
 
-	percent = floor ((100.0 * nautilus_get_relative_icon_size_for_zoom_level (zoom_level)) + .5);
-	item_text = g_strdup_printf ("%d%%", percent);
+	item_text = nautilus_get_string_icon_size_for_zoom_level (zoom_level);
 
 	radio_item_group = previous_radio_item == NULL
 		? NULL
Index: src/nautilus-file-management-properties.glade
===================================================================
--- src/nautilus-file-management-properties.glade	(revisione 13591)
+++ src/nautilus-file-management-properties.glade	(copia locale)
@@ -381,13 +381,7 @@
 			      <child>
 				<widget class="GtkComboBox" id="icon_view_zoom_combobox">
 				  <property name="visible">True</property>
-				  <property name="items" translatable="yes">25%
-50%
-75%
-100%
-150%
-200%
-400%</property>
+				  <property name="items" translatable="yes"></property>
 				  <property name="add_tearoffs">False</property>
 				  <property name="focus_on_click">True</property>
 				</widget>
@@ -543,13 +537,7 @@
 			      <child>
 				<widget class="GtkComboBox" id="list_view_zoom_combobox">
 				  <property name="visible">True</property>
-				  <property name="items" translatable="yes">25%
-50%
-75%
-100%
-150%
-200%
-400%</property>
+				  <property name="items" translatable="yes"></property>
 				  <property name="add_tearoffs">False</property>
 				  <property name="focus_on_click">True</property>
 				</widget>
Index: src/nautilus-file-management-properties.c
===================================================================
--- src/nautilus-file-management-properties.c	(revisione 13591)
+++ src/nautilus-file-management-properties.c	(copia locale)
@@ -48,6 +48,7 @@
 #include <libnautilus-private/nautilus-column-chooser.h>
 #include <libnautilus-private/nautilus-column-utilities.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
+#include <libnautilus-private/nautilus-icon-info.h>
 #include <libnautilus-private/nautilus-module.h>
 
 /* string enum preferences */
@@ -442,6 +443,81 @@
 }
 
 static void
+create_icon_zoom_level_menu (GladeXML *xml_dialog)
+{
+	GtkWidget *combo_box;
+	gchar *zoom_level;
+	combo_box = glade_xml_get_widget (xml_dialog,
+					NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALLEST);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALLER);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALL);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_STANDARD);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGE);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGER);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGEST);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+}
+
+
+static void
+create_list_zoom_level_menu (GladeXML *xml_dialog)
+{
+	GtkWidget *combo_box;
+	gchar *zoom_level;
+	combo_box = glade_xml_get_widget (xml_dialog,
+					NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALLEST);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALLER);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_SMALL);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_STANDARD);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGE);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGER);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+
+	zoom_level = nautilus_get_string_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_LARGEST);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), zoom_level);
+	g_free (zoom_level);
+}
+
+static void
 create_date_format_menu (GladeXML *xml_dialog)
 {
 	GtkWidget *combo_box;
@@ -538,6 +614,10 @@
 	nautilus_file_management_properties_size_group_create (xml_dialog,
 							       "preview_label",
 							       5);
+	create_icon_zoom_level_menu (xml_dialog);
+
+	create_list_zoom_level_menu (xml_dialog);
+
 	create_date_format_menu (xml_dialog);
 
 	/* setup preferences */
Index: libnautilus-private/nautilus-icon-info.c
===================================================================
--- libnautilus-private/nautilus-icon-info.c	(revisione 13591)
+++ libnautilus-private/nautilus-icon-info.c	(copia locale)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include "nautilus-icon-info.h"
 #include "nautilus-default-file-icon.h"
+#include <glib/gi18n.h>
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkiconfactory.h>
 #include <gio/gio.h>
@@ -579,6 +580,28 @@
 	return (float)nautilus_get_icon_size_for_zoom_level (zoom_level) / NAUTILUS_ICON_SIZE_STANDARD;
 }
 
+char *
+nautilus_get_string_icon_size_for_zoom_level (NautilusZoomLevel  zoom_level)
+{
+	switch (zoom_level) {
+	case NAUTILUS_ZOOM_LEVEL_SMALLEST:
+		return g_strdup (Q_("ZoomLevel|Extra small"));
+	case NAUTILUS_ZOOM_LEVEL_SMALLER:
+		return g_strdup (Q_("ZoomLevel|Small"));
+	case NAUTILUS_ZOOM_LEVEL_SMALL:
+		return g_strdup (Q_("ZoomLevel|Medium"));
+	case NAUTILUS_ZOOM_LEVEL_STANDARD:
+		return g_strdup (Q_("ZoomLevel|Normal"));
+	case NAUTILUS_ZOOM_LEVEL_LARGE:
+		return g_strdup (Q_("ZoomLevel|Large"));
+	case NAUTILUS_ZOOM_LEVEL_LARGER:
+		return g_strdup (Q_("ZoomLevel|Extra large"));
+	case NAUTILUS_ZOOM_LEVEL_LARGEST:
+		return g_strdup (Q_("ZoomLevel|Enormous"));
+	}
+	g_return_val_if_reached (g_strdup (Q_("ZoomLevel|Normal")));
+}
+
 guint
 nautilus_icon_get_larger_icon_size (guint size)
 {
Index: libnautilus-private/nautilus-icon-info.h
===================================================================
--- libnautilus-private/nautilus-icon-info.h	(revisione 13591)
+++ libnautilus-private/nautilus-icon-info.h	(copia locale)
@@ -75,6 +75,7 @@
 /* Relationship between zoom levels and icons sizes. */
 guint nautilus_get_icon_size_for_zoom_level          (NautilusZoomLevel  zoom_level);
 float nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel  zoom_level);
+char *nautilus_get_string_icon_size_for_zoom_level   (NautilusZoomLevel  zoom_level);
 
 guint nautilus_icon_get_larger_icon_size             (guint              size);
 guint nautilus_icon_get_smaller_icon_size            (guint              size);


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