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

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-197-g4d83eae)



The branch, master has been updated
       via  4d83eae30b789deb8ab9235a89c191630ebf18be (commit)
       via  44028f9c988a134748c8cea5e439983377ae3fd3 (commit)
       via  253caac857e22ba28ba7ce05b36f95a5f78bd683 (commit)
      from  3c0d85eae92d5764aa7dee2899c6a066c3470ee3 (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/prototype.h       |    2 +-
 gschem/src/gschem.c              |   19 +++++++++++++------
 gschem/src/x_fileselect.c        |   17 ++---------------
 libgeda/include/libgeda/funcs.h  |    5 +----
 libgeda/include/libgeda/struct.h |   10 +++++++---
 libgeda/src/f_basic.c            |    9 +++------
 libgeda/src/s_basic.c            |   16 ++++++++++++----
 libgeda/src/s_page.c             |    2 --
 libgeda/src/s_toplevel.c         |    3 +++
 9 files changed, 42 insertions(+), 41 deletions(-)


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

commit 4d83eae30b789deb8ab9235a89c191630ebf18be
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:17:01 2009 +0000

    libgeda: Refactor load backup query callback.
    
    Passing user data allows the gschem callback to be called with a
    GSCHEM_TOPLEVEL instead of a TOPLEVEL.

:100644 100644 5339ec7... 4bd7594... M	gschem/include/prototype.h
:100644 100644 5834c16... e768aa5... M	gschem/src/gschem.c
:100644 100644 8ebab24... 46c3ea6... M	gschem/src/x_fileselect.c
:100644 100644 b6b2fbd... 48af7e0... M	libgeda/include/libgeda/funcs.h
:100644 100644 b29634a... 0ecd5a0... M	libgeda/include/libgeda/struct.h
:100644 100644 f90f5ea... 44ec096... M	libgeda/src/f_basic.c
:100644 100644 85669a3... feef956... M	libgeda/src/s_page.c
:100644 100644 57269d3... a9e09e9... M	libgeda/src/s_toplevel.c

commit 44028f9c988a134748c8cea5e439983377ae3fd3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:16:59 2009 +0000

    libgeda: Don't use compiled-in GEDADATA on Windows.
    
    On Windows, the compiled-in data path set with configure is unlikely
    to be the same as the path gEDA is actually installed to -- so don't
    use it. Instead, permit the s_path_*() funcs to return NULL.

:100644 100644 d56a3fc... a33bfe8... M	libgeda/src/s_basic.c

commit 253caac857e22ba28ba7ce05b36f95a5f78bd683
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:16:43 2009 +0000

    gschem: Better checks that GEDADATA has been found.
    
    If libgeda fails to locate the gEDA data directory, show a dialog
    before quitting. This is important for users running gschem from
    e.g. a .desktop file in their system menu, when the stderr/stdout may
    not be easy to get at.

:100644 100644 af4511e... 5834c16... M	gschem/src/gschem.c

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

commit 4d83eae30b789deb8ab9235a89c191630ebf18be
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:17:01 2009 +0000

    libgeda: Refactor load backup query callback.
    
    Passing user data allows the gschem callback to be called with a
    GSCHEM_TOPLEVEL instead of a TOPLEVEL.

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 5339ec7..4bd7594 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -801,7 +801,7 @@ void x_compselect_deselect (GSCHEM_TOPLEVEL *w_current);
 /* x_fileselect.c */
 void x_fileselect_open(GSCHEM_TOPLEVEL *w_current);
 void x_fileselect_save(GSCHEM_TOPLEVEL *w_current);
-int x_fileselect_load_backup(TOPLEVEL *toplevel, GString *message);
+int x_fileselect_load_backup(void *user_data, GString *message);
 /* x_grid.c */
 void x_grid_draw_region(GSCHEM_TOPLEVEL *w_current, int x, int y, int width, int height);
 int x_grid_query_drawn_spacing(GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index 5834c16..e768aa5 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -174,7 +174,6 @@ void main_prog(void *closure, int argc, char *argv[])
   path_draw_func = o_path_draw;
   pin_draw_func = o_pin_draw;
   text_draw_func = o_text_draw;
-  load_newer_backup_func = x_fileselect_load_backup;
   select_func = o_select_object;
 
   /* create log file right away even if logging is enabled */
@@ -238,6 +237,9 @@ void main_prog(void *closure, int argc, char *argv[])
   w_current->toplevel = s_toplevel_new ();
   global_window_current = w_current;
 
+  w_current->toplevel->load_newer_backup_func = x_fileselect_load_backup;
+  w_current->toplevel->load_newer_backup_data = w_current;
+
   /* Now read in RC files. */
   g_rc_parse_gtkrc();
   g_rc_parse(w_current->toplevel, "gschemrc", rc_filename);
diff --git a/gschem/src/x_fileselect.c b/gschem/src/x_fileselect.c
index 8ebab24..46c3ea6 100644
--- a/gschem/src/x_fileselect.c
+++ b/gschem/src/x_fileselect.c
@@ -317,23 +317,10 @@ x_fileselect_save (GSCHEM_TOPLEVEL *w_current)
  *  \param [in] message   Message to display to user.
  *  \return TRUE if the user wants to load the backup file, FALSE otherwise.
  */
-int x_fileselect_load_backup(TOPLEVEL *toplevel, GString *message)
+int x_fileselect_load_backup(void *user_data, GString *message)
 {
   GtkWidget *dialog;
-  GSCHEM_TOPLEVEL *window, *w_current = NULL;
-   GList *iter;
-
-  /* Find the matching GSCHEM_TOPLEVEL for the TOPLEVEL we were passed */
-  iter = global_window_list;
-  while (iter != NULL) {
-    window = (GSCHEM_TOPLEVEL *)iter->data;
-    if (window->toplevel == toplevel) {
-      w_current = window;
-      break;
-    }
-    iter = g_list_next (iter);
-  }
-  g_assert( w_current != NULL );
+  GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL *) user_data;
 
   g_string_append(message, "\nIf you load the original file, the backup file will be overwritten in the next autosave timeout and it will be lost.\n\nDo you want to load the backup file?\n");
 
diff --git a/libgeda/include/libgeda/funcs.h b/libgeda/include/libgeda/funcs.h
index b6b2fbd..48af7e0 100644
--- a/libgeda/include/libgeda/funcs.h
+++ b/libgeda/include/libgeda/funcs.h
@@ -11,7 +11,4 @@ extern void (*pin_draw_func)();
 extern void (*path_draw_func)();
 extern void (*select_func)();
 extern void (*x_log_update_func)();
-/* load_newer_backup_func is called if an autosave backup file is found
-   when loading a new schematic. It should ask the user what to do, and
-   return TRUE if the backup file should be loaded, or FALSE otherwise */
-extern int (*load_newer_backup_func)();
+
diff --git a/libgeda/include/libgeda/struct.h b/libgeda/include/libgeda/struct.h
index b29634a..0ecd5a0 100644
--- a/libgeda/include/libgeda/struct.h
+++ b/libgeda/include/libgeda/struct.h
@@ -431,9 +431,6 @@ struct st_page {
   gint ops_since_last_backup;
   gchar do_autosave_backup;
 
-  /* Function which asks the user wether to load a newer backup file */
-  int (*load_newer_backup_func)();
-
 };
 
 /*! \brief different kind of snapping mechanisms used in TOPLEVEL */
@@ -442,6 +439,9 @@ typedef enum {SNAP_OFF, SNAP_GRID, SNAP_RESNAP, SNAP_STATE_COUNT} SNAP_STATE;
 /*! \brief Type of callback function for calculating text bounds */
 typedef int(*RenderedBoundsFunc)(void *, OBJECT *, int *, int *, int *, int *);
 
+/*! \brief Type of callback function for querying loading of backups */
+typedef gboolean(*LoadBackupQueryFunc)(void *, GString *);
+
 struct st_toplevel {
 
   /* have to decided on component list stuff */
@@ -580,6 +580,10 @@ struct st_toplevel {
   /* Callback function for calculating text bounds */
   RenderedBoundsFunc rendered_text_bounds_func;
   void *rendered_text_bounds_data;
+
+  /* Callback function for deciding whether to load a backup file. */
+  LoadBackupQueryFunc load_newer_backup_func;
+  void *load_newer_backup_data;
 };
 
 /* structures below are for gnetlist */
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index f90f5ea..44ec096 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -55,9 +55,6 @@
 #include <dmalloc.h>
 #endif
 
-/*! Default setting for arc draw function. */
-int (*load_newer_backup_func)() = NULL;
-
 /*! \brief Get the autosave filename for a file
  *  \par Function description
  *  Returns the expected autosave filename for the \a filename passed.
@@ -264,13 +261,13 @@ int f_open_flags(TOPLEVEL *toplevel, const gchar *filename,
         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 abruptly.\n"));
-      if (toplevel->page_current->load_newer_backup_func == NULL) {
+      if (toplevel->load_newer_backup_func == NULL) {
         g_warning ("%s", message->str);
         g_warning (_("\nRun gschem and correct the situation.\n\n"));
       } else {
         /* Ask the user if load the backup or the original file */
-        if (toplevel->page_current->load_newer_backup_func
-            (toplevel, message)) {
+        if (toplevel->load_newer_backup_func
+            (toplevel->load_newer_backup_data, message)) {
           /* Load the backup file */
           load_backup_file = 1;
         }
diff --git a/libgeda/src/s_page.c b/libgeda/src/s_page.c
index 85669a3..feef956 100644
--- a/libgeda/src/s_page.c
+++ b/libgeda/src/s_page.c
@@ -122,8 +122,6 @@ PAGE *s_page_new (TOPLEVEL *toplevel, const gchar *filename)
   page->saved_since_first_loaded = 0;
   page->do_autosave_backup = 0;
 
-  page->load_newer_backup_func = load_newer_backup_func;
-
   /* now append page to page list of toplevel */
   geda_list_add( toplevel->pages, page );
 
diff --git a/libgeda/src/s_toplevel.c b/libgeda/src/s_toplevel.c
index 57269d3..a9e09e9 100644
--- a/libgeda/src/s_toplevel.c
+++ b/libgeda/src/s_toplevel.c
@@ -147,6 +147,9 @@ TOPLEVEL *s_toplevel_new (void)
   toplevel->rendered_text_bounds_func = NULL;
   toplevel->rendered_text_bounds_data = NULL;
 
+  toplevel->load_newer_backup_func = NULL;
+  toplevel->load_newer_backup_data = NULL;
+
   /* Auto-save interval */
   toplevel->auto_save_interval = 0;
   toplevel->auto_save_timeout = 0;

commit 44028f9c988a134748c8cea5e439983377ae3fd3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:16:59 2009 +0000

    libgeda: Don't use compiled-in GEDADATA on Windows.
    
    On Windows, the compiled-in data path set with configure is unlikely
    to be the same as the path gEDA is actually installed to -- so don't
    use it. Instead, permit the s_path_*() funcs to return NULL.

diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
index d56a3fc..a33bfe8 100644
--- a/libgeda/src/s_basic.c
+++ b/libgeda/src/s_basic.c
@@ -496,21 +496,25 @@ s_expand_env_variables (const gchar *string)
  *  users. If the GEDADATA environment variable is set, returns its
  *  value; otherwise, uses a compiled-in path.
  *
+ *  On Windows, the compiled in path is *not* used, as it might not
+ *  match the path where the user has installed gEDA.
+ *
  *  \warning The returned string is owned by libgeda and should not be
  *  modified or free'd.
  *
- *  \todo On Windows, we probably shouldn't use the compiled-in
- *  default.
+ *  \return the gEDA shared data path, or NULL if none could be found.
  */
 const char *s_path_sys_data () {
   static const char *p = NULL;
   if (p == NULL) {
     p = g_getenv ("GEDADATA");
   }
+# if !defined (_WIN32)
   if (p == NULL) {
     p = GEDADATADIR;
     g_setenv ("GEDADATA", p, FALSE);
   }
+# endif
   return p;
 }
 
@@ -518,10 +522,14 @@ const char *s_path_sys_data () {
  *  \par Function description
  *  Returns the path to be searched for gEDA configuration shared
  *  between all users. If the GEDADATARC environment variable is set,
- *  returns its value; otherwise, uses a compiled-in path.
+ *  returns its value; otherwise, uses a compiled-in path. Finally
+ *  fallback to using the system data path.
  *
  *  \warning The returned string is owned by libgeda and should not be
  *  modified or free'd.
+ *
+ *  \return the gEDA shared config path, or NULL if none could be
+ *  found.
  */
 const char *s_path_sys_config () {
   static const char *p = NULL;
@@ -538,8 +546,8 @@ const char *s_path_sys_config () {
       /* Otherwise, just use the data directory */
       p = s_path_sys_data ();
     }
-    g_setenv("GEDADATARC", p, FALSE);
   }
+  if (p != NULL) g_setenv("GEDADATARC", p, FALSE);
   return p;
 }
 

commit 253caac857e22ba28ba7ce05b36f95a5f78bd683
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 21 21:16:43 2009 +0000

    gschem: Better checks that GEDADATA has been found.
    
    If libgeda fails to locate the gEDA data directory, show a dialog
    before quitting. This is important for users running gschem from
    e.g. a .desktop file in their system menu, when the stderr/stdout may
    not be easy to get at.

diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index af4511e..5834c16 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -128,7 +128,6 @@ void main_prog(void *closure, int argc, char *argv[])
   char *input_str = NULL;
   int argv_index;
   int first_page = 1;
-  char *geda_data = NULL;
   char *filename;
   SCM scm_tmp;
 
@@ -222,10 +221,16 @@ void main_prog(void *closure, int argc, char *argv[])
 
   o_undo_init(); 
 
-  geda_data = getenv("GEDADATA");
-  if (geda_data == NULL) {
-    fprintf(stderr, _("You must set the GEDADATA environment variable!\n"));
-    exit(-1);
+  if (s_path_sys_data () == NULL) {
+    gchar *message = _("You must set the GEDADATA environment variable!\n\n"
+                       "gschem cannot locate its data files. You must set the GEDADATA\n"
+                       "environment variable to point to the correct location.\n");
+    GtkWidget* error_diag =
+      gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+                              GTK_BUTTONS_OK,
+                              message);
+    gtk_dialog_run (GTK_DIALOG (error_diag));
+    g_error (message);
   }
 
   /* Allocate w_current */




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