Commit 4f0a87ff authored by Michael Natterer's avatar Michael Natterer 😴

app, libgimpwidgets, themes: fix some themeing

Add CSS names using gtk_widget_class_set_css_name(), remove styling in
code and instead do it properly in CSS, so far in the System theme.
All horribly incomplete but a start.
parent 56b28773
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdock.c
* Copyright (C) 2001-2005 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2018 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -45,9 +45,6 @@
#include "gimp-intl.h"
#define DEFAULT_DOCK_FONT_SCALE PANGO_SCALE_SMALL
enum
{
BOOK_ADDED,
......@@ -73,8 +70,6 @@ struct _GimpDockPrivate
static void gimp_dock_dispose (GObject *object);
static void gimp_dock_style_updated (GtkWidget *widget);
static gchar * gimp_dock_real_get_description (GimpDock *dock,
gboolean complete);
static void gimp_dock_real_book_added (GimpDock *dock,
......@@ -140,8 +135,6 @@ gimp_dock_class_init (GimpDockClass *klass)
object_class->dispose = gimp_dock_dispose;
widget_class->style_updated = gimp_dock_style_updated;
klass->get_description = gimp_dock_real_get_description;
klass->set_host_geometry_hints = NULL;
klass->book_added = gimp_dock_real_book_added;
......@@ -149,13 +142,7 @@ gimp_dock_class_init (GimpDockClass *klass)
klass->description_invalidated = NULL;
klass->geometry_invalidated = NULL;
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));
gtk_widget_class_set_css_name (widget_class, "GimpDock");
g_type_class_add_private (klass, sizeof (GimpDockPrivate));
}
......@@ -223,60 +210,6 @@ gimp_dock_dispose (GObject *object)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_dock_style_updated (GtkWidget *widget)
{
GimpDock *dock = GIMP_DOCK (widget);
gdouble font_scale = 1.0;
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
gtk_widget_style_get (widget,
"font-scale", &font_scale,
NULL);
if (font_scale != 1.0)
{
PangoContext *context;
PangoFontDescription *font_desc;
gint font_size;
gchar *font_str;
gchar *css_string;
context = gtk_widget_get_pango_context (widget);
font_desc = pango_context_get_font_description (context);
font_desc = pango_font_description_copy (font_desc);
font_size = pango_font_description_get_size (font_desc);
font_size = font_scale * font_size;
pango_font_description_set_size (font_desc, font_size);
font_str = pango_font_description_to_string (font_desc);
pango_font_description_free (font_desc);
css_string = g_strdup_printf ("#gimp-internal-dock-%d * {\n"
" font: %s;\n"
"}",
dock->p->ID,
font_str);
g_free (font_str);
if (! dock->p->css_provider)
{
dock->p->css_provider = gtk_css_provider_new ();
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget),
GTK_STYLE_PROVIDER (dock->p->css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
gtk_css_provider_load_from_data (dock->p->css_provider,
css_string, -1, NULL);
g_free (css_string);
gtk_widget_reset_style (widget);
}
}
static gchar *
gimp_dock_real_get_description (GimpDock *dock,
gboolean complete)
......
......@@ -189,6 +189,8 @@ gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
NULL, NULL,
GDK_TYPE_RGBA,
GIMP_PARAM_READABLE));
gtk_widget_class_set_css_name (widget_class, "GimpHistogramView");
}
static void
......
......@@ -134,6 +134,8 @@ gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
selector_class->set_model_visible = gimp_color_notebook_set_model_visible;
selector_class->set_config = gimp_color_notebook_set_config;
gtk_widget_class_set_css_name (widget_class, "GimpColorNotebook");
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("tab-icon-size",
NULL,
......
......@@ -143,8 +143,6 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
widget_class->scroll_event = gimp_color_scale_scroll;
widget_class->draw = gimp_color_scale_draw;
gtk_widget_class_set_css_name (widget_class, "GimpColorScale");
/**
* GimpColorScale:channel:
*
......@@ -161,6 +159,8 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gtk_widget_class_set_css_name (widget_class, "GimpColorScale");
g_type_class_add_private (object_class, sizeof (GimpColorScalePrivate));
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
......@@ -200,7 +200,7 @@ gimp_color_scale_init (GimpColorScale *scale)
" min-width: 24px;"
" min-height: 24px;"
"}\n"
"GimpColorScale slider {"
"GimpColorScale contents trough slider {"
" min-width: 14px;"
" min-height: 14px;"
"}",
......@@ -280,7 +280,6 @@ gimp_color_scale_size_allocate (GtkWidget *widget,
{
GimpColorScalePrivate *priv = GET_PRIVATE (widget);
GtkRange *range = GTK_RANGE (widget);
GtkStyleContext *style = gtk_widget_get_style_context (widget);
GdkRectangle range_rect;
gint focus = 0;
gint trough_border;
......@@ -1053,7 +1052,7 @@ gimp_color_scale_render_stipple (GimpColorScale *scale)
GdkRGBA color;
guchar r, g, b;
guchar *buf;
guchar insensitive[4];
guchar insensitive[4] = { 0, };
guint x, y;
if ((buf = priv->buf) == NULL)
......
......@@ -196,6 +196,7 @@ static void
gimp_color_scales_class_init (GimpColorScalesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
object_class->dispose = gimp_color_scales_dispose;
......@@ -221,6 +222,8 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gtk_widget_class_set_css_name (widget_class, "GimpColorScales");
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
babl_format ("CIE LCH(ab) alpha double"));
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) alpha double"),
......
......@@ -39,7 +39,6 @@
**/
#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_SMALL
#define MINIMUM_INCR 5
#define IMMEDIATE_REDRAW_THRESHOLD 20
......@@ -74,7 +73,6 @@ typedef struct
GdkRectangle last_pos_rect;
guint pos_redraw_idle_id;
PangoLayout *layout;
gdouble font_scale;
GList *track_widgets;
} GimpRulerPrivate;
......@@ -182,8 +180,6 @@ gimp_ruler_class_init (GimpRulerClass *klass)
widget_class->motion_notify_event = gimp_ruler_motion_notify;
widget_class->draw = gimp_ruler_draw;
g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
g_object_class_install_property (object_class,
PROP_ORIENTATION,
g_param_spec_enum ("orientation",
......@@ -242,14 +238,9 @@ gimp_ruler_class_init (GimpRulerClass *klass)
0.0,
GIMP_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_double ("font-scale",
"Font Scale",
"The size of the used font",
0.0,
G_MAXDOUBLE,
DEFAULT_RULER_FONT_SCALE,
GIMP_PARAM_READABLE));
gtk_widget_class_set_css_name (widget_class, "GimpRuler");
g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
}
static void
......@@ -274,8 +265,6 @@ gimp_ruler_init (GimpRuler *ruler)
priv->last_pos_rect.width = 0;
priv->last_pos_rect.height = 0;
priv->pos_redraw_idle_id = 0;
priv->font_scale = DEFAULT_RULER_FONT_SCALE;
}
static void
......@@ -959,10 +948,6 @@ gimp_ruler_style_updated (GtkWidget *widget)
GTK_WIDGET_CLASS (gimp_ruler_parent_class)->style_updated (widget);
gtk_widget_style_get (widget,
"font-scale", &priv->font_scale,
NULL);
priv->backing_store_valid = FALSE;
g_clear_object (&priv->layout);
......@@ -1389,30 +1374,6 @@ gimp_ruler_make_pixmap (GimpRuler *ruler)
priv->backing_store_valid = FALSE;
}
static PangoLayout *
gimp_ruler_create_layout (GtkWidget *widget,
const gchar *text)
{
GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (widget);
PangoLayout *layout;
PangoAttrList *attrs;
PangoAttribute *attr;
layout = gtk_widget_create_pango_layout (widget, text);
attrs = pango_attr_list_new ();
attr = pango_attr_scale_new (priv->font_scale);
attr->start_index = 0;
attr->end_index = -1;
pango_attr_list_insert (attrs, attr);
pango_layout_set_attributes (layout, attrs);
pango_attr_list_unref (attrs);
return layout;
}
static PangoLayout *
gimp_ruler_get_layout (GtkWidget *widget,
const gchar *text)
......@@ -1425,7 +1386,7 @@ gimp_ruler_get_layout (GtkWidget *widget,
return priv->layout;
}
priv->layout = gimp_ruler_create_layout (widget, text);
priv->layout = gtk_widget_create_pango_layout (widget, text);
return priv->layout;
}
......
......@@ -22,7 +22,6 @@
-GtkPaned-handle-size: 6;
-GimpDockWindow-default-height: 300;
-GimpDock-font-scale: 0.8333;
-GimpMenuDock-minimal-width: 200;
-GimpDockWindow-menu-preview-size: button;
-GimpToolPalette-tool-icon-size: button;
......@@ -49,29 +48,44 @@ GimpColorNotebook tab {
padding: 0 0 0 0;
}
GimpDockbook tab {
GimpColorScales spinbutton button {
padding: 0 0 0 0;
}
GimpDockbook GtkButton {
// -GtkWidget-focus-padding: 0;
GimpColorScales spinbutton entry {
min-height: 0;
}
GimpDock {
font-size: smaller;
}
GimpDock notebook tab {
padding: 0 0 0 0;
}
GimpDock spinbutton button {
padding: 0 0 0 0;
}
GimpDock spinbutton entry {
min-height: 0;
}
GimpDockable {
-GimpFrame-label-bold: 0;
-GimpFrame-label-spacing: 2;
// -GtkWidget-focus-line-width: 1;
// -GtkWidget-focus-padding: 0;
/* -GtkWidget-focus-line-width: 1; */
/* -GtkWidget-focus-padding: 0; */
}
GimpDisplayShell {
-GimpRuler-font-scale: 0.8333;
-GimpUnitComboBox-label-scale: 0.8333;
-GimpScaleComboBox-label-scale: 0.8333;
-GtkComboBox-arrow-size: 8;
-GtkButton-inner-border: 0 0 0 0;
// -GtkWidget-focus-line_width: 0;
// -GtkWidget-focus-padding: 0;
/* -GtkWidget-focus-line_width: 0; */
/* -GtkWidget-focus-padding: 0; */
}
GimpColorFrame {
......@@ -95,9 +109,10 @@ GimpHistogramView:selected {
}
GimpOverlayFrame {
// -GtkButton-focus-line-width: 1;
/* -GtkButton-focus-line-width: 1; */
}
GimpRuler {
font-size: smaller;
background-color: @bg_color;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment