From 0490cd0a75207e656f1615cb456de389fd6b7c7f Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 18 Sep 2008 09:33:20 +0000 Subject: [PATCH] made the font scale factor for the docks configurable in gtkrc. 2008-09-18 Sven Neumann * app/widgets/gimpdock.c: made the font scale factor for the docks configurable in gtkrc. * themes/Default/gtkrc * themes/Small/gtkrc: for documentation purposes, added the default value for GimpDock::font-scale here. Changed all style property names to use the canonical names. svn path=/trunk/; revision=26988 --- ChangeLog | 10 ++++++ app/widgets/gimpdock.c | 72 +++++++++++++++++++++++++----------------- themes/Default/gtkrc | 53 ++++++++++++++++--------------- themes/Small/gtkrc | 61 ++++++++++++++++++----------------- 4 files changed, 112 insertions(+), 84 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9458543921..b4f4c8281e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-09-18 Sven Neumann + + * app/widgets/gimpdock.c: made the font scale factor for the docks + configurable in gtkrc. + + * themes/Default/gtkrc + * themes/Small/gtkrc: for documentation purposes, added the + default value for GimpDock::font-scale here. Changed all style + property names to use the canonical names. + 2008-09-18 Sven Neumann * app/core/gimpdrawable-shadow.c (gimp_drawable_get_shadow_tiles): diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c index 3a4ee08959..1899573492 100644 --- a/app/widgets/gimpdock.c +++ b/app/widgets/gimpdock.c @@ -40,15 +40,15 @@ #include "gimpdockseparator.h" #include "gimpwidgets-utils.h" -#include "gimpsessioninfo.h" /* FIXME */ +#include "gimpsessioninfo.h" /* FIXME */ #include "core/gimpcontainer.h" /* FIXME */ -#include "dialogs/dialogs.h" /* FIXME */ +#include "dialogs/dialogs.h" /* FIXME */ #include "gimp-intl.h" -#define DEFAULT_DOCK_HEIGHT 300 - +#define DEFAULT_DOCK_HEIGHT 300 +#define DEFAULT_DOCK_FONT_SCALE PANGO_SCALE_SMALL enum { @@ -156,6 +156,13 @@ gimp_dock_class_init (GimpDockClass *klass) -1, G_MAXINT, DEFAULT_DOCK_HEIGHT, GIMP_PARAM_READABLE)); + gtk_widget_class_install_style_property (widget_class, + g_param_spec_double ("font-scale", + NULL, NULL, + 0.0, + G_MAXDOUBLE, + DEFAULT_DOCK_FONT_SCALE, + GIMP_PARAM_READABLE)); } static void @@ -312,12 +319,8 @@ static void gimp_dock_style_set (GtkWidget *widget, GtkStyle *prev_style) { - PangoContext *context; - PangoFontDescription *font_desc; - gint font_size; - gint default_height; - gchar *font_str; - gchar *rc_string; + gint default_height; + gdouble font_scale; GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); @@ -325,29 +328,40 @@ gimp_dock_style_set (GtkWidget *widget, gtk_window_set_default_size (GTK_WINDOW (widget), -1, default_height); - context = gtk_widget_get_pango_context (widget); - font_desc = pango_context_get_font_description (context); - font_desc = pango_font_description_copy (font_desc); + gtk_widget_style_get (widget, "font-scale", &font_scale, NULL); - font_size = pango_font_description_get_size (font_desc); - font_size = PANGO_SCALE_SMALL * font_size; - pango_font_description_set_size (font_desc, font_size); + if (font_scale != 1.0) + { + PangoContext *context; + PangoFontDescription *font_desc; + gint font_size; + gchar *font_str; + gchar *rc_string; - font_str = pango_font_description_to_string (font_desc); - pango_font_description_free (font_desc); + context = gtk_widget_get_pango_context (widget); + font_desc = pango_context_get_font_description (context); + font_desc = pango_font_description_copy (font_desc); - rc_string = - g_strdup_printf ("style \"gimp-dock-style\"" - "{" - " font_name = \"%s\"" - "}" - "widget \"gimp-dock-%d.*\" style \"gimp-dock-style\"", - font_str, - GIMP_DOCK (widget)->ID); - g_free (font_str); + font_size = pango_font_description_get_size (font_desc); + font_size = font_scale * font_size; + pango_font_description_set_size (font_desc, font_size); - gtk_rc_parse_string (rc_string); - g_free (rc_string); + font_str = pango_font_description_to_string (font_desc); + pango_font_description_free (font_desc); + + rc_string = + g_strdup_printf ("style \"gimp-dock-style\"" + "{" + " font_name = \"%s\"" + "}" + "widget \"gimp-dock-%d.*\" style \"gimp-dock-style\"", + font_str, + GIMP_DOCK (widget)->ID); + g_free (font_str); + + gtk_rc_parse_string (rc_string); + g_free (rc_string); + } } static void diff --git a/themes/Default/gtkrc b/themes/Default/gtkrc index 43d247ac59..df3a42368d 100644 --- a/themes/Default/gtkrc +++ b/themes/Default/gtkrc @@ -36,26 +36,27 @@ style "gimp-default-style" { "images/stock-warning-64.png", *, *, "gtk-dialog" } } - GtkPaned::handle_size = 6 - GimpDock::default_height = 300 + GtkPaned::handle-size = 6 + GimpDock::default-height = 300 + GimpDock::font-scale = 0.8333 GimpDockSeparator::height = 6 - GimpMenuDock::minimal_width = 200 - GimpMenuDock::menu_preview_size = button - GimpToolbox::tool_icon_size = button - GimpToolbox::button_relief = none - GimpDockbook::tab_border = 0 - GimpDockbook::tab_icon_size = button - GimpColorNotebook::tab_border = 0 - GimpColorNotebook::tab_icon_size = button - GimpDockable::content_border = 2 - GimpEditor::content_spacing = 2 - GimpEditor::button_spacing = 2 - GimpEditor::button_icon_size = menu - GimpDataEditor::minimal_height = 96 - GtkDialog::content_area_border = 0 - GtkDialog::button_spacing = 6 - GtkDialog::action_area_border = 12 - GimpUnitComboBox::appears_as_list = 0 + GimpMenuDock::minimal-width = 200 + GimpMenuDock::menu-preview-size = button + GimpToolbox::tool-icon-size = button + GimpToolbox::button-relief = none + GimpDockbook::tab-border = 0 + GimpDockbook::tab-icon-size = button + GimpColorNotebook::tab-border = 0 + GimpColorNotebook::tab-icon-size = button + GimpDockable::content-border = 2 + GimpEditor::content-spacing = 2 + GimpEditor::button-spacing = 2 + GimpEditor::button-icon-size = menu + GimpDataEditor::minimal-height = 96 + GtkDialog::content-area-border = 0 + GtkDialog::button-spacing = 6 + GtkDialog::action-area-border = 12 + GimpUnitComboBox::appears-as-list = 0 } class "GtkWidget" style "gimp-default-style" @@ -63,7 +64,7 @@ class "GtkWidget" style "gimp-default-style" style "gimp-tool-dialog-style" = "gimp-default-style" { - GtkDialog::action_area_border = 6 + GtkDialog::action-area-border = 6 } class "GimpToolDialog" style "gimp-tool-dialog-style" @@ -79,10 +80,10 @@ widget "*GimpContainerGridView*GtkViewport*" style "gimp-grid-view-style" style "gimp-dockable-style" = "gimp-default-style" { - GimpFrame::label_bold = 0 - GimpFrame::label_spacing = 2 - GtkButton::focus_line_width = 1 - GtkButton::focus_padding = 0 + GimpFrame::label-bold = 0 + GimpFrame::label-spacing = 2 + GtkButton::focus-line_width = 1 + GtkButton::focus-padding = 0 } widget "*GimpDockable.*" style "gimp-dockable-style" @@ -94,8 +95,8 @@ style "gimp-display-style" = "gimp-default-style" GimpScaleComboBox::label-scale = 0.8333 GtkComboBox::arrow-size = 8 GtkButton::inner-border = { 0, 0, 0, 0 } - GtkButton::focus_line_width = 0 - GtkButton::focus_padding = 0 + GtkButton::focus-line_width = 0 + GtkButton::focus-padding = 0 } widget "*GimpDisplayShell.*" style "gimp-display-style" diff --git a/themes/Small/gtkrc b/themes/Small/gtkrc index 51674b64fa..eab9d58ab9 100644 --- a/themes/Small/gtkrc +++ b/themes/Small/gtkrc @@ -30,38 +30,41 @@ style "gimp-default-style" { "../Default/images/stock-warning-64.png", *, *, "gtk-dialog" } } +# Uncommenting this line allows to set a different (smaller) font for GIMP. +# # font_name = "sans 8" # Enabling the following line for some reason breaks toolbox resize # increment calculation. You can enable it to get an even smaller GUI # but need to restart GIMP after the theme change. # -# GtkWidget::focus_padding = 0 +# GtkWidget::focus-padding = 0 - GtkOptionMenu::indicator_size = { 5, 11 } - GtkOptionMenu::indicator_spacing = { 4, 3, 1, 1 } + GtkOptionMenu::indicator-size = { 5, 11 } + GtkOptionMenu::indicator-spacing = { 4, 3, 1, 1 } - GtkPaned::handle_size = 5 - GimpDock::default_height = 240 + GtkPaned::handle-size = 5 + GimpDock::default-height = 240 + GimpDock::font-scale = 0.8333 GimpDockSeparator::height = 5 - GimpMenuDock::minimal_width = 200 - GimpMenuDock::menu_preview_size = small-toolbar - GimpToolbox::tool_icon_size = menu - GimpToolbox::button_relief = none - GimpDockbook::tab_border = 0 - GimpDockbook::tab_icon_size = menu - GimpColorNotebook::tab_border = 0 - GimpColorNotebook::tab_icon_size = menu - GimpDockable::content_border = 1 - GimpEditor::content_spacing = 1 - GimpEditor::button_spacing = 1 - GimpEditor::button_icon_size = menu - GimpDataEditor::minimal_height = 64 - GimpFrame::label_spacing = 2 - GtkDialog::content_area_border = 0 - GtkDialog::button_spacing = 6 - GtkDialog::action_area_border = 12 - GimpUnitComboBox::appears_as_list = 0 + GimpMenuDock::minimal-width = 200 + GimpMenuDock::menu-preview-size = small-toolbar + GimpToolbox::tool-icon-size = menu + GimpToolbox::button-relief = none + GimpDockbook::tab-border = 0 + GimpDockbook::tab-icon-size = menu + GimpColorNotebook::tab-border = 0 + GimpColorNotebook::tab-icon-size = menu + GimpDockable::content-border = 1 + GimpEditor::content-spacing = 1 + GimpEditor::button-spacing = 1 + GimpEditor::button-icon-size = menu + GimpDataEditor::minimal-height = 64 + GimpFrame::label-spacing = 2 + GtkDialog::content-area-border = 0 + GtkDialog::button-spacing = 6 + GtkDialog::action-area-border = 12 + GimpUnitComboBox::appears-as-list = 0 } class "GtkWidget" style "gimp-default-style" @@ -69,7 +72,7 @@ class "GtkWidget" style "gimp-default-style" style "gimp-tool-dialog-style" = "gimp-default-style" { - GtkDialog::action_area_border = 6 + GtkDialog::action-area-border = 6 } class "GimpToolDialog" style "gimp-tool-dialog-style" @@ -85,9 +88,9 @@ widget "*GimpContainerGridView*GtkViewport*" style "gimp-grid-view-style" style "gimp-dockable-style" = "gimp-default-style" { - GimpFrame::label_bold = 0 - GtkButton::focus_line_width = 1 - GtkButton::focus_padding = 0 + GimpFrame::label-bold = 0 + GtkButton::focus-line_width = 1 + GtkButton::focus-padding = 0 } widget "*GimpDockable.*" style "gimp-dockable-style" @@ -99,8 +102,8 @@ style "gimp-display-style" = "gimp-default-style" GimpScaleComboBox::label-scale = 0.8333 GtkComboBox::arrow-size = 8 GtkButton::inner-border = { 0, 0, 0, 0 } - GtkButton::focus_line_width = 0 - GtkButton::focus_padding = 0 + GtkButton::focus-line-width = 0 + GtkButton::focus-padding = 0 } widget "*GimpDisplayShell.*" style "gimp-display-style"