mirror of https://github.com/GNOME/gimp.git
Undeprecate/improve GimpScaleComboBox and GimpUnitComboBox
Remove label-scale style properties and gtk_widget_modify_font() hacks and theme them using CSS.
This commit is contained in:
parent
26ba39884c
commit
4133a032de
|
@ -56,8 +56,6 @@ enum
|
|||
static void gimp_scale_combo_box_constructed (GObject *object);
|
||||
static void gimp_scale_combo_box_finalize (GObject *object);
|
||||
|
||||
static void gimp_scale_combo_box_style_updated (GtkWidget *widget);
|
||||
|
||||
static void gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box);
|
||||
static void gimp_scale_combo_box_entry_activate (GtkWidget *entry,
|
||||
GimpScaleComboBox *combo_box);
|
||||
|
@ -82,8 +80,7 @@ static guint scale_combo_box_signals[LAST_SIGNAL] = { 0 };
|
|||
static void
|
||||
gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
scale_combo_box_signals[ENTRY_ACTIVATED] =
|
||||
g_signal_new ("entry-activated",
|
||||
|
@ -94,20 +91,8 @@ gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
|
|||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->constructed = gimp_scale_combo_box_constructed;
|
||||
object_class->finalize = gimp_scale_combo_box_finalize;
|
||||
|
||||
widget_class->style_updated = gimp_scale_combo_box_style_updated;
|
||||
|
||||
klass->entry_activated = NULL;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_double ("label-scale",
|
||||
NULL, NULL,
|
||||
0.0,
|
||||
G_MAXDOUBLE,
|
||||
1.0,
|
||||
GIMP_PARAM_READABLE));
|
||||
object_class->constructed = gimp_scale_combo_box_constructed;
|
||||
object_class->finalize = gimp_scale_combo_box_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -208,37 +193,6 @@ gimp_scale_combo_box_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_combo_box_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
||||
|
||||
entry = gtk_bin_get_child (GTK_BIN (widget));
|
||||
|
||||
if (entry)
|
||||
{
|
||||
PangoContext *context;
|
||||
PangoFontDescription *font_desc;
|
||||
gint font_size;
|
||||
gdouble scale;
|
||||
|
||||
gtk_widget_style_get (widget, "label-scale", &scale, NULL);
|
||||
|
||||
context = gtk_widget_get_pango_context (entry);
|
||||
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);
|
||||
pango_font_description_set_size (font_desc, scale * font_size);
|
||||
|
||||
gtk_widget_override_font (entry, font_desc);
|
||||
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_combo_box_changed (GimpScaleComboBox *combo_box)
|
||||
{
|
||||
|
|
|
@ -55,15 +55,6 @@ gimp_unit_combo_box_class_init (GimpUnitComboBoxClass *klass)
|
|||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->style_updated = gimp_unit_combo_box_style_updated;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_double ("label-scale",
|
||||
"Label Scale",
|
||||
"The scale for the text cell renderer",
|
||||
0.0,
|
||||
G_MAXDOUBLE,
|
||||
1.0,
|
||||
GIMP_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -88,23 +79,18 @@ gimp_unit_combo_box_style_updated (GtkWidget *widget)
|
|||
{
|
||||
GtkCellLayout *layout;
|
||||
GtkCellRenderer *cell;
|
||||
gdouble scale;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
||||
|
||||
gtk_widget_style_get (widget, "label-scale", &scale, NULL);
|
||||
|
||||
/* hackedehack ... */
|
||||
layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
|
||||
gtk_cell_layout_clear (layout);
|
||||
|
||||
cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
|
||||
"scale", scale,
|
||||
NULL);
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (layout, cell, TRUE);
|
||||
gtk_cell_layout_set_attributes (layout, cell,
|
||||
"text", GIMP_UNIT_STORE_UNIT_SHORT_FORMAT,
|
||||
NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -83,9 +83,12 @@ GimpDockable {
|
|||
-GimpFrame-label-spacing: 2;
|
||||
}
|
||||
|
||||
GimpDisplayShell {
|
||||
-GimpUnitComboBox-label-scale: 0.8333;
|
||||
-GimpScaleComboBox-label-scale: 0.8333;
|
||||
GimpDisplayShell combobox entry {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
GimpDisplayShell combobox button {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
GimpColorFrame {
|
||||
|
|
Loading…
Reference in New Issue