Re: desktop font + PATCH for 82565



> > Whatever, whoever implements it is the man...I'm just some lazy out of
> > school college kid who has too much time on his hands to think about
> > annoying ui issues.
> 
> I'm working on it.

Ok, patch is attached. I took some time tweaking the font sizes for the
different default zoom levels and I think it's pretty good now. Unless
you have a really large/small default zoom with a normal font everything
should be fine.

I'm running it here and it works like a charm for me.

May I commit?

- Frank


PS: how about the default window size patch? Can I commit that too? With
those too in there my two biggest pet peeves would be fixed. :)
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5338
diff -u -p -r1.5338 ChangeLog
--- ChangeLog	2002/05/29 16:49:32	1.5338
+++ ChangeLog	2002/05/30 02:48:55
@@ -1,3 +1,11 @@
+2002-05-29  Frank Worsley  <fworsley shaw ca>
+
+	* src/file-manager/fm-icon-view.c:
+	* src/file-manager/fm-list-view.c:
+	always use user selected font at the default zoom level
+	that way if you run at a lower/higher default zoom you still
+	keep your selected font and don't have a tiny/large font
+
 2002-05-29  Michael Meeks  <michael ximian com>
 
 	* libnautilus-private/nautilus-file.c
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.261
diff -u -p -r1.261 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	2002/05/21 18:24:19	1.261
+++ src/file-manager/fm-icon-view.c	2002/05/30 02:49:10
@@ -959,6 +959,99 @@ fm_icon_view_end_loading (FMDirectoryVie
 	icon_view->details->loading = FALSE;
 }
 
+static void
+fm_icon_view_update_font_size_table (FMIconView *view)
+{
+	NautilusIconContainer *container;
+	int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
+	int default_zoom;
+
+	container = get_icon_container (view);
+	g_assert (container != NULL);
+
+	default_zoom = eel_preferences_get_enum (
+				NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL);
+
+	switch (default_zoom)
+	{
+	case NAUTILUS_ZOOM_LEVEL_LARGEST:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -5 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    = -4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  0 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_LARGER:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  2 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_LARGE:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  4 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_STANDARD:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  4 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_SMALL:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  5 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_SMALLER:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  5 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  5 * PANGO_SCALE;
+		break;
+	case NAUTILUS_ZOOM_LEVEL_SMALLEST:
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  5 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  5 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  6 * PANGO_SCALE;
+		break;
+	default:
+		g_warning ("invalid default list-view zoom level");
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER]  = -3 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL]    = -2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] =  0 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE]    =  2 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER]   =  4 * PANGO_SCALE;
+		font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST]  =  4 * PANGO_SCALE;
+		break;
+	}
+
+	nautilus_icon_container_set_font_size_table (container, font_size_table);
+}
+
 static NautilusZoomLevel
 fm_icon_view_get_zoom_level (FMIconView *view)
 {
@@ -2012,6 +2105,7 @@ default_zoom_level_changed_callback (gpo
 		level = nautilus_file_get_integer_metadata (file, 
 							    NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, 
 							    get_default_zoom_level ());
+		fm_icon_view_update_font_size_table (icon_view);
 		fm_icon_view_set_zoom_level (icon_view, level, TRUE);
 	}
 }
@@ -2130,6 +2224,7 @@ create_icon_container (FMIconView *icon_
 			   GTK_WIDGET (icon_container));
 
 	fm_icon_view_update_click_mode (icon_view);
+	fm_icon_view_update_font_size_table (icon_view);
 
 	gtk_widget_show (GTK_WIDGET (icon_container));
 }
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.174
diff -u -p -r1.174 fm-list-view.c
--- src/file-manager/fm-list-view.c	2002/05/21 09:43:37	1.174
+++ src/file-manager/fm-list-view.c	2002/05/30 02:49:10
@@ -79,7 +79,8 @@ static NautilusZoomLevel        default_
 static GList *              fm_list_view_get_selection         (FMDirectoryView *view);
 static void                 fm_list_view_set_zoom_level        (FMListView *view,
 								NautilusZoomLevel new_level,
-								gboolean always_set_level);
+								gboolean always_set_level,
+								gboolean update_size_table);
 
 GNOME_CLASS_BOILERPLATE (FMListView, fm_list_view,
 			 FMDirectoryView, FM_TYPE_DIRECTORY_VIEW)
@@ -422,7 +423,7 @@ set_zoom_level_from_metadata_and_prefere
 		level = nautilus_file_get_integer_metadata (file,
 							    NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL, 
 							    default_zoom_level_auto_value);
-		fm_list_view_set_zoom_level (list_view, level, TRUE);
+		fm_list_view_set_zoom_level (list_view, level, TRUE, TRUE);
 	}
 }
 
@@ -549,21 +550,125 @@ fm_list_view_reset_to_defaults (FMDirect
 		 fm_list_model_get_sort_column_id_from_sort_type (default_sort_order_auto_value),
 		 default_sort_reversed_auto_value ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
 
-	fm_list_view_set_zoom_level (FM_LIST_VIEW (view), default_zoom_level_auto_value, FALSE);
+	fm_list_view_set_zoom_level (FM_LIST_VIEW (view), default_zoom_level_auto_value, FALSE, FALSE);
 }
 
 static void
+fm_list_view_scale_font_size (FMListView *view, 
+					NautilusZoomLevel new_level,
+					gboolean update_table)
+{
+	static gboolean first_time = TRUE;
+	static double pango_scale[7];	
+	int default_zoom;
+
+	if (update_table || first_time) {
+		first_time = FALSE;
+		default_zoom = eel_preferences_get_enum (
+					NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL);
+	
+		switch (default_zoom)
+		{
+		case NAUTILUS_ZOOM_LEVEL_LARGEST:
+			pango_scale[0] = 0.6 * PANGO_SCALE_XX_SMALL;
+			pango_scale[1] = 0.8 * PANGO_SCALE_XX_SMALL;
+			pango_scale[2] = PANGO_SCALE_XX_SMALL;
+			pango_scale[3] = PANGO_SCALE_X_SMALL;
+			pango_scale[4] = PANGO_SCALE_SMALL;
+			pango_scale[5] = PANGO_SCALE_MEDIUM;
+			pango_scale[6] = PANGO_SCALE_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_LARGER:
+			pango_scale[0] = 0.8 * PANGO_SCALE_XX_SMALL;
+			pango_scale[1] = PANGO_SCALE_XX_SMALL;
+			pango_scale[2] = PANGO_SCALE_X_SMALL;
+			pango_scale[3] = PANGO_SCALE_SMALL;
+			pango_scale[4] = PANGO_SCALE_MEDIUM;
+			pango_scale[5] = PANGO_SCALE_LARGE;
+			pango_scale[6] = PANGO_SCALE_X_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_LARGE:
+			pango_scale[0] = PANGO_SCALE_XX_SMALL;
+			pango_scale[1] = PANGO_SCALE_X_SMALL;
+			pango_scale[2] = PANGO_SCALE_SMALL;
+			pango_scale[3] = PANGO_SCALE_MEDIUM;
+			pango_scale[4] = PANGO_SCALE_LARGE;
+			pango_scale[5] = PANGO_SCALE_X_LARGE;
+			pango_scale[6] = PANGO_SCALE_XX_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_STANDARD:
+			pango_scale[0] = PANGO_SCALE_X_SMALL;
+			pango_scale[1] = PANGO_SCALE_SMALL;
+			pango_scale[2] = PANGO_SCALE_MEDIUM;
+			pango_scale[3] = PANGO_SCALE_LARGE;
+			pango_scale[4] = PANGO_SCALE_X_LARGE;
+			pango_scale[5] = PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.2 * PANGO_SCALE_XX_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_SMALL:
+			pango_scale[0] = PANGO_SCALE_SMALL;
+			pango_scale[1] = PANGO_SCALE_MEDIUM;
+			pango_scale[2] = PANGO_SCALE_LARGE;
+			pango_scale[3] = PANGO_SCALE_X_LARGE;
+			pango_scale[4] = PANGO_SCALE_XX_LARGE;
+			pango_scale[5] = 1.2 * PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.4 * PANGO_SCALE_XX_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_SMALLER:
+			/* From here on down we use PANGO_SCALE_MEDIUM for the
+			 * default zoom. Since the icons are now smaller this 
+			 * looks better at default zoom.
+			 */
+			pango_scale[0] = PANGO_SCALE_SMALL;
+			pango_scale[1] = PANGO_SCALE_MEDIUM;
+			pango_scale[2] = PANGO_SCALE_LARGE;
+			pango_scale[3] = PANGO_SCALE_X_LARGE;
+			pango_scale[4] = PANGO_SCALE_XX_LARGE;
+			pango_scale[5] = 1.2 * PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.4 * PANGO_SCALE_XX_LARGE;
+			break;
+		case NAUTILUS_ZOOM_LEVEL_SMALLEST:
+			pango_scale[0] = PANGO_SCALE_MEDIUM;
+			pango_scale[1] = PANGO_SCALE_LARGE;
+			pango_scale[2] = PANGO_SCALE_X_LARGE;
+			pango_scale[3] = PANGO_SCALE_XX_LARGE;
+			pango_scale[4] = 1.2 * PANGO_SCALE_XX_LARGE;
+			pango_scale[5] = 1.4 * PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.6 * PANGO_SCALE_XX_LARGE;
+			break;
+		default:
+			g_warning ("invalid default list-view zoom level");
+			pango_scale[0] = PANGO_SCALE_X_SMALL;
+			pango_scale[1] = PANGO_SCALE_SMALL;
+			pango_scale[2] = PANGO_SCALE_MEDIUM;
+			pango_scale[3] = PANGO_SCALE_LARGE;
+			pango_scale[4] = PANGO_SCALE_X_LARGE;
+			pango_scale[5] = PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.2 * PANGO_SCALE_XX_LARGE;
+			break;
+		}
+	}
+					 
+	g_object_set (G_OBJECT (view->details->file_name_cell),
+		      "scale", pango_scale[new_level],
+		      NULL);
+	g_object_set (G_OBJECT (view->details->size_cell),
+		      "scale", pango_scale[new_level],
+		      NULL);
+	g_object_set (G_OBJECT (view->details->type_cell),
+		      "scale", pango_scale[new_level],
+		      NULL);
+	g_object_set (G_OBJECT (view->details->date_modified_cell),
+		      "scale", pango_scale[new_level],
+		      NULL);
+}
+
+static void
 fm_list_view_set_zoom_level (FMListView *view,
 			     NautilusZoomLevel new_level,
-			     gboolean always_set_level)
+			     gboolean always_set_level,
+			     gboolean update_size_table)
 {
-	static double pango_scale[7] = { PANGO_SCALE_X_SMALL,
-					 PANGO_SCALE_SMALL,
-					 PANGO_SCALE_MEDIUM,
-					 PANGO_SCALE_LARGE,
-					 PANGO_SCALE_X_LARGE,
-					 PANGO_SCALE_XX_LARGE,
-					 1.2 * PANGO_SCALE_XX_LARGE };
 	int icon_size;
 	int column;
 
@@ -575,6 +680,15 @@ fm_list_view_set_zoom_level (FMListView 
 		if (always_set_level) {
 			fm_directory_view_set_zoom_level (FM_DIRECTORY_VIEW(view), new_level);
 		}
+		if (update_size_table) {
+			fm_list_view_scale_font_size (view, new_level, update_size_table);
+			
+			/* FIXME - if we don't queue a draw here the list view 
+			 * wont update the font sizes until the user moves the
+			 * mouse over a row. 
+			 */
+			gtk_widget_queue_draw (GTK_WIDGET (view));
+		}
 		return;
 	}
 
@@ -595,18 +709,7 @@ fm_list_view_set_zoom_level (FMListView 
 					     NULL);
 
 	/* Scale text. */
-	g_object_set (G_OBJECT (view->details->file_name_cell),
-		      "scale", pango_scale[new_level],
-		      NULL);
-	g_object_set (G_OBJECT (view->details->size_cell),
-		      "scale", pango_scale[new_level],
-		      NULL);
-	g_object_set (G_OBJECT (view->details->type_cell),
-		      "scale", pango_scale[new_level],
-		      NULL);
-	g_object_set (G_OBJECT (view->details->date_modified_cell),
-		      "scale", pango_scale[new_level],
-		      NULL);
+	fm_list_view_scale_font_size (view, new_level, update_size_table);
 
 	/* Make all rows the same size. */
 	icon_size = nautilus_get_icon_size_for_zoom_level (new_level);
@@ -629,7 +732,7 @@ fm_list_view_bump_zoom_level (FMDirector
 
 	if (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST &&
 	    new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST) {
-		fm_list_view_set_zoom_level (list_view, new_level, FALSE);
+		fm_list_view_set_zoom_level (list_view, new_level, FALSE, FALSE);
 	}
 }
 
@@ -642,7 +745,7 @@ fm_list_view_zoom_to_level (FMDirectoryV
 
 	list_view = FM_LIST_VIEW (view);
 
-	fm_list_view_set_zoom_level (list_view, zoom_level, FALSE);
+	fm_list_view_set_zoom_level (list_view, zoom_level, FALSE, FALSE);
 }
 
 static void
@@ -654,7 +757,7 @@ fm_list_view_restore_default_zoom_level 
 
 	list_view = FM_LIST_VIEW (view);
 
-	fm_list_view_set_zoom_level (list_view, default_zoom_level_auto_value, FALSE);
+	fm_list_view_set_zoom_level (list_view, default_zoom_level_auto_value, FALSE, FALSE);
 }
 
 static gboolean 
@@ -843,6 +946,6 @@ fm_list_view_instance_init (FMListView *
 						  list_view, G_OBJECT (list_view));
 
 	click_policy_changed_callback (list_view);
-
+	
 	fm_list_view_sort_directories_first_changed (FM_DIRECTORY_VIEW (list_view));
 }


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