Re: goocanvas 1.91.x releases?



On Wed, 2010-10-27 at 08:59 +0200, Murray Cumming wrote:
> > I did one, 1.90.1:
> >   http://ftp.gnome.org/pub/GNOME/sources/goocanvas/1.90/
> > 
> > The only thing changed since that is I fixed the flicker when
> zooming,
> > which isn't a major problem.
> 
> Many thanks. 

Unfortunately that doesn't build with the latest GTK+ release - GTK+
2.91.2, which changes how scrolling works. This patch fixes the build,
using code based on GtkTextView's new scrolling support. But I don't
actually see scrollbars in the demo, though I can't remember if I ever
did.
 
-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com
>From 8ded18b1b0dbe8301d8184a3bc8614c7f561a6b2 Mon Sep 17 00:00:00 2001
From: Murray Cumming <murrayc murrayc com>
Date: Wed, 27 Oct 2010 09:33:42 +0200
Subject: [PATCH] Fix the build with GTK+ 2.91.2, using GtkScrollable.

* src/goocanvas.[h|c] (goo_canvas_class_init): Implemeent the GtkScrollable
interface, overriding the hadjustment and vadjustment properties, instead
of implementing the set_scroll_adjustments vfunc, which was removed from
GtkWidget. Likewise remove the set_scroll_adjustments_signal because it
is no longer needed.
(goo_canvas_get_property), (goo_canvas_set_property): Handle the new
properties.
(goo_canvas_set_hadjustment), (goo_canvas_set_vadjustment): Replace
the old goo_canvas_set_adjustments() function with individual functions
because they can be set separately, and to have code that is as similar as
possible to, for instance, GtkTextView.
---
 ChangeLog       |   16 +++++++
 src/goocanvas.c |  135 +++++++++++++++++++++++++------------------------------
 src/goocanvas.h |    4 --
 3 files changed, 77 insertions(+), 78 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f6283e..872b53f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-27  Murray Cumming  <murrayc murrayc com>
+
+	Fix the build with GTK+ 2.91.2, using GtkScrollable.
+
+	* src/goocanvas.[h|c] (goo_canvas_class_init): Implemeent the GtkScrollable
+	interface, overriding the hadjustment and vadjustment properties, instead
+	of implementing the set_scroll_adjustments vfunc, which was removed from
+	GtkWidget. Likewise remove the set_scroll_adjustments_signal because it
+	is no longer needed.
+	(goo_canvas_get_property), (goo_canvas_set_property): Handle the new
+	properties.
+	(goo_canvas_set_hadjustment), (goo_canvas_set_vadjustment): Replace
+	the old goo_canvas_set_adjustments() function with individual functions
+	because they can be set separately, and to have code that is as similar as
+	possible to, for instance, GtkTextView.
+
 2010-10-24  Damon Chaplin  <damon gnome org>
 
 	* src/goocanvas.c (redraw_static_items_at_position)
diff --git a/src/goocanvas.c b/src/goocanvas.c
index b653969..52f13fd 100644
--- a/src/goocanvas.c
+++ b/src/goocanvas.c
@@ -138,7 +138,9 @@ enum {
   PROP_BACKGROUND_COLOR_RGB,
   PROP_INTEGER_LAYOUT,
   PROP_CLEAR_BACKGROUND,
-  PROP_REDRAW_WHEN_SCROLLED
+  PROP_REDRAW_WHEN_SCROLLED,
+  PROP_HADJUSTMENT,
+  PROP_VADJUSTMENT
 };
 
 enum {
@@ -161,9 +163,10 @@ static void     goo_canvas_size_request    (GtkWidget        *widget,
 					    GtkRequisition   *requisition);
 static void     goo_canvas_size_allocate   (GtkWidget        *widget,
 					    GtkAllocation    *allocation);
-static void     goo_canvas_set_adjustments (GooCanvas        *canvas,
-					    GtkAdjustment    *hadj,
-					    GtkAdjustment    *vadj);
+static void     goo_canvas_set_hadjustment (GooCanvas        *canvas,
+					    GtkAdjustment    *adjustment);
+static void     goo_canvas_set_vadjustment (GooCanvas        *canvas,
+					    GtkAdjustment    *adjustment);
 static gboolean goo_canvas_draw	   (GtkWidget        *widget,
 					    cairo_t          *cr);
 static gboolean goo_canvas_button_press    (GtkWidget        *widget,
@@ -227,7 +230,8 @@ static void     goo_canvas_convert_to_static_item_space (GooCanvas     *canvas,
 							 gdouble       *x,
 							 gdouble       *y);
 
-G_DEFINE_TYPE (GooCanvas, goo_canvas, GTK_TYPE_CONTAINER)
+G_DEFINE_TYPE_WITH_CODE (GooCanvas, goo_canvas, GTK_TYPE_CONTAINER,
+  G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
 
 /* This evaluates to TRUE if an item is still in the canvas. */
 #define ITEM_IS_VALID(item) (goo_canvas_item_get_canvas (item))
@@ -273,8 +277,6 @@ goo_canvas_class_init (GooCanvasClass *klass)
   container_class->remove	     = goo_canvas_remove;
   container_class->forall            = goo_canvas_forall;
 
-  klass->set_scroll_adjustments      = goo_canvas_set_adjustments;
-
   /* Register our accessible factory, but only if accessibility is enabled. */
   if (!ATK_IS_NO_OP_OBJECT_FACTORY (atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET)))
     {
@@ -428,27 +430,9 @@ goo_canvas_class_init (GooCanvasClass *klass)
 							 FALSE,
 							 G_PARAM_READWRITE));
 
-  /**
-   * GooCanvas::set-scroll-adjustments
-   * @canvas: the canvas.
-   * @hadjustment: the horizontal adjustment.
-   * @vadjustment: the vertical adjustment.
-   *
-   * This is used when the #GooCanvas is placed inside a #GtkScrolledWindow,
-   * to connect up the adjustments so scrolling works properly.
-   *
-   * It isn't useful for applications.
-   */
-  widget_class->set_scroll_adjustments_signal =
-    g_signal_new ("set_scroll_adjustments",
-		  G_OBJECT_CLASS_TYPE (gobject_class),
-		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		  G_STRUCT_OFFSET (GooCanvasClass, set_scroll_adjustments),
-		  NULL, NULL,
-		  goo_canvas_marshal_VOID__OBJECT_OBJECT,
-		  G_TYPE_NONE, 2,
-		  GTK_TYPE_ADJUSTMENT,
-		  GTK_TYPE_ADJUSTMENT);
+  /* GtkScrollable interface */
+  g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
+  g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
 
   /* Signals. */
 
@@ -773,6 +757,12 @@ goo_canvas_get_property    (GObject            *object,
     case PROP_REDRAW_WHEN_SCROLLED:
       g_value_set_boolean (value, canvas->redraw_when_scrolled);
       break;
+    case PROP_HADJUSTMENT:
+      goo_canvas_set_hadjustment (canvas, g_value_get_object (value));
+      break;
+    case PROP_VADJUSTMENT:
+      goo_canvas_set_vadjustment (canvas, g_value_get_object (value));
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -879,6 +869,12 @@ goo_canvas_set_property    (GObject            *object,
     case PROP_REDRAW_WHEN_SCROLLED:
       canvas->redraw_when_scrolled = g_value_get_boolean (value);
       break;
+    case PROP_HADJUSTMENT:
+      g_value_set_object (value, canvas->hadjustment);
+      break;
+    case PROP_VADJUSTMENT:
+      g_value_set_object (value, canvas->vadjustment);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -2069,71 +2065,62 @@ goo_canvas_adjustment_value_changed (GtkAdjustment *adjustment,
     }
 }
 
-
-/* Sets either or both adjustments, If hadj or vadj is NULL a new adjustment
-   is created. */
 static void
-goo_canvas_set_adjustments (GooCanvas     *canvas,
-			    GtkAdjustment *hadj,
-			    GtkAdjustment *vadj)
+goo_canvas_set_hadjustment (GooCanvas *canvas,
+			    GtkAdjustment *adjustment)
 {
-  gboolean need_reconfigure = FALSE;
-
   g_return_if_fail (GOO_IS_CANVAS (canvas));
 
-  if (hadj)
-    g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
-  else if (canvas->hadjustment)
-    hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
-
-  if (vadj)
-    g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
-  else if (canvas->vadjustment)
-    vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+  if (adjustment && canvas->hadjustment == adjustment)
+    return;
 
-  if (canvas->hadjustment && (canvas->hadjustment != hadj))
+  if (canvas->hadjustment)
     {
       g_signal_handlers_disconnect_by_func (canvas->hadjustment,
-					    goo_canvas_adjustment_value_changed,
-					    canvas);
+                                            goo_canvas_adjustment_value_changed,
+                                            canvas);
       g_object_unref (canvas->hadjustment);
     }
 
-  if (canvas->vadjustment && (canvas->vadjustment != vadj))
+  if (adjustment == NULL)
+    adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+  g_signal_connect (adjustment, "value-changed",
+                    G_CALLBACK (goo_canvas_adjustment_value_changed), canvas);
+  canvas->hadjustment = g_object_ref_sink (adjustment);
+  reconfigure_canvas (canvas, TRUE);
+
+  g_object_notify (G_OBJECT (canvas), "hadjustment");
+}
+
+static void
+goo_canvas_set_vadjustment (GooCanvas   *canvas,
+			    GtkAdjustment *adjustment)
+{
+  g_return_if_fail (GOO_IS_CANVAS (canvas));
+
+  if (adjustment && canvas->vadjustment == adjustment)
+    return;
+
+  if (canvas->vadjustment)
     {
       g_signal_handlers_disconnect_by_func (canvas->vadjustment,
-					    goo_canvas_adjustment_value_changed,
-					    canvas);
+                                            goo_canvas_adjustment_value_changed,
+                                            canvas);
       g_object_unref (canvas->vadjustment);
     }
 
-  if (canvas->hadjustment != hadj)
-    {
-      canvas->hadjustment = hadj;
-      g_object_ref_sink (canvas->hadjustment);
+  if (adjustment == NULL)
+    adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
 
-      g_signal_connect (canvas->hadjustment, "value_changed",
-			G_CALLBACK (goo_canvas_adjustment_value_changed),
-			canvas);
-      need_reconfigure = TRUE;
-    }
-
-  if (canvas->vadjustment != vadj)
-    {
-      canvas->vadjustment = vadj;
-      g_object_ref_sink (canvas->vadjustment);
-
-      g_signal_connect (canvas->vadjustment, "value_changed",
-			G_CALLBACK (goo_canvas_adjustment_value_changed),
-			canvas);
-      need_reconfigure = TRUE;
-    }
+  g_signal_connect (adjustment, "value-changed",
+                    G_CALLBACK (goo_canvas_adjustment_value_changed), canvas);
+  canvas->vadjustment = g_object_ref_sink (adjustment);
+  reconfigure_canvas (canvas, TRUE);
 
-  if (need_reconfigure)
-    reconfigure_canvas (canvas, TRUE);
+  g_object_notify (G_OBJECT (canvas), "vadjustment");
 }
 
-
 /* Sets one of our pointers to an item, adding a reference to it and
    releasing any reference to the current item. */
 static void
diff --git a/src/goocanvas.h b/src/goocanvas.h
index e2e41ac..9d511a6 100644
--- a/src/goocanvas.h
+++ b/src/goocanvas.h
@@ -172,10 +172,6 @@ struct _GooCanvasClass
   /*< private >*/
   GtkContainerClass parent_class;
 
-  void		 (* set_scroll_adjustments) (GooCanvas          *canvas,
-					     GtkAdjustment      *hadjustment,
-					     GtkAdjustment      *vadjustment);
-
   /* Virtual methods. */
   /*< public >*/
   GooCanvasItem* (* create_item)	    (GooCanvas          *canvas,
-- 
1.7.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]