GtkViewport patch



Unless I've missed some, this patch removes the deprecated functions
from GtkViewport.  There were also some signal_emit_by_name which are not
needed as GtkAdjustment has public functions to do the same.

(Also attached to 52790. Hope I get this right this time. :-)

Cheers,
Greg Merchan
Index: gtk/gtkviewport.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkviewport.c,v
retrieving revision 1.55
diff -u -r1.55 gtkviewport.c
--- gtk/gtkviewport.c	2002/01/09 12:24:03	1.55
+++ gtk/gtkviewport.c	2002/01/19 21:21:00
@@ -79,19 +79,20 @@
 
   if (!viewport_type)
     {
-      static const GtkTypeInfo viewport_info =
+      static const GTypeInfo viewport_info =
       {
-	"GtkViewport",
-	sizeof (GtkViewport),
 	sizeof (GtkViewportClass),
-	(GtkClassInitFunc) gtk_viewport_class_init,
-	(GtkObjectInitFunc) gtk_viewport_init,
-	/* reserved_1 */ NULL,
-        /* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
+	NULL,
+	NULL,
+	(GClassInitFunc) gtk_viewport_class_init,
+	NULL,
+	NULL,
+	sizeof (GtkViewport),
+	0,
+	(GInstanceInitFunc) gtk_viewport_init
       };
 
-      viewport_type = gtk_type_unique (GTK_TYPE_BIN, &viewport_info);
+      viewport_type = g_type_register_static (gtk_bin_get_type (), "GtkViewport", &viewport_info, 0);
     }
 
   return viewport_type;
@@ -109,7 +110,7 @@
   gobject_class = G_OBJECT_CLASS (class);
   widget_class = (GtkWidgetClass*) class;
   container_class = (GtkContainerClass*) class;
-  parent_class = (GtkBinClass*) gtk_type_class (GTK_TYPE_BIN);
+  parent_class = (GtkBinClass*) g_type_class_peek_parent (class);
 
   gobject_class->set_property = gtk_viewport_set_property;
   gobject_class->get_property = gtk_viewport_get_property;
@@ -152,12 +153,13 @@
 						      G_PARAM_READWRITE));
 
   widget_class->set_scroll_adjustments_signal =
-    gtk_signal_new ("set_scroll_adjustments",
-		    GTK_RUN_LAST,
-		    GTK_CLASS_TYPE (object_class),
-		    GTK_SIGNAL_OFFSET (GtkViewportClass, set_scroll_adjustments),
-		    _gtk_marshal_VOID__OBJECT_OBJECT,
-		    GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
+    g_signal_new ("set_scroll_adjustments",
+		  G_TYPE_FROM_CLASS (gobject_class),
+		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		  G_STRUCT_OFFSET (GtkViewportClass, set_scroll_adjustments),
+		  NULL, NULL,
+		  _gtk_marshal_VOID__OBJECT_OBJECT,
+		  G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
 }
 
 static void
@@ -259,14 +261,14 @@
 
   if (viewport->hadjustment)
     {
-      gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), viewport);
-      gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
+      g_signal_handlers_disconnect_matched (viewport->hadjustment, G_SIGNAL_MATCH_DATA, 0, 0, NULL, 0, viewport);
+      g_object_unref (viewport->hadjustment);
       viewport->hadjustment = NULL;
     }
   if (viewport->vadjustment)
     {
-      gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), viewport);
-      gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
+      g_signal_handlers_disconnect_matched (viewport->vadjustment, G_SIGNAL_MATCH_DATA, 0, 0, NULL, 0, viewport);
+      g_object_unref (viewport->vadjustment);
       viewport->vadjustment = NULL;
     }
 
@@ -328,8 +330,8 @@
 
   if (viewport->hadjustment && viewport->hadjustment != adjustment)
     {
-      gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), viewport);
-      gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
+      g_signal_handlers_disconnect_matched (viewport->hadjustment, G_SIGNAL_MATCH_DATA, 0, 0, NULL, 0, viewport);
+      g_object_unref (viewport->hadjustment);
       viewport->hadjustment = NULL;
     }
 
@@ -340,15 +342,15 @@
   if (viewport->hadjustment != adjustment)
     {
       viewport->hadjustment = adjustment;
-      gtk_object_ref (GTK_OBJECT (viewport->hadjustment));
+      g_object_ref (viewport->hadjustment);
       gtk_object_sink (GTK_OBJECT (viewport->hadjustment));
       
-      gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
-			  (GtkSignalFunc) gtk_viewport_adjustment_changed,
-			  (gpointer) viewport);
-      gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
-			  (GtkSignalFunc) gtk_viewport_adjustment_value_changed,
-			  (gpointer) viewport);
+      g_signal_connect (adjustment, "changed",
+			G_CALLBACK (gtk_viewport_adjustment_changed),
+			(gpointer) viewport);
+      g_signal_connect (adjustment, "value_changed",
+			G_CALLBACK (gtk_viewport_adjustment_value_changed),
+			(gpointer) viewport);
 
       gtk_viewport_adjustment_changed (adjustment, viewport);
     }
@@ -373,8 +375,8 @@
 
   if (viewport->vadjustment && viewport->vadjustment != adjustment)
     {
-      gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), viewport);
-      gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
+      g_signal_handlers_disconnect_matched (viewport->vadjustment, G_SIGNAL_MATCH_DATA, 0, 0, NULL, 0, viewport);
+      g_object_unref (viewport->vadjustment);
       viewport->vadjustment = NULL;
     }
 
@@ -385,15 +387,15 @@
   if (viewport->vadjustment != adjustment)
     {
       viewport->vadjustment = adjustment;
-      gtk_object_ref (GTK_OBJECT (viewport->vadjustment));
+      g_object_ref (viewport->vadjustment);
       gtk_object_sink (GTK_OBJECT (viewport->vadjustment));
       
-      gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
-			  (GtkSignalFunc) gtk_viewport_adjustment_changed,
-			  (gpointer) viewport);
-      gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
-			  (GtkSignalFunc) gtk_viewport_adjustment_value_changed,
-			  (gpointer) viewport);
+      g_signal_connect (adjustment, "changed",
+			G_CALLBACK (gtk_viewport_adjustment_changed),
+			(gpointer) viewport);
+      g_signal_connect (adjustment, "value_changed",
+			G_CALLBACK (gtk_viewport_adjustment_value_changed),
+			(gpointer) viewport);
 
       gtk_viewport_adjustment_changed (adjustment, viewport);
     }
@@ -768,17 +770,17 @@
       gtk_widget_size_allocate (bin->child, &child_allocation);
     }
 
-  gtk_signal_emit_by_name (GTK_OBJECT (viewport->hadjustment), "changed");
-  gtk_signal_emit_by_name (GTK_OBJECT (viewport->vadjustment), "changed");
+  gtk_adjustment_changed (GTK_ADJUSTMENT (viewport->hadjustment));
+  gtk_adjustment_changed (GTK_ADJUSTMENT (viewport->vadjustment));
   if (viewport->hadjustment->value != hval)
     {
       viewport->hadjustment->value = hval;
-      gtk_signal_emit_by_name (GTK_OBJECT (viewport->hadjustment), "value_changed");
+      gtk_adjustment_value_changed (GTK_ADJUSTMENT (viewport->hadjustment));
     }
   if (viewport->vadjustment->value != vval)
     {
       viewport->vadjustment->value = vval;
-      gtk_signal_emit_by_name (GTK_OBJECT (viewport->vadjustment), "value_changed");
+      gtk_adjustment_value_changed (GTK_ADJUSTMENT (viewport->vadjustment));
     }
 }
 


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