diff options
author | Ross Burton <ross@openedhand.com> | 2007-07-26 10:35:02 +0000 |
---|---|---|
committer | Ross Burton <ross@openedhand.com> | 2007-07-26 10:35:02 +0000 |
commit | 828cb20d18fc67aabe22d13c4e3c519e6611f908 (patch) | |
tree | f2ecc02e94d16896e906ea2afc95d94173783846 | |
parent | f7bf74a05ae7b857dbf935738ee20b0fad9de496 (diff) | |
download | poky-828cb20d18fc67aabe22d13c4e3c519e6611f908.tar.gz |
Add patch so that the size of the toggle cell renderer is based on font size
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2228 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r-- | meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff | 100 | ||||
-rw-r--r-- | meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff | 69 | ||||
-rw-r--r-- | meta/packages/gtk+/gtk+_2.10.12.bb | 3 | ||||
-rw-r--r-- | meta/packages/gtk+/gtk+_2.6.10.bb | 3 |
4 files changed, 173 insertions, 2 deletions
diff --git a/meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff b/meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff new file mode 100644 index 0000000000..928da72430 --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff | |||
@@ -0,0 +1,100 @@ | |||
1 | Index: gtk/gtkcellrenderertoggle.c | ||
2 | =================================================================== | ||
3 | --- gtk/gtkcellrenderertoggle.c (revision 18523) | ||
4 | +++ gtk/gtkcellrenderertoggle.c (working copy) | ||
5 | @@ -71,6 +71,8 @@ | ||
6 | PROP_INDICATOR_SIZE | ||
7 | }; | ||
8 | |||
9 | +/* This is a hard-coded default which promptly gets overridden by a size | ||
10 | + calculated from the font size. */ | ||
11 | #define TOGGLE_WIDTH 12 | ||
12 | |||
13 | static guint toggle_cell_signals[LAST_SIGNAL] = { 0 }; | ||
14 | @@ -80,8 +82,9 @@ | ||
15 | typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate; | ||
16 | struct _GtkCellRendererTogglePrivate | ||
17 | { | ||
18 | - gint indicator_size; | ||
19 | - | ||
20 | + gint indicator_size; /* This is the real size */ | ||
21 | + gint override_size; /* This is the size set from the indicator-size property */ | ||
22 | + GtkWidget *cached_widget; | ||
23 | guint inconsistent : 1; | ||
24 | }; | ||
25 | |||
26 | @@ -104,6 +107,7 @@ | ||
27 | GTK_CELL_RENDERER (celltoggle)->ypad = 2; | ||
28 | |||
29 | priv->indicator_size = TOGGLE_WIDTH; | ||
30 | + priv->override_size = 0; | ||
31 | priv->inconsistent = FALSE; | ||
32 | } | ||
33 | |||
34 | @@ -210,7 +214,7 @@ | ||
35 | g_value_set_boolean (value, celltoggle->radio); | ||
36 | break; | ||
37 | case PROP_INDICATOR_SIZE: | ||
38 | - g_value_set_int (value, priv->indicator_size); | ||
39 | + g_value_set_int (value, priv->override_size ? priv->override_size : priv->indicator_size); | ||
40 | break; | ||
41 | default: | ||
42 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); | ||
43 | @@ -245,7 +249,7 @@ | ||
44 | celltoggle->radio = g_value_get_boolean (value); | ||
45 | break; | ||
46 | case PROP_INDICATOR_SIZE: | ||
47 | - priv->indicator_size = g_value_get_int (value); | ||
48 | + priv->override_size = g_value_get_int (value); | ||
49 | break; | ||
50 | default: | ||
51 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); | ||
52 | @@ -273,6 +277,27 @@ | ||
53 | } | ||
54 | |||
55 | static void | ||
56 | +on_widget_style_set (GtkWidget *widget, GtkStyle *previous, gpointer user_data) | ||
57 | +{ | ||
58 | + GtkCellRendererTogglePrivate *priv = user_data; | ||
59 | + PangoContext *context; | ||
60 | + PangoFontMetrics *metrics; | ||
61 | + int height; | ||
62 | + | ||
63 | + context = gtk_widget_get_pango_context (widget); | ||
64 | + metrics = pango_context_get_metrics (context, | ||
65 | + widget->style->font_desc, | ||
66 | + pango_context_get_language (context)); | ||
67 | + | ||
68 | + height = pango_font_metrics_get_ascent (metrics) + | ||
69 | + pango_font_metrics_get_descent (metrics); | ||
70 | + | ||
71 | + pango_font_metrics_unref (metrics); | ||
72 | + | ||
73 | + priv->indicator_size = PANGO_PIXELS (height * 0.85); | ||
74 | +} | ||
75 | + | ||
76 | +static void | ||
77 | gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell, | ||
78 | GtkWidget *widget, | ||
79 | GdkRectangle *cell_area, | ||
80 | @@ -287,6 +312,20 @@ | ||
81 | |||
82 | priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (cell); | ||
83 | |||
84 | + if (priv->override_size) { | ||
85 | + priv->indicator_size = priv->override_size; | ||
86 | + } else if (priv->cached_widget != widget) { | ||
87 | + if (priv->cached_widget) { | ||
88 | + g_object_remove_weak_pointer (widget, &priv->cached_widget); | ||
89 | + g_signal_handlers_disconnect_by_func (priv->cached_widget, on_widget_style_set, priv); | ||
90 | + } | ||
91 | + priv->cached_widget = widget; | ||
92 | + g_object_add_weak_pointer (widget, &priv->cached_widget); | ||
93 | + g_signal_connect (widget, "style-set", on_widget_style_set, priv); | ||
94 | + | ||
95 | + on_widget_style_set (widget, NULL, priv); | ||
96 | + } | ||
97 | + | ||
98 | calc_width = (gint) cell->xpad * 2 + priv->indicator_size; | ||
99 | calc_height = (gint) cell->ypad * 2 + priv->indicator_size; | ||
100 | |||
diff --git a/meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff b/meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff new file mode 100644 index 0000000000..ad3bc6e38c --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff | |||
@@ -0,0 +1,69 @@ | |||
1 | Index: gtk/gtkcellrenderertoggle.c | ||
2 | =================================================================== | ||
3 | --- gtk/gtkcellrenderertoggle.c (revision 18542) | ||
4 | +++ gtk/gtkcellrenderertoggle.c (working copy) | ||
5 | @@ -80,6 +80,8 @@ | ||
6 | typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate; | ||
7 | struct _GtkCellRendererTogglePrivate | ||
8 | { | ||
9 | + gint indicator_size; | ||
10 | + GtkWidget *cached_widget; | ||
11 | guint inconsistent : 1; | ||
12 | }; | ||
13 | |||
14 | @@ -281,6 +283,27 @@ | ||
15 | } | ||
16 | |||
17 | static void | ||
18 | +on_widget_style_set (GtkWidget *widget, GtkStyle *previous, gpointer user_data) | ||
19 | +{ | ||
20 | + GtkCellRendererTogglePrivate *priv = user_data; | ||
21 | + PangoContext *context; | ||
22 | + PangoFontMetrics *metrics; | ||
23 | + int height; | ||
24 | + | ||
25 | + context = gtk_widget_get_pango_context (widget); | ||
26 | + metrics = pango_context_get_metrics (context, | ||
27 | + widget->style->font_desc, | ||
28 | + pango_context_get_language (context)); | ||
29 | + | ||
30 | + height = pango_font_metrics_get_ascent (metrics) + | ||
31 | + pango_font_metrics_get_descent (metrics); | ||
32 | + | ||
33 | + pango_font_metrics_unref (metrics); | ||
34 | + | ||
35 | + priv->indicator_size = PANGO_PIXELS (height * 0.85); | ||
36 | +} | ||
37 | + | ||
38 | +static void | ||
39 | gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell, | ||
40 | GtkWidget *widget, | ||
41 | GdkRectangle *cell_area, | ||
42 | @@ -291,10 +314,25 @@ | ||
43 | { | ||
44 | gint calc_width; | ||
45 | gint calc_height; | ||
46 | + GtkCellRendererTogglePrivate *priv; | ||
47 | |||
48 | - calc_width = (gint) cell->xpad * 2 + TOGGLE_WIDTH; | ||
49 | - calc_height = (gint) cell->ypad * 2 + TOGGLE_WIDTH; | ||
50 | + priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (cell); | ||
51 | |||
52 | + if (priv->cached_widget != widget) { | ||
53 | + if (priv->cached_widget) { | ||
54 | + g_object_remove_weak_pointer (widget, &priv->cached_widget); | ||
55 | + g_signal_handlers_disconnect_by_func (priv->cached_widget, on_widget_style_set, priv); | ||
56 | + } | ||
57 | + priv->cached_widget = widget; | ||
58 | + g_object_add_weak_pointer (widget, &priv->cached_widget); | ||
59 | + g_signal_connect (widget, "style-set", on_widget_style_set, priv); | ||
60 | + | ||
61 | + on_widget_style_set (widget, NULL, priv); | ||
62 | + } | ||
63 | + | ||
64 | + calc_width = (gint) cell->xpad * 2 + priv->indicator_size; | ||
65 | + calc_height = (gint) cell->ypad * 2 + priv->indicator_size; | ||
66 | + | ||
67 | if (width) | ||
68 | *width = calc_width; | ||
69 | |||
diff --git a/meta/packages/gtk+/gtk+_2.10.12.bb b/meta/packages/gtk+/gtk+_2.10.12.bb index 4c0e63fcf1..e7e5a9f763 100644 --- a/meta/packages/gtk+/gtk+_2.10.12.bb +++ b/meta/packages/gtk+/gtk+_2.10.12.bb | |||
@@ -1,7 +1,7 @@ | |||
1 | require gtk+.inc | 1 | require gtk+.inc |
2 | 2 | ||
3 | DEPENDS += "cairo" | 3 | DEPENDS += "cairo" |
4 | PR = "r9" | 4 | PR = "r10" |
5 | 5 | ||
6 | # disable per default - untested and not all patches included. | 6 | # disable per default - untested and not all patches included. |
7 | DEFAULT_PREFERENCE = "-1" | 7 | DEFAULT_PREFERENCE = "-1" |
@@ -21,6 +21,7 @@ SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.10/gtk+-${PV}.tar.bz2 \ | |||
21 | file://no-demos.patch;patch=1 \ | 21 | file://no-demos.patch;patch=1 \ |
22 | file://cellrenderer-cairo.patch;patch=1;pnum=0 \ | 22 | file://cellrenderer-cairo.patch;patch=1;pnum=0 \ |
23 | file://entry-cairo.patch;patch=1;pnum=0 \ | 23 | file://entry-cairo.patch;patch=1;pnum=0 \ |
24 | file://toggle-font.diff;patch=1;pnum=0 \ | ||
24 | file://scrolled-placement.patch;patch=1;pnum=0" | 25 | file://scrolled-placement.patch;patch=1;pnum=0" |
25 | # file://scroll-timings.patch;patch=1 \ | 26 | # file://scroll-timings.patch;patch=1 \ |
26 | # file://pangoxft2.10.6.diff;patch=1" | 27 | # file://pangoxft2.10.6.diff;patch=1" |
diff --git a/meta/packages/gtk+/gtk+_2.6.10.bb b/meta/packages/gtk+/gtk+_2.6.10.bb index c364950856..86fc8fcb17 100644 --- a/meta/packages/gtk+/gtk+_2.6.10.bb +++ b/meta/packages/gtk+/gtk+_2.6.10.bb | |||
@@ -1,6 +1,6 @@ | |||
1 | require gtk+.inc | 1 | require gtk+.inc |
2 | 2 | ||
3 | PR = "r9" | 3 | PR = "r10" |
4 | 4 | ||
5 | SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \ | 5 | SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \ |
6 | file://no-demos.patch;patch=1 \ | 6 | file://no-demos.patch;patch=1 \ |
@@ -15,6 +15,7 @@ SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \ | |||
15 | file://filesystem-volumes.patch;patch=1 \ | 15 | file://filesystem-volumes.patch;patch=1 \ |
16 | file://filechooser-respect-style.patch;patch=1 \ | 16 | file://filechooser-respect-style.patch;patch=1 \ |
17 | file://filechooser-default.patch;patch=1 \ | 17 | file://filechooser-default.patch;patch=1 \ |
18 | file://toggle-font.diff;patch=1;pnum=0 \ | ||
18 | " | 19 | " |
19 | 20 | ||
20 | EXTRA_OECONF = "--without-libtiff --disable-xkb --disable-glibtest" | 21 | EXTRA_OECONF = "--without-libtiff --disable-xkb --disable-glibtest" |