patch to gnome-propertybox.c




I think all the setup stuff should be in gnome_property_box_init()
rather than in _new(), so the widget can be subclassed. This would be
consistent with GtkDialog and that tictactoe example in the Gtk
tutorial.

This patch does the appropriate cut and paste.

Havoc Pennington
http://pobox.com/~hp

Index: gnome-libs/libgnomeui/gnome-propertybox.c
===================================================================
RCS file: /debian/home/gnomecvs/gnome-libs/libgnomeui/gnome-propertybox.c,v
retrieving revision 1.3
diff -u -r1.3 gnome-propertybox.c
--- gnome-propertybox.c	1998/03/22 08:37:45	1.3
+++ gnome-propertybox.c	1998/03/23 21:43:46
@@ -157,10 +157,68 @@
 static void
 gnome_property_box_init (GnomePropertyBox *property_box)
 {
-	property_box->notebook = property_box->ok_button = NULL;
-	property_box->apply_button = property_box->cancel_button = NULL;
-	property_box->help_button = NULL;
-	property_box->items = NULL;
+  GtkWidget *vbox, *hbox, *bf;
+
+  property_box->notebook = gtk_notebook_new ();
+
+  property_box->ok_button = gnome_stock_button (GNOME_STOCK_BUTTON_OK);
+  property_box->apply_button
+    = gnome_stock_button (GNOME_STOCK_BUTTON_APPLY);
+  property_box->cancel_button
+    = gnome_stock_button (GNOME_STOCK_BUTTON_CLOSE);
+  property_box->help_button
+    = gnome_stock_button (GNOME_STOCK_BUTTON_HELP);
+
+  property_box->items = NULL;
+
+  gtk_widget_set_sensitive (property_box->ok_button, FALSE);
+  gtk_widget_set_sensitive (property_box->apply_button, FALSE);
+
+  gtk_signal_connect (GTK_OBJECT (property_box->ok_button), "clicked",
+		      GTK_SIGNAL_FUNC (apply_and_close), property_box);
+  gtk_signal_connect (GTK_OBJECT (property_box->apply_button), "clicked",
+		      GTK_SIGNAL_FUNC (global_apply), property_box);
+  gtk_signal_connect (GTK_OBJECT (property_box->cancel_button),
+		      "clicked",
+		      GTK_SIGNAL_FUNC (just_close), property_box);
+  gtk_signal_connect (GTK_OBJECT (property_box->help_button), "clicked",
+		      GTK_SIGNAL_FUNC (help), property_box);
+
+  /* FIXME: connect delete_event to run just_close?  */
+
+  hbox = gtk_hbox_new (FALSE, GNOME_PAD);
+  gtk_container_border_width (GTK_CONTAINER (hbox), GNOME_PAD);
+
+  bf = gtk_frame_new (NULL);
+  gtk_frame_set_shadow_type (GTK_FRAME (bf), GTK_SHADOW_OUT);
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (property_box), vbox);
+
+  gtk_box_pack_start (GTK_BOX (vbox), property_box->notebook,
+		      FALSE, FALSE, 0);
+
+  gtk_box_pack_end (GTK_BOX (hbox), property_box->help_button,
+		    FALSE, FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (hbox), property_box->cancel_button,
+		    FALSE, FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (hbox), property_box->apply_button,
+		    FALSE, FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (hbox), property_box->ok_button,
+		    FALSE, FALSE, 0);
+
+  gtk_container_add (GTK_CONTAINER (bf), hbox);
+  gtk_box_pack_start (GTK_BOX (vbox), bf, FALSE, FALSE, 0);
+
+  gtk_widget_show (property_box->ok_button);
+  gtk_widget_show (property_box->apply_button);
+  gtk_widget_show (property_box->cancel_button);
+  gtk_widget_show (property_box->help_button);
+
+  gtk_widget_show (hbox);
+  gtk_widget_show (bf);
+  gtk_widget_show (property_box->notebook);
+  gtk_widget_show (vbox);
 }
 
 static void
@@ -185,74 +243,7 @@
 GtkWidget *
 gnome_property_box_new (void)
 {
-	GtkWidget *ret, *vbox, *hbox, *bf;
-	GnomePropertyBox *property_box;
-
-	ret = gtk_type_new (gnome_property_box_get_type ());
-	property_box = GNOME_PROPERTY_BOX (ret);
-
-	property_box->notebook = gtk_notebook_new ();
-
-	property_box->ok_button = gnome_stock_button (GNOME_STOCK_BUTTON_OK);
-	property_box->apply_button
-		= gnome_stock_button (GNOME_STOCK_BUTTON_APPLY);
-	property_box->cancel_button
-		= gnome_stock_button (GNOME_STOCK_BUTTON_CLOSE);
-	property_box->help_button
-		= gnome_stock_button (GNOME_STOCK_BUTTON_HELP);
-
-	property_box->items = NULL;
-
-	gtk_widget_set_sensitive (property_box->ok_button, FALSE);
-	gtk_widget_set_sensitive (property_box->apply_button, FALSE);
-
-	gtk_signal_connect (GTK_OBJECT (property_box->ok_button), "clicked",
-			    GTK_SIGNAL_FUNC (apply_and_close), property_box);
-	gtk_signal_connect (GTK_OBJECT (property_box->apply_button), "clicked",
-			    GTK_SIGNAL_FUNC (global_apply), property_box);
-	gtk_signal_connect (GTK_OBJECT (property_box->cancel_button),
-			    "clicked",
-			    GTK_SIGNAL_FUNC (just_close), property_box);
-	gtk_signal_connect (GTK_OBJECT (property_box->help_button), "clicked",
-			    GTK_SIGNAL_FUNC (help), property_box);
-
-	/* FIXME: connect delete_event to run just_close?  */
-
-	hbox = gtk_hbox_new (FALSE, GNOME_PAD);
-	gtk_container_border_width (GTK_CONTAINER (hbox), GNOME_PAD);
-
-	bf = gtk_frame_new (NULL);
-	gtk_frame_set_shadow_type (GTK_FRAME (bf), GTK_SHADOW_OUT);
-
-	vbox = gtk_vbox_new (FALSE, 0);
-	gtk_container_add (GTK_CONTAINER (property_box), vbox);
-
-	gtk_box_pack_start (GTK_BOX (vbox), property_box->notebook,
-			    FALSE, FALSE, 0);
-
-	gtk_box_pack_end (GTK_BOX (hbox), property_box->help_button,
-			  FALSE, FALSE, 0);
-	gtk_box_pack_end (GTK_BOX (hbox), property_box->cancel_button,
-			  FALSE, FALSE, 0);
-	gtk_box_pack_end (GTK_BOX (hbox), property_box->apply_button,
-			  FALSE, FALSE, 0);
-	gtk_box_pack_end (GTK_BOX (hbox), property_box->ok_button,
-			  FALSE, FALSE, 0);
-
-	gtk_container_add (GTK_CONTAINER (bf), hbox);
-	gtk_box_pack_start (GTK_BOX (vbox), bf, FALSE, FALSE, 0);
-
-	gtk_widget_show (property_box->ok_button);
-	gtk_widget_show (property_box->apply_button);
-	gtk_widget_show (property_box->cancel_button);
-	gtk_widget_show (property_box->help_button);
-
-	gtk_widget_show (hbox);
-	gtk_widget_show (bf);
-	gtk_widget_show (property_box->notebook);
-	gtk_widget_show (vbox);
-
-	return ret;
+  return GTK_WIDGET(gtk_type_new (gnome_property_box_get_type ()));
 }
 
 static void




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