[patch] change calculation of font size in list view / zoom levels discussion



I'm attaching a patch that changes the way nautilus calculates the font
size in the list view. Instead of simply using pango scale-factors,
which don't have the same scaling interval as nautilus scale-factors, we
now let pango calculate the height in pixels of the current font, and
then adjust the size of that font to match the height of the icon.

This has some merits:
- nautilus no longer gets confused over default zoom levels (#98634)
- fonts scale as much as the icons do
- we no longer depend on the default application font-size to match with
the default zoom level; changing that size no longer has any impact on
the size of the font in the list view. Users that want larger text can
simply choose a larger zoom level. (addition to the fix for #105520)

This only affects font sizes in the list view.

The font size in the default zoom level (50%) stays the same (on my
machine...); we're always using about 70% of the available vertical
space.
Screenshots of nautilus with the patch applied:
http://terborgh.demon.nl/~marten/after-50.png
http://terborgh.demon.nl/~marten/after-75.png

Another thing: I think the icon size associated with each zoom-level
needs rethinking. Currently, these sizes only make sense in the icon
view - the icons are two times too large for the list view. This
screenshot illustrates this:
http://terborgh.demon.nl/~marten/oversize.png
I think we should introduce a new zoom-level between 50% and 25%, get
rid of the 200% and 400% and maybe the 100% zoom levels and rename the
whole thing so that 50% becomes 100%, 25% becomes 50% and so on. This,
of course, only for the list view. The zoom levels for the icon view are
about right, altough the 400% and 25% zoom levels don't look very useful
to me... Is anybody actually using them?

Changelog-entry:

	* src/file-manager/fm-list-view.c (fm_list_view_scale_font_size):
	Base list view font size on icon size, fixes #98634, 
	fixes #105520 again, but nicer :-)

	Patch from Marten ter Borgh <marten terborgh demon nl>



Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.198
diff -c -r1.198 fm-list-view.c
*** src/file-manager/fm-list-view.c	28 Mar 2003 11:28:39 -0000	1.198
--- src/file-manager/fm-list-view.c	30 Mar 2003 11:24:57 -0000
***************
*** 999,1037 ****
  			      NautilusZoomLevel new_level,
  			      gboolean update_size_table)
  {
! 	static gboolean first_time = TRUE;
! 	static double pango_scale[7];
! 	int default_zoom_level, i;
! 
  	g_return_if_fail (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST &&
  			  new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST);
  
! 	if (update_size_table || first_time) {
! 		first_time = FALSE;
  
! 		default_zoom_level = get_default_zoom_level ();
  
! 		pango_scale[default_zoom_level] = PANGO_SCALE_MEDIUM;
! 		for (i = default_zoom_level; i > NAUTILUS_ZOOM_LEVEL_SMALLEST; i--) {
! 			pango_scale[i - 1] = (1 / 1.2) * pango_scale[i];
! 		}
! 		for (i = default_zoom_level; i < NAUTILUS_ZOOM_LEVEL_LARGEST; i++) {
! 			pango_scale[i + 1] = 1.2 * pango_scale[i];
! 		}
! 	}
! 					 
! 	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
--- 999,1040 ----
  			      NautilusZoomLevel new_level,
  			      gboolean update_size_table)
  {
! 	PangoLayout *pango_layout;
! 	PangoFontDescription *font_description;
! 	int pango_size, pixel_height, pixel_width, icon_size;
! 	float compensation_factor;
! 	
  	g_return_if_fail (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST &&
  			  new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST);
  
! 	icon_size = nautilus_get_icon_size_for_zoom_level(new_level);
! 
! 	pango_layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), NULL);
! 	pango_layout_get_pixel_size (pango_layout, &pixel_width, &pixel_height);
! 	compensation_factor = ((float)icon_size / (float)pixel_height) * 0.7;
! 
! 	font_description = pango_font_description_copy(gtk_widget_get_style (GTK_WIDGET(view))->font_desc);
! 	pango_size = (pango_font_description_get_size (font_description) * compensation_factor);
  
! 	//fonts smaller than 5 points aren't readable
! 	if (pango_size < (PANGO_SCALE * 4.9))
! 	{pango_size = PANGO_SCALE * 5;}
! 			
! 	pango_font_description_set_size(font_description, pango_size);
  
! 	g_object_set(G_OBJECT (view->details->file_name_cell),
! 			"font-desc", font_description, NULL);
! 	g_object_set(G_OBJECT (view->details->size_cell),
! 			"font-desc", font_description, NULL);
! 	g_object_set(G_OBJECT (view->details->type_cell),
! 			"font-desc", font_description, NULL);
! 	g_object_set(G_OBJECT (view->details->date_modified_cell),
! 			"font-desc", font_description, NULL);
! 	
! 	g_free(font_description);
! 	g_free(pango_layout);
! 	
! 	return;
  }
  
  static void


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