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

Re: gEDA-dev: GschemDialog finally works!



> Peter, I would really appreciate if you could review the
> patch and remove things like '#if 0' and some other commented
> code since I'm not sure what it does or if it will be needed.
> As for the comments, I don't think there is much work needed,
> the functions in gschem_dialog.c are pretty much self explanatory,
> but what I feel missing is perhaps a paragraph about creating new
> dialogs with GschemDialog as a base. Other than that, I am very
> positive about this patch.

Ivan, here is a slightly updated patch. I'm away this weekend, so
haven't got this completed yet. It does remove the #if 0 sections, and
re-introduces a commented out default size for the page manager. (Still
useful until the settings are saved.)

I'm uneasy about the use of "atexit(..)" with regards to portability. It
seems a little low level for us to be using generally like this.

I'm unsure where the correct place to call from is, but x_window_close()
or gschem_quit() look like contenders. We could add a close handler
hooking API for this so that we don't have to explicitly add a
non-static save_geometry_to_file(..) and call it ourselves.

This retinas the spirit of the current code, whilst avoiding the low
level atexit() call.

There was also the question of emitting our own signals, "save-state"
and "restore-state" for example, which derived dialogs could use to add
extra saved data.

I'd appreciate feedback from Ales, and those using other architectures
(Dan / Dave McGuire / DJ?) as to whether atexit() might cause issues.

Best regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
diff --git a/gschem/include/Makefile.am b/gschem/include/Makefile.am
index b27904e..2ffb9bc 100644
--- a/gschem/include/Makefile.am
+++ b/gschem/include/Makefile.am
@@ -6,7 +6,8 @@ noinst_HEADERS = \
 	globals.h i_vars.h prototype.h x_dialog.h x_event.h x_states.h \
 	gettext.h \
 	x_compselect.h \
-	x_log.h x_multiattrib.h x_pagesel.h x_print.h x_preview.h
+	x_log.h x_multiattrib.h x_pagesel.h x_print.h x_preview.h \
+	gschem_dialog.h
 
 MOSTLYCLEANFILES = *.log core FILE *~
 CLEANFILES = *.log core FILE *~
diff --git a/gschem/include/gschem_dialog.h b/gschem/include/gschem_dialog.h
new file mode 100644
index 0000000..bffd5b0
--- /dev/null
+++ b/gschem/include/gschem_dialog.h
@@ -0,0 +1,54 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2004 Ales V. Hvezda
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef __GSCHEM_DIALOG_H__
+#define __GSCHEM_DIALOG_H__
+
+
+#define GSCHEM_TYPE_DIALOG           (gschem_dialog_get_type())
+#define GSCHEM_DIALOG(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSCHEM_TYPE_DIALOG, GschemDialog))
+#define GSCHEM_DIALOG_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass),  GSCHEM_TYPE_DIALOG, GschemDialogClass))
+#define GSCHEM_IS_DIALOG(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSCHEM_TYPE_DIALOG))
+#define GSCHEM_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),  GSCHEM_TYPE_DIALOG, GschemDialogClass))
+
+typedef struct _GschemDialogClass GschemDialogClass;
+typedef struct _GschemDialog      GschemDialog;
+
+
+struct _GschemDialogClass {
+  GtkDialogClass parent_class;
+};
+
+struct _GschemDialog {
+  GtkDialog parent_instance;
+
+  gchar *settings_name;
+  TOPLEVEL *toplevel;
+};
+
+
+GType gschem_dialog_get_type (void);
+
+GtkWidget* gschem_dialog_new_with_buttons (const gchar *title, GtkWindow *parent, GtkDialogFlags flags,
+                                           const gchar *settings_name, TOPLEVEL *toplevel,
+                                           const gchar *first_button_text, ...);
+
+
+#endif /* __GSCHEM_DIALOG_H__ */
diff --git a/gschem/include/x_compselect.h b/gschem/include/x_compselect.h
index ead1ea7..18d718f 100644
--- a/gschem/include/x_compselect.h
+++ b/gschem/include/x_compselect.h
@@ -52,17 +52,15 @@ typedef struct _Compselect      Compselect;
 
 
 struct _CompselectClass {
-  GtkDialogClass parent_class;
+  GschemDialogClass parent_class;
 
   guint behavior_changed_signal_id;
 
 };
 
 struct _Compselect {
-  GtkDialog parent_instance;
+  GschemDialog parent_instance;
 
-  TOPLEVEL *toplevel;
-  
   GtkTreeView *treeview;
   Preview     *preview;
   GtkEntry    *entry_filter;
diff --git a/gschem/include/x_log.h b/gschem/include/x_log.h
index 17081a1..e5fa5de 100644
--- a/gschem/include/x_log.h
+++ b/gschem/include/x_log.h
@@ -35,11 +35,11 @@ typedef struct _Log      Log;
 
 
 struct _LogClass {
-  GtkDialogClass parent_class;
+  GschemDialogClass parent_class;
 };
 
 struct _Log {
-  GtkDialog parent_instance;
+  GschemDialog parent_instance;
 
   GtkTextView *textview;
 
diff --git a/gschem/include/x_multiattrib.h b/gschem/include/x_multiattrib.h
index 4a78862..2fe2684 100644
--- a/gschem/include/x_multiattrib.h
+++ b/gschem/include/x_multiattrib.h
@@ -42,14 +42,13 @@ typedef struct _Multiattrib      Multiattrib;
 
 
 struct _MultiattribClass {
-  GtkDialogClass parent_class;
+  GschemDialogClass parent_class;
   
 };
 
 struct _Multiattrib {
-  GtkDialog parent_instance;
+  GschemDialog parent_instance;
 
-  TOPLEVEL *toplevel;
   OBJECT *object;
 
   GtkTreeView    *treeview;
diff --git a/gschem/include/x_pagesel.h b/gschem/include/x_pagesel.h
index 2efe5a8..fcf9a1e 100644
--- a/gschem/include/x_pagesel.h
+++ b/gschem/include/x_pagesel.h
@@ -36,16 +36,13 @@ typedef struct _Pagesel      Pagesel;
 
 
 struct _PageselClass {
-  GtkDialogClass parent_class;
+  GschemDialogClass parent_class;
 };
 
 struct _Pagesel {
-  GtkDialog parent_instance;
-
-  TOPLEVEL *toplevel;
+  GschemDialog parent_instance;
 
   GtkTreeView *treeview;
-  
 };
 
 
diff --git a/gschem/include/x_print.h b/gschem/include/x_print.h
index 0b5914a..c3505e4 100644
--- a/gschem/include/x_print.h
+++ b/gschem/include/x_print.h
@@ -35,12 +35,12 @@ typedef struct _PrintDialog PrintDialog;
 
 struct _PrintDialogClass
 {
-  GtkDialogClass parent_class;
+  GschemDialogClass parent_class;
 };
 
 struct _PrintDialog
 {
-  GtkDialog parent_instance;
+  GschemDialog parent_instance;
 
   GtkEntry *fnfield, *cmdfield;
   GtkRadioButton *fileradio, *cmdradio;
diff --git a/gschem/src/Makefile.am b/gschem/src/Makefile.am
index 012015a..f99ee92 100644
--- a/gschem/src/Makefile.am
+++ b/gschem/src/Makefile.am
@@ -22,7 +22,8 @@ gschem_SOURCES = \
 	x_pagesel.c x_print.c x_window.c x_stroke.c x_image.c x_color.c \
 	x_compselect.c x_fileselect.c x_preview.c x_attribedit.c \
 	x_multiattrib.c \
-	parsecmd.c o_cue.c
+	parsecmd.c o_cue.c \
+	gschem_dialog.c
 
 if CCISGCC
 AM_CFLAGS = -Wall
diff --git a/gschem/src/gschem_dialog.c b/gschem/src/gschem_dialog.c
new file mode 100644
index 0000000..e47103d
--- /dev/null
+++ b/gschem/src/gschem_dialog.c
@@ -0,0 +1,368 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2000 Ales V. Hvezda
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ */
+
+#include <config.h>
+
+#include <glib/gstdio.h>
+
+#include <libgeda/libgeda.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "../include/globals.h"
+#include "../include/prototype.h"
+
+#ifdef HAVE_LIBDMALLOC
+#include <dmalloc.h>
+#endif
+
+#include "../include/gschem_dialog.h"
+
+
+#if !GLIB_CHECK_VERSION(2,6,0)
+
+static inline void save_geometry (GschemDialog *dialog) { }
+static inline void restore_geometry (GschemDialog *dialog) { }
+
+#else
+
+static GKeyFile *dialog_geometry = NULL;
+
+#define DIALOG_GEOMETRY_STORE "gschem-dialog-geometry"
+
+/*! \brief Save all geometry data into a file.
+ *
+ *  This is called at program exit.
+ */
+static void save_geometry_to_file()
+{
+  gchar *data, *file;
+
+  g_assert( dialog_geometry != NULL );
+
+  data = g_key_file_to_data(dialog_geometry, NULL, NULL);
+  file = g_build_filename(g_get_home_dir (), ".gEDA", DIALOG_GEOMETRY_STORE,
+        NULL);
+  g_file_set_contents(file, data, -1, NULL);
+  g_free(data);
+  g_free(file);
+}
+
+/*! \brief Save dialog's current position and size.
+ *
+ *  The dialog is referenced by its unique name (the
+ *  "settings-name" property).
+ */
+static void save_geometry (GschemDialog *dialog)
+{
+  gint x, y, width, height;
+  gchar *name;
+
+  name = dialog->settings_name;
+  if (name == NULL) return;
+
+  g_assert( dialog_geometry != NULL );
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+  gtk_window_get_size (GTK_WINDOW (dialog), &width, &height);
+
+  g_key_file_set_integer (dialog_geometry, name, "x", x);
+  g_key_file_set_integer (dialog_geometry, name, "y", y);
+  g_key_file_set_integer (dialog_geometry, name, "width",  width );
+  g_key_file_set_integer (dialog_geometry, name, "height", height);
+}
+
+
+/*! \brief Restore dialog's last position and size.
+ *
+ *  If the dialog is unknown, do nothing.
+ */
+static void restore_geometry (GschemDialog *dialog)
+{
+  gchar *name;
+  gint x, y, width, height;
+
+  name = dialog->settings_name;
+  if (name == NULL) return;
+
+  if (!dialog_geometry) {
+    gchar *file = g_build_filename (g_get_home_dir (), ".gEDA",
+                                    DIALOG_GEOMETRY_STORE, NULL);
+
+    dialog_geometry = g_key_file_new();
+
+    /* Remember to save data on program exit */
+    atexit(save_geometry_to_file);
+
+    if (!g_file_test (file, G_FILE_TEST_EXISTS)) {
+      gchar *dir = g_build_filename (g_get_home_dir (), ".gEDA", NULL);
+      g_mkdir (dir, S_IRWXU | S_IRWXG);
+      g_free (dir);
+
+      g_file_set_contents (file, "", -1, NULL);
+    }
+
+    if (!g_key_file_load_from_file (dialog_geometry, file, G_KEY_FILE_NONE, NULL)) {
+      /* error opening key file, create an empty one and try again */
+      g_file_set_contents (file, "", -1, NULL);
+      if ( !g_key_file_load_from_file (dialog_geometry, file, G_KEY_FILE_NONE, NULL)) {
+         g_free (file);
+         return;
+      }
+    }
+    g_free (file);
+  }
+
+  if (g_key_file_has_group (dialog_geometry, name)) {
+    x = g_key_file_get_integer (dialog_geometry, name, "x", NULL);
+    y = g_key_file_get_integer (dialog_geometry, name, "y", NULL);
+    width  = g_key_file_get_integer (dialog_geometry, name, "width",  NULL);
+    height = g_key_file_get_integer (dialog_geometry, name, "height", NULL);
+
+    gtk_window_move (GTK_WINDOW (dialog), x, y);
+    gtk_window_resize (GTK_WINDOW (dialog), width, height);
+  }
+}
+
+#endif   /* !GLIB_CHECK_VERSION(2,6,0) */
+
+
+enum {
+  PROP_SETTINGS_NAME = 1,
+  PROP_TOPLEVEL
+};
+
+static GObjectClass *gschem_dialog_parent_class = NULL;
+
+/*! \brief This handler is invoked right before the widget is
+ *  shown.
+ */
+static void show_handler (GtkWidget *widget)
+{
+  GschemDialog *dialog = GSCHEM_DIALOG( widget );
+
+  restore_geometry (dialog);
+
+  /* Let GTK show the window */
+  GTK_WIDGET_CLASS (gschem_dialog_parent_class)->show (widget);
+}
+
+
+/*! \brief This handler is invoked right before the widget is
+ *  unmapped (typically when you call gtk_widget_destroy()).
+ */
+static void unmap_handler (GtkWidget *widget)
+{
+  GschemDialog *dialog = GSCHEM_DIALOG (widget);
+
+  save_geometry (dialog);
+
+  /* Let GTK unmap the window */
+  GTK_WIDGET_CLASS (gschem_dialog_parent_class)->unmap (widget);
+}
+
+
+static void gschem_dialog_finalize (GObject *object)
+{
+  GschemDialog *dialog = GSCHEM_DIALOG (object);
+
+  if (dialog->settings_name) g_free (dialog->settings_name);
+
+  G_OBJECT_CLASS (gschem_dialog_parent_class)->finalize (object);
+}
+
+
+static void gschem_dialog_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+  GschemDialog *dialog = GSCHEM_DIALOG (object);
+
+  switch(property_id) {
+    case PROP_SETTINGS_NAME:
+      if (dialog->settings_name) g_free (dialog->settings_name);
+      dialog->settings_name = g_strdup (g_value_get_string (value));
+      break;
+    case PROP_TOPLEVEL:
+      dialog->toplevel = (TOPLEVEL*)g_value_get_pointer (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+
+}
+
+
+static void gschem_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+  GschemDialog *dialog = GSCHEM_DIALOG (object);
+
+  switch(property_id) {
+      case PROP_SETTINGS_NAME:
+        g_value_set_string (value, dialog->settings_name);
+        break;
+      case PROP_TOPLEVEL:
+        g_value_set_pointer (value, (gpointer)dialog->toplevel);
+        break;
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+
+}
+
+
+static void gschem_dialog_init (GschemDialog *dialog)
+{
+}
+
+
+static void gschem_dialog_class_init (GschemDialogClass *klass)
+{
+  GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+  GObjectClass     *gobject_class =   G_OBJECT_CLASS (klass);
+
+  gschem_dialog_parent_class = g_type_class_peek_parent (klass);
+
+  gtkwidget_class->show        = show_handler;
+  gtkwidget_class->unmap       = unmap_handler;
+
+  gobject_class->finalize      = gschem_dialog_finalize;
+  gobject_class->set_property  = gschem_dialog_set_property;
+  gobject_class->get_property  = gschem_dialog_get_property;
+
+  g_object_class_install_property (
+    gobject_class, PROP_SETTINGS_NAME,
+    g_param_spec_string ("settings-name",
+                         "",
+                         "",
+                         NULL,
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+  g_object_class_install_property (
+    gobject_class, PROP_TOPLEVEL,
+    g_param_spec_pointer ("toplevel",
+                          "",
+                          "",
+                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+}
+
+
+GType gschem_dialog_get_type ()
+{
+  static GType gschem_dialog_type = 0;
+
+  if (!gschem_dialog_type) {
+    static const GTypeInfo gschem_dialog_info = {
+      sizeof(GschemDialogClass),
+      NULL, /* base_init */
+      NULL, /* base_finalize */
+      (GClassInitFunc) gschem_dialog_class_init,
+      NULL, /* class_finalize */
+      NULL, /* class_data */
+      sizeof(GschemDialog),
+      0,    /* n_preallocs */
+      (GInstanceInitFunc) gschem_dialog_init,
+    };
+
+    gschem_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
+                                                 "GschemDialog",
+                                                 &gschem_dialog_info, 0);
+  }
+
+  return gschem_dialog_type;
+}
+
+/* Modified from GTK+-2.4.14 gtkdialog.c */
+static void gschem_dialog_add_buttons_valist (GtkDialog      *dialog,
+                                              const gchar    *first_button_text,
+                                              va_list         args)
+{
+  const gchar* text;
+  gint response_id;
+
+  g_return_if_fail (GTK_IS_DIALOG (dialog));
+
+  if (first_button_text == NULL)
+    return;
+
+  text = first_button_text;
+  response_id = va_arg (args, gint);
+
+  while (text != NULL)
+    {
+      gtk_dialog_add_button (dialog, text, response_id);
+
+      text = va_arg (args, gchar*);
+      if (text == NULL)
+        break;
+      response_id = va_arg (args, int);
+    }
+}
+
+/* Modified from GTK+-2.4.14 gtkdialog.c */
+static GtkWidget* gschem_dialog_new_empty (const gchar     *title,
+                                           GtkWindow       *parent,
+                                           GtkDialogFlags   flags,
+                                           const gchar *settings_name,
+                                           TOPLEVEL *toplevel)
+{
+  GschemDialog *dialog;
+
+  dialog = g_object_new (GSCHEM_TYPE_DIALOG,
+                         "settings-name", settings_name,
+                         "toplevel", toplevel,
+                         NULL);
+
+  if (title)
+    gtk_window_set_title (GTK_WINDOW (dialog), title);
+
+  if (parent)
+    gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+  if (flags & GTK_DIALOG_MODAL)
+    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+  if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
+    gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+
+  if (flags & GTK_DIALOG_NO_SEPARATOR)
+    gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+  return GTK_WIDGET (dialog);
+}
+
+
+/* Modified from GTK+-2.4.14 gtkdialog.c */
+GtkWidget* gschem_dialog_new_with_buttons (const gchar *title, GtkWindow *parent, GtkDialogFlags flags,
+                                           const gchar *settings_name, TOPLEVEL *toplevel,
+                                           const gchar *first_button_text, ...)
+{
+  GschemDialog *dialog;
+  va_list args;
+
+  dialog = GSCHEM_DIALOG (gschem_dialog_new_empty (title, parent, flags, settings_name, toplevel));
+
+  va_start (args, first_button_text);
+
+  gschem_dialog_add_buttons_valist (GTK_DIALOG (dialog),
+                                    first_button_text,
+                                    args);
+
+  va_end (args);
+
+  return GTK_WIDGET (dialog);
+}
+
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 08975a6..6dd541f 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -33,6 +33,7 @@
 #include "../include/i_vars.h"
 #include "../include/globals.h"
 #include "../include/prototype.h"
+#include "../include/gschem_dialog.h"
 #include "../include/x_dialog.h"
 
 #ifdef HAVE_LIBDMALLOC
@@ -322,14 +323,15 @@ void attrib_edit_dialog(TOPLEVEL * w_current, OBJECT * list, int flag)
     }
   }
 
-  aewindow = gtk_dialog_new_with_buttons(_("Single Attribute Editor"),
-					 GTK_WINDOW(w_current->main_window),
-					 GTK_DIALOG_MODAL,
-					 GTK_STOCK_CANCEL,
-					 GTK_RESPONSE_REJECT,
-					 GTK_STOCK_OK,
-					 GTK_RESPONSE_APPLY,
-					 NULL);
+  aewindow = gschem_dialog_new_with_buttons(_("Single Attribute Editor"),
+                                            GTK_WINDOW(w_current->main_window),
+                                            GTK_DIALOG_MODAL,
+                                            "singleattrib", w_current,
+                                            GTK_STOCK_CANCEL,
+                                            GTK_RESPONSE_REJECT,
+                                            GTK_STOCK_OK,
+                                            GTK_RESPONSE_APPLY,
+                                            NULL);
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
   gtk_dialog_set_alternative_button_order(GTK_DIALOG(aewindow),
diff --git a/gschem/src/x_autonumber.c b/gschem/src/x_autonumber.c
index a520db6..4a94f67 100644
--- a/gschem/src/x_autonumber.c
+++ b/gschem/src/x_autonumber.c
@@ -34,6 +34,7 @@
 #include "../include/i_vars.h"
 #include "../include/globals.h"
 #include "../include/prototype.h"
+#include "../include/gschem_dialog.h"
 #include "../include/x_dialog.h"
 
 #ifdef HAVE_LIBDMALLOC
@@ -1216,14 +1217,15 @@ GtkWidget* autonumber_create_dialog(TOPLEVEL *w_current)
   GtkWidget *label3;
 
 
-  autonumber_text = gtk_dialog_new_with_buttons(_("Autonumber text"),
-						GTK_WINDOW(w_current->main_window),
-						0, /* not modal */
-						GTK_STOCK_CLOSE,
-						GTK_RESPONSE_REJECT,
-						GTK_STOCK_APPLY,
-						GTK_RESPONSE_ACCEPT,
-						NULL);
+  autonumber_text = gschem_dialog_new_with_buttons(_("Autonumber text"),
+                                                   GTK_WINDOW(w_current->main_window),
+                                                   0, /* not modal */
+                                                   "autonumber", w_current,
+                                                   GTK_STOCK_CLOSE,
+                                                   GTK_RESPONSE_REJECT,
+                                                   GTK_STOCK_APPLY,
+                                                   GTK_RESPONSE_ACCEPT,
+                                                   NULL);
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
   gtk_dialog_set_alternative_button_order(GTK_DIALOG(autonumber_text),
diff --git a/gschem/src/x_compselect.c b/gschem/src/x_compselect.c
index 5f6e1b8..7ac33fd 100644
--- a/gschem/src/x_compselect.c
+++ b/gschem/src/x_compselect.c
@@ -46,8 +46,8 @@
 #include <dmalloc.h>
 #endif
 
+#include "../include/gschem_dialog.h"
 #include "../include/x_preview.h"
-
 #include "../include/x_compselect.h"
 
 /*! \def COMPSELECT_FILTER_INTERVAL
@@ -197,6 +197,9 @@ x_compselect_open (TOPLEVEL *toplevel)
   if (toplevel->cswindow == NULL) {
     toplevel->cswindow = GTK_WIDGET (
       g_object_new (TYPE_COMPSELECT,
+                    /* GschemDialog */
+                    "settings-name", "compselect",
+                    "toplevel",      toplevel,
                     NULL));
 
     g_signal_connect (toplevel->cswindow,
@@ -643,7 +646,7 @@ compselect_get_type ()
       (GInstanceInitFunc) compselect_init,
     };
                 
-    compselect_type = g_type_register_static (GTK_TYPE_DIALOG,
+    compselect_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
                                               "Compselect",
                                               &compselect_info, 0);
   }
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index 4fa4c79..862072d 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -33,6 +33,7 @@
 #include "../include/globals.h"
 #include "../include/prototype.h"
 #include "../include/x_dialog.h"
+#include "../include/gschem_dialog.h"
 
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
@@ -179,14 +180,15 @@ void text_input_dialog (TOPLEVEL *w_current)
   int real_tab_width;
 
   if (!w_current->tiwindow) { /* dialog not created yet */
-    w_current->tiwindow = gtk_dialog_new_with_buttons(_("Text Entry..."),
-						      GTK_WINDOW(w_current->main_window),
-						      0, /* NON_MODAL */
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_APPLY,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->tiwindow = gschem_dialog_new_with_buttons(_("Text Entry..."),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         0, /* NON_MODAL */
+                                                         "text-entry", w_current,
+                                                         GTK_STOCK_CLOSE,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_APPLY,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -503,14 +505,15 @@ void text_edit_dialog (TOPLEVEL *w_current, char *string, int text_size,
   int select_index=0;
 
   if (!w_current->tewindow) {
-    w_current->tewindow = gtk_dialog_new_with_buttons(_("Edit Text Properties"),
-						      GTK_WINDOW(w_current->main_window),
-						      GTK_DIALOG_MODAL,
-						      GTK_STOCK_CANCEL,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_OK,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->tewindow = gschem_dialog_new_with_buttons(_("Edit Text Properties"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "text-edit", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -867,14 +870,15 @@ void line_type_dialog (TOPLEVEL *w_current, GList *objects)
   line_type_data = (struct line_type_data*) g_malloc (
     sizeof (struct line_type_data));
 
-  dialog = gtk_dialog_new_with_buttons(_("Edit Line Width & Type"),
-				       GTK_WINDOW(w_current->main_window),
-				       GTK_DIALOG_MODAL,
-				       GTK_STOCK_CANCEL,
-				       GTK_RESPONSE_REJECT,
-				       GTK_STOCK_OK,
-				       GTK_RESPONSE_ACCEPT,
-				       NULL);
+  dialog = gschem_dialog_new_with_buttons(_("Edit Line Width & Type"),
+                                          GTK_WINDOW(w_current->main_window),
+                                          GTK_DIALOG_MODAL,
+                                          "line-type", w_current,
+                                          GTK_STOCK_CANCEL,
+                                          GTK_RESPONSE_REJECT,
+                                          GTK_STOCK_OK,
+                                          GTK_RESPONSE_ACCEPT,
+                                          NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1253,14 +1257,15 @@ void fill_type_dialog(TOPLEVEL *w_current, GList *objects)
   fill_type_data = (struct fill_type_data*) g_malloc (
     sizeof (struct fill_type_data));
 
-  dialog = gtk_dialog_new_with_buttons(_("Edit Fill Type"),
-				       GTK_WINDOW(w_current->main_window),
-				       GTK_DIALOG_MODAL,
-				       GTK_STOCK_CANCEL,
-				       GTK_RESPONSE_REJECT,
-				       GTK_STOCK_OK,
-				       GTK_RESPONSE_ACCEPT,
-				       NULL);
+  dialog = gschem_dialog_new_with_buttons(_("Edit Fill Type"),
+                                          GTK_WINDOW(w_current->main_window),
+                                          GTK_DIALOG_MODAL,
+                                          "fill-type", w_current,
+                                          GTK_STOCK_CANCEL,
+                                          GTK_RESPONSE_REJECT,
+                                          GTK_STOCK_OK,
+                                          GTK_RESPONSE_ACCEPT,
+                                          NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1474,14 +1479,15 @@ void arc_angle_dialog (TOPLEVEL *w_current)
   GtkWidget *spin_start, *spin_sweep;
 
   if (!w_current->aawindow) {
-    w_current->aawindow = gtk_dialog_new_with_buttons(_("Arc Params"),
-						      GTK_WINDOW(w_current->main_window),
-						      GTK_DIALOG_MODAL,
-						      GTK_STOCK_CANCEL,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_OK,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->aawindow = gschem_dialog_new_with_buttons(_("Arc Params"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "arc-angle", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1594,14 +1600,15 @@ void translate_dialog (TOPLEVEL *w_current)
   GtkWidget *vbox;
 
   if (!w_current->trwindow) {
-    w_current->trwindow = gtk_dialog_new_with_buttons(_("Translate"),
-						      GTK_WINDOW(w_current->main_window),
-						      GTK_DIALOG_MODAL,
-						      GTK_STOCK_CANCEL,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_OK,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->trwindow = gschem_dialog_new_with_buttons(_("Translate"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "translate", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1693,14 +1700,15 @@ void text_size_dialog (TOPLEVEL *w_current)
   GtkWidget *spin_size;
 
   if (!w_current->tswindow) {
-    w_current->tswindow = gtk_dialog_new_with_buttons(_("Text Size"),
-                                                      GTK_WINDOW(w_current->main_window),
-                                                      GTK_DIALOG_MODAL,
-                                                      GTK_STOCK_CANCEL,
-                                                      GTK_RESPONSE_REJECT,
-                                                      GTK_STOCK_OK,
-                                                      GTK_RESPONSE_ACCEPT,
-                                                      NULL);
+    w_current->tswindow = gschem_dialog_new_with_buttons(_("Text Size"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "text-size", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1799,14 +1807,15 @@ void snap_size_dialog (TOPLEVEL *w_current)
   GtkWidget *spin_size;
 
   if (!w_current->tswindow) {
-    w_current->tswindow = gtk_dialog_new_with_buttons(_("Snap Size"),
-                                                      GTK_WINDOW(w_current->main_window),
-                                                      GTK_DIALOG_MODAL,
-                                                      GTK_STOCK_CANCEL,
-                                                      GTK_RESPONSE_REJECT,
-                                                      GTK_STOCK_OK,
-                                                      GTK_RESPONSE_ACCEPT,
-                                                      NULL);
+    w_current->tswindow = gschem_dialog_new_with_buttons(_("Snap Size"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "snap-size", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1903,14 +1912,15 @@ void slot_edit_dialog (TOPLEVEL *w_current, char *string)
   GtkWidget *vbox;
 
   if (!w_current->sewindow) {
-    w_current->sewindow = gtk_dialog_new_with_buttons(_("Edit slot number"),
-						      GTK_WINDOW(w_current->main_window),
-						      GTK_DIALOG_MODAL,
-						      GTK_STOCK_CANCEL,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_OK,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->sewindow = gschem_dialog_new_with_buttons(_("Edit slot number"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "slot-edit", w_current,
+                                                         GTK_STOCK_CANCEL,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_OK,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -1997,12 +2007,13 @@ void about_dialog (TOPLEVEL *w_current)
   char *string;
 
   if (!w_current->abwindow) {
-    w_current->abwindow = gtk_dialog_new_with_buttons(_("About..."),
-						      GTK_WINDOW(w_current->main_window),
-						      GTK_DIALOG_MODAL,
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      NULL);
+    w_current->abwindow = gschem_dialog_new_with_buttons(_("About..."),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         GTK_DIALOG_MODAL,
+                                                         "about", w_current,
+                                                         GTK_STOCK_CLOSE,
+                                                         GTK_RESPONSE_REJECT,
+                                                         NULL);
 
     gtk_window_position (GTK_WINDOW (w_current->abwindow),
                          GTK_WIN_POS_MOUSE);
@@ -2090,12 +2101,13 @@ void coord_dialog (TOPLEVEL *w_current, int x, int y)
   GtkWidget *vbox;
 
   if (!w_current->cowindow) {
-    w_current->cowindow = gtk_dialog_new_with_buttons(_("Coords"),
-						      GTK_WINDOW(w_current->main_window),
-						      0, /* Not modal GTK_DIALOG_MODAL */
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      NULL);
+    w_current->cowindow = gschem_dialog_new_with_buttons(_("Coords"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         0, /* Not modal GTK_DIALOG_MODAL */
+                                                         "coord", w_current,
+                                                         GTK_STOCK_CLOSE,
+                                                         GTK_RESPONSE_REJECT,
+                                                         NULL);
 
     gtk_window_position (GTK_WINDOW (w_current->cowindow),
                          GTK_WIN_POS_NONE);
@@ -2405,14 +2417,15 @@ void color_edit_dialog (TOPLEVEL *w_current)
   int select_index = 0;
 
   if (!w_current->clwindow) {
-    w_current->clwindow = gtk_dialog_new_with_buttons(_("Color Edit"),
-						      GTK_WINDOW(w_current->main_window),
-						      0, /* nonmodal dialog */
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_APPLY,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->clwindow = gschem_dialog_new_with_buttons(_("Color Edit"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         0, /* nonmodal dialog */
+                                                         "color-edit", w_current,
+                                                         GTK_STOCK_CLOSE,
+                                                         GTK_RESPONSE_REJECT,
+                                                         GTK_STOCK_APPLY,
+                                                         GTK_RESPONSE_ACCEPT,
+                                                         NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -2498,12 +2511,13 @@ void x_dialog_hotkeys (TOPLEVEL *w_current)
   };
 
   if (!w_current->hkwindow) {
-    w_current->hkwindow = gtk_dialog_new_with_buttons(_("Hotkeys"),
-                                                      GTK_WINDOW(w_current->main_window),
-                                                      0, /* not modal */
-                                                      GTK_STOCK_CLOSE,
-                                                      GTK_RESPONSE_REJECT,
-                                                      NULL);
+    w_current->hkwindow = gschem_dialog_new_with_buttons(_("Hotkeys"),
+                                                         GTK_WINDOW(w_current->main_window),
+                                                         0, /* not modal */
+                                                         "hotkeys", w_current,
+                                                         GTK_STOCK_CLOSE,
+                                                         GTK_RESPONSE_REJECT,
+                                                         NULL);
 
     gtk_window_position (GTK_WINDOW (w_current->hkwindow),
                          GTK_WIN_POS_NONE);
@@ -2922,14 +2936,15 @@ void find_text_dialog(TOPLEVEL * w_current)
   }
 
   if (!w_current->tfindwindow) {
-    w_current->tfindwindow = gtk_dialog_new_with_buttons(_("Find Text"),
-							 GTK_WINDOW(w_current->main_window),
-							 0, /* not modal GTK_DIALOG_MODAL */
-							 GTK_STOCK_CLOSE,
-							 GTK_RESPONSE_REJECT,
-							 GTK_STOCK_FIND,
-							 GTK_RESPONSE_ACCEPT,
-							 NULL);
+    w_current->tfindwindow = gschem_dialog_new_with_buttons(_("Find Text"),
+                                                            GTK_WINDOW(w_current->main_window),
+                                                            0, /* not modal GTK_DIALOG_MODAL */
+                                                            "find-text", w_current,
+                                                            GTK_STOCK_CLOSE,
+                                                            GTK_RESPONSE_REJECT,
+                                                            GTK_STOCK_FIND,
+                                                            GTK_RESPONSE_ACCEPT,
+                                                            NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -3028,14 +3043,15 @@ void hide_text_dialog(TOPLEVEL * w_current)
   GtkWidget *vbox;
 
   if (!w_current->thidewindow) {
-    w_current->thidewindow = gtk_dialog_new_with_buttons(_("Hide Text"),
-						      GTK_WINDOW(w_current->main_window),
-						      0, /* not modal GTK_DIALOG_MODAL, */
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_APPLY,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->thidewindow = gschem_dialog_new_with_buttons(_("Hide Text"),
+                                                           GTK_WINDOW(w_current->main_window),
+                                                           0, /* not modal GTK_DIALOG_MODAL, */
+                                                           "hide-text", w_current,
+                                                           GTK_STOCK_CLOSE,
+                                                           GTK_RESPONSE_REJECT,
+                                                           GTK_STOCK_APPLY,
+                                                           GTK_RESPONSE_ACCEPT,
+                                                           NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
@@ -3128,14 +3144,15 @@ void show_text_dialog(TOPLEVEL * w_current)
   GtkWidget *vbox;
 
   if (!w_current->tshowwindow) {
-    w_current->tshowwindow = gtk_dialog_new_with_buttons(_("Show Text"),
-						      GTK_WINDOW(w_current->main_window),
-						      0, /* not modal GTK_DIALOG_MODAL, */
-						      GTK_STOCK_CLOSE,
-						      GTK_RESPONSE_REJECT,
-						      GTK_STOCK_APPLY,
-						      GTK_RESPONSE_ACCEPT,
-						      NULL);
+    w_current->tshowwindow = gschem_dialog_new_with_buttons(_("Show Text"),
+                                                            GTK_WINDOW(w_current->main_window),
+                                                            0, /* not modal GTK_DIALOG_MODAL, */
+                                                            "show-text", w_current,
+                                                            GTK_STOCK_CLOSE,
+                                                            GTK_RESPONSE_REJECT,
+                                                            GTK_STOCK_APPLY,
+                                                            GTK_RESPONSE_ACCEPT,
+                                                            NULL);
 
 #if GTK_CHECK_VERSION (2,6,0)
   /* Set the alternative button order (ok, cancel, help) for other systems */
diff --git a/gschem/src/x_log.c b/gschem/src/x_log.c
index fdee735..c230f64 100644
--- a/gschem/src/x_log.c
+++ b/gschem/src/x_log.c
@@ -43,6 +43,7 @@
 #include <dmalloc.h>
 #endif
 
+#include "../include/gschem_dialog.h"
 #include "../include/x_log.h"
 
 static void x_log_callback_response (GtkDialog *dialog,
@@ -62,6 +63,9 @@ void x_log_open ()
     gchar *contents;
     
     log_dialog = GTK_WIDGET (g_object_new (TYPE_LOG,
+                                           /* GschemDialog */
+                                           "settings-name", "log",
+                                           /* "toplevel", TOPEVEL * */
                                            NULL));
 
     g_signal_connect (log_dialog,
@@ -192,7 +196,7 @@ GType log_get_type ()
       (GInstanceInitFunc) log_init,
     };
 		
-    log_type = g_type_register_static (GTK_TYPE_DIALOG,
+    log_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
                                        "Log",
                                        &log_info, 0);
   }
diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index 363dd59..97caddb 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -37,6 +37,7 @@
 #endif
 
 #include <gdk/gdkkeysyms.h>
+#include "../include/gschem_dialog.h"
 #include "../include/x_multiattrib.h"
 
 /*! \brief Open multiple attribute editor dialog.
@@ -55,13 +56,16 @@ void x_multiattrib_open (TOPLEVEL *toplevel, OBJECT *object)
   GtkWidget *dialog;
 
   dialog = GTK_WIDGET (g_object_new (TYPE_MULTIATTRIB,
-                                     "toplevel", toplevel,
                                      "object", object,
+                                     /* GschemDialog */
+                                     "settings-name", "multiattrib",
+                                     "toplevel", toplevel,
                                      NULL));
 
   gtk_window_set_transient_for(GTK_WINDOW(dialog),
 			       GTK_WINDOW(toplevel->main_window));
 
+  multiattrib_update (MULTIATTRIB(dialog));
   gtk_widget_show (dialog);
   switch (gtk_dialog_run ((GtkDialog*)dialog)) {
       case MULTIATTRIB_RESPONSE_CLOSE:
@@ -378,8 +382,7 @@ static void cellrenderermultilinetext_init(CellRendererMultiLineText *self)
 
 
 enum {
-  PROP_TOPLEVEL=1,
-  PROP_OBJECT
+  PROP_OBJECT = 1
 };
 
 enum {
@@ -637,7 +640,7 @@ static void multiattrib_callback_edited_name(GtkCellRendererText *cellrendererte
   gchar *name, *value, *newtext;
 
   model = gtk_tree_view_get_model (multiattrib->treeview);
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
 
   if (!gtk_tree_model_get_iter_from_string (model, &iter, arg1)) {
     return;
@@ -692,7 +695,7 @@ static void multiattrib_callback_edited_value(GtkCellRendererText *cell_renderer
   gchar *name, *value, *newtext;
 
   model = gtk_tree_view_get_model (multiattrib->treeview);
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
 
   if (!gtk_tree_model_get_iter_from_string (model, &iter, arg1)) {
     return;
@@ -736,7 +739,7 @@ static void multiattrib_callback_toggled_visible(GtkCellRendererToggle *cell_ren
   gint visibility;
 
   model = gtk_tree_view_get_model (multiattrib->treeview);
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
 
   if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
     return;
@@ -778,7 +781,7 @@ static void multiattrib_callback_toggled_show_name(GtkCellRendererToggle *cell_r
   gint new_snv;
 
   model = gtk_tree_view_get_model (multiattrib->treeview);
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
 
   if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
     return;
@@ -827,7 +830,7 @@ static void multiattrib_callback_toggled_show_value(GtkCellRendererToggle *cell_
   gint new_snv;
 
   model = gtk_tree_view_get_model (multiattrib->treeview);
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
 
   if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
     return;
@@ -889,7 +892,7 @@ static gboolean multiattrib_callback_key_pressed(GtkWidget *widget,
                         -1);
     g_assert (o_attrib->type == OBJ_TEXT);
     
-    multiattrib_action_delete_attribute (multiattrib->toplevel,
+    multiattrib_action_delete_attribute (GSCHEM_DIALOG (multiattrib)->toplevel,
                                          o_attrib);
     
     /* update the treeview contents */
@@ -955,7 +958,7 @@ static void multiattrib_callback_popup_duplicate(GtkMenuItem *menuitem,
     return;
   }
 
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
   object   = multiattrib->object;
   
   gtk_tree_model_get (model, &iter,
@@ -991,8 +994,8 @@ static void multiattrib_callback_popup_delete(GtkMenuItem *menuitem,
     return;
   }
 
-  toplevel = multiattrib->toplevel;
-  
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
+
   gtk_tree_model_get (model, &iter,
                       COLUMN_ATTRIBUTE, &o_attrib,
                       -1);
@@ -1081,7 +1084,7 @@ static void multiattrib_callback_button_add(GtkButton *button,
   gboolean visible;
   gint shownv;
 
-  toplevel = multiattrib->toplevel;
+  toplevel = GSCHEM_DIALOG (multiattrib)->toplevel;
   object   = multiattrib->object;
   buffer   = gtk_text_view_get_buffer (multiattrib->textview_value);
   
@@ -1251,7 +1254,7 @@ GType multiattrib_get_type()
       (GInstanceInitFunc) multiattrib_init,
     };
 		
-    multiattrib_type = g_type_register_static (GTK_TYPE_DIALOG,
+    multiattrib_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
                                                "Multiattrib",
                                                &multiattrib_info, 0);
   }
@@ -1272,12 +1275,6 @@ static void multiattrib_class_init(MultiattribClass *klass)
   gobject_class->get_property = multiattrib_get_property;
 
   g_object_class_install_property (
-    gobject_class, PROP_TOPLEVEL,
-    g_param_spec_pointer ("toplevel",
-                          "",
-                          "",
-                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-  g_object_class_install_property (
     gobject_class, PROP_OBJECT,
     g_param_spec_pointer ("object",
                           "",
@@ -1317,7 +1314,6 @@ static void multiattrib_init(Multiattrib *multiattrib)
                 "has-separator",   TRUE,
                 NULL);
 
-  multiattrib->toplevel = NULL;
   multiattrib->object   = NULL;
 
   /* connect to the key-press-event of dialog */
@@ -1608,9 +1604,6 @@ static void multiattrib_set_property (GObject *object,
   Multiattrib *multiattrib = MULTIATTRIB (object);
 
   switch(property_id) {
-      case PROP_TOPLEVEL:
-        multiattrib->toplevel = (TOPLEVEL*)g_value_get_pointer (value);
-        break;
       case PROP_OBJECT:
         multiattrib->object = (OBJECT*)g_value_get_pointer (value);
         multiattrib_update (multiattrib);
@@ -1634,9 +1627,6 @@ static void multiattrib_get_property (GObject *object,
   Multiattrib *multiattrib = MULTIATTRIB (object);
 
   switch(property_id) {
-      case PROP_TOPLEVEL:
-        g_value_set_pointer (value, (gpointer)multiattrib->toplevel);
-        break;
       case PROP_OBJECT:
         g_value_set_pointer (value, (gpointer)multiattrib->object);
         break;
@@ -1658,7 +1648,7 @@ void multiattrib_update (Multiattrib *multiattrib)
   OBJECT **object_attribs, *o_current;
   gint i;
   
-  if (multiattrib->toplevel == NULL ||
+  if (GSCHEM_DIALOG (multiattrib)->toplevel == NULL ||
       multiattrib->object   == NULL) {
     /* we can not do anything until both toplevel and object are set */
     return;
@@ -1671,7 +1661,7 @@ void multiattrib_update (Multiattrib *multiattrib)
  
   /* get list of attributes */
   object_attribs = o_attrib_return_attribs (
-    multiattrib->toplevel->page_current->object_head,
+    GSCHEM_DIALOG (multiattrib)->toplevel->page_current->object_head,
     multiattrib->object);
   /* populate the store with attributes */
   if (object_attribs) {
diff --git a/gschem/src/x_pagesel.c b/gschem/src/x_pagesel.c
index a50caa0..8f1a8a7 100644
--- a/gschem/src/x_pagesel.c
+++ b/gschem/src/x_pagesel.c
@@ -35,6 +35,7 @@
 #include <dmalloc.h>
 #endif
 
+#include "../include/gschem_dialog.h"
 #include "../include/x_pagesel.h"
 
 
@@ -55,7 +56,9 @@ void x_pagesel_open (TOPLEVEL *toplevel)
 {
   if (toplevel->pswindow == NULL) {
     toplevel->pswindow = GTK_WIDGET (g_object_new (TYPE_PAGESEL,
-                                                   "toplevel", toplevel,
+                                                   /* GschemDialog */
+                                                   "settings-name", "pagesel",
+                                                   "toplevel",      toplevel,
                                                    NULL));
 
     g_signal_connect (toplevel->pswindow,
@@ -133,10 +136,6 @@ static void x_pagesel_callback_response (GtkDialog *dialog,
 }
 
 enum {
-  PROP_TOPLEVEL=1
-};
-
-enum {
   COLUMN_PAGE,
   COLUMN_NAME,
   COLUMN_CHANGED,
@@ -176,7 +175,7 @@ static void pagesel_callback_selection_changed (GtkTreeSelection *selection,
     return;
   }
 
-  toplevel = pagesel->toplevel;
+  toplevel = GSCHEM_DIALOG (pagesel)->toplevel;
   gtk_tree_model_get (model, &iter,
                       COLUMN_PAGE, &page,
                       -1);
@@ -234,7 +233,7 @@ static void                                                       \
 pagesel_callback_popup_ ## name (GtkMenuItem *menuitem,           \
                                  gpointer user_data)              \
 {                                                                 \
-  i_callback_ ## action (PAGESEL (user_data)->toplevel, 0, NULL); \
+  i_callback_ ## action (GSCHEM_DIALOG (user_data)->toplevel, 0, NULL); \
 }
 
 DEFINE_POPUP_CALLBACK (new_page,     file_new)
@@ -330,7 +329,7 @@ GType pagesel_get_type()
       (GInstanceInitFunc) pagesel_init,
     };
 		
-    pagesel_type = g_type_register_static (GTK_TYPE_DIALOG,
+    pagesel_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
                                            "Pagesel",
                                            &pagesel_info, 0);
   }
@@ -350,13 +349,6 @@ static void pagesel_class_init (PageselClass *klass)
   gobject_class->set_property = pagesel_set_property;
   gobject_class->get_property = pagesel_get_property;
 
-  g_object_class_install_property (
-    gobject_class, PROP_TOPLEVEL,
-    g_param_spec_pointer ("toplevel",
-                          "",
-                          "",
-                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-	
 }
 
 /*! \todo Finish function documentation!!!
@@ -492,7 +484,8 @@ static void pagesel_init (Pagesel *pagesel)
 					  -1);
 #endif
 
-  
+  /* Strictly, this has the wrong prototype, but it doesn't matter */
+  g_signal_connect( pagesel, "notify::toplevel", G_CALLBACK (pagesel_update), NULL );
 }
 
 /*! \todo Finish function documentation!!!
@@ -505,13 +498,9 @@ static void pagesel_set_property (GObject *object,
 				  const GValue *value,
 				  GParamSpec *pspec)
 {
-  Pagesel *pagesel = PAGESEL (object);
+/*  Pagesel *pagesel = PAGESEL (object); */
 
   switch(property_id) {
-      case PROP_TOPLEVEL:
-        pagesel->toplevel = (TOPLEVEL*)g_value_get_pointer (value);
-        pagesel_update (pagesel);
-        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -528,12 +517,9 @@ static void pagesel_get_property (GObject *object,
 				  GValue *value,
 				  GParamSpec *pspec)
 {
-  Pagesel *pagesel = PAGESEL (object);
+/*  Pagesel *pagesel = PAGESEL (object); */
 
   switch(property_id) {
-      case PROP_TOPLEVEL:
-        g_value_set_pointer (value, (gpointer)pagesel->toplevel);
-        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -628,9 +614,9 @@ void pagesel_update (Pagesel *pagesel)
 
   g_assert (IS_PAGESEL (pagesel));
 
-  g_return_if_fail (pagesel->toplevel);
+  g_return_if_fail (GSCHEM_DIALOG (pagesel)->toplevel);
 
-  toplevel = pagesel->toplevel;
+  toplevel = GSCHEM_DIALOG (pagesel)->toplevel;
   model    = gtk_tree_view_get_model (pagesel->treeview);
 
   /* wipe out every thing in the store */
diff --git a/gschem/src/x_print.c b/gschem/src/x_print.c
index 0a64694..dc0ca58 100644
--- a/gschem/src/x_print.c
+++ b/gschem/src/x_print.c
@@ -30,6 +30,7 @@
 
 #include "../include/globals.h"
 #include "../include/prototype.h"
+#include "../include/gschem_dialog.h"
 #include "../include/x_print.h"
 
 #ifdef HAVE_LIBDMALLOC
@@ -675,7 +676,7 @@ print_dialog_get_type ()
 	0,			/* n_preallocs */
 	(GInstanceInitFunc) print_dialog_init,
       };
-      print_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
+      print_dialog_type = g_type_register_static (GSCHEM_TYPE_DIALOG,
 						  "PrintDialog",
 						  &print_dialog_info, 0);
     }
@@ -729,13 +730,16 @@ x_print_setup (TOPLEVEL * w_current, char *filename)
   /* Create a print dialog, find out whether the user clicks Print or
      Cancel, and then print or return accordingly */
   dialog = GTK_DIALOG (g_object_new (TYPE_PRINT_DIALOG,
-						"command", command,
-						"filename", filename,
-						"papersize", paperidx,
-						"orientation", orient,
-						"type", type,
-						"usefile", usefile,
-						 NULL));
+                                     "command", command,
+                                     "filename", filename,
+                                     "papersize", paperidx,
+                                     "orientation", orient,
+                                     "type", type,
+                                     "usefile", usefile,
+                                     /* GschemDialog */
+                                     "settings-name", "print",
+                                     "toplevel", w_current,
+                                     NULL));
   gtk_widget_show_all (GTK_WIDGET (dialog));
 
   gtk_dialog_set_default_response(GTK_DIALOG(dialog),


_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev