[gucharmap] Implement [hv]scroll-policy properties
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] Implement [hv]scroll-policy properties
- Date: Tue, 26 Oct 2010 11:51:07 +0000 (UTC)
commit 1d381b01a2e21f73acc96a5399ce8d5134967a3a
Author: Christian Persch <chpe gnome org>
Date: Tue Oct 26 13:50:26 2010 +0200
Implement [hv]scroll-policy properties
gucharmap/gucharmap-chartable.c | 40 ++++++++++++++++++++++++++++++++++++--
gucharmap/gucharmap-private.h | 6 +++++
2 files changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/gucharmap/gucharmap-chartable.c b/gucharmap/gucharmap-chartable.c
index fa3865c..17ad733 100644
--- a/gucharmap/gucharmap-chartable.c
+++ b/gucharmap/gucharmap-chartable.c
@@ -67,6 +67,8 @@ enum
#if GTK_CHECK_VERSION (2, 91, 2)
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
+ PROP_HSCROLL_POLICY,
+ PROP_VSCROLL_POLICY,
#endif
PROP_ACTIVE_CHAR,
PROP_CODEPOINT_LIST,
@@ -1866,9 +1868,17 @@ gucharmap_chartable_get_accessible (GtkWidget *widget)
static void
gucharmap_chartable_set_hadjustment (GucharmapChartable *chartable,
- GtkAdjustment *vadjustment)
+ GtkAdjustment *hadjustment)
{
- /* do nothing */
+ GucharmapChartablePrivate *priv = chartable->priv;
+
+ if (hadjustment == priv->hadjustment)
+ return;
+
+ if (priv->hadjustment)
+ g_object_unref (priv->hadjustment);
+
+ priv->hadjustment = hadjustment ? g_object_ref_sink (hadjustment) : NULL;
}
static void
@@ -2103,7 +2113,7 @@ gucharmap_chartable_init (GucharmapChartable *chartable)
GucharmapChartablePrivate *priv;
priv = chartable->priv = G_TYPE_INSTANCE_GET_PRIVATE (chartable, GUCHARMAP_TYPE_CHARTABLE, GucharmapChartablePrivate);
-
+
priv->page_first_cell = 0;
priv->active_cell = 0;
priv->rows = 1;
@@ -2113,6 +2123,13 @@ gucharmap_chartable_init (GucharmapChartable *chartable)
priv->snap_pow2_enabled = FALSE;
priv->font_fallback = TRUE;
+ priv->vadjustment = NULL;
+#if GTK_CHECK_VERSION (2, 91, 2)
+ priv->hadjustment = NULL;
+ priv->hscroll_policy = GTK_SCROLL_NATURAL;
+ priv->vscroll_policy = GTK_SCROLL_NATURAL;
+#endif
+
/* This didn't fix the slow expose events either: */
/* gtk_widget_set_double_buffered (widget, FALSE); */
@@ -2169,6 +2186,7 @@ gucharmap_chartable_set_property (GObject *object,
GParamSpec *pspec)
{
GucharmapChartable *chartable = GUCHARMAP_CHARTABLE (object);
+ GucharmapChartablePrivate *priv = chartable->priv;
switch (prop_id) {
#if GTK_CHECK_VERSION (2, 91, 2)
@@ -2178,6 +2196,14 @@ gucharmap_chartable_set_property (GObject *object,
case PROP_VADJUSTMENT:
gucharmap_chartable_set_vadjustment (chartable, g_value_get_object (value));
break;
+ case PROP_HSCROLL_POLICY:
+ priv->hscroll_policy = g_value_get_enum (value);
+ gtk_widget_queue_resize_no_redraw (GTK_WIDGET (chartable));
+ break;
+ case PROP_VSCROLL_POLICY:
+ priv->vscroll_policy = g_value_get_enum (value);
+ gtk_widget_queue_resize_no_redraw (GTK_WIDGET (chartable));
+ break;
#endif
case PROP_ACTIVE_CHAR:
gucharmap_chartable_set_active_character (chartable, g_value_get_uint (value));
@@ -2223,6 +2249,12 @@ gucharmap_chartable_get_property (GObject *object,
case PROP_VADJUSTMENT:
g_value_set_object (value, priv->vadjustment);
break;
+ case PROP_HSCROLL_POLICY:
+ g_value_set_enum (value, priv->hscroll_policy);
+ break;
+ case PROP_VSCROLL_POLICY:
+ g_value_set_enum (value, priv->vscroll_policy);
+ break;
#endif
case PROP_ACTIVE_CHAR:
g_value_set_uint (value, gucharmap_chartable_get_active_character (chartable));
@@ -2306,6 +2338,8 @@ gucharmap_chartable_class_init (GucharmapChartableClass *klass)
/* GtkScrollable interface properties */
g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
+ g_object_class_override_property (object_class, PROP_HSCROLL_POLICY, "hscroll-policy");
+ g_object_class_override_property (object_class, PROP_VSCROLL_POLICY, "vscroll-policy");
#else
diff --git a/gucharmap/gucharmap-private.h b/gucharmap/gucharmap-private.h
index ad6d53c..b52ee37 100644
--- a/gucharmap/gucharmap-private.h
+++ b/gucharmap/gucharmap-private.h
@@ -37,6 +37,12 @@ struct _GucharmapChartablePrivate {
/* scrollable implementation */
GtkAdjustment *vadjustment;
gulong vadjustment_changed_handler_id;
+#if GTK_CHECK_VERSION (2, 91, 2)
+ /* GtkScrollable impl */
+ GtkAdjustment *hadjustment; /* unused */
+ guint hscroll_policy : 1; /* unused */
+ guint vscroll_policy : 1;
+#endif
/* Font */
PangoFontDescription *font_desc;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]