~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpunitcombobox.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpunitcombobox.c
5
 
 * Copyright (C) 2004  Sven Neumann <sven@gimp.org>
 
5
 * Copyright (C) 2004, 2008  Sven Neumann <sven@gimp.org>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
29
29
#include "gimpunitstore.h"
30
30
 
31
31
 
 
32
static void  gimp_unit_combo_box_style_set (GtkWidget *widget,
 
33
                                            GtkStyle  *prev_style);
 
34
 
 
35
 
32
36
G_DEFINE_TYPE (GimpUnitComboBox, gimp_unit_combo_box, GTK_TYPE_COMBO_BOX)
33
37
 
34
38
#define parent_class gimp_unit_combo_box_parent_class
37
41
static void
38
42
gimp_unit_combo_box_class_init (GimpUnitComboBoxClass *klass)
39
43
{
 
44
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
45
 
 
46
  widget_class->style_set = gimp_unit_combo_box_style_set;
 
47
 
 
48
  gtk_widget_class_install_style_property (widget_class,
 
49
                                           g_param_spec_double ("label-scale",
 
50
                                                                NULL, NULL,
 
51
                                                                0.0,
 
52
                                                                G_MAXDOUBLE,
 
53
                                                                1.0,
 
54
                                                                GIMP_PARAM_READABLE));
40
55
}
41
56
 
42
57
static void
50
65
  gtk_cell_layout_set_attributes (layout, cell,
51
66
                                  "text", GIMP_UNIT_STORE_UNIT_PLURAL,
52
67
                                  NULL);
 
68
}
 
69
 
 
70
static void
 
71
gimp_unit_combo_box_style_set (GtkWidget *widget,
 
72
                               GtkStyle  *prev_style)
 
73
{
 
74
  GtkCellLayout   *layout;
 
75
  GtkCellRenderer *cell;
 
76
  gdouble          scale;
 
77
 
 
78
  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
 
79
 
 
80
  gtk_widget_style_get (widget, "label-scale", &scale, NULL);
53
81
 
54
82
  /*  hackedehack ...  */
55
 
  layout = GTK_CELL_LAYOUT (GTK_BIN (combo)->child);
 
83
  layout = GTK_CELL_LAYOUT (gtk_bin_get_child (GTK_BIN (widget)));
56
84
  gtk_cell_layout_clear (layout);
57
85
 
58
 
  cell = gtk_cell_renderer_text_new ();
 
86
  cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
 
87
                       "scale", scale,
 
88
                       NULL);
59
89
  gtk_cell_layout_pack_start (layout, cell, TRUE);
60
90
  gtk_cell_layout_set_attributes (layout, cell,
61
 
                                  "text", GIMP_UNIT_STORE_UNIT_ABBREVIATION,
 
91
                                  "text",  GIMP_UNIT_STORE_UNIT_ABBREVIATION,
62
92
                                  NULL);
63
93
}
64
94