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

gEDA-cvs: branch: master updated (1.0-20070526-82-g62e7775)



The branch, master has been updated
       via  62e7775f82d947efb1515ef8f9f776da88de62b4 (commit)
       via  b034307ae05d909a726c09d4eb02a5eed6f401ea (commit)
       via  907857c70c12707f00696d0688eb8392ac1e9294 (commit)
       via  c144221daf8ef133f39e14c76447a1b556c54853 (commit)
       via  ba691725f807a4b0a250bfab5111a2c74c289413 (commit)
      from  301614ec1f0e97de952f071d5f40f885ca7484ce (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
=========

 gschem/include/x_preview.h  |    2 +
 gschem/src/x_compselect.c   |   14 ++--
 gschem/src/x_preview.c      |   52 +++++++++++--
 libgeda/include/prototype.h |    4 +-
 libgeda/include/struct.h    |    7 ++
 libgeda/src/f_basic.c       |  177 ++++++++++++++++++++++++-------------------
 libgeda/src/s_clib.c        |    2 +-
 symbols/Makefile.am         |    2 +-
 8 files changed, 163 insertions(+), 97 deletions(-)


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

commit 62e7775f82d947efb1515ef8f9f776da88de62b4
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:36:42 2007 +0100

    libgeda: Add a newline to a component library log message

:100644 100644 61dd4da... 712d390... M	libgeda/src/s_clib.c

commit b034307ae05d909a726c09d4eb02a5eed6f401ea
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:08:04 2007 +0100

    gschem: Support preview of symbols from all library types.

:100644 100644 351326d... bbab75f... M	gschem/src/x_compselect.c

commit 907857c70c12707f00696d0688eb8392ac1e9294
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:08:00 2007 +0100

    gschem: Preview data from a buffer.
    
    Add the ability to parse & preview a gEDA schematic or symbol from a
    character buffer.

:100644 100644 f222907... a24e650... M	gschem/include/x_preview.h
:100644 100644 52b2ee2... 25636d0... M	gschem/src/x_preview.c

commit c144221daf8ef133f39e14c76447a1b556c54853
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 15:50:31 2007 +0100

    libgeda: Add fine-grained control over f_open() behaviour.
    
    Add a function f_open_flags() which takes an extra argument which is a
    set of flags controlling actions taking while opening a file. f_open()
    wraps this with a default set of flags.
    
    Coincidentally, this also leads to a trivial fix for the file open
    dialog backup-message bug.

:100644 100644 ceb04da... 52b2ee2... M	gschem/src/x_preview.c
:100644 100644 471a844... 57a64b9... M	libgeda/include/prototype.h
:100644 100644 dcf2cd9... c117110... M	libgeda/include/struct.h
:100644 100644 0fa8a41... 58d6892... M	libgeda/src/f_basic.c

commit ba691725f807a4b0a250bfab5111a2c74c289413
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 15:49:44 2007 +0100

    symbols: Distribute ChangeLog-1.0

:100644 100644 4631b2d... fcd5eed... M	symbols/Makefile.am

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

commit 62e7775f82d947efb1515ef8f9f776da88de62b4
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:36:42 2007 +0100

    libgeda: Add a newline to a component library log message

diff --git a/libgeda/src/s_clib.c b/libgeda/src/s_clib.c
index 61dd4da..712d390 100644
--- a/libgeda/src/s_clib.c
+++ b/libgeda/src/s_clib.c
@@ -771,7 +771,7 @@ const CLibSource *s_clib_add_directory (const gchar *directory,
 
   oldsource = s_clib_get_source_by_name (realname);
   if (oldsource != NULL) {
-    s_log_message ("Cannot add library [%s]: name in use.",
+    s_log_message ("Cannot add library [%s]: name in use.\n",
 		   realname);
     g_free (realname);
     return NULL;

commit b034307ae05d909a726c09d4eb02a5eed6f401ea
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:08:04 2007 +0100

    gschem: Support preview of symbols from all library types.

diff --git a/gschem/src/x_compselect.c b/gschem/src/x_compselect.c
index 351326d..bbab75f 100644
--- a/gschem/src/x_compselect.c
+++ b/gschem/src/x_compselect.c
@@ -374,8 +374,8 @@ compselect_callback_tree_selection_changed (GtkTreeSelection *selection,
   GtkTreeModel *model;
   GtkTreeIter iter, parent;
   Compselect *compselect = (Compselect*)user_data;
-  CLibSymbol *sym = NULL;
-  gchar *filename;
+  const CLibSymbol *sym = NULL;
+  gchar *buffer = NULL;
 
   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
     return;
@@ -388,11 +388,12 @@ compselect_callback_tree_selection_changed (GtkTreeSelection *selection,
   
   /* build full path to component looking at parents */
   gtk_tree_model_get (model, &iter, 0, &sym, -1);
-  filename = s_clib_symbol_get_filename(sym);
 
-  /* update the treeview with new filename */
+  buffer = s_clib_symbol_get_data (sym);
+
+  /* update the preview with new symbol data */
   g_object_set (compselect->preview,
-                "filename", filename,
+                "buffer", buffer,
                 NULL);
 
   /* signal a component has been selected to parent of dialog */
@@ -401,8 +402,7 @@ compselect_callback_tree_selection_changed (GtkTreeSelection *selection,
                          GTK_RESPONSE_APPLY,
                          NULL);
 
-  g_free (filename);
-
+  g_free (buffer);
 }
 
 /*! \brief Requests re-evaluation of the filter.

commit 907857c70c12707f00696d0688eb8392ac1e9294
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 18:08:00 2007 +0100

    gschem: Preview data from a buffer.
    
    Add the ability to parse & preview a gEDA schematic or symbol from a
    character buffer.

diff --git a/gschem/include/x_preview.h b/gschem/include/x_preview.h
index f222907..a24e650 100644
--- a/gschem/include/x_preview.h
+++ b/gschem/include/x_preview.h
@@ -47,6 +47,8 @@ struct _Preview {
   TOPLEVEL *preview_toplevel;
 
   gchar *filename;
+  gchar *buffer;
+
   gboolean active;
   
 };
diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index 52b2ee2..25636d0 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -47,6 +47,7 @@ extern int mouse_x, mouse_y;
 
 enum {
   PROP_FILENAME=1,
+  PROP_BUFFER,
   PROP_ACTIVE
 };
 
@@ -239,14 +240,31 @@ preview_update (Preview *preview)
   s_page_delete (preview_toplevel, preview_toplevel->page_current);
   s_page_goto (preview_toplevel, s_page_new (preview_toplevel, "preview"));
   
-  if (preview->active && preview->filename != NULL) {
-    /* open up file in current page */
-    f_open_flags (preview_toplevel, preview->filename,
-                  F_OPEN_RC | F_OPEN_RESTORE_CWD);
-    /* test value returned by f_open... - Fix me */
-    /* we should display something if there an error occured - Fix me */
+  if (preview->active) {
+    g_assert ((preview->filename == NULL) || (preview->buffer == NULL));
+    if (preview->filename != NULL) {
+      /* open up file in current page */
+      f_open_flags (preview_toplevel, preview->filename,
+                    F_OPEN_RC | F_OPEN_RESTORE_CWD);
+      /* test value returned by f_open... - Fix me */
+      /* we should display something if there an error occured - Fix me */
+    }
+    if (preview->buffer != NULL) {
+
+      /* Load the data buffer */
+      preview_toplevel->page_current->object_tail = (OBJECT *) 
+        o_read_buffer (preview_toplevel, 
+                       preview_toplevel->page_current->object_tail, 
+                       preview->buffer, -1, "Preview Buffer");
+      preview_toplevel->page_current->object_tail = (OBJECT *) 
+        return_tail(preview_toplevel->page_current->object_head); 
+
+      /* Is this needed? */
+      if (preview_toplevel->net_consolidate == TRUE) {	
+              o_net_consolidate(preview_toplevel);
+      }
+    }
   }
-
   /* display current page (possibly empty) */
   a_zoom_extents (preview_toplevel,
                   preview_toplevel->page_current->object_head,
@@ -299,6 +317,13 @@ preview_class_init (PreviewClass *klass)
                          "",
                          NULL,
                          G_PARAM_READWRITE));
+  g_object_class_install_property (
+    gobject_class, PROP_BUFFER,
+    g_param_spec_string ("buffer",
+                         "",
+                         "",
+                         NULL,
+                         G_PARAM_WRITABLE));
   g_object_class_install_property(
     gobject_class, PROP_ACTIVE,
     g_param_spec_boolean ("active",
@@ -347,7 +372,8 @@ preview_init (Preview *preview)
                 NULL);
 
   preview->active   = FALSE;
-  preview->filename = NULL;  
+  preview->filename = NULL;
+  preview->buffer   = NULL;
   
   gtk_widget_set_events (GTK_WIDGET (preview), 
                          GDK_EXPOSURE_MASK | 
@@ -376,9 +402,18 @@ preview_set_property (GObject *object,
   switch(property_id) {
       case PROP_FILENAME:
         g_free (preview->filename);
+        g_free (preview->buffer);
         preview->filename = g_strdup (g_value_get_string (value));
-        if (preview->active) preview_update (preview);
+        preview_update (preview);
+        break;
+
+      case PROP_BUFFER:
+        g_free (preview->filename);
+        g_free (preview->buffer);
+        preview->buffer = g_strdup (g_value_get_string (value));
+        preview_update (preview);
         break;
+
       case PROP_ACTIVE:
         preview->active = g_value_get_boolean (value);
         preview_update (preview);

commit c144221daf8ef133f39e14c76447a1b556c54853
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 15:50:31 2007 +0100

    libgeda: Add fine-grained control over f_open() behaviour.
    
    Add a function f_open_flags() which takes an extra argument which is a
    set of flags controlling actions taking while opening a file. f_open()
    wraps this with a default set of flags.
    
    Coincidentally, this also leads to a trivial fix for the file open
    dialog backup-message bug.

diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index ceb04da..52b2ee2 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -241,7 +241,8 @@ preview_update (Preview *preview)
   
   if (preview->active && preview->filename != NULL) {
     /* open up file in current page */
-    f_open (preview_toplevel, preview->filename);
+    f_open_flags (preview_toplevel, preview->filename,
+                  F_OPEN_RC | F_OPEN_RESTORE_CWD);
     /* test value returned by f_open... - Fix me */
     /* we should display something if there an error occured - Fix me */
   }
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 471a844..57a64b9 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -7,7 +7,9 @@ OBJECT *o_read(TOPLEVEL *w_current, OBJECT *object_list, char *filename);
 void o_scale(TOPLEVEL *w_current, OBJECT *list, int x_scale, int y_scale);
 
 /* f_basic.c */
-int f_open(TOPLEVEL *w_current, char *filename);
+int f_open(TOPLEVEL *w_current, const gchar *filename);
+int f_open_flags(TOPLEVEL *w_current, const gchar *filename, 
+                 const gint flags);
 void f_close(TOPLEVEL *w_current);
 void f_save_close(TOPLEVEL *w_current, char *filename);
 int f_save(TOPLEVEL *w_current, const char *filename);
diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h
index dcf2cd9..c117110 100644
--- a/libgeda/include/struct.h
+++ b/libgeda/include/struct.h
@@ -65,6 +65,13 @@ typedef struct _CLibSymbol CLibSymbol;
 /* Component library search modes */
 typedef enum { CLIB_EXACT=0, CLIB_GLOB } CLibSearchMode;
 
+/* f_open behaviour flags.  See documentation for f_open_flags() in
+   f_basic.c. */
+typedef enum { F_OPEN_RC           = 1,
+               F_OPEN_CHECK_BACKUP = 2,
+               F_OPEN_RESTORE_CWD  = 4,
+} FOpenFlags;
+
 /* PB : change begin */
 /* PB : these enum are constant to define :
    - the end of open line of an object ;
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index 0fa8a41..58d6892 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -50,15 +50,38 @@
 
 /*! \brief Opens the schematic file.
  *  \par Function Description
- *  Opens the schematic file. Before it reads the schematic, it tries to
- *  open and read the local gafrc file.
+ *  Opens the schematic file by calling f_open_flags() with the
+ *  F_OPEN_RC and F_OPEN_CHECK_BACKUP flags.
  *
  *  \param [in,out] w_current  The TOPLEVEL object to load the schematic into.
  *  \param [in]      filename  A character string containing the file name
  *                             to open.
  *  \return 0 on failure, 1 on success.
  */
-int f_open(TOPLEVEL *w_current, char *filename)
+int f_open(TOPLEVEL *w_current, const gchar *filename)
+{
+  return f_open_flags (w_current, filename, 
+                       F_OPEN_RC | F_OPEN_CHECK_BACKUP);
+}
+
+/*! \brief Opens the schematic file with fine-grained control over behaviour.
+ *  \par Function Description
+ *  Opens the schematic file and carries out a number of actions
+ *  depending on the \a flags set.  If #F_OPEN_RC is set, executes
+ *  configuration files found in the target directory.  If
+ *  #F_OPEN_CHECK_BACKUP is set, warns user if a backup is found for
+ *  the file being loaded, and possibly prompts user for whether to
+ *  load the backup instead.  If #F_OPEN_RESTORE_CWD is set, does not
+ *  change the working directory to that of the file being loaded.
+ *
+ *  \param [in,out] w_current  The TOPLEVEL object to load the schematic into.
+ *  \param [in]     filename   A character string containing the file name
+ *                             to open.
+ *  \param [in]     flags      Combination of #FOpenFlags values.
+ *  \return 0 on failure, 1 on success.
+ */
+int f_open_flags(TOPLEVEL *w_current, const gchar *filename, 
+                 const gint flags)
 {
   int opened=FALSE;
   char *full_filename = NULL;
@@ -76,12 +99,9 @@ int f_open(TOPLEVEL *w_current, char *filename)
              w_current->init_top,  w_current->init_bottom);
 
 
-  /* 
-   * If we are only opening a preview window, we don't want to 
-   * change the directory. Therefore, if this is only a preview window, 
-   * we cache the cwd so we can restore it later.
-   */
-  if (w_current->wid == -1) {
+  /* Cache the cwd so we can restore it later. */
+  /*! \bug Assumes cwd will be less than 1024 characters. */
+  if (flags & F_OPEN_RESTORE_CWD) {
     saved_cwd = getcwd(NULL, 1024);
   }
 
@@ -98,73 +118,77 @@ int f_open(TOPLEVEL *w_current, char *filename)
   /* First cd into file's directory. */
   file_directory = g_dirname (full_filename);
 
-  full_rcfilename = g_strconcat (file_directory,  
-                                 G_DIR_SEPARATOR_S, 
-                                 "gafrc",
-                                 NULL);
   if (file_directory) { 
     chdir(file_directory);  
-    /* Probably should do some checking of chdir return values */
+    /*! \bug Probably should do some checking of chdir return values */
   }
-  /* If directory is not found, we should do something . . . . */
 
   /* Now open RC and process file */
-  g_rc_parse_specified_rc(w_current, full_rcfilename);
-
-  /* Check if there is a newer autosave backup file */
-  backup_filename = g_strdup_printf("%s%c"AUTOSAVE_BACKUP_FILENAME_STRING,
-				    file_directory, G_DIR_SEPARATOR, 
-				    g_path_get_basename(full_filename));
-
-  g_free (file_directory);
-
-  if ( g_file_test (backup_filename, G_FILE_TEST_EXISTS) && 
-       (! g_file_test (backup_filename, G_FILE_TEST_IS_DIR))) {
-    /* An autosave backup file exists. Check if it's newer */
-    struct stat stat_backup;
-    struct stat stat_file;
-    char error_stat = 0;
-    GString *message;
+  if (flags & F_OPEN_RC) {
+    full_rcfilename = g_strconcat (file_directory,  
+                                   G_DIR_SEPARATOR_S, 
+                                   "gafrc",
+                                   NULL);
+    g_rc_parse_specified_rc(w_current, full_rcfilename);
+  }
+
+  if (flags & F_OPEN_CHECK_BACKUP) {
+    /* Check if there is a newer autosave backup file */
+    backup_filename 
+      = g_strdup_printf("%s%c"AUTOSAVE_BACKUP_FILENAME_STRING,
+                        file_directory, G_DIR_SEPARATOR, 
+                        g_path_get_basename(full_filename));
+
+    g_free (file_directory);
+
+    if ( g_file_test (backup_filename, G_FILE_TEST_EXISTS) && 
+         (! g_file_test (backup_filename, G_FILE_TEST_IS_DIR))) {
+      /* An autosave backup file exists. Check if it's newer */
+      struct stat stat_backup;
+      struct stat stat_file;
+      char error_stat = 0;
+      GString *message;
     
-    if (stat (backup_filename, &stat_backup) != 0) {
-      s_log_message ("f_open: Unable to get stat information of backup file %s.", 
-		     backup_filename);
-      error_stat = 1 ;
-    }
-    if (stat (full_filename, &stat_file) != 0) {
-      s_log_message ("f_open: Unable to get stat information of file %s.", 
-		     full_filename);
-      error_stat = 1;
-    }
-    if ((difftime (stat_file.st_ctime, stat_backup.st_ctime) < 0) ||
-	(error_stat == 1))
-    {
-      /* Found an autosave backup. It's newer if error_stat is 0 */
-      message = g_string_new ("");
-      g_string_append_printf(message, "\nWARNING: Found an autosave backup file:\n  %s.\n\n", backup_filename);
-      if (error_stat == 1) {
-	g_string_append(message, "I could not guess if it is newer, so you have to"
-			  "do it manually.\n");
-      }
-      else {
-	g_string_append(message, "The backup copy is newer than the schematic, so it seems you should load it instead of the original file.\n");
-      }
-      g_string_append (message, "Gschem usually makes backup copies automatically, and this situation happens when it crashed or it was forced to exit abruptely.\n");
-      if (w_current->page_current->load_newer_backup_func == NULL) {
-	s_log_message(message->str);
-	s_log_message("\nRun gschem and correct the situation.\n\n");
-	fprintf(stderr, message->str);
-	fprintf(stderr, "\nRun gschem and correct the situation.\n\n");
+      if (stat (backup_filename, &stat_backup) != 0) {
+        s_log_message ("f_open: Unable to get stat information of backup file %s.", 
+                       backup_filename);
+        error_stat = 1 ;
       }
-      else {
-	/* Ask the user if load the backup or the original file */
-	if (w_current->page_current->load_newer_backup_func 
-	    (w_current, message)) {
-	  /* Load the backup file */
-	  load_backup_file = 1;
-	}
+      if (stat (full_filename, &stat_file) != 0) {
+        s_log_message ("f_open: Unable to get stat information of file %s.", 
+                       full_filename);
+        error_stat = 1;
       }
-      g_string_free (message, TRUE);
+      if ((difftime (stat_file.st_ctime, stat_backup.st_ctime) < 0) ||
+          (error_stat == 1))
+        {
+          /* Found an autosave backup. It's newer if error_stat is 0 */
+          message = g_string_new ("");
+          g_string_append_printf(message, "\nWARNING: Found an autosave backup file:\n  %s.\n\n", backup_filename);
+          if (error_stat == 1) {
+            g_string_append(message, "I could not guess if it is newer, so you have to"
+                            "do it manually.\n");
+          }
+          else {
+            g_string_append(message, "The backup copy is newer than the schematic, so it seems you should load it instead of the original file.\n");
+          }
+          g_string_append (message, "Gschem usually makes backup copies automatically, and this situation happens when it crashed or it was forced to exit abruptely.\n");
+          if (w_current->page_current->load_newer_backup_func == NULL) {
+            s_log_message(message->str);
+            s_log_message("\nRun gschem and correct the situation.\n\n");
+            fprintf(stderr, message->str);
+            fprintf(stderr, "\nRun gschem and correct the situation.\n\n");
+          }
+          else {
+            /* Ask the user if load the backup or the original file */
+            if (w_current->page_current->load_newer_backup_func 
+                (w_current, message)) {
+              /* Load the backup file */
+              load_backup_file = 1;
+            }
+          }
+          g_string_free (message, TRUE);
+        }
     }
   }
 
@@ -183,20 +207,16 @@ int f_open(TOPLEVEL *w_current, char *filename)
 	   full_filename);
   }
 
-  g_free (backup_filename);
-
   if (w_current->page_current->object_tail != NULL) {
     s_log_message("Opened file [%s]\n", full_filename);
     opened = TRUE;
-
   } else {
     /* Failed to open page */
     opened = FALSE;	 
   }
 
-
-  w_current->page_current->object_tail = (OBJECT *) 
-  return_tail(w_current->page_current->object_head); 
+  w_current->page_current->object_tail 
+    = (OBJECT *) return_tail(w_current->page_current->object_head); 
 
   /* make sure you init net_consolide to false (default) in all */
   /* programs */
@@ -216,12 +236,11 @@ int f_open(TOPLEVEL *w_current, char *filename)
 
   g_free(full_filename);
   g_free(full_rcfilename);
+  g_free (backup_filename);
 
-  /* If this was a preview window, reset the directory to the 
-   * value it had when f_open was called.  Also get rid of component
-   * libraries opened while opening preview window.  If the component
-   * is actually selected, they will be re-read later. */
-  if (w_current->wid == -1) {
+  /* Reset the directory to the value it had when f_open was
+   * called. */
+  if (flags & F_OPEN_RESTORE_CWD) {
     chdir(saved_cwd);
     g_free(saved_cwd);
   }

commit ba691725f807a4b0a250bfab5111a2c74c289413
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Thu Jun 28 15:49:44 2007 +0100

    symbols: Distribute ChangeLog-1.0

diff --git a/symbols/Makefile.am b/symbols/Makefile.am
index 4631b2d..fcd5eed 100644
--- a/symbols/Makefile.am
+++ b/symbols/Makefile.am
@@ -9,7 +9,7 @@ SUBDIRS = \
 scmdatadir = @GEDADATADIR@@PATHSEP@scheme
 dist_scmdata_DATA = geda-clib.scm geda-font.scm
 
-EXTRA_DIST = autogen.sh
+EXTRA_DIST = autogen.sh ChangeLog-1.0
 
 distclean-local:
 	-rm -rf autom4te.cache




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