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

gEDA-cvs: branch: master updated (1.1.1.20070708-46-g0a7ab22)



The branch, master has been updated
       via  0a7ab22a482a896818dff52fbf289856d76efc87 (commit)
       via  ba79b83da22590108b7ca86e3e01de96ca05e1c9 (commit)
       via  224f1c8c4731eacbd63634efc01dcc6eead2e19e (commit)
       via  efc421976c48b6ed67537e796dd0c0fe3820d2c5 (commit)
       via  66e808f376b11460faec4c78834f8359969e6547 (commit)
       via  1aad087e0f59deb2cff728ff750bc34dcffc8ede (commit)
       via  789581dc215e86e9455eca830c66495592246f56 (commit)
       via  de149fd2d81b2c5432dceadfdc1100204d0f9d4e (commit)
      from  c31bd4adb677d671af8bdf5aed71f96a4995f9b1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gattrib/include/Makefile.am   |    5 +-
 gattrib/include/globals.h     |   63 +-------
 gattrib/include/pixmaps.h     |  243 ---------------------------
 gattrib/include/prototype.h   |   75 +--------
 gattrib/include/struct.h      |    1 -
 gattrib/include/x_menu.h      |  206 -----------------------
 gattrib/lib/Makefile.am       |    4 +-
 gattrib/lib/gattrib-menus.xml |   33 ++++
 gattrib/src/g_rc.c            |    4 +-
 gattrib/src/gattrib.c         |  221 ++++---------------------
 gattrib/src/globals.c         |   25 +---
 gattrib/src/s_toplevel.c      |  197 ++++------------------
 gattrib/src/x_dialog.c        |  156 ++++++------------
 gattrib/src/x_fileselect.c    |  180 ++++++++------------
 gattrib/src/x_gtksheet.c      |    3 +-
 gattrib/src/x_window.c        |  366 +++++++++++++++++++----------------------
 gschem/src/x_dialog.c         |    2 +-
 17 files changed, 411 insertions(+), 1373 deletions(-)
 delete mode 100644 gattrib/include/pixmaps.h
 delete mode 100644 gattrib/include/x_menu.h
 create mode 100644 gattrib/lib/gattrib-menus.xml


=================
 Commit Messages
=================

commit 0a7ab22a482a896818dff52fbf289856d76efc87
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Aug 1 22:58:05 2007 +0100

    Alter grammar in gschem's "Unsaved changes" dialog box.

:100644 100644 d71ac90... 3a2fe3f... M	gschem/src/x_dialog.c

commit ba79b83da22590108b7ca86e3e01de96ca05e1c9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Aug 1 22:57:05 2007 +0100

    Make gattrib honour the user's answer to confirm quit? on window close

:100644 100644 1d785e7... 1191737... M	gattrib/include/prototype.h
:100644 100644 8226793... 5c5c178... M	gattrib/src/gattrib.c
:100644 100644 d4275de... bb4f18f... M	gattrib/src/x_window.c

commit 224f1c8c4731eacbd63634efc01dcc6eead2e19e
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 22:56:58 2007 +0100

    gattrib: more dialog cleanup

:100644 100644 153637d... 1d785e7... M	gattrib/include/prototype.h
:100644 100644 02833ef... d948fa5... M	gattrib/src/x_dialog.c
:100644 100644 d2a055b... d4275de... M	gattrib/src/x_window.c

commit efc421976c48b6ed67537e796dd0c0fe3820d2c5
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:57:36 2007 +0100

    move menu callbacks to x_window.c
    
    This patch moves all menu callbacks to x_window.c, where
    they belong. The x_window_init() function is cleaned up.
    Selecting File->Open now causes the "unimplemented feature"
    dialog to pop up.

:100644 100644 fb14198... 0816c18... M	gattrib/include/globals.h
:100644 100644 5fa68b7... 153637d... M	gattrib/include/prototype.h
:100644 100644 8cd310f... 369a831... M	gattrib/src/s_toplevel.c
:100644 100644 8afb72b... d2a055b... M	gattrib/src/x_window.c

commit 66e808f376b11460faec4c78834f8359969e6547
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:52:42 2007 +0100

    gattrib: remove unused pixmaps.h

:100644 100644 ff01009... b94eb41... M	gattrib/include/Makefile.am
:100644 000000 5fb65e3... 0000000... D	gattrib/include/pixmaps.h
:100644 100644 89bc8f4... b245505... M	gattrib/include/struct.h

commit 1aad087e0f59deb2cff728ff750bc34dcffc8ede
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:52:40 2007 +0100

    gattrib: overhaul menu creation code

:100644 100644 05c77f2... ff01009... M	gattrib/include/Makefile.am
:100644 100644 378a5ab... 5fa68b7... M	gattrib/include/prototype.h
:100644 000000 b7f87e7... 0000000... D	gattrib/include/x_menu.h
:100644 100644 34ff2b2... 919c3db... M	gattrib/lib/Makefile.am
:000000 100644 0000000... 1526cb3... A	gattrib/lib/gattrib-menus.xml
:100644 100644 07aa160... 8cd310f... M	gattrib/src/s_toplevel.c
:100644 100644 b09ba0d... 8afb72b... M	gattrib/src/x_window.c

commit 789581dc215e86e9455eca830c66495592246f56
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 19:27:41 2007 +0100

    gattrib: remove unneeded globals

:100644 100644 e7561d2... fb14198... M	gattrib/include/globals.h
:100644 100644 b8a5a57... 2355d79... M	gattrib/src/g_rc.c
:100644 100644 6e98838... 8226793... M	gattrib/src/gattrib.c
:100644 100644 84e6abc... 390a60f... M	gattrib/src/globals.c

commit de149fd2d81b2c5432dceadfdc1100204d0f9d4e
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 19:27:31 2007 +0100

    gattrib: reorganize file opening code
    
    This patch reorganizes the file opening code
    and related code paths in gattrib. Besides
    simplifying the code, the patch also improves
    error reporting.

:100644 100644 c035c7f... e7561d2... M	gattrib/include/globals.h
:100644 100644 4fc48b7... 378a5ab... M	gattrib/include/prototype.h
:100644 100644 9d295d0... 6e98838... M	gattrib/src/gattrib.c
:100644 100644 ece96de... 84e6abc... M	gattrib/src/globals.c
:100644 100644 0e03f71... 07aa160... M	gattrib/src/s_toplevel.c
:100644 100644 204e27e... 02833ef... M	gattrib/src/x_dialog.c
:100644 100644 05dd4c0... f4e0d3f... M	gattrib/src/x_fileselect.c
:100644 100644 ea6d6da... b1d7b79... M	gattrib/src/x_gtksheet.c
:100644 100644 c30202b... b09ba0d... M	gattrib/src/x_window.c

=========
 Changes
=========

commit 0a7ab22a482a896818dff52fbf289856d76efc87
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Aug 1 22:58:05 2007 +0100

    Alter grammar in gschem's "Unsaved changes" dialog box.

diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index d71ac90..3a2fe3f 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -3725,7 +3725,7 @@ close_confirmation_dialog_constructor (GType type,
   } else {
     /* multi page */
     tmp = g_strdup_printf (
-      _("There is %d schematics with unsaved changes. "
+      _("There are %d schematics with unsaved changes. "
         "Save changes before closing?"),
       count_pages (GTK_TREE_MODEL (dialog->store_unsaved_pages)));
   }

commit ba79b83da22590108b7ca86e3e01de96ca05e1c9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Aug 1 22:57:05 2007 +0100

    Make gattrib honour the user's answer to confirm quit? on window close

diff --git a/gattrib/include/prototype.h b/gattrib/include/prototype.h
index 1d785e7..1191737 100644
--- a/gattrib/include/prototype.h
+++ b/gattrib/include/prototype.h
@@ -4,7 +4,7 @@
  */
 
 /* ---------------- gattrib.c ---------------- */
-void gattrib_really_quit(void);
+gboolean gattrib_really_quit(void);
 gint gattrib_quit(gint return_code);
 
 /* -------------- parsecmd.c ----------------- */
diff --git a/gattrib/src/gattrib.c b/gattrib/src/gattrib.c
index 8226793..5c5c178 100644
--- a/gattrib/src/gattrib.c
+++ b/gattrib/src/gattrib.c
@@ -74,7 +74,7 @@
  *  \return Returns 0 to shell (successful quit).
  *
  *------------------------------------------------------------------*/
-void gattrib_really_quit(void)
+gboolean gattrib_really_quit(void)
 {
   if (sheet_head->CHANGED == TRUE) {
     printf("User is quitting without saving last changes.\n");
@@ -82,6 +82,7 @@ void gattrib_really_quit(void)
   } else {
     gattrib_quit(0);
   }
+  return TRUE;
 }
 
 /*------------------------------------------------------------------*/
diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index d4275de..bb4f18f 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -88,8 +88,6 @@ x_window_init()
   
   gtk_signal_connect (GTK_OBJECT (window), "delete_event",
 		      GTK_SIGNAL_FUNC (gattrib_really_quit), 0);
-  gtk_signal_connect (GTK_OBJECT (window), "destroy",
-		      GTK_SIGNAL_FUNC (gattrib_really_quit), 0);
 
   /* -----  Now create main_vbox.  This is a container which organizes child  ----- */  
   /* -----  widgets into a vertical column.  ----- */  
@@ -191,7 +189,7 @@ static const GtkActionEntry actions[] = {
   { "file-save", GTK_STOCK_SAVE, "Save", "<Control>S", "", menu_file_save},
   { "file-export-csv", NULL, "Export CSV", "", "", menu_file_export_csv},
   { "file-print", GTK_STOCK_PRINT, "Print", "<Control>P", "", x_dialog_unimplemented_feature},
-  { "file-quit", GTK_STOCK_QUIT, "Quit", "<Control>Q", "", gattrib_really_quit},
+  { "file-quit", GTK_STOCK_QUIT, "Quit", "<Control>Q", "", G_CALLBACK(gattrib_really_quit)},
 
   /* Edit menu */
   { "edit", NULL, "_Edit"},

commit 224f1c8c4731eacbd63634efc01dcc6eead2e19e
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 22:56:58 2007 +0100

    gattrib: more dialog cleanup

diff --git a/gattrib/include/prototype.h b/gattrib/include/prototype.h
index 153637d..1d785e7 100644
--- a/gattrib/include/prototype.h
+++ b/gattrib/include/prototype.h
@@ -164,65 +164,14 @@ void i_vars_setnames(TOPLEVEL * w_current);
 
 
 /* ------------- x_dialog.c ------------- */
-void x_dialog_newattrib_get_name();
-int x_dialog_newattrib_keypress_callback(GtkWidget * widget, 
-					 GdkEventKey * event,
-					 GtkWidget *window);
-void x_dialog_newattrib_close_callback(GtkWidget * widget, 
-				      GtkWidget *window);
-void x_dialog_newattrib_ok_callback(GtkWidget * widget, 
-				      GtkWidget *window);
-
-void x_dialog_delattrib_confirm();
-int x_dialog_delattrib_keypress_callback(GtkWidget * widget, 
-					 GdkEventKey * event,
-					 GtkWidget *window);
-void x_dialog_delattrib_close_callback(GtkWidget *buttonclose, 
-				      GtkWidget *window);
-void x_dialog_delattrib_yes_callback(GtkWidget *buttonok, 
-				    GtkWidget *window);
-
+void x_dialog_newattrib();
+void x_dialog_delattrib();
 void x_dialog_missing_sym();
-int x_dialog_missing_sym_donothing_callback(GtkWidget * widget,
-					    GdkEventKey * event,
-					    GtkWidget *window);
-void x_dialog_missing_sym_continue_callback(GtkWidget *buttonclose,
-					   GtkWidget *window);
-void x_dialog_missing_sym_abort_callback(GtkWidget *buttonyes,
-					GtkWidget *window);
-
 void x_dialog_unsaved_data();
-int x_dialog_unsaved_data_donothing_callback(GtkWidget * widget,
-					    GdkEventKey * event,
-					    GtkWidget *window);
-void x_dialog_unsaved_data_continue_callback(GtkWidget *buttonclose,
-					   GtkWidget *window);
-void x_dialog_unsaved_data_abort_callback(GtkWidget *buttonyes,
-					GtkWidget *window);
-
 void x_dialog_unimplemented_feature();
-
 void x_dialog_fatal_error(gchar *string, gint return_code);
-
-int x_dialog_about_keypress_callback(GtkWidget * widget, GdkEventKey * event,
-				     GtkWidget * window);
-void x_dialog_about_close_callback(GtkWidget * widget, GtkWidget *window);
 void x_dialog_about_dialog();
-
 void x_dialog_export_file();
-int x_dialog_export_file_keypress_callback(GtkWidget * widget, 
-					 GdkEventKey * event,
-					 GtkWidget *window);
-void x_dialog_export_file_close_callback(GtkWidget * widget, 
-				      GtkWidget *window);
-void x_dialog_export_file_ok_callback(GtkWidget * widget, 
-				      GtkWidget *window);
-
-
-GtkWidget *x_dialog_create_dialog_box(GtkWidget ** out_vbox,
-				      GtkWidget ** out_action_area);
-void x_dialog_close_window(GtkWidget * window);
-
 
 /* ------------- x_gtksheet.c ------------- */
 void x_gtksheet_init();
diff --git a/gattrib/src/x_dialog.c b/gattrib/src/x_dialog.c
index 02833ef..d948fa5 100644
--- a/gattrib/src/x_dialog.c
+++ b/gattrib/src/x_dialog.c
@@ -59,25 +59,17 @@
 #include <dmalloc.h>
 #endif
 
-/* ========================================================= *
- * new attrib dialog widgets
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This asks for the name of the attrib column to insert
- * --------------------------------------------------------- */
-void x_dialog_newattrib_get_name()
+
+/*! \brief This asks for the name of the attrib column to insert
+ *         and then inserts the column.
+ */
+void x_dialog_newattrib()
 {
   GtkWidget *dialog;
   GtkWidget *label;
   GtkWidget *attrib_entry;
   gchar *entry_text;
 
-#ifdef DEBUG
-  printf("In x_dialog_newattrib_get_name, creating windows.\n");
-#endif
-
-
   /* Create the dialog */
   dialog = gtk_dialog_new_with_buttons("Add new attribute", NULL, 
 				       GTK_DIALOG_MODAL,
@@ -120,25 +112,16 @@ void x_dialog_newattrib_get_name()
 }
 
 
-/* ========================================================= *
- * delete attrib column dialog widgets
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This fcn throws up the "detele foo, are you sure" dialog
- * box.  It offers two buttons: "yes" and "cancel" 
- * --------------------------------------------------------- */
-void x_dialog_delattrib_confirm()
+/*! \brief This function throws up the "Delete foo, are you sure?" dialog
+ *         box.  It offers two buttons: "yes" and "cancel".
+ */
+void x_dialog_delattrib()
 {
   GtkWidget *dialog;
   gint mincol, maxcol;
   GtkSheet *sheet;
   gint cur_page;
 
-#ifdef DEBUG
-  printf("In x_dialog_delattrib_confirm, creating windows.\n");
-#endif
-
   /* First verify that exactly one column is selected.  */ 
   cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
   sheet = GTK_SHEET(sheets[cur_page]);
@@ -148,17 +131,12 @@ void x_dialog_delattrib_confirm()
 
   mincol = x_gtksheet_get_min_col(sheet);
   maxcol =  x_gtksheet_get_max_col(sheet);
-#ifdef DEBUG
-  printf("In x_dialog_delattrib_confirm, column range selected = %d, %d\n",
-	 mincol, maxcol);
-#endif
 
   if ( (mincol != maxcol) || (mincol == -1) || (maxcol == -1) ) {
     /* Improper selection -- maybe throw up error box? */
     return;
   }
 
-
   /* Create the dialog */
   dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
                                   GTK_MESSAGE_QUESTION,
@@ -222,25 +200,15 @@ void x_dialog_missing_sym()
   gtk_widget_destroy(dialog);
 }
 
-
-/* ========================================================= *
- * Unsaved data windows
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This is the "Unsaved data -- are you sure you want to quit?"
- * dialog box which is thrown up before the user quits.
- * --------------------------------------------------------- */
+/*! \brief This is the "Unsaved data -- are you sure you want to quit?" dialog
+ *         box which is thrown up before the user quits.
+ */
 void x_dialog_unsaved_data()
 {
   GtkWidget *dialog;
   const char *string = "Warning!  You have unsaved data in the spreadsheet!\n"
                        "Are you sure you want to quit?";
 
-#ifdef DEBUG
-  printf("In x_dialog_unsaved_data, creating windows.\n");
-#endif
-
   /* Create the dialog */
   dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
                                   GTK_MESSAGE_WARNING,
@@ -262,16 +230,9 @@ void x_dialog_unsaved_data()
   return;
 }
 
-
-/* ========================================================= *
- * Unimplemented feature callback
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This fcn informs the user that he has chosen an 
- * unimplemented feature.  It presents only an "OK" button
- * to leave.
- * --------------------------------------------------------- */
+/*! \brief This function informs the user that he has chosen an unimplemented
+ *         feature.  It presents only an "OK" button to leave.
+ */
 void x_dialog_unimplemented_feature()
 {
   GtkWidget *dialog;
@@ -322,9 +283,8 @@ void x_dialog_fatal_error(gchar *string, gint return_code)
   exit(GPOINTER_TO_INT(return_code));
 }
 
-/* ========================================================= *
- * help/about dialog widgets
- * ========================================================= */
+/*! \brief This dosplays the about dialog.
+ */
 void x_dialog_about_dialog()
 {
   GtkWidget *dialog;
@@ -349,12 +309,9 @@ void x_dialog_about_dialog()
   gtk_widget_destroy(dialog);
 }
 
-/* ========================================================= *
- * Get name of file for export of CSV
- * ========================================================= */
-/* --------------------------------------------------------- *
- * This asks for the filename for the export file
- * --------------------------------------------------------- */
+/*! \brief This asks for the filename for the CSV export file and then
+ *         does the exporting.
+ */
 void x_dialog_export_file()
 {
   gchar *filename;
diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index d2a055b..d4275de 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -173,14 +173,14 @@ menu_edit_newattrib()
 
   /* Check that we are on components page. */
   if (cur_page == 0) {
-    x_dialog_newattrib_get_name();  /* This creates dialog box  */
+    x_dialog_newattrib();  /* This creates dialog box  */
   }
 }
 
 static void
 menu_edit_delattrib()
 {
-  x_dialog_delattrib_confirm();
+  x_dialog_delattrib();
 }
 
 static const GtkActionEntry actions[] = {

commit efc421976c48b6ed67537e796dd0c0fe3820d2c5
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:57:36 2007 +0100

    move menu callbacks to x_window.c
    
    This patch moves all menu callbacks to x_window.c, where
    they belong. The x_window_init() function is cleaned up.
    Selecting File->Open now causes the "unimplemented feature"
    dialog to pop up.

diff --git a/gattrib/include/globals.h b/gattrib/include/globals.h
index fb14198..0816c18 100644
--- a/gattrib/include/globals.h
+++ b/gattrib/include/globals.h
@@ -83,8 +83,6 @@ SHEET_DATA *sheet_head;
 #define NUM_SHEETS 3            /* Components, Nets, and Pins */
 
 GtkWidget *window;              /* Main window */
-GtkWidget *main_vbox;           /* Container which vertically aligns children */
-GtkWidget *menu_bar;            /* Menu bar (holding file, edit, etc . . . */
 GtkWidget *notebook;
 
 GtkSheet **sheets;             /* These are the spreadsheet widgets themselves */
diff --git a/gattrib/include/prototype.h b/gattrib/include/prototype.h
index 5fa68b7..153637d 100644
--- a/gattrib/include/prototype.h
+++ b/gattrib/include/prototype.h
@@ -88,14 +88,8 @@ void s_toplevel_verify_design(TOPLEVEL *pr_current);
 void s_toplevel_empty_project();
 void s_toplevel_gtksheet_to_toplevel();
 void s_toplevel_update_page(OBJECT *start_obj);
-void s_toplevel_menubar_file_open();
-void s_toplevel_menubar_file_save();
-void s_toplevel_menubar_file_export_csv();
-void s_toplevel_menubar_edit_newattrib();
 void s_toplevel_add_new_attrib(gchar *new_attrib_name);
-void s_toplevel_menubar_edit_delattrib();
 void s_toplevel_delete_attrib_col();
-void s_toplevel_menubar_unimplemented_feature();
 void s_toplevel_select_object();
 void s_toplevel_sheetdata_to_toplevel(OBJECT *start_obj);
 
diff --git a/gattrib/src/s_toplevel.c b/gattrib/src/s_toplevel.c
index 8cd310f..369a831 100644
--- a/gattrib/src/s_toplevel.c
+++ b/gattrib/src/s_toplevel.c
@@ -156,107 +156,6 @@ s_toplevel_gtksheet_to_toplevel()
 }
 
 
-
-/* =======================  Callbacks  ====================== */
-
-/* I am putting all callbacks from the menubar here.  This is kind
- * of stupid, since most of the time I just use the fcns here to 
- * invoke a fcn in x_*.  Perhaps I'll change this later.
- */
-
-/*------------------------------------------------------------------
- * This fcn is the callback from the menu bar.  It throws up the 
- * filedialog widget, and then accepts from it a list of files to
- * open.  Then it figures out if there is already an existing
- * project, and call the appropriate version of s_toplevel_read 
- * depending upon that.
- * TODO: this should really be done in two stages:
- * 1. close the current project and reinitialize structures
- * 2. load the new project
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_open()
-{
-  GSList *file_list;
-
-  file_list = x_fileselect_open();
-  
-  /* Load the files, don't check if it went OK */
-  x_fileselect_load_files(file_list);
-  
-  g_slist_foreach(file_list, (GFunc)g_free, NULL);
-  g_slist_free(file_list);
-}
-
-
-/*------------------------------------------------------------------
- * This fcn is the file->save callback from the menu bar.  It 
- * first updates the proect, and then saves the project without
- * throwing up the filedialog widget.
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_save()
-{
-
-#ifdef DEBUG
-  printf("In s_toplevel_menubar_file_save, about to save out the project\n");
-#endif
-
-  s_toplevel_gtksheet_to_toplevel();  /* Dumps sheet data into TOPLEVEL */
-  s_page_save_all(pr_current);  /* saves all pages in design */
-
-  sheet_head->CHANGED = FALSE;
-
-  return;
-}
-
-
-/*------------------------------------------------------------------
- * This is called when the user wants to export csv
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_export_csv()
-{
-  gint cur_page;
-
-
-  /* first verify that we are on the correct page (components) */
-  cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
-  /* Check that we are on components page. */
-  if (cur_page == 0) {
-#ifdef DEBUG
-    printf("In s_toplevel_menubar_file_export_csv, about to export csv\n");
-#endif
-    x_dialog_export_file();
-  } else {
-    x_dialog_unimplemented_feature();  /* We only support export 
-                                          of components now */
-  }
-  return;
-}
-
-
-/*------------------------------------------------------------------
- *  This fcn is the edit->new attrib column callback from the menu bar.
- *  It throws up the "enter new attrib name" dialog box, then returns.
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_edit_newattrib()
-{
-  gint cur_page;
-
-  /* first verify that we are on the correct page (components) */
-  cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
-  /* Check that we are on components page. */
-  if (cur_page == 0) {
-#ifdef DEBUG
-    printf("In s_toplevel_menubar_edit_newattrib, about to add new attrib column\n");
-#endif
-    x_dialog_newattrib_get_name();  /* This creates dialog box  */
-  }
-
-  return;
-}  
-
-
 /*------------------------------------------------------------------
  *  This fcn gets called when the user has entered a new attrib name,
  *  and clicked the OK button.  It does this:
@@ -349,21 +248,6 @@ void s_toplevel_add_new_attrib(gchar *new_attrib_name) {
 
 
 /*------------------------------------------------------------------
- *  This fcn is the edit->new attrib column callback from the menu bar.
- *  It throws up the "enter new attrib name" dialog box, then returns.
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_edit_delattrib()
-{
-#ifdef DEBUG
-  printf("In s_toplevel_menubar_edit_delattrib, about to delete attribute column\n");
-#endif
-
-  x_dialog_delattrib_confirm();
-  return;
-}  
-
-
-/*------------------------------------------------------------------
  *  This fcn gets called when the user has selected a single attrib
  *  column, selected the edit->delete attrib item from the pull-down
  *  menu, and then said "yes" to the confirm dialog.
@@ -465,22 +349,6 @@ void s_toplevel_delete_attrib_col() {
 
 
 /*------------------------------------------------------------------
- *  This fcn is the edit->new attrib column callback from the menu bar.
- *  It throws up the "enter new attrib name" dialog box, then returns.
- *------------------------------------------------------------------*/
-void s_toplevel_menubar_unimplemented_feature()
-{
-#ifdef DEBUG
-  printf("In s_toplevel_menubar_unimplemented_feature, telling the user that feature is lacking\n");
-#endif
-
-  x_dialog_unimplemented_feature();  /* This creates dialog box  */
-  return;
-}  
-
-
-
-/*------------------------------------------------------------------
  * This fcn is a hack.  It gives a non-NULL value to the select_func
  * defined in globals.c for libgeda.  A non-NULL value for this fcn
  * makes sure that object->sel_func = 1 when the project is saved out,
diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index 8afb72b..d2a055b 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -34,17 +34,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <glib.h>
-#include <glib-object.h>
 
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 
-
 #include "gtksheet_2_2.h"
 #include "gtkitementry_2_2.h"
 
@@ -63,128 +57,149 @@
 static void
 x_window_create_menu(GtkWidget **menubar);
 
-/* ======================  Public functions  ======================== */
-
-/*------------------------------------------------------------------
- * x_window_init -- this fcn initialies the toplevel gtksheet stuff.  It
- * basically just initializes the following widgets:
+/*! \brief This function initializes the toplevel gtksheet stuff. 
+ *
+ *  It basically just initializes the following widgets:
  *  GTK_WINDOW *window 
  *  GTK_CONTAINER *main_vbox
  *  GTK_MENU 
- * Note that it doesn't display the spreadsheet itself.  This is done
- * in x_sheet_build_sheet.
- * I suppose I ctould postpone all initialization until x_sheet_build_sheet, but I 
- * figured that I could at least do some initialization here.  
- * In particular, the stuff to put up the menus is long & it is worthwhile
- * to separate it from other code.  Maybe I'll refactor this later.
- *------------------------------------------------------------------*/
+ * 
+ *  Note that it doesn't display the spreadsheet itself.  This is done
+ *  in x_sheet_build_sheet. I suppose I could postpone all initialization 
+ *  until x_sheet_build_sheet, but I figured that I could at least do 
+ *  some initialization here. In particular, the stuff to put up the 
+ *  menus is long & it is worthwhile to separate it from other code.  
+ *  Maybe I'll refactor this later.
+ */
 void
 x_window_init()
 {
-  /* note that the graphical widgets themselves (window, main_vbox, menu_bar)
-   * are globals defined in ../include/globals.h   On pr_current I 
-   * attach pointers to some of them here for future reference.  */
-  gint i;
-
-  /* -----  First initialize stuff in the top-level window  ----- */  
- 
-#ifdef DEBUG
-  printf("In x_window_init, about to call gtk_window_new.\n");
-#endif
+  GtkWidget *menu_bar;
+  GtkWidget *main_vbox;
+
   /*  window is a global declared in globals.h.  */
-  window = (GtkWidget *) gtk_window_new(GTK_WINDOW_TOPLEVEL);  
+  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);  
 
   /* I attach a pointer to window to the TOPLEVEL structure */
   pr_current->main_window = window;
   
-#ifdef DEBUG
-  printf("In x_window_init, about to call gtk_window_set_title.\n");
-#endif
   gtk_window_set_title( GTK_WINDOW(window), "gattrib -- gEDA attribute editor"); 
-  /*  gtk_widget_set_usize(GTK_WIDGET(window), 900, 600);  */
   gtk_window_set_default_size(GTK_WINDOW(window), 750, 600);  
   
-
-#ifdef DEBUG
-  printf("In x_window_init, about to connect delete and destroy signals to window.\n");
-#endif
   gtk_signal_connect (GTK_OBJECT (window), "delete_event",
 		      GTK_SIGNAL_FUNC (gattrib_really_quit), 0);
   gtk_signal_connect (GTK_OBJECT (window), "destroy",
 		      GTK_SIGNAL_FUNC (gattrib_really_quit), 0);
-  
 
   /* -----  Now create main_vbox.  This is a container which organizes child  ----- */  
   /* -----  widgets into a vertical column.  ----- */  
-  /* main_vbox is a global defined in globals.h */
-#ifdef DEBUG
-  printf("In x_window_init, about to set up vobx.\n");
-#endif
   main_vbox = gtk_vbox_new(FALSE,1);
   gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
   gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(main_vbox) );
-  gtk_widget_show(GTK_WIDGET(main_vbox) );
-
 
   /* -----  Now create menu bar  ----- */  
-  /* menu_bar is a global defined in globals.h */
-#ifdef DEBUG
-  printf("In x_window_init, about to create menu bar.\n");
-#endif
   x_window_create_menu(&menu_bar);
   pr_current->menubar = menu_bar;    /* attach pointer to menu_bar to (TOPLEVEL pr_current) */
-  gtk_box_pack_start (GTK_BOX (main_vbox), menu_bar, FALSE, TRUE, 0);
-  gtk_widget_show( GTK_WIDGET(menu_bar) );
+  gtk_box_pack_start(GTK_BOX (main_vbox), menu_bar, FALSE, TRUE, 0);
 
   /* -----  Now init notebook widget  ----- */  
-#ifdef DEBUG
-  printf("In x_window_init, about to create notbook.\n");
-#endif
-  notebook=gtk_notebook_new();
+  notebook = gtk_notebook_new();
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
   gtk_box_pack_start(GTK_BOX(main_vbox), notebook, TRUE, TRUE, 0);
-  gtk_widget_show( notebook );
-
   
   /* -----  Now malloc -- but don't fill out -- space for sheets  ----- */  
   /* This basically sets up the overhead for the sheets, as I understand
    * it.  The memory for the actual sheet cells is allocated later,
    * when gtk_sheet_new is invoked, I think.  */
-#ifdef DEBUG
-  printf("In x_window_init, about to malloc space for sheets.\n");
+  sheets = g_malloc0(NUM_SHEETS * sizeof(GtkWidget *));
+}
+
+
+/*------------------------------------------------------------------
+ * TODO: this should really be done in two stages:
+ * 1. close the current project and reinitialize structures
+ * 2. load the new projec:t
+ *------------------------------------------------------------------*/
+static void
+menu_file_open()
+{
+  x_dialog_unimplemented_feature();
+#if 0
+  GSList *file_list;
+
+  file_list = x_fileselect_open();
+  
+  /* Load the files, don't check if it went OK */
+  x_fileselect_load_files(file_list);
+  
+  g_slist_foreach(file_list, (GFunc)g_free, NULL);
+  g_slist_free(file_list);
 #endif
-  for(i=0; i<NUM_SHEETS; i++){
-    sheets=(GtkSheet **) g_realloc(sheets, (i+1)*sizeof(GtkWidget *));
+}
+
+static void
+menu_file_save()
+{
+  s_toplevel_gtksheet_to_toplevel();  /* Dumps sheet data into TOPLEVEL */
+  s_page_save_all(pr_current);  /* saves all pages in design */
+
+  sheet_head->CHANGED = FALSE;
+}
+
+static void 
+menu_file_export_csv()
+{
+  gint cur_page;
+
+  /* first verify that we are on the correct page (components) */
+  cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
+
+  /* Check that we are on components page. */
+  if (cur_page == 0) {
+    x_dialog_export_file();
+  } else {
+    x_dialog_unimplemented_feature();  /* We only support export 
+                                          of components now */
   }
+}
 
-  /* -----  Finally show top level window to make everything appear  ----- */
-#ifdef DEBUG
-  /*   printf("In x_window_init, about to show window widget.\n"); */
-#endif
+static void 
+menu_edit_newattrib()
+{
+  gint cur_page;
 
-  /*
-   *  gtk_widget_show( GTK_WIDGET(window) );
-   */
-  
+  /* first verify that we are on the correct page (components) */
+  cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
+
+  /* Check that we are on components page. */
+  if (cur_page == 0) {
+    x_dialog_newattrib_get_name();  /* This creates dialog box  */
+  }
+}
+
+static void
+menu_edit_delattrib()
+{
+  x_dialog_delattrib_confirm();
 }
 
 static const GtkActionEntry actions[] = {
   /* name, stock-id, label, accelerator, tooltip, callback function */
   /* File menu */
   { "file", NULL, "_File"},
-  { "file-open", GTK_STOCK_OPEN, "Open", "<Control>O", "", s_toplevel_menubar_file_open},
-  { "file-save", GTK_STOCK_SAVE, "Save", "<Control>S", "", s_toplevel_menubar_file_save},
-  { "file-export-csv", NULL, "Export CSV", "", "", s_toplevel_menubar_file_export_csv},
-  { "file-print", GTK_STOCK_PRINT, "Print", "<Control>P", "", s_toplevel_menubar_unimplemented_feature},
+  { "file-open", GTK_STOCK_OPEN, "Open", "<Control>O", "", menu_file_open},
+  { "file-save", GTK_STOCK_SAVE, "Save", "<Control>S", "", menu_file_save},
+  { "file-export-csv", NULL, "Export CSV", "", "", menu_file_export_csv},
+  { "file-print", GTK_STOCK_PRINT, "Print", "<Control>P", "", x_dialog_unimplemented_feature},
   { "file-quit", GTK_STOCK_QUIT, "Quit", "<Control>Q", "", gattrib_really_quit},
 
   /* Edit menu */
   { "edit", NULL, "_Edit"},
-  { "edit-add-attrib", NULL, "Add new attrib column", "", "", s_toplevel_menubar_edit_newattrib},
-  { "edit-delete-attrib", NULL, "Delete attrib column", "", "",s_toplevel_menubar_edit_delattrib},
-  { "edit-find-attrib", GTK_STOCK_FIND, "Find attrib value", "<Control>F", "",s_toplevel_menubar_unimplemented_feature},
-  { "edit-search-replace-attrib-value", NULL, "Search and replace attrib value", "", "",s_toplevel_menubar_unimplemented_feature},
-  { "edit-search-for-refdes", NULL, "Search for refdes", "", "",s_toplevel_menubar_unimplemented_feature},
+  { "edit-add-attrib", NULL, "Add new attrib column", "", "", menu_edit_newattrib},
+  { "edit-delete-attrib", NULL, "Delete attrib column", "", "", menu_edit_delattrib},
+  { "edit-find-attrib", GTK_STOCK_FIND, "Find attrib value", "<Control>F", "", x_dialog_unimplemented_feature},
+  { "edit-search-replace-attrib-value", NULL, "Search and replace attrib value", "", "", x_dialog_unimplemented_feature},
+  { "edit-search-for-refdes", NULL, "Search for refdes", "", "", x_dialog_unimplemented_feature},
 
   /* Visibility menu */
   { "visibility", NULL, "_Visibility"},
@@ -219,7 +234,7 @@ x_window_create_menu(GtkWidget **menubar)
 
   /* Create and fill the action group object */
   action_group = gtk_action_group_new("");
-  gtk_action_group_add_actions(action_group, actions, G_N_ELEMENTS(actions), 0);
+  gtk_action_group_add_actions(action_group, actions, G_N_ELEMENTS(actions), NULL);
 
   /* Create the UI manager object */
   ui = gtk_ui_manager_new();

commit 66e808f376b11460faec4c78834f8359969e6547
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:52:42 2007 +0100

    gattrib: remove unused pixmaps.h

diff --git a/gattrib/include/Makefile.am b/gattrib/include/Makefile.am
index ff01009..b94eb41 100644
--- a/gattrib/include/Makefile.am
+++ b/gattrib/include/Makefile.am
@@ -8,9 +8,7 @@ noinst_HEADERS = \
 	gtkitementry_2_2.h \
 	i_vars.h \
 	struct.h \
-	gtkextra-marshal.h \
-	pixmaps.h
-
+	gtkextra-marshal.h
 
 MOSTLYCLEANFILES = *.log core FILE *~ #*#
 CLEANFILES = *.log core FILE *~ #*#
diff --git a/gattrib/include/pixmaps.h b/gattrib/include/pixmaps.h
deleted file mode 100644
index 5fb65e3..0000000
--- a/gattrib/include/pixmaps.h
+++ /dev/null
@@ -1,243 +0,0 @@
-#ifndef __pixmap_h__
-#define __pixmap_h__
-
-/* XPM */
-static char * bullet_xpm[] = {
-"16 16 26 1",
-" 	c #None",
-".	c #000000000000",
-"X	c #0000E38D0000",
-"o	c #0000EBAD0000",
-"O	c #0000F7DE0000",
-"+	c #0000FFFF0000",
-"@	c #0000CF3C0000",
-"#	c #0000D75C0000",
-"$	c #0000B6DA0000",
-"%	c #0000C30B0000",
-"&	c #0000A2890000",
-"*	c #00009A690000",
-"=	c #0000AEBA0000",
-"-	c #00008E380000",
-";	c #000086170000",
-":	c #000079E70000",
-">	c #000071C60000",
-",	c #000065950000",
-"<	c #000059650000",
-"1	c #000051440000",
-"2	c #000045140000",
-"3	c #00003CF30000",
-"4	c #000030C20000",
-"5	c #000028A20000",
-"6	c #00001C710000",
-"7	c #000014510000",
-"     ......     ",
-"    .XooO++.    ",
-"  ..@@@#XoO+..  ",
-" .$$$$$%@#XO++. ",
-" .&&*&&=$%@XO+. ",
-".*-;;;-*&=%@XO+.",
-".;:>>>:;-&=%#o+.",
-".>,<<<,>:-&$@XO.",
-".<12321<>;*=%#o.",
-".1345431,:-&$@o.",
-".2467642<>;&$@X.",
-" .57.753<>;*$@. ",
-" .467642<>;&$@. ",
-"  ..5431,:-&..  ",
-"    .21<>;*.    ",
-"     ......     "};
-
-/* XPM */
-static char *center_just [] =
-{
-  "28 26 2 1",
-  ".      c #None",
-  "X      c #000000000000",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "        XXXXXXXXXXXX        ",
-  "        XXXXXXXXXXXX        ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "        XXXXXXXXXXXX        ",
-  "        XXXXXXXXXXXX        ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "        XXXXXXXXXXXX        ",
-  "        XXXXXXXXXXXX        ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-};
-/* XPM */
-static char * font[] = {
-"26 26 3 1",
-" 	c #None",
-".	c #000000000000",
-"X	c #000000000000",
-"                          ",
-"                          ",
-"                          ",
-"            .             ",
-"           ...            ",
-"           ...            ",
-"          .....           ",
-"          .....           ",
-"         .. ....          ",
-"         .. ....          ",
-"        ..   ....         ",
-"        .........         ",
-"       ...........        ",
-"       ..     ....        ",
-"      ..       ....       ",
-"      ..       ....       ",
-"    .....     .......     ",
-"                          ",
-"                          ",
-"                          ",
-"     XXXXXXXXXXXXXXXX     ",
-"     XXXXXXXXXXXXXXXX     ",
-"     XXXXXXXXXXXXXXXX     ",
-"     XXXXXXXXXXXXXXXX     ",
-"                          ",
-"                          ",
-"                          "};
-/* XPM */
-static char *left_just [] =
-{
-  "28 26 2 1",
-  ".      c #None",
-  "X      c #000000000000",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "     XXXXXXXXXXXXX          ",
-  "     XXXXXXXXXXXXX          ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "     XXXXXXXXXXXXX          ",
-  "     XXXXXXXXXXXXX          ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "     XXXXXXXXXXXXX          ",
-  "     XXXXXXXXXXXXX          ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-};
-/* XPM */
-static char *paint [] =
-{
-  "26 26 6 1",
-  ".      c #None",
-  "a      c #000000000000",
-  "e      c #929292929292",
-  "g      c #DBDBDBDBDBDB",
-  "h      c #FFFFFFFFFFFF",
-  "X      c #FFFFFFFFFFFF",
-  "..........................",
-  "...........ee.............",
-  "..........eeee............",
-  ".........eeggee...........",
-  ".........eegaee...........",
-  ".........eeahee...........",
-  ".........aahheeaa.........",
-  ".........ahhgeegaaa.......",
-  "........ahhghaeggaaa......",
-  ".......ahhghagaggeaaa.....",
-  "......ahhghggaggeeaaae....",
-  ".....ahhghgggggeeaaaae....",
-  ".....ahghgggggeeaeaaae....",
-  "......ahgggggeeaeeaaae....",
-  ".......ahgggeeaee.aaae....",
-  "........aggeeaee..aaee....",
-  ".........aeeaee...aee.....",
-  "..........aaee.....e......",
-  "...........ee.............",
-  "..........................",
-  "....XXXXXXXXXXXXXXXXXX....",
-  "....XXXXXXXXXXXXXXXXXX....",
-  "....XXXXXXXXXXXXXXXXXX....",
-  "....XXXXXXXXXXXXXXXXXX....",
-  "..........................",
-  "..........................",
-};
-/* XPM */
-static char *right_just [] =
-{
-  "28 26 2 1",
-  ".      c #None",
-  "X      c #000000000000",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "          XXXXXXXXXXXXX     ",
-  "          XXXXXXXXXXXXX     ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "          XXXXXXXXXXXXX     ",
-  "          XXXXXXXXXXXXX     ",
-  "                            ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "     XXXXXXXXXXXXXXXXXX     ",
-  "                            ",
-  "          XXXXXXXXXXXXX     ",
-  "          XXXXXXXXXXXXX     ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-  "                            ",
-};
-
-/* XPM */
-static char * smile_xpm[] = {
-"16 16 3 1",
-" 	c #None",
-".	c #000000000000",
-"X	c #FFFFFFFF0000",
-"     ......     ",
-"    .XXXXXX.    ",
-"  ..XXXXXXXX..  ",
-" .XXXXXXXXXXXX. ",
-" .XXX..XX..XXX. ",
-".XXXX..XX..XXXX.",
-".XXXX..XX..XXXX.",
-".XXXXXXXXXXXXXX.",
-".XX..XXXXXX..XX.",
-".XX..XXXXXX..XX.",
-".XXX.XXXXXX.XXX.",
-" .XXX.XXXX.XXX. ",
-" .XXXX....XXXX. ",
-"  ..XXXXXXXX..  ",
-"    .XXXXXX.    ",
-"     ......     "};
-
-#endif
diff --git a/gattrib/include/struct.h b/gattrib/include/struct.h
index 89bc8f4..b245505 100644
--- a/gattrib/include/struct.h
+++ b/gattrib/include/struct.h
@@ -37,7 +37,6 @@
 #include "gtksheet_2_2.h"
 #include "gtkitementry_2_2.h"
 
-/* #include "pixmaps.h" */
 
 /* ========  Data structures used in processing below here  ========== */
 

commit 1aad087e0f59deb2cff728ff750bc34dcffc8ede
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 20:52:40 2007 +0100

    gattrib: overhaul menu creation code

diff --git a/gattrib/include/Makefile.am b/gattrib/include/Makefile.am
index 05c77f2..ff01009 100644
--- a/gattrib/include/Makefile.am
+++ b/gattrib/include/Makefile.am
@@ -9,8 +9,7 @@ noinst_HEADERS = \
 	i_vars.h \
 	struct.h \
 	gtkextra-marshal.h \
-	pixmaps.h \
-	x_menu.h
+	pixmaps.h
 
 
 MOSTLYCLEANFILES = *.log core FILE *~ #*#
diff --git a/gattrib/include/prototype.h b/gattrib/include/prototype.h
index 378a5ab..5fa68b7 100644
--- a/gattrib/include/prototype.h
+++ b/gattrib/include/prototype.h
@@ -88,10 +88,9 @@ void s_toplevel_verify_design(TOPLEVEL *pr_current);
 void s_toplevel_empty_project();
 void s_toplevel_gtksheet_to_toplevel();
 void s_toplevel_update_page(OBJECT *start_obj);
-void s_toplevel_menubar_file_open(TOPLEVEL *pr_current);
-void s_toplevel_menubar_file_save(TOPLEVEL *pr_current);
-void s_toplevel_menubar_file_open(TOPLEVEL *pr_current);
-void s_toplevel_menubar_file_export_csv(TOPLEVEL *pr_current);
+void s_toplevel_menubar_file_open();
+void s_toplevel_menubar_file_save();
+void s_toplevel_menubar_file_export_csv();
 void s_toplevel_menubar_edit_newattrib();
 void s_toplevel_add_new_attrib(gchar *new_attrib_name);
 void s_toplevel_menubar_edit_delattrib();
@@ -290,7 +289,6 @@ gboolean x_fileselect_load_files (GSList *filenames);
 
 /* ------------- x_window.c ------------- */
 void x_window_init();
-void x_window_create_menu(GtkWidget **menubar);
 void x_window_add_items();
 
 
diff --git a/gattrib/include/x_menu.h b/gattrib/include/x_menu.h
deleted file mode 100644
index b7f87e7..0000000
--- a/gattrib/include/x_menu.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/* This is the stuff to define the graphical widgets used 
- * by gattrib.  I had to separate them off from the other
- * structs in order to define the callbacks first.  The
- * include order required is:
-   #include <libgeda/libgeda.h>     
-   #include "../include/struct.h"   
-   #include "../include/prototype.h"
-   #include "../include/globals.h"  
-   #include "../include/x_menu.h"   
- */
-
-
-#ifndef X_MENU_H
-#define X_MENU_H
-
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <glib.h>
-#include <glib-object.h>
- 
-
-/* -------  Includes needed to make the GTK stuff work  ------ */
-
-#include "gtksheet_2_2.h"
-#include "gtkitementry_2_2.h"
-
-/* #include "pixmaps.h" */
-
-/* ----------  Menu definition -- copied from the GTK tutorial file  ---------- */
-/* ----------  and edited/adapted by SDB for gattrib.  ---------- */
-/* This is the GtkItemFactoryEntry structure used to generate new menus.
-   Item 1: The menu path. The letter after the underscore indicates an
-           accelerator key once the menu is open.
-   Item 2: The accelerator key for the entry
-   Item 3: The callback function.
-   Item 4: The callback action.  This changes the parameters with
-           which the function is called.  The default is 0.
-   Item 5: The item type, used to define what kind of an item it is.
-           Here are the possible values:
-
-           NULL               -> "<Item>"
-           ""                 -> "<Item>"
-           "<Title>"          -> create a title item
-           "<Item>"           -> create a simple item
-           "<CheckItem>"      -> create a check item
-           "<ToggleItem>"     -> create a toggle item
-           "<RadioItem>"      -> create a radio item
-           <path>             -> path of a radio item to link against
-           "<Separator>"      -> create a separator
-           "<Branch>"         -> create an item to hold sub items (optional)
-           "<LastBranch>"     -> create a right justified branch 
-*/
-
-GtkItemFactoryEntry menu_items[] = {
-  /* ------- File menu ------- */
-  { "/_File", 
-    NULL,
-    NULL, 
-    0, 
-    "<Branch>" 
-  },
-
-  { "/File/_Open",
-    "<control>O", 
-    s_toplevel_menubar_file_open, 
-    0, 
-    NULL 
-  },
-
-  { "/File/_Save",
-    "<control>S", 
-    s_toplevel_menubar_file_save, 
-    0, 
-    NULL },
-
-  { "/File/sep1",    
-    NULL,    
-    NULL,
-    0, 
-    "<Separator>"
-  },
-
-  { "/File/Print setup",
-    NULL,
-    s_toplevel_menubar_unimplemented_feature,
-    0, 
-    NULL 
-  },
-
-  { "/File/Print",
-    NULL,
-    s_toplevel_menubar_unimplemented_feature,
-    0, 
-    NULL },
-
-  { "/File/sep1",    
-    NULL,    
-    NULL,
-    0, 
-    "<Separator>"
-  },
-
-  { "/File/Export CSV",
-    NULL,
-    s_toplevel_menubar_file_export_csv,
-    0, 
-    NULL 
-  },
-
-  { "/File/sep1",    
-    NULL,    
-    NULL,
-    0, 
-    "<Separator>"
-  },
-
-  { "/File/Quit",   
-    "<control>Q", 
-    gattrib_really_quit,
-    0, 
-    NULL
-  },
-  /* ------- Edit menu ------- */
-  { "/_Edit",    
-    NULL,    
-    NULL, 
-    0, 
-    "<Branch>" 
-  },
-
-  { "/Edit/Add new attrib column",      
-    NULL,  
-    s_toplevel_menubar_edit_newattrib, 
-    0, 
-    NULL
-  },
-
-  { "/Edit/Delete attrib column",  
-    NULL,  
-    s_toplevel_menubar_edit_delattrib,
-    0,
-    NULL 
-  },
-
-  { "/Edit/Search for attrib value",
-    NULL,
-    s_toplevel_menubar_unimplemented_feature,
-    0, 
-    NULL 
-  },
-
-  { "/Edit/Search and replace attrib value", 
-    NULL, 
-    s_toplevel_menubar_unimplemented_feature,
-    0, 
-    NULL 
-  },
-
-  { "/Edit/Search for refdes", 
-    NULL,
-    s_toplevel_menubar_unimplemented_feature,
-    0,
-    NULL 
-  },
-  /* ------- Visibility menu ------- */
-  { "/_Visibility",    
-    NULL,
-    NULL,
-    0, 
-    "<Branch>" 
-  },
-  { "/Visibility/Set selected invisible",
-    NULL,
-    s_visibility_set_invisible,
-    10,
-    NULL
-  },
-  { "/Visibility/Set selected name visible only",
-    NULL,
-    s_visibility_set_name_only,
-    11,
-    NULL
-  },
-  { "/Visibility/Set selected value visible only",
-    NULL,
-    s_visibility_set_value_only,
-    12,
-    NULL
-  },
-  { "/Visibility/Set selected name and value visible",
-    NULL,
-    s_visibility_set_name_and_value,
-    13, 
-    NULL
-  },
-  /* ------- Help menu ------- */
-  { "/_Help",         NULL,         NULL, 0, "<LastBranch>" },
-  { "/_Help/About",   NULL,         x_dialog_about_dialog, 0, NULL },
-};
-
-
-#endif
-
-
diff --git a/gattrib/lib/Makefile.am b/gattrib/lib/Makefile.am
index 34ff2b2..919c3db 100644
--- a/gattrib/lib/Makefile.am
+++ b/gattrib/lib/Makefile.am
@@ -1,8 +1,8 @@
 
 rcdatadir = @GEDARCDIR@
-rcdata_DATA = system-gattribrc 
+rcdata_DATA = system-gattribrc gattrib-menus.xml
 
-EXTRA_DIST = system-gattribrc.in 
+EXTRA_DIST = system-gattribrc.in gattrib-menus.xml
 
 MOSTLYCLEANFILES = *.log *~
 CLEANFILES = *.log *~
diff --git a/gattrib/lib/gattrib-menus.xml b/gattrib/lib/gattrib-menus.xml
new file mode 100644
index 0000000..1526cb3
--- /dev/null
+++ b/gattrib/lib/gattrib-menus.xml
@@ -0,0 +1,33 @@
+<ui>
+  <menubar>
+    <menu action="file">
+      <menuitem action="file-open" />
+      <menuitem action="file-save" />
+      <menuitem action="file-export-csv" />
+      <separator/>
+      <menuitem action="file-print" />
+      <separator/>
+      <menuitem action="file-quit" />
+    </menu>
+
+    <menu action="edit">
+      <menuitem action="edit-add-attrib" />
+      <menuitem action="edit-delete-attrib" />
+      <menuitem action="edit-find-attrib" />
+      <menuitem action="edit-search-replace-attrib-value" />
+      <menuitem action="edit-search-for-refdes" />
+    </menu>
+
+    <menu action="visibility">
+      <menuitem action="visibility-invisible" />
+      <menuitem action="visibility-name-only" />
+      <menuitem action="visibility-value-only" />
+      <menuitem action="visibility-name-value" />
+    </menu>
+
+    <menu action="help">
+      <menuitem action="help-about" />
+    </menu>
+  </menubar>
+</ui>
+
diff --git a/gattrib/src/s_toplevel.c b/gattrib/src/s_toplevel.c
index 07aa160..8cd310f 100644
--- a/gattrib/src/s_toplevel.c
+++ b/gattrib/src/s_toplevel.c
@@ -174,7 +174,7 @@ s_toplevel_gtksheet_to_toplevel()
  * 1. close the current project and reinitialize structures
  * 2. load the new project
  *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_open(TOPLEVEL *pr_current)
+void s_toplevel_menubar_file_open()
 {
   GSList *file_list;
 
@@ -193,7 +193,7 @@ void s_toplevel_menubar_file_open(TOPLEVEL *pr_current)
  * first updates the proect, and then saves the project without
  * throwing up the filedialog widget.
  *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_save(TOPLEVEL *pr_current)
+void s_toplevel_menubar_file_save()
 {
 
 #ifdef DEBUG
@@ -212,7 +212,7 @@ void s_toplevel_menubar_file_save(TOPLEVEL *pr_current)
 /*------------------------------------------------------------------
  * This is called when the user wants to export csv
  *------------------------------------------------------------------*/
-void s_toplevel_menubar_file_export_csv(TOPLEVEL *pr_current)
+void s_toplevel_menubar_file_export_csv()
 {
   gint cur_page;
 
diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index b09ba0d..8afb72b 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -55,12 +55,13 @@
 #include "../include/struct.h"     /* typdef and struct declarations */
 #include "../include/prototype.h"  /* function prototypes */
 #include "../include/globals.h"
-#include "../include/x_menu.h"
 
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
 #endif
 
+static void
+x_window_create_menu(GtkWidget **menubar);
 
 /* ======================  Public functions  ======================== */
 
@@ -167,52 +168,78 @@ x_window_init()
   
 }
 
-
-/*------------------------------------------------------------------
- * x_window_create_menu:  This creates the menu widget.  This fcn
- * cloned from GTK+ tutorial.
- *------------------------------------------------------------------*/
-void
+static const GtkActionEntry actions[] = {
+  /* name, stock-id, label, accelerator, tooltip, callback function */
+  /* File menu */
+  { "file", NULL, "_File"},
+  { "file-open", GTK_STOCK_OPEN, "Open", "<Control>O", "", s_toplevel_menubar_file_open},
+  { "file-save", GTK_STOCK_SAVE, "Save", "<Control>S", "", s_toplevel_menubar_file_save},
+  { "file-export-csv", NULL, "Export CSV", "", "", s_toplevel_menubar_file_export_csv},
+  { "file-print", GTK_STOCK_PRINT, "Print", "<Control>P", "", s_toplevel_menubar_unimplemented_feature},
+  { "file-quit", GTK_STOCK_QUIT, "Quit", "<Control>Q", "", gattrib_really_quit},
+
+  /* Edit menu */
+  { "edit", NULL, "_Edit"},
+  { "edit-add-attrib", NULL, "Add new attrib column", "", "", s_toplevel_menubar_edit_newattrib},
+  { "edit-delete-attrib", NULL, "Delete attrib column", "", "",s_toplevel_menubar_edit_delattrib},
+  { "edit-find-attrib", GTK_STOCK_FIND, "Find attrib value", "<Control>F", "",s_toplevel_menubar_unimplemented_feature},
+  { "edit-search-replace-attrib-value", NULL, "Search and replace attrib value", "", "",s_toplevel_menubar_unimplemented_feature},
+  { "edit-search-for-refdes", NULL, "Search for refdes", "", "",s_toplevel_menubar_unimplemented_feature},
+
+  /* Visibility menu */
+  { "visibility", NULL, "_Visibility"},
+  { "visibility-invisible", NULL, "Set selected invisible", "", "", s_visibility_set_invisible},
+  { "visibility-name-only", NULL, "Set selected name visible only", "", "", s_visibility_set_name_only},
+  { "visibility-value-only", NULL, "Set selected value visible only", "", "", s_visibility_set_value_only},
+  { "visibility-name-value", NULL, "Set selected name and value visible", "", "", s_visibility_set_name_and_value},
+
+  /* Help menu */
+  { "help", NULL, "_Help"},
+  { "help-about", GTK_STOCK_ABOUT, "About", "", "", x_dialog_about_dialog},
+};
+
+
+/*! \brief Create the menu bar and attach it to the main window.
+ *
+ *  First, the GtkActionGroup object is created and filled with
+ *  entries of type GtkActionEntry (each entry specifies a single
+ *  action, such as opening a file). Then the GtkUIManager object
+ *  is created and used to load menus.xml file with the menu
+ *  description. Finally, the GtkAccelGroup is added to the
+ *  main window to enable keyboard accelerators and a pointer
+ *  to the menu bar is retrieved from the GtkUIManager object.
+ */
+static void
 x_window_create_menu(GtkWidget **menubar)
 {
-  GtkItemFactory *item_factory;
-  GtkAccelGroup *accel_group;
-  gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
-
-  accel_group = gtk_accel_group_new ();
-
-  /* This function initializes the item factory.
-     Param 1: The type of menu - can be GTK_TYPE_MENU_BAR, GTK_TYPE_MENU,
-              or GTK_TYPE_OPTION_MENU.
-     Param 2: The path of the menu.
-     Param 3: A pointer to a gtk_accel_group.  The item factory sets up
-              the accelerator table while generating menus.
-  */
-
-#ifdef DEBUG
-  printf("In x_window_create_menu, about to create new item factory\n");
-#endif
-  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
-                                       accel_group);
-
-  /* This function generates the menu items. Pass the item factory,
-     the number of items in the array, the array itself, and any
-     callback data for the the menu items. */
-  /* SDB notes: callback data is pr_current, which should hopefully have pointers
-   * to any data required in the callback. */
-  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, pr_current);
-
+  gchar *menu_file;
+  GtkUIManager *ui;
+  GtkActionGroup *action_group;
+  GError *error = NULL;
+
+  /* Create and fill the action group object */
+  action_group = gtk_action_group_new("");
+  gtk_action_group_add_actions(action_group, actions, G_N_ELEMENTS(actions), 0);
+
+  /* Create the UI manager object */
+  ui = gtk_ui_manager_new();
+
+  gtk_ui_manager_insert_action_group(ui, action_group, 0);
+
+  menu_file = g_build_filename(GEDADATADIR, "gattrib-menus.xml", NULL);
+  gtk_ui_manager_add_ui_from_file(ui, menu_file, &error);
+  if(error != NULL) {
+    /* An error occured, terminate */
+    fprintf(stderr, "Error loading %s:\n%s\n", menu_file, error->message);
+    exit(1);
+  }
 
-  /* Attach the new accelerator group to the window. */
-  /* SDB says: Here's where it comes in handy to have attached a pointer to 
-   * the main window to the TOPLEVEL structure. */
-  gtk_window_add_accel_group (GTK_WINDOW(pr_current->main_window), accel_group);
+  g_free(menu_file);
 
-  if (menubar)
-    /* Finally, return the actual menu bar created by the item factory. */ 
-    *menubar = gtk_item_factory_get_widget (item_factory, "<main>");
+  gtk_window_add_accel_group (GTK_WINDOW(pr_current->main_window),
+      gtk_ui_manager_get_accel_group(ui));
 
-  return;
+  *menubar = gtk_ui_manager_get_widget(ui, "/ui/menubar/");
 }
 
 

commit 789581dc215e86e9455eca830c66495592246f56
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 19:27:41 2007 +0100

    gattrib: remove unneeded globals

diff --git a/gattrib/include/globals.h b/gattrib/include/globals.h
index e7561d2..fb14198 100644
--- a/gattrib/include/globals.h
+++ b/gattrib/include/globals.h
@@ -85,68 +85,17 @@ SHEET_DATA *sheet_head;
 GtkWidget *window;              /* Main window */
 GtkWidget *main_vbox;           /* Container which vertically aligns children */
 GtkWidget *menu_bar;            /* Menu bar (holding file, edit, etc . . . */
-
 GtkWidget *notebook;
+
 GtkSheet **sheets;             /* These are the spreadsheet widgets themselves */
 
 GtkWidget **scrolled_windows;
-GtkWidget *show_hide_box;
-GtkWidget *status_box;
-GtkWidget *location;
 GtkWidget *entry;
-GtkWidget *fgcolorcombo;
-GtkWidget *bgcolorcombo;
-GtkWidget *bordercombo;
-GdkPixmap *pixmap;
-GdkBitmap *mask;
-GtkWidget *bg_pixmap;
-GtkWidget *fg_pixmap;
-GtkWidget *toolbar;
+GtkWidget *location;
 GtkWidget *left_button;
 GtkWidget *center_button;
 GtkWidget *right_button;
-GtkWidget *tpixmap;
-GtkWidget *bullet[10];
-GtkWidget *smile;
-GtkWidget *curve;
-GtkWidget *popup;
-
 GtkWidget *label;
-GtkWidget *font_combo;
-GtkWidget *toggle_combo;
-
-/*------------------------------------------------------------------
- * This stuff copied over from gschem
- *------------------------------------------------------------------*/
-/* color stuff */
-extern GdkColormap *colormap; 
-extern GdkVisual *visual; 
-
-/* colors */
-extern GdkColor white;
-extern GdkColor black;
-extern GdkColor red;
-extern GdkColor green;
-extern GdkColor blue;
-extern GdkColor cyan;
-extern GdkColor yellow;
-extern GdkColor grey;
-extern GdkColor grey90;
-extern GdkColor darkgreen;
-extern GdkColor darkred;
-extern GdkColor darkyellow;
-extern GdkColor darkcyan;
-extern GdkColor darkblue;
-extern GdkColor darkgrey; 
-
-extern char *rc_filename;
-
-extern int logfile_fd;
-extern int do_logging;
-extern int logging_dest;
-
-/* gattrib specific stuff */
-extern char *guile_proc;   /* Needed for read-in of rc files */
 
 /* command line switch settings */
 extern int verbose_mode;
diff --git a/gattrib/src/g_rc.c b/gattrib/src/g_rc.c
index b8a5a57..2355d79 100644
--- a/gattrib/src/g_rc.c
+++ b/gattrib/src/g_rc.c
@@ -73,8 +73,8 @@ SCM g_rc_gattrib_version(SCM version)
             "You are running gEDA/gaf version [%s%s.%s],\n",
             PREPEND_VERSION_STRING, DOTTED_VERSION, DATE_VERSION);
     fprintf(stderr,
-            "but you have a version [%s] gattribrc file:\n[%s]\n",
-            SCM_STRING_CHARS (version), rc_filename);
+            "but you have a version [%s] gattribrc file.\n",
+            SCM_STRING_CHARS (version));
     fprintf(stderr,
             "Please be sure that you have the latest rc file.\n");
     return SCM_BOOL_F;
diff --git a/gattrib/src/gattrib.c b/gattrib/src/gattrib.c
index 6e98838..8226793 100644
--- a/gattrib/src/gattrib.c
+++ b/gattrib/src/gattrib.c
@@ -178,7 +178,7 @@ void gattrib_main(void *closure, int argc, char *argv[])
   pr_current = s_toplevel_new();
 
   /* ----- Read in RC files.   ----- */
-  g_rc_parse(pr_current, "gattribrc", rc_filename);
+  g_rc_parse(pr_current, "gattribrc", NULL);
 
   i_window_vars_set(pr_current);   /* The window vars are used in gschem,
                                       but we need to set them here because
diff --git a/gattrib/src/globals.c b/gattrib/src/globals.c
index 84e6abc..390a60f 100644
--- a/gattrib/src/globals.c
+++ b/gattrib/src/globals.c
@@ -32,19 +32,11 @@
 #include <dmalloc.h>
 #endif
 
-char *rc_filename = NULL; 
-
-/* color stuff */
-GdkColormap *colormap; 
-GdkVisual *visual; 
-
-/* colors */
-GdkColor white;
-GdkColor black;
-
-int logfile_fd=-1;
 int do_logging=TRUE;
-int logging_dest=LOG_WINDOW;
+
+/* command line arguments */
+int verbose_mode=FALSE;
+int quiet_mode=FALSE;
 
 /* these are required by libgeda */
 /* I have made most of these NULL because they aren't needed
@@ -64,9 +56,3 @@ void (*x_log_update_func)() = NULL;
 void (*variable_set_func)() = i_vars_set;
 int (*load_newer_backup_func)() = NULL;
 
-/* command line arguments */
-int verbose_mode=FALSE;
-int quiet_mode=FALSE;
-
-
-

commit de149fd2d81b2c5432dceadfdc1100204d0f9d4e
Author: Ivan Stankovic <ivan.stankovic@xxxxxx>
Date:   Wed Aug 1 19:27:31 2007 +0100

    gattrib: reorganize file opening code
    
    This patch reorganizes the file opening code
    and related code paths in gattrib. Besides
    simplifying the code, the patch also improves
    error reporting.

diff --git a/gattrib/include/globals.h b/gattrib/include/globals.h
index c035c7f..e7561d2 100644
--- a/gattrib/include/globals.h
+++ b/gattrib/include/globals.h
@@ -69,12 +69,6 @@
 TOPLEVEL *pr_current;
 
 /*------------------------------------------------------------------
- * first_page -- this will eventually get folded into the TOPLEVEL
- * struct.
- *------------------------------------------------------------------*/
-int first_page;  /* set to zero after first page is read in. */
-
-/*------------------------------------------------------------------
  * (SHEET_DATA *sheet_head) -- my own data structure which I made
  * a global because it was easier to deal with when handing
  * callbacks.  It is defined in structs.h
diff --git a/gattrib/include/prototype.h b/gattrib/include/prototype.h
index 4fc48b7..378a5ab 100644
--- a/gattrib/include/prototype.h
+++ b/gattrib/include/prototype.h
@@ -6,9 +6,6 @@
 /* ---------------- gattrib.c ---------------- */
 void gattrib_really_quit(void);
 gint gattrib_quit(gint return_code);
-void gattrib_main(void *closure, int argc, char *argv[]);
-int main(int argc, char *argv[]);
-
 
 /* -------------- parsecmd.c ----------------- */
 void usage(char *cmd);   
@@ -212,9 +209,7 @@ void x_dialog_unsaved_data_abort_callback(GtkWidget *buttonyes,
 
 void x_dialog_unimplemented_feature();
 
-void x_dialog_exit_announcement(gchar *string, gint return_code);
-void x_dialog_exit_announcement_close_callback(GtkWidget *buttonok, 
-				   gpointer return_code);
+void x_dialog_fatal_error(gchar *string, gint return_code);
 
 int x_dialog_about_keypress_callback(GtkWidget * widget, GdkEventKey * event,
 				     GtkWidget * window);
@@ -289,8 +284,9 @@ void do_show_column_titles(GtkWidget *widget);
 
 
 /* ------------- x_fileselect.c ------------- */
-void x_fileselect_open (void);
+GSList *x_fileselect_open (void);
 void x_fileselect_save (void);
+gboolean x_fileselect_load_files (GSList *filenames);
 
 /* ------------- x_window.c ------------- */
 void x_window_init();
diff --git a/gattrib/src/gattrib.c b/gattrib/src/gattrib.c
index 9d295d0..6e98838 100644
--- a/gattrib/src/gattrib.c
+++ b/gattrib/src/gattrib.c
@@ -84,7 +84,6 @@ void gattrib_really_quit(void)
   }
 }
 
-
 /*------------------------------------------------------------------*/
 /*! \brief gattrib_quit -- wrap up and quit fcn. 
  *
@@ -106,7 +105,6 @@ gint gattrib_quit(gint return_code)
   exit(return_code);
 }
 
-
 /*------------------------------------------------------------------*/
 /*! \brief gattrib_main -- main gattrib fcn. 
  *
@@ -119,12 +117,9 @@ void gattrib_main(void *closure, int argc, char *argv[])
   /* SHEET_DATA *sheet_head is a global */
   /* GtkWidget *main_window is a global */
 
-  int i;
-  int return_code;  /* used when invoking s_toplevel_read_page */
   int argv_index;
-  char *cwd;
-  PAGE *p_local;
-  char *logfile;
+  gchar *cwd;
+  gchar *logfile;
 
 #ifdef HAVE_GTHREAD
   /* Gattrib isn't threaded, but some of GTK's file chooser
@@ -140,17 +135,18 @@ void gattrib_main(void *closure, int argc, char *argv[])
   /* Note that argv_index holds index to first non-flag command line option 
    * (that is, to the first file name) */
   argv_index = parse_commandline(argc, argv);
-  cwd = g_strdup(getcwd(NULL, 1024));
   
   /* ----------  create log file right away ---------- */
   /* ----------  even if logging is enabled ---------- */
+  cwd = g_get_current_dir();
   logfile = g_build_path (G_DIR_SEPARATOR_S,
                           cwd,
                           "gattrib.log",
                           NULL);
   s_log_init (logfile);
   g_free (logfile);
-  
+  g_free (cwd);
+
   s_log_message
     ("gEDA/gattrib version %s%s.%s\n", PREPEND_VERSION_STRING, 
      DOTTED_VERSION, DATE_VERSION);
@@ -174,7 +170,6 @@ void gattrib_main(void *closure, int argc, char *argv[])
     fprintf(stderr,
 	    "conditions; please see the COPYING file for more details.\n\n");
   }
-  
 
   /* ------  register guile (scheme) functions.  Necessary to parse RC file.  ------ */
   g_register_funcs();
@@ -185,198 +180,43 @@ void gattrib_main(void *closure, int argc, char *argv[])
   /* ----- Read in RC files.   ----- */
   g_rc_parse(pr_current, "gattribrc", rc_filename);
 
-  /*
-  i_vars_set(pr_current);
-  */
-
   i_window_vars_set(pr_current);   /* The window vars are used in gschem,
                                       but we need to set them here because
                                       graphical information is used
                                       when introducing new attributes. */
 
-#if DEBUG
-  printf("In gattrib_main -- we have just created and init'ed a new pr_current\n");
-#endif  
-
-
-
-  /* --------  Initialize main_window.  -------- */
-#if DEBUG
-  printf("In gattrib_main -- calling gtk_init. . . ..\n");
-#endif  
   gtk_init(&argc, &argv);
 
   x_window_init();  
-#if DEBUG
-  printf("In gattrib_main -- we have just initialized the main_window.\n");
-#endif  
- 
   
   /* ---------- Initialize SHEET_DATA data structure ---------- */
   sheet_head = s_sheet_data_new();   /* sheet_head was declared in globals.h */
 
-
-  /* ----- Now loop on the files specified on the cmd line & read them in ---- */
-  /* argv[0] = name of this prog (gattrib).  argv_index holds the 
-   * position of the first filename  */
-  i = argv_index;
-  while(argv[i] != NULL) {
-
-    gchar *temp_filename;
-    gchar *filename;
-#ifdef __MINGW32__
-    if (argv[i][1] == ':' && (argv[i][2] == G_DIR_SEPARATOR ||
-                              argv[i][2] == OTHER_PATH_SEPARATER_CHAR))
-#else
-    if (argv[i][0] == G_DIR_SEPARATOR)
-#endif
-    {
-      /* Path is already absolute so no need to do any concat of cwd */
-      temp_filename = g_strdup(argv[i]);
-    } else {
-      temp_filename = g_build_path (G_DIR_SEPARATOR_S, cwd, argv[i], NULL);
-    }
-
-    filename = f_normalize_filename(temp_filename);
-    g_free(temp_filename);
-
-    s_log_message("Loading file [%s]\n", filename);
-    if (!quiet_mode) {
-      printf ("Loading file [%s]\n", filename);
-    }
-
-    s_page_goto (pr_current,
-		 s_page_new (pr_current, filename));
-    
-    return_code = 0;
-    if (first_page == 1) {
-      return_code |= s_toplevel_read_page(filename);
-      first_page = 0;
-    } else {
-      return_code |= s_toplevel_read_page(filename);
-    }
-    
-    /* Now add all items found to the master lists */
-    s_sheet_data_add_master_comp_list_items(pr_current->page_current->object_head); 
-    s_sheet_data_add_master_comp_attrib_list_items(pr_current->page_current->object_head); 
-    
-#if 0
-    /* Note that this must be changed.  We need to input the entire project
-     * before doing anything with the nets because we need to first
-     * determine where they are all connected!   */
-    s_sheet_data_add_master_net_list_items(pr_current->page_current->object_head);    
-    s_sheet_data_add_master_net_attrib_list_items(pr_current->page_current->object_head); 
-#endif
-
-    s_sheet_data_add_master_pin_list_items(pr_current->page_current->object_head); 
-    s_sheet_data_add_master_pin_attrib_list_items(pr_current->page_current->object_head); 
-
-    i++;
-    g_free(filename);
-  }  /* while(argv[i])  */
-  g_free(cwd); /* cwd is allocated with g_strdup so, g_free is correct */
-
-
-  /* ---------- Now complete read-in of project  ---------- */
-  if ( first_page != 1 ) { 
-
-
-    /* ---------- Sort the master lists  ---------- */
-    s_string_list_sort_master_comp_list();
-    s_string_list_sort_master_comp_attrib_list();
-
-#if 0
-    /* Note that this must be changed.  We need to input the entire project
-     * before doing anything with the nets because we need to first
-     * determine where they are all connected!   */
-    s_string_list_sort_master_net_list();
-    s_string_list_sort_master_net_attrib_list();
-#endif
-
-    s_string_list_sort_master_pin_list();
-    s_string_list_sort_master_pin_attrib_list();
-
-    /* ---------- Create and load the tables  ---------- */
-    sheet_head->component_table = s_table_new(sheet_head->comp_count, sheet_head->comp_attrib_count);
-    sheet_head->net_table = s_table_new(sheet_head->net_count, sheet_head->net_attrib_count);
-    sheet_head->pin_table = s_table_new(sheet_head->pin_count, sheet_head->pin_attrib_count);
-    
-    p_local = pr_current->page_head; /* must iterate over all pages in design */
-    while (p_local != NULL) {
-      if (p_local->pid != -1) {   /* only traverse pages which are toplevel */
-	if (p_local->object_head && p_local->page_control == 0) {
-	  s_table_add_toplevel_comp_items_to_comp_table(p_local->object_head);    /* adds all components from page to comp_table */
-
-#if 0
-	  /* Note that this must be changed.  We need to input the entire project
-	   * before doing anything with the nets because we need to first
-	   * determine where they are all connected!   */
-	  s_table_add_toplevel_net_items_to_net_table(p_local->object_head);     /* adds all nets from page to net_table */
-#endif
-
-	  s_table_add_toplevel_pin_items_to_pin_table(p_local->object_head);    /* adds all pins from page to pin_table */
-
-	}
-      }
-      p_local = p_local->next;  /* iterate to next schematic page */
-    }
-#if DEBUG
-    printf("In gattrib_main -- we have just returned from adding to the tables.\n");
-#endif  
-
-
-#if DEBUG
-    /*  -----  Make debug printout of entire object list  -----  */
-    printf("In gattrib_main -- we have just read in the project and filled out pr_current\n");
-    printf("----------------------------  Object list -----------------------------\n");
-    s_page_print_all(pr_current);
-    printf("-----------------------------------------------------------------------\n");
-#endif
-
-    
-    /* -------------- Next, update windows --------------- */
-    x_window_add_items();    /* This updates the top level stuff,
-			      * and then calls another fcn to update
-			      * the GtkSheet itself.  */
-#if DEBUG
-    printf("In gattrib_main -- we have just returned from x_window_add_items.\n");
-#endif  
-    
-  }  /* if (first_page != 1) */
-  else {
-    /* no filename found on command line, therefore we are still on the first page */
-#if DEBUG
-    printf("In gattrib_main -- no files specified on command line.  Throw up filedialog.\n");
-#endif
-    x_fileselect_open ();
-
-    gtk_widget_show( GTK_WIDGET(notebook) );
-    gtk_widget_show( GTK_WIDGET(window) );
-
-    while( gtk_events_pending () ) {
-#ifdef DEBUG
-      printf("In gattrib_main, trying to flush gtk event queue before running gtk_main. . . . \n");
-#endif
-      gtk_main_iteration();  /* force window exposure by running event handler once */
-    }
-    
+  GSList *file_list = NULL;
+  if(argv[argv_index] == NULL) {
+     /* No files specified on the command line, pop up the File open dialog. */
+     file_list = x_fileselect_open();
+     if(file_list == NULL)
+        exit(0);
+  } else {
+     /* Construct the list of filenames from the command line.
+      * argv_index holds the position of the first filename  */
+     while(argv[argv_index] != NULL) {
+        file_list = g_slist_append(file_list, f_normalize_filename(argv[argv_index]));
+        argv_index++;
+     }
   }
 
-  /* ---------- Now verify correctness of read-in design.  ---------- */
-  s_toplevel_verify_design(pr_current);
-
+  /* Load the files */
+  if(x_fileselect_load_files(file_list) == FALSE) {
+     /* just exit the program */
+     exit(1);
+  }
+  
+  g_slist_foreach(file_list, (GFunc)g_free, NULL);
+  g_slist_free(file_list);
 
-  /* ---------- Now enter main event loop for spreadsheet.  ---------- */
-  gtk_widget_show( GTK_WIDGET(window) );  /*  One final show for good measure  */
-  gtk_main_iteration();  /* force window exposure by running event handler once */
   gtk_main();
-
-
-  /* ---------- Spreadsheet has been killed; we are quitting.  ---------- */
-#ifdef DEBUG
-  printf("In gattrib_main, we have exited gtk_main. \n");
-#endif  
-
   exit(0);
 }
 
@@ -391,7 +231,6 @@ void gattrib_main(void *closure, int argc, char *argv[])
  *------------------------------------------------------------------*/
 int main(int argc, char *argv[])
 {
-
   /* This is i18n stuff */
 #if ENABLE_NLS
   setlocale(LC_ALL, "");
@@ -407,8 +246,5 @@ int main(int argc, char *argv[])
   
   scm_boot_guile( argc, argv, gattrib_main, NULL);
 
-#ifdef DEBUG
-  printf("Now exiting main . . . Bye!\n");
-#endif
   exit(0);   /* This is not real exit point.  Real exit is in gattrib_quit. */
 }
diff --git a/gattrib/src/globals.c b/gattrib/src/globals.c
index ece96de..84e6abc 100644
--- a/gattrib/src/globals.c
+++ b/gattrib/src/globals.c
@@ -64,9 +64,6 @@ void (*x_log_update_func)() = NULL;
 void (*variable_set_func)() = i_vars_set;
 int (*load_newer_backup_func)() = NULL;
 
-/* gattrib specific variables */
-int first_page = 1;
-
 /* command line arguments */
 int verbose_mode=FALSE;
 int quiet_mode=FALSE;
diff --git a/gattrib/src/s_toplevel.c b/gattrib/src/s_toplevel.c
index 0e03f71..07aa160 100644
--- a/gattrib/src/s_toplevel.c
+++ b/gattrib/src/s_toplevel.c
@@ -48,10 +48,12 @@
 /* ===================  Public Functions  ====================== */
 
 
-/*------------------------------------------------------------------
- * This fcn reads in a page & calls f_open, which fills out the 
- * pr_current structure.  
- *------------------------------------------------------------------*/
+/*! \brief Reads in a page & calls f_open, which fills out the
+ *         pr_current structure.
+ *
+ *  \param [in] filename file to be opened
+ *  \returns 1 on success, 0 on failure
+ */
 int s_toplevel_read_page(char *filename)
 {
   int file_return_code;
@@ -61,50 +63,43 @@ int s_toplevel_read_page(char *filename)
   
   /* read in and fill out pr_current using f_open and its callees */
   file_return_code = f_open(pr_current, filename);
-  if (!file_return_code) {     /* 1 = success reading in page */
-                               /* 0 = failure reading in page */
-    fprintf(stderr, "Couldn't load schematic [%s]\n", filename);
-  }
   return file_return_code;
 }
 
 
-/*------------------------------------------------------------------
- * This fcn loops through all components in the design looking for
- * components which are placeholders.  Placeholders are inserted into
- * the object list when no symbol file is found.  If this fcn finds 
- * a placeholder, it warns the user.  
- *------------------------------------------------------------------*/
+/*! \brief This function loops through all components in the
+ *         design looking for components which are placeholders.
+ *
+ *  Placeholders are inserted into the object list when
+ *  no symbol file is found.  If this function finds a
+ *  placeholder, it warns the user.
+ *
+ *  \param [in] pr_current a toplevel object
+ */
 void s_toplevel_verify_design(TOPLEVEL *pr_current)
 {
   OBJECT *o_current;
   PAGE *p_current;
   int missing_sym_flag = 0;
 
-#ifdef DEBUG
-   printf("In s_toplevel_verify_design, about to check that all components have sym files.\n");
-#endif
-   
-   p_current = pr_current->page_head; /* must iterate over all pages in design */
-   while (p_current != NULL) {
-     if (p_current->pid != -1) {  /* skip over page_head which has pid = -1. */
-       o_current = p_current->object_head;
-       while (o_current != NULL) { 
-	 /* --- look for object, and verify that it has a symbol file attached. ---- */
-	 if (o_current->type == OBJ_PLACEHOLDER) {  
-	   missing_sym_flag = 1;  /* flag to signal that problem exists.  */
-	 }
-	 o_current = o_current->next;
-       }
-     }  /* if (p_current->pid != -1) */
-     p_current = p_current->next;
-   }
-
-   if (missing_sym_flag) {
-     x_dialog_missing_sym();  /* dialog gives user option to quit */
-   }
-
-   return;
+  p_current = pr_current->page_head; /* must iterate over all pages in design */
+  while (p_current != NULL) {
+    if (p_current->pid != -1) {  /* skip over page_head which has pid = -1. */
+      o_current = p_current->object_head;
+      while (o_current != NULL) {
+        /* --- look for object, and verify that it has a symbol file attached. ---- */
+        if (o_current->type == OBJ_PLACEHOLDER) {
+          missing_sym_flag = 1;  /* flag to signal that problem exists.  */
+        }
+        o_current = o_current->next;
+      }
+    }  /* if (p_current->pid != -1) */
+    p_current = p_current->next;
+  }
+
+  if (missing_sym_flag) {
+    x_dialog_missing_sym();  /* dialog gives user option to quit */
+  }
 }
 
 
@@ -175,15 +170,21 @@ s_toplevel_gtksheet_to_toplevel()
  * open.  Then it figures out if there is already an existing
  * project, and call the appropriate version of s_toplevel_read 
  * depending upon that.
+ * TODO: this should really be done in two stages:
+ * 1. close the current project and reinitialize structures
+ * 2. load the new project
  *------------------------------------------------------------------*/
 void s_toplevel_menubar_file_open(TOPLEVEL *pr_current)
 {
-#ifdef DEBUG
-  printf("In s_toplevel_menubar_file_open, about to create fileselect box\n");
-#endif
+  GSList *file_list;
 
-  x_fileselect_open ();
-  return;
+  file_list = x_fileselect_open();
+  
+  /* Load the files, don't check if it went OK */
+  x_fileselect_load_files(file_list);
+  
+  g_slist_foreach(file_list, (GFunc)g_free, NULL);
+  g_slist_free(file_list);
 }
 
 
diff --git a/gattrib/src/x_dialog.c b/gattrib/src/x_dialog.c
index 204e27e..02833ef 100644
--- a/gattrib/src/x_dialog.c
+++ b/gattrib/src/x_dialog.c
@@ -180,40 +180,32 @@ void x_dialog_delattrib_confirm()
   gtk_widget_destroy(dialog);
 }
 
-/* ========================================================= *
- * Missing symbol file dialog boxes.                         *
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This is the "missing symbol file found on object" dialog.
- * It offers the user the chance to close the project without
- * saving because he read a schematic with a missing symbol file.
- * --------------------------------------------------------- */
+/*! \brief This is the "missing symbol file found on object" dialog.
+ *
+ *  It offers the user the chance to close the project without
+ *  saving because he read a schematic with a missing symbol file.
+ */
 void x_dialog_missing_sym()
 {
-  GtkWidget *label;
   GtkWidget *dialog;
-  const char *string = "Warning!  One or more components have been found with missing symbol files!\n\n"
-    "This probably happened because gattrib couldn't find your component libraries,\n"
-    "perhaps because your gafrc or gattribrc files are misconfigured.\n"
+  const char *string = "One or more components have been found with missing symbol files!\n\n"
+    "This probably happened because gattrib couldn't find your component libraries, "
+    "perhaps because your gafrc or gattribrc files are misconfigured.\n\n"
     "Chose \"Quit\" to leave gattrib and fix the problem, or\n"
     "\"Forward\" to continue working with gattrib.\n";
 
-#ifdef DEBUG
-  printf("In x_dialog_missing_sym, creating windows.\n");
-#endif
-
   /* Create the dialog */
-  dialog = gtk_dialog_new_with_buttons("Missing symbol file found for component!", NULL,
-      GTK_DIALOG_MODAL,
-      GTK_STOCK_QUIT, GTK_RESPONSE_REJECT,
-      GTK_STOCK_GO_FORWARD, GTK_RESPONSE_ACCEPT,
-      NULL);
-  
-  label = gtk_label_new(string);
-  gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
-  gtk_widget_show(label);
+  dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                  GTK_MESSAGE_WARNING,
+                                  GTK_BUTTONS_NONE,
+                                  string);
+
+  gtk_dialog_add_buttons(GTK_DIALOG(dialog), 
+                  GTK_STOCK_QUIT, GTK_RESPONSE_REJECT,
+                  GTK_STOCK_GO_FORWARD, GTK_RESPONSE_ACCEPT,
+                  NULL);
 
+  gtk_window_set_title(GTK_WINDOW(dialog), "Missing symbol file found for component!");
   gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_REJECT);
 
   switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
@@ -223,7 +215,7 @@ void x_dialog_missing_sym()
 
     default:
       /* Terminate */
-      gattrib_quit(0);
+      exit(0);
       break;
   }
 
@@ -303,32 +295,31 @@ void x_dialog_unimplemented_feature()
   gtk_widget_destroy(dialog);
 }
 
-
-
-/* ========================================================= *
- * Exit announcment callback
- * ========================================================= */
-
-/* --------------------------------------------------------- *
- * This fcn accepts a string and displays it.  It presents
- * only an "OK" button to close the box and exit gattrib.
- * --------------------------------------------------------- */
-void x_dialog_exit_announcement(gchar *string, gint return_code)
+/*! \brief This function displays a dialog with the error string and
+ *         terminates the program.
+ *
+ *  \param [in] string the error string
+ *  \param [in] return_code the exit code
+ *  \return this function never returns
+ */
+void x_dialog_fatal_error(gchar *string, gint return_code)
 {
   GtkWidget *dialog;
+  
+  fprintf(stderr, "%s\n", string);
 
   /* Create the dialog */
   dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
-                                  GTK_MESSAGE_WARNING,
+                                  GTK_MESSAGE_ERROR,
                                   GTK_BUTTONS_OK,
                                   string);
 
-  gtk_window_set_title(GTK_WINDOW(dialog), "Attention!");
+  gtk_window_set_title(GTK_WINDOW(dialog), "Fatal error");
 
   gtk_dialog_run(GTK_DIALOG(dialog));
   gtk_widget_destroy(dialog);
   
-  gattrib_quit( GPOINTER_TO_INT(return_code) );
+  exit(GPOINTER_TO_INT(return_code));
 }
 
 /* ========================================================= *
diff --git a/gattrib/src/x_fileselect.c b/gattrib/src/x_fileselect.c
index 05dd4c0..f4e0d3f 100644
--- a/gattrib/src/x_fileselect.c
+++ b/gattrib/src/x_fileselect.c
@@ -159,50 +159,40 @@ x_fileselect_setup_filechooser_filters (GtkFileChooser *filechooser)
 
 }
 
-/*------------------------------------------------------------------
+/*! \brief Open all files specified in the list. The caller
+ *         is responsible for freeing the strings and the list
+ *         itself.
  *
- *------------------------------------------------------------------*/
-static void
-x_fileselect_open_files (GSList *filenames)
+ *  \par Function Description
+ *  The function updates the user interface. At the end of the function, 
+ *  the toplevel's current page is set to the page of the last loaded page.
+ *
+ *  \param [in] filenames list of files to be opened
+ *  \returns FALSE if any of the files could not be opened, TRUE otherwise
+ */
+gboolean
+x_fileselect_load_files (GSList *filenames)
 {
   PAGE *p_local;
-  int return_code = 0;
-  int old_num_rows, old_num_cols;  /* There is a better way . . . */
-
   GSList *filename;
 
-#ifdef DEBUG
-  printf("We have just entered x_fileselect_open_file.\n");
-#endif
-
-  old_num_rows = sheet_head->comp_count;
-  old_num_cols = sheet_head->comp_attrib_count;
-
   /* iterate over selected files */
   for (filename = filenames;
        filename != NULL;
        filename = g_slist_next (filename)) {
     gchar *string = (gchar*)filename->data;
     
-#if DEBUG
-    printf("In x_fileselect_open_file, opening string = %s\n", string);
-#endif
-    
     if (!quiet_mode) {
       s_log_message("Loading file [%s]\n", string);
     }
-    
+
     s_page_goto (pr_current, s_page_new (pr_current, string));
-      
-    return_code = 0;
-    if (first_page == 1) {
-      return_code |= s_toplevel_read_page(string);
-      first_page = 0;
-    } else {
-      return_code |= s_toplevel_read_page(string);
+
+    if(s_toplevel_read_page(string) == 0) {
+       fprintf(stderr, "Couldn't load schematic [%s]\n", string);
+       return FALSE;
     }
-    g_free(string);
-      
+
     /* Now add all items found to the master lists */
     s_sheet_data_add_master_comp_list_items(pr_current->page_current->object_head); 
     s_sheet_data_add_master_comp_attrib_list_items(pr_current->page_current->object_head); 
@@ -216,90 +206,74 @@ x_fileselect_open_files (GSList *filenames)
     
     s_sheet_data_add_master_pin_list_items(pr_current->page_current->object_head);    
     s_sheet_data_add_master_pin_attrib_list_items(pr_current->page_current->object_head); 
-    
-    
   }  	/* end of loop over files     */
   
-  /* Now update rest of project if we had at least one new file */
-  if (return_code) {
-    /* ---------- Sort the master lists  ---------- */
-    s_string_list_sort_master_comp_list();
-    s_string_list_sort_master_comp_attrib_list();
+
+  /* ---------- Sort the master lists  ---------- */
+  s_string_list_sort_master_comp_list();
+  s_string_list_sort_master_comp_attrib_list();
+
 #if 0
-    /* Note that this must be changed.  We need to input the entire project
-     * before doing anything with the nets because we need to first
-     * determine where they are all connected!   */
-    s_string_list_sort_master_net_list();
-    s_string_list_sort_master_net_attrib_list();
+  /* Note that this must be changed.  We need to input the entire project
+   * before doing anything with the nets because we need to first
+   * determine where they are all connected!   */
+  s_string_list_sort_master_net_list();
+  s_string_list_sort_master_net_attrib_list();
 #endif
-    
-    s_string_list_sort_master_pin_list();
-    s_string_list_sort_master_pin_attrib_list();
-    
-    
-    /* ---------- Now create and load the tables  ---------- */
-    sheet_head->component_table = s_table_new(sheet_head->comp_count, sheet_head->comp_attrib_count);
-    sheet_head->net_table = s_table_new(sheet_head->net_count, sheet_head->net_attrib_count);
-    sheet_head->pin_table = s_table_new(sheet_head->pin_count, sheet_head->pin_attrib_count);
-    
-    
-    p_local = pr_current->page_head; /* must iterate over all pages in design */
-    while (p_local != NULL) {
-      if (p_local->pid != -1) {   /* only traverse pages which are toplevel */
+
+  s_string_list_sort_master_pin_list();
+  s_string_list_sort_master_pin_attrib_list();
+
+  /* ---------- Create and load the tables  ---------- */
+  sheet_head->component_table = s_table_new(sheet_head->comp_count, sheet_head->comp_attrib_count);
+  sheet_head->net_table = s_table_new(sheet_head->net_count, sheet_head->net_attrib_count);
+  sheet_head->pin_table = s_table_new(sheet_head->pin_count, sheet_head->pin_attrib_count);
+
+  p_local = pr_current->page_head; /* must iterate over all pages in design */
+  while (p_local != NULL) {
+     if (p_local->pid != -1) {   /* only traverse pages which are toplevel */
         if (p_local->object_head && p_local->page_control == 0) {
-          s_table_add_toplevel_comp_items_to_comp_table(p_local->object_head);    /* adds all objects from page */
+           /* adds all components from page to comp_table */
+           s_table_add_toplevel_comp_items_to_comp_table(p_local->object_head);    
 #if 0
-          /* Note that this must be changed.  We need to input the entire project
-           * before doing anything with the nets because we need to first
-           * determine where they are all connected!   */
-          s_table_add_toplevel_net_items_to_net_table(p_local->object_head);     /* adds all objects from page */
+           /* Note that this must be changed.  We need to input the entire project
+            * before doing anything with the nets because we need to first
+            * determine where they are all connected!   */
+
+           /* adds all nets from page to net_table */
+           s_table_add_toplevel_net_items_to_net_table(p_local->object_head);
 #endif
-          
-          s_table_add_toplevel_pin_items_to_pin_table(p_local->object_head);     /* adds all objects from page */
-          
+
+           /* adds all pins from page to pin_table */
+           s_table_add_toplevel_pin_items_to_pin_table(p_local->object_head);
         }
-      }
-      p_local = p_local->next;  /* iterate to next schematic page */
-    }   /* while(p_local != NULL) */
-    
-#if DEBUG
-    printf("In x_fileselect_open_file -- we have just added more files to the project.\n");
-#endif  
-    
-    /* -------------- update windows --------------- */
-    x_window_add_items();    /* This updates the top level stuff,
-                              * and then calls another fcn to update
-                              * the GtkSheet itself.  */
-    
-#ifdef DEBUG
-    printf("In x_fileselect_open_file -- we have just returned from x_window_add_items.\n");
-#endif
-  } else {
-    fprintf(stderr, "Couldn't open any file!.\n");
+     }
+     p_local = p_local->next;  /* iterate to next schematic page */
   }
 
-  /* try showing all windows now */
-  gtk_widget_show( GTK_WIDGET(notebook));
-  gtk_widget_show( GTK_WIDGET(window));
-  
+  /* -------------- update windows --------------- */
+  x_window_add_items();    /* This updates the top level stuff,
+                            * and then calls another fcn to update
+                            * the GtkSheet itself.  */
+
+
   /* ---------- Now verify correctness of entire design.  ---------- */
   s_toplevel_verify_design(pr_current);  /* pr_current is a global */
-  
+
+  return TRUE;
 }
 
-/*------------------------------------------------------------------
- *  This function opens a file chooser dialog and wait for the user to
- *  select at least one file to load as toplevel's new pages.
- *
- *  The function updates the user interface.
+/*! \brief This function opens a file chooser dialog and waits for the user
+ *         to select at least one file to load as toplevel's new pages.
  *
- *  At the end of the function, the toplevel's current page is set to
- *  the page of the last loaded page.
- *------------------------------------------------------------------*/
-void
+ *  \returns list of files to be opened, or NULL if the user cancelled
+ *           the dialog
+ */
+GSList *
 x_fileselect_open (void)
 {
   GtkWidget *dialog;
+  GSList *filenames = NULL;
 
   dialog = gtk_file_chooser_dialog_new ("Open...",
                                         GTK_WINDOW(window),
@@ -323,22 +297,12 @@ x_fileselect_open (void)
   /* add file filters to dialog */
   x_fileselect_setup_filechooser_filters (GTK_FILE_CHOOSER (dialog));
   gtk_widget_show (dialog);
-  if (gtk_dialog_run ((GtkDialog*)dialog) == GTK_RESPONSE_ACCEPT) {
-    GSList *filenames =
-      gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog));
-
-    /* open each file */
-    x_fileselect_open_files (filenames);
 
-    if (filenames != NULL) {
-      /* free the list of filenames */
-      g_slist_foreach (filenames, (GFunc)g_free, NULL);
-      g_slist_free (filenames);
-    }
-    
-  }
-  gtk_widget_destroy (dialog);
+  if(gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+     filenames = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog));
   
+  gtk_widget_destroy (dialog);
+  return filenames;
 }
 
 /*------------------------------------------------------------------
diff --git a/gattrib/src/x_gtksheet.c b/gattrib/src/x_gtksheet.c
index ea6d6da..b1d7b79 100644
--- a/gattrib/src/x_gtksheet.c
+++ b/gattrib/src/x_gtksheet.c
@@ -92,8 +92,7 @@ x_gtksheet_init()
     fflush(stdout);
     printf("In x_gtksheet_init, no components in comp sheet.\n");
 #endif
-    x_dialog_exit_announcement("No components found in design.  Please check your schematic and try again!\n", -1);
-    gtk_main();  /* Run gtk loop here since the next thing we do is quit. */ 
+    x_dialog_fatal_error("No components found in design.  Please check your schematic and try again!\n", 1);
   }
   
 
diff --git a/gattrib/src/x_window.c b/gattrib/src/x_window.c
index c30202b..b09ba0d 100644
--- a/gattrib/src/x_window.c
+++ b/gattrib/src/x_window.c
@@ -216,17 +216,19 @@ x_window_create_menu(GtkWidget **menubar)
 }
 
 
-/*------------------------------------------------------------------
- * x_window_add_items -- this fcn updates the top level window
- * after a new page is read in.  It does the following:
+/*! \brief This function updates the top level window
+ *         after a new page is read in.  
+ *
+ *  \par Function Description
+ *  It does the following:
  * 
- * 2.  Create a new gtksheet having the current dimensions.
- * 3.  Call x_gktsheet_add_row_labels(comp_count, master_*_list_head)
- * 4.  Call x_gktsheet_add_col_labels(comp_attrib_count, master_*_attrib_list_head)
- * 5.  Call x_gktsheet_add_row_labels(net_count, master_*_list_head)
- * 6.  Call x_gktsheet_add_col_labels(net_attrib_count, master_*_attrib_list_head)
- * 7.  loop on i, j -- call x_gtksheet_add_entry(i, j, attrib_value)
- * 8.  Call gtk_widget_show(window) to show new window.
+ *  2.  Create a new gtksheet having the current dimensions.
+ *  3.  Call x_gktsheet_add_row_labels(comp_count, master_*_list_head)
+ *  4.  Call x_gktsheet_add_col_labels(comp_attrib_count, master_*_attrib_list_head)
+ *  5.  Call x_gktsheet_add_row_labels(net_count, master_*_list_head)
+ *  6.  Call x_gktsheet_add_col_labels(net_attrib_count, master_*_attrib_list_head)
+ *  7.  loop on i, j -- call x_gtksheet_add_entry(i, j, attrib_value)
+ *  8.  Call gtk_widget_show(window) to show new window.
  *------------------------------------------------------------------*/
 void
 x_window_add_items()
@@ -236,59 +238,30 @@ x_window_add_items()
   gchar *text, *error_string;
   gint visibility, show_name_value;
   
-#ifdef DEBUG
-  fflush(stderr);
-  fflush(stdout);
-  printf("Entered x_window_add_items . . . . . ..\n");
-#endif
-
   /* Do these sanity check to prevent later segfaults */
   if (sheet_head->comp_count == 0) {
-    error_string = g_strdup("\n\nNo components found in entire design!  ");
-    error_string = g_strconcat(error_string, 
-                            "Do you have refdeses on your components?  \n", NULL);
-    error_string = g_strconcat(error_string, 
-			    "Exiting. . . .\n", NULL);
-    fprintf(stderr, "%s", error_string);
-    x_dialog_exit_announcement(error_string, -1);
-    g_free(error_string);
-    gtk_main();
+    error_string = "No components found in entire design!\n"
+            "Do you have refdeses on your components?";
+    x_dialog_fatal_error(error_string, 1);
   }
 
   if (sheet_head->comp_attrib_count == 0) {
-    error_string = g_strdup("\n\nNo configurable component attributes found in entire design!  ");
-    error_string = g_strconcat(error_string, 
-                            "Please attach at least some attributes before running gattrib.\n", NULL);
-    error_string = g_strconcat(error_string, "Exiting. . . .\n", NULL);
-    fprintf(stderr, "%s", error_string);
-    x_dialog_exit_announcement(error_string, -2);
-    g_free(error_string);
-    gtk_main();
+    error_string = "No configurable component attributes found in entire design!\n"
+            "Please attach at least some attributes before running gattrib.";
+    x_dialog_fatal_error(error_string, 2);
   }
 
-
   if (sheet_head->pin_count == 0) {
-    error_string = g_strdup("\n\nNo pins found on any components!  ");
-    error_string = g_strconcat(error_string, "Please check your design.\n", NULL);
-    error_string = g_strconcat(error_string, "Exiting. . . .\n", NULL);
-    fprintf(stderr, "%s", error_string);
-    x_dialog_exit_announcement(error_string, -3);
-    g_free(error_string);
-    gtk_main();
+    error_string = "No pins found on any components!\n"
+            "Please check your design.";
+    x_dialog_fatal_error(error_string, 3);
   }
 
 
   /*  initialize the gtksheet. */
-#ifdef DEBUG
-  printf("In x_window_add_items, about to call x_gtksheet_init.\n");
-#endif
   x_gtksheet_init();  /* this creates a new gtksheet having dimensions specified
 		       * in sheet_head->comp_count, etc. . .  */
 
-
-#ifdef DEBUG
-  printf("In x_window_add_items, now load up the row and column labels.\n");
-#endif
   if (sheet_head->comp_count > 0 ) {
     x_gtksheet_add_row_labels(GTK_SHEET(sheets[0]), 
 			      sheet_head->comp_count, sheet_head->master_comp_list_head);
@@ -296,7 +269,6 @@ x_window_add_items()
 			      sheet_head->comp_attrib_count, sheet_head->master_comp_attrib_list_head);
   }
 
-
   /* This is not ready.  I need to implement net attributes */
   if (sheet_head->net_count > 0 ) {
     x_gtksheet_add_row_labels(GTK_SHEET(sheets[1]), 
@@ -316,10 +288,6 @@ x_window_add_items()
 			      sheet_head->pin_attrib_count, sheet_head->master_pin_attrib_list_head);
   }
   
-
-#ifdef DEBUG
-  printf("In x_window_add_items, now put comp attrib values in the comp sheet.\n");
-#endif
   /* ------ Comp sheet: put values in the individual cells ------- */
   num_rows = sheet_head->comp_count;
   num_cols = sheet_head->comp_attrib_count;
@@ -335,14 +303,7 @@ x_window_add_items()
       }
     }
   }
-  /* Do I really need these shows here? */
-  gtk_widget_show( GTK_WIDGET(sheets[0]) );
-  gtk_widget_show( GTK_WIDGET(scrolled_windows[0]) );
-
 
-#ifdef DEBUG
-  printf("In x_window_add_items, now put net attrib values in the net sheet.\n");
-#endif
   /* ------ Net sheet: put values in the individual cells ------- */
   num_rows = sheet_head->net_count;
   num_cols = sheet_head->net_attrib_count;
@@ -358,16 +319,7 @@ x_window_add_items()
       }
     }
   }
-  /* Do I really need these shows here? */
-  if (sheet_head->net_count > 0) {
-    gtk_widget_show( GTK_WIDGET(sheets[1]) );
-    gtk_widget_show( GTK_WIDGET(scrolled_windows[1]) );
-  }
-
 
-#ifdef DEBUG
-  printf("In x_window_add_items, now put pin attrib values in the pin sheet.\n");
-#endif
   /* ------ Pin sheet: put pin attribs in the individual cells ------- */
   num_rows = sheet_head->pin_count;
   num_cols = sheet_head->pin_attrib_count;
@@ -382,19 +334,7 @@ x_window_add_items()
       }
     }
   }
-  /* Do I really need these shows here? */
-  if (sheet_head->pin_count > 0) {
-    gtk_widget_show( GTK_WIDGET(sheets[2]) );
-    gtk_widget_show( GTK_WIDGET(scrolled_windows[2]) );
-  }
-
-  gtk_widget_show( GTK_WIDGET(notebook) );
-  /*  gtk_widget_show( GTK_WIDGET(main_vbox) ); */
-  gtk_widget_show( GTK_WIDGET(window) );
-
-  return;
 
+  gtk_widget_show_all( GTK_WIDGET(window) );
 }
-/* ======================  Private functions  ======================== */
-
 




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