mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 18:49:32 +02:00
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
This commit is contained in:
100
meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff
vendored
Normal file
100
meta/packages/gtk+/gtk+-2.10.12/toggle-font.diff
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
Index: gtk/gtkcellrenderertoggle.c
|
||||||
|
===================================================================
|
||||||
|
--- gtk/gtkcellrenderertoggle.c (revision 18523)
|
||||||
|
+++ gtk/gtkcellrenderertoggle.c (working copy)
|
||||||
|
@@ -71,6 +71,8 @@
|
||||||
|
PROP_INDICATOR_SIZE
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* This is a hard-coded default which promptly gets overridden by a size
|
||||||
|
+ calculated from the font size. */
|
||||||
|
#define TOGGLE_WIDTH 12
|
||||||
|
|
||||||
|
static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
@@ -80,8 +82,9 @@
|
||||||
|
typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate;
|
||||||
|
struct _GtkCellRendererTogglePrivate
|
||||||
|
{
|
||||||
|
- gint indicator_size;
|
||||||
|
-
|
||||||
|
+ gint indicator_size; /* This is the real size */
|
||||||
|
+ gint override_size; /* This is the size set from the indicator-size property */
|
||||||
|
+ GtkWidget *cached_widget;
|
||||||
|
guint inconsistent : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -104,6 +107,7 @@
|
||||||
|
GTK_CELL_RENDERER (celltoggle)->ypad = 2;
|
||||||
|
|
||||||
|
priv->indicator_size = TOGGLE_WIDTH;
|
||||||
|
+ priv->override_size = 0;
|
||||||
|
priv->inconsistent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -210,7 +214,7 @@
|
||||||
|
g_value_set_boolean (value, celltoggle->radio);
|
||||||
|
break;
|
||||||
|
case PROP_INDICATOR_SIZE:
|
||||||
|
- g_value_set_int (value, priv->indicator_size);
|
||||||
|
+ g_value_set_int (value, priv->override_size ? priv->override_size : priv->indicator_size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@@ -245,7 +249,7 @@
|
||||||
|
celltoggle->radio = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
case PROP_INDICATOR_SIZE:
|
||||||
|
- priv->indicator_size = g_value_get_int (value);
|
||||||
|
+ priv->override_size = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@@ -273,6 +277,27 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
+on_widget_style_set (GtkWidget *widget, GtkStyle *previous, gpointer user_data)
|
||||||
|
+{
|
||||||
|
+ GtkCellRendererTogglePrivate *priv = user_data;
|
||||||
|
+ PangoContext *context;
|
||||||
|
+ PangoFontMetrics *metrics;
|
||||||
|
+ int height;
|
||||||
|
+
|
||||||
|
+ context = gtk_widget_get_pango_context (widget);
|
||||||
|
+ metrics = pango_context_get_metrics (context,
|
||||||
|
+ widget->style->font_desc,
|
||||||
|
+ pango_context_get_language (context));
|
||||||
|
+
|
||||||
|
+ height = pango_font_metrics_get_ascent (metrics) +
|
||||||
|
+ pango_font_metrics_get_descent (metrics);
|
||||||
|
+
|
||||||
|
+ pango_font_metrics_unref (metrics);
|
||||||
|
+
|
||||||
|
+ priv->indicator_size = PANGO_PIXELS (height * 0.85);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkRectangle *cell_area,
|
||||||
|
@@ -287,6 +312,20 @@
|
||||||
|
|
||||||
|
priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (cell);
|
||||||
|
|
||||||
|
+ if (priv->override_size) {
|
||||||
|
+ priv->indicator_size = priv->override_size;
|
||||||
|
+ } else if (priv->cached_widget != widget) {
|
||||||
|
+ if (priv->cached_widget) {
|
||||||
|
+ g_object_remove_weak_pointer (widget, &priv->cached_widget);
|
||||||
|
+ g_signal_handlers_disconnect_by_func (priv->cached_widget, on_widget_style_set, priv);
|
||||||
|
+ }
|
||||||
|
+ priv->cached_widget = widget;
|
||||||
|
+ g_object_add_weak_pointer (widget, &priv->cached_widget);
|
||||||
|
+ g_signal_connect (widget, "style-set", on_widget_style_set, priv);
|
||||||
|
+
|
||||||
|
+ on_widget_style_set (widget, NULL, priv);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
calc_width = (gint) cell->xpad * 2 + priv->indicator_size;
|
||||||
|
calc_height = (gint) cell->ypad * 2 + priv->indicator_size;
|
||||||
|
|
||||||
69
meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff
vendored
Normal file
69
meta/packages/gtk+/gtk+-2.6.10/toggle-font.diff
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
Index: gtk/gtkcellrenderertoggle.c
|
||||||
|
===================================================================
|
||||||
|
--- gtk/gtkcellrenderertoggle.c (revision 18542)
|
||||||
|
+++ gtk/gtkcellrenderertoggle.c (working copy)
|
||||||
|
@@ -80,6 +80,8 @@
|
||||||
|
typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate;
|
||||||
|
struct _GtkCellRendererTogglePrivate
|
||||||
|
{
|
||||||
|
+ gint indicator_size;
|
||||||
|
+ GtkWidget *cached_widget;
|
||||||
|
guint inconsistent : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -281,6 +283,27 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
+on_widget_style_set (GtkWidget *widget, GtkStyle *previous, gpointer user_data)
|
||||||
|
+{
|
||||||
|
+ GtkCellRendererTogglePrivate *priv = user_data;
|
||||||
|
+ PangoContext *context;
|
||||||
|
+ PangoFontMetrics *metrics;
|
||||||
|
+ int height;
|
||||||
|
+
|
||||||
|
+ context = gtk_widget_get_pango_context (widget);
|
||||||
|
+ metrics = pango_context_get_metrics (context,
|
||||||
|
+ widget->style->font_desc,
|
||||||
|
+ pango_context_get_language (context));
|
||||||
|
+
|
||||||
|
+ height = pango_font_metrics_get_ascent (metrics) +
|
||||||
|
+ pango_font_metrics_get_descent (metrics);
|
||||||
|
+
|
||||||
|
+ pango_font_metrics_unref (metrics);
|
||||||
|
+
|
||||||
|
+ priv->indicator_size = PANGO_PIXELS (height * 0.85);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GdkRectangle *cell_area,
|
||||||
|
@@ -291,10 +314,25 @@
|
||||||
|
{
|
||||||
|
gint calc_width;
|
||||||
|
gint calc_height;
|
||||||
|
+ GtkCellRendererTogglePrivate *priv;
|
||||||
|
|
||||||
|
- calc_width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
|
||||||
|
- calc_height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
|
||||||
|
+ priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (cell);
|
||||||
|
|
||||||
|
+ if (priv->cached_widget != widget) {
|
||||||
|
+ if (priv->cached_widget) {
|
||||||
|
+ g_object_remove_weak_pointer (widget, &priv->cached_widget);
|
||||||
|
+ g_signal_handlers_disconnect_by_func (priv->cached_widget, on_widget_style_set, priv);
|
||||||
|
+ }
|
||||||
|
+ priv->cached_widget = widget;
|
||||||
|
+ g_object_add_weak_pointer (widget, &priv->cached_widget);
|
||||||
|
+ g_signal_connect (widget, "style-set", on_widget_style_set, priv);
|
||||||
|
+
|
||||||
|
+ on_widget_style_set (widget, NULL, priv);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ calc_width = (gint) cell->xpad * 2 + priv->indicator_size;
|
||||||
|
+ calc_height = (gint) cell->ypad * 2 + priv->indicator_size;
|
||||||
|
+
|
||||||
|
if (width)
|
||||||
|
*width = calc_width;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
require gtk+.inc
|
require gtk+.inc
|
||||||
|
|
||||||
DEPENDS += "cairo"
|
DEPENDS += "cairo"
|
||||||
PR = "r9"
|
PR = "r10"
|
||||||
|
|
||||||
# disable per default - untested and not all patches included.
|
# disable per default - untested and not all patches included.
|
||||||
DEFAULT_PREFERENCE = "-1"
|
DEFAULT_PREFERENCE = "-1"
|
||||||
@@ -21,6 +21,7 @@ SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.10/gtk+-${PV}.tar.bz2 \
|
|||||||
file://no-demos.patch;patch=1 \
|
file://no-demos.patch;patch=1 \
|
||||||
file://cellrenderer-cairo.patch;patch=1;pnum=0 \
|
file://cellrenderer-cairo.patch;patch=1;pnum=0 \
|
||||||
file://entry-cairo.patch;patch=1;pnum=0 \
|
file://entry-cairo.patch;patch=1;pnum=0 \
|
||||||
|
file://toggle-font.diff;patch=1;pnum=0 \
|
||||||
file://scrolled-placement.patch;patch=1;pnum=0"
|
file://scrolled-placement.patch;patch=1;pnum=0"
|
||||||
# file://scroll-timings.patch;patch=1 \
|
# file://scroll-timings.patch;patch=1 \
|
||||||
# file://pangoxft2.10.6.diff;patch=1"
|
# file://pangoxft2.10.6.diff;patch=1"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require gtk+.inc
|
require gtk+.inc
|
||||||
|
|
||||||
PR = "r9"
|
PR = "r10"
|
||||||
|
|
||||||
SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
|
SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
|
||||||
file://no-demos.patch;patch=1 \
|
file://no-demos.patch;patch=1 \
|
||||||
@@ -15,6 +15,7 @@ SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
|
|||||||
file://filesystem-volumes.patch;patch=1 \
|
file://filesystem-volumes.patch;patch=1 \
|
||||||
file://filechooser-respect-style.patch;patch=1 \
|
file://filechooser-respect-style.patch;patch=1 \
|
||||||
file://filechooser-default.patch;patch=1 \
|
file://filechooser-default.patch;patch=1 \
|
||||||
|
file://toggle-font.diff;patch=1;pnum=0 \
|
||||||
"
|
"
|
||||||
|
|
||||||
EXTRA_OECONF = "--without-libtiff --disable-xkb --disable-glibtest"
|
EXTRA_OECONF = "--without-libtiff --disable-xkb --disable-glibtest"
|
||||||
|
|||||||
Reference in New Issue
Block a user