Re: desktop font + PATCH for 82565



> Not yet. I probably wont have time until Saturday, there's gonna be a 6
> hour power outage tomorrow.

I'm back online and here's the updated patch.

I've fixed everything as David indicated. I'm still using the auto value
in the list view since it's used all over the place there by other
functions too, so I assume it's ok. (Although I guess that could mean it
never was done right in the first place).

Anyway, patch is attached and works well for me. I hope this isn't gonna
cause breakage this late in the game.

- Frank
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/31 23:20:11
@@ -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-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/31 23:20:11
@@ -80,6 +80,9 @@ static GList *              fm_list_view
 static void                 fm_list_view_set_zoom_level        (FMListView *view,
 								NautilusZoomLevel new_level,
 								gboolean always_set_level);
+static void			    fm_list_view_scale_font_size 	   (FMListView *view, 
+								NautilusZoomLevel new_level,
+								gboolean update_size_table);
 
 GNOME_CLASS_BOILERPLATE (FMListView, fm_list_view,
 			 FMDirectoryView, FM_TYPE_DIRECTORY_VIEW)
@@ -423,6 +426,15 @@ set_zoom_level_from_metadata_and_prefere
 							    NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL, 
 							    default_zoom_level_auto_value);
 		fm_list_view_set_zoom_level (list_view, level, TRUE);
+		
+		/* reset the font size table for the new default zoom level */
+		fm_list_view_scale_font_size (list_view, level, TRUE);
+		
+		/* FIXME - we have to schedule a draw here so the tree view
+		 * updates its fonts. Otherwise the fonts only get updated
+		 * when the user moves the mouse over a row. Tree view bug?
+		 */
+		gtk_widget_queue_draw (GTK_WIDGET (list_view));
 	}
 }
 
@@ -553,17 +565,117 @@ fm_list_view_reset_to_defaults (FMDirect
 }
 
 static void
+fm_list_view_scale_font_size (FMListView *view, 
+					NautilusZoomLevel new_level,
+					gboolean update_size_table)
+{
+	static gboolean first_time = TRUE;
+	static double pango_scale[7];	
+
+	if (update_size_table || first_time) {
+		first_time = FALSE;
+	
+		switch (default_zoom_level_auto_value)
+		{
+		case NAUTILUS_ZOOM_LEVEL_LARGEST:
+			pango_scale[0] = (1 / 1.2) * (1 / 1.2) * PANGO_SCALE_XX_SMALL;
+			pango_scale[1] = (1 / 1.2) * 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] = (1 / 1.2) * 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.2 * 1.2 * 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.2 * 1.2 * 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.2 * 1.2 * PANGO_SCALE_XX_LARGE;
+			pango_scale[6] = 1.2 * 1.2 * 1.2 * 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)
 {
-	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;
 
@@ -595,18 +707,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, FALSE);
 
 	/* Make all rows the same size. */
 	icon_size = nautilus_get_icon_size_for_zoom_level (new_level);
@@ -843,6 +944,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));
 }
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/31 23:20:11
@@ -959,6 +959,95 @@ 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];
+
+	container = get_icon_container (view);
+	g_assert (container != NULL);
+
+	switch (get_default_zoom_level ())
+	{
+	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 +2101,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 +2220,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));
 }


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