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

gEDA-cvs: gaf.git: branch: master updated (1.6.1-20100214-182-ga49c4cf)



The branch, master has been updated
       via  a49c4cf66556570af7ba8dd2af1a6186015ea367 (commit)
       via  5ce6132459b30cd8c228c71797ea04b90e9018d9 (commit)
       via  3b0905a748953a6b1cb72b747f096ccc7b936884 (commit)
      from  2a1d0d17247f272803101b0342917f0e65c0cd9e (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
=========

 gnetlist/src/g_netlist.c   |    1 +
 gschem/include/globals.h   |    3 +
 gschem/include/prototype.h |    3 -
 gschem/src/gschem.c        |    5 -
 gschem/src/x_menus.c       |  350 +++++++-------------------------------------
 gschem/src/x_window.c      |    6 +-
 6 files changed, 62 insertions(+), 306 deletions(-)


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

commit a49c4cf66556570af7ba8dd2af1a6186015ea367
Author: Felix Ruoff <Felix@xxxxxxxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Replace recent file list with GtkRecentManager.
    
    This patch replaces the implemented recent-file - list by the recent-manager provided by GTK since version 2.10.
    Only schematic-files (*.sch) and symbol-files (*.sym) will be shown (case insensitive).
    Known differences to previous version:
    * No 'free recent list' option
    * Shows just filename (not full path) as menu-label
    * Full file-path avaiable as tooltip
    * Shows filetype-icons
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

:100644 100644 86ec43a... 49dcd39... M	gschem/include/globals.h
:100644 100644 5948c74... d0439a3... M	gschem/include/prototype.h
:100644 100644 fc15726... 9efb61d... M	gschem/src/gschem.c
:100644 100644 3d438c1... 6ac1eb5... M	gschem/src/x_menus.c
:100644 100644 3d9d608... 2f79e36... M	gschem/src/x_window.c

commit 5ce6132459b30cd8c228c71797ea04b90e9018d9
Author: Patrick Bernaud <patrickb@xxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Fix memory leak in g_get_package_attribute().
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

:100644 100644 b3af8fa... 14441cc... M	gnetlist/src/g_netlist.c

commit 3b0905a748953a6b1cb72b747f096ccc7b936884
Author: Felix Ruoff <Felix@xxxxxxxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Fix warning on moving over menu-item without action
    
    Fix a warning at the info-dialog if the mouse moves over a menu-item
    which has no action defined, e.g. the top item of a submenu.
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

:100644 100644 63fe5a6... 3d438c1... M	gschem/src/x_menus.c

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

commit a49c4cf66556570af7ba8dd2af1a6186015ea367
Author: Felix Ruoff <Felix@xxxxxxxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Replace recent file list with GtkRecentManager.
    
    This patch replaces the implemented recent-file - list by the recent-manager provided by GTK since version 2.10.
    Only schematic-files (*.sch) and symbol-files (*.sym) will be shown (case insensitive).
    Known differences to previous version:
    * No 'free recent list' option
    * Shows just filename (not full path) as menu-label
    * Full file-path avaiable as tooltip
    * Shows filetype-icons
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

diff --git a/gschem/include/globals.h b/gschem/include/globals.h
index 86ec43a..49dcd39 100644
--- a/gschem/include/globals.h
+++ b/gschem/include/globals.h
@@ -27,6 +27,9 @@ extern GSCHEM_TOPLEVEL *global_window_current;
 /* window list */
 extern GList *global_window_list;
 
+/* Manager for recently used files */
+GtkRecentManager *recent_manager;
+
 /* colors */
 extern GdkColor white;
 extern GdkColor black;
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 5948c74..d0439a3 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -828,9 +828,6 @@ gint do_popup(GSCHEM_TOPLEVEL *w_current, GdkEventButton *event);
 void x_menus_sensitivity(GSCHEM_TOPLEVEL *w_current, const char *buf, int flag);
 void x_menus_popup_sensitivity(GSCHEM_TOPLEVEL *w_current, const char *buf, int flag);
 void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current);
-void recent_files_load();
-void recent_files_save(gpointer user_data);
-void recent_files_add(const char *filename);
 /* x_multiattrib.c */
 void x_multiattrib_open (GSCHEM_TOPLEVEL *w_current);
 void x_multiattrib_close (GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index fc15726..9efb61d 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -259,11 +259,6 @@ void main_prog(void *closure, int argc, char *argv[])
   free (input_str); /* M'allocated by scm_to_locale_string() */
   scm_remember_upto_here_1 (scm_tmp);
 
-  /* Load recent files list. This must be done
-   * before calling x_window_setup(). */
-  recent_files_load();
-  gschem_atexit(recent_files_save, NULL);
-
   /* Set default icon */
   x_window_set_default_icon();
 
diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index 3d438c1..6ac1eb5 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -357,91 +357,26 @@ void x_menus_popup_sensitivity (GSCHEM_TOPLEVEL *w_current, const char *buf, int
   }
 }
 
-/* The list of recently loaded files. */
-static GList *recent_files = NULL;
-
-#define RECENT_FILES_STORE "gschem-recent-files"
 #define MAX_RECENT_FILES 10
-
-struct recent_file_menu_data {
-  GSCHEM_TOPLEVEL *w_current;
-  gchar *filename;
-};
-
-/*! \brief Make all toplevels reflect changes to the
- *         recent files list.
- */
-static void update_recent_files_menus()
-{
-   GSCHEM_TOPLEVEL *w_current;
-   GtkWidget *submenu, *recent_menu_item;
-   GList *iter;
-
-   for (iter = global_window_list;
-        iter != NULL;
-        iter = g_list_next (iter)) {
-      w_current = (GSCHEM_TOPLEVEL *)iter->data;
-
-      if (w_current->menubar == NULL)
-        continue;
-
-      recent_menu_item =
-        (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w_current->menubar),
-                                          "_File/Open Recen_t");
-      if(recent_menu_item == NULL)
-         return;
-
-      submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(recent_menu_item));
-      gtk_widget_destroy(submenu);
-      x_menu_attach_recent_files_submenu(w_current);
-   }
-}
-
-/*! \brief Remove all entries from the recent files
- *         list and update all toplevels.
+/*! \brief Callback for recent-chooser.
+ *
+ * Will be called if element of recent-file-list is activated
  */
-static void clear_recent_file_list(gpointer data)
+void
+recent_chooser_item_activated (GtkRecentChooser *chooser, GSCHEM_TOPLEVEL *w_current)
 {
-   GList *p;
-
-   p = recent_files;
-   while(p) {
-      g_free(p->data);
-      p = g_list_next(p);
-   }
-   g_list_free(recent_files);
-   recent_files = NULL;
+  PAGE *page;
+  gchar *uri;
+  gchar *filename;
 
-   update_recent_files_menus();
-}
+  uri = gtk_recent_chooser_get_current_uri (chooser);
+  filename = g_filename_from_uri(uri, NULL, NULL);
+  gtk_recent_manager_add_item(recent_manager, uri);
+  page = x_window_open_page(w_current, (char *)filename);
+  x_window_set_current_page(w_current, page);
 
-static void
-recent_file_free_menu_data (gpointer data, GClosure *closure) {
-  g_free (data);
-}
-
-static void recent_file_clicked(GtkMenuItem *menuitem, gpointer user_data)
-{
-   FILE *fp;
-   PAGE *page;
-   struct recent_file_menu_data *data =
-     (struct recent_file_menu_data *) user_data;
-   GSCHEM_TOPLEVEL *w_current = data->w_current;
-   gchar *filename = data->filename;
-
-   /* Check if the file exists */
-   fp = fopen((char *) filename, "r");
-   if(fp == NULL) {
-      /* Remove this entry from all menus */
-      s_log_message(_("Couldn't open file %s\n"), (char *) filename);
-      recent_files = g_list_remove(recent_files, filename);
-      update_recent_files_menus();
-      return;
-   }
-   fclose(fp);
-
-   page = x_window_open_page(w_current, (char *)filename);
-   x_window_set_current_page(w_current, page);
+  g_free(uri);
+  g_free(filename);
 }
 
 /*! \brief Attach a submenu with filenames to the 'Open Recent'
@@ -451,203 +386,30 @@ static void recent_file_clicked(GtkMenuItem *menuitem, gpointer user_data)
  */
 void x_menu_attach_recent_files_submenu(GSCHEM_TOPLEVEL *w_current)
 {
-   gulong id;
-   GtkWidget *tmp;
-   GtkWidget *recent_menu_item, *recent_submenu;
-
-   recent_menu_item = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(
-            w_current->menubar), "_File/Open Recen_t");
-   if(recent_menu_item == NULL)
-      return;
-
-   /* disconnect all unblocked signals */
-   while(1) {
-      id = g_signal_handler_find(recent_menu_item, G_SIGNAL_MATCH_UNBLOCKED,
-            0, 0, NULL, NULL, NULL);
-      if(id == 0)
-         break;
-      gtk_signal_disconnect(recent_menu_item, id);
-   }
-
-   recent_submenu = gtk_menu_new();
-   GList *p = recent_files;
-   while(p) {
-     struct recent_file_menu_data *menu_data = g_new0 (struct recent_file_menu_data, 1);
-     menu_data->filename = p->data;
-     menu_data->w_current = w_current;
-     tmp = gtk_menu_item_new_with_label((gchar *)p->data);
-     g_signal_connect_data (GTK_OBJECT(tmp), "activate",
-                            (GCallback) recent_file_clicked,
-                            menu_data,
-                            (GClosureNotify) recent_file_free_menu_data,
-                            0);
-     gtk_menu_append(GTK_MENU(recent_submenu), tmp);
-     p = g_list_next(p);
-   }
-
-   if(recent_files != NULL) {
-      /* Append the 'Clear' menu item to the submenu */
-      GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0);
-
-      tmp = gtk_menu_item_new();
-      gtk_container_add(GTK_CONTAINER(alignment), gtk_label_new(_("Clear")));
-      gtk_container_add(GTK_CONTAINER(tmp), alignment);
-
-      gtk_signal_connect_object(GTK_OBJECT(tmp), "activate",
-            GTK_SIGNAL_FUNC (clear_recent_file_list), NULL);
-
-      gtk_menu_append(GTK_MENU(recent_submenu), gtk_separator_menu_item_new());
-      gtk_menu_append(GTK_MENU(recent_submenu), tmp);
-   }
-
-   gtk_widget_show_all(recent_submenu);
-   gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent_menu_item), recent_submenu);
-}
-
-/*! \brief Add a filename to the list of recent files.
- *
- *  If filename is already in the list, moves it to the head of the
- *  list.
- */
-void recent_files_add(const char *filename)
-{
-   gchar *basename;
-   gchar *save_fn;
-   GError *err = NULL;
-   GList *p = recent_files;
-
-   basename = g_path_get_basename(filename);
-   if(strstr(basename, "untitled_") == basename) {
-      g_free(basename);
-      return;
-   }
-
-   g_free(basename);
-
-   /* Normalize the filename. */
-   save_fn = f_normalize_filename (filename, &err);
-   if (err != NULL) {
-     save_fn = g_strdup (filename);
-     g_error_free (err);
-   }
-
-   /* Check if the file is already in the list.  */
-   while (p != NULL) {
-     if (strcmp (save_fn, (gchar *) p->data) == 0) {
-       break;
-     }
-     p = g_list_next (p);
-   }
-
-   if (p != NULL) {
-     /* Since we found the filename already in the list, move it to
-      * the head of the list. */
-     g_free (save_fn);
-     save_fn = (gchar *) p->data;
-     recent_files = g_list_delete_link (recent_files, p);
-     recent_files = g_list_prepend (recent_files, save_fn);
-   } else {
-     /* Otherwise, just add the new filename to the front of the
-      * list. */
-     recent_files = g_list_prepend (recent_files, save_fn);
-   }
-
-   update_recent_files_menus();
-}
-
-/*! \brief Make RECENT_FILES_STORE contain an empty file list.
- */
-static void recent_files_create_empty()
-{
-   gchar *c;
-   const gchar * const tmp[] = { NULL };
-   GKeyFile *kf = g_key_file_new();
-   gchar *file = g_build_filename(s_path_user_config (), RECENT_FILES_STORE, NULL);
-
-   g_key_file_set_string_list(kf, "Recent files", "Files", tmp, 0);
-   c = g_key_file_to_data(kf, NULL, NULL);
-   g_key_file_free(kf);
-
-   g_file_set_contents(file, c, -1, NULL);
-   g_free(c);
-   g_free(file);
-}
-
-/*! \brief Save the list of recent files to RECENT_FILES_STORE.
- *
- *  \param [in] user_data unused
- */
-void recent_files_save(gpointer user_data)
-{
-   gchar *files[MAX_RECENT_FILES];
-   int num = 0;
-   gchar *c;
-   gchar *file = g_build_filename(s_path_user_config (), RECENT_FILES_STORE, NULL);
-
-   GList *p = recent_files;
-   if(p == NULL) {
-      recent_files_create_empty();
-      return;
-   }
-
-   while((p != NULL) && (num < MAX_RECENT_FILES)) {
-     files[num++] = (gchar *)p->data;
-     p = g_list_next(p);
-   }
-
-   GKeyFile *kf = g_key_file_new();
-
-   g_key_file_set_string_list(kf, "Recent files", "Files", 
-         (const gchar **)files, num);
-   c = g_key_file_to_data(kf, NULL, NULL);
-   g_file_set_contents(file, c, -1, NULL);
-
-   g_free(c);
-   g_free(file);
-   g_key_file_free(kf);
-}
-
-/*! \brief Load the recent file list using data from
- *         RECENT_FILES_STORE. 
- *
- *  Must be called before any other recent-files-related
- *  functions.
- */
-void recent_files_load()
-{
-   GKeyFile *kf = g_key_file_new();
-   gchar *file = g_build_filename(s_path_user_config (), RECENT_FILES_STORE, NULL);
-
-   if(!g_file_test(file, G_FILE_TEST_EXISTS)) {
-     g_mkdir(s_path_user_config (), S_IRWXU | S_IRWXG);
-
-      recent_files_create_empty();
-   }
-
-   if(!g_key_file_load_from_file(kf, file, G_KEY_FILE_NONE, NULL)) {
-      /* error opening key file, create an empty one and try again */
-      recent_files_create_empty();
-      if(!g_key_file_load_from_file(kf, file, G_KEY_FILE_NONE, NULL))
-         return;
-   }
-
-   gsize len;
-   gchar **list = g_key_file_get_string_list(kf, "Recent files",
-         "Files", &len, NULL);
-
-   if(list == NULL) {
-      /* error reading key file, don't bother to correct;
-       * just overwrite it with an empty one */
-      recent_files_create_empty();
-      return;
-   }
-
-   while(len > 0) {
-      len--;
-      recent_files = g_list_prepend(recent_files, list[len]);
-   }
-
-   g_free(list);
-   g_free(file);
-   g_key_file_free(kf);
+  GtkWidget* menuitem_to_append_to = NULL;
+  GtkRecentFilter *recent_filter;
+  GtkWidget *menuitem_file_recent_items;
+  recent_manager = gtk_recent_manager_get_default();
+
+  menuitem_file_recent_items = gtk_recent_chooser_menu_new_for_manager(recent_manager);
+
+  /* Show only schematic- and symbol-files (*.sch and *.sym) in list */
+  recent_filter = gtk_recent_filter_new();
+  gtk_recent_filter_add_mime_type(recent_filter, "application/x-geda-schematic");
+  gtk_recent_filter_add_mime_type(recent_filter, "application/x-geda-symbol");
+  gtk_recent_chooser_add_filter(GTK_RECENT_CHOOSER(menuitem_file_recent_items), recent_filter);
+
+  gtk_recent_chooser_set_show_tips(GTK_RECENT_CHOOSER(menuitem_file_recent_items), TRUE);
+  gtk_recent_chooser_set_sort_type(GTK_RECENT_CHOOSER(menuitem_file_recent_items),
+                                   GTK_RECENT_SORT_MRU);
+  gtk_recent_chooser_set_limit(GTK_RECENT_CHOOSER(menuitem_file_recent_items), MAX_RECENT_FILES);
+  gtk_recent_chooser_set_local_only(GTK_RECENT_CHOOSER(menuitem_file_recent_items), FALSE);
+  gtk_recent_chooser_menu_set_show_numbers(GTK_RECENT_CHOOSER_MENU(menuitem_file_recent_items), TRUE);
+  g_signal_connect(GTK_OBJECT(menuitem_file_recent_items), "item-activated",
+                   G_CALLBACK(recent_chooser_item_activated), w_current);
+
+  menuitem_to_append_to = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w_current->menubar), "_File/Open Recen_t");
+  if(menuitem_to_append_to == NULL)
+    return;
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_to_append_to), menuitem_file_recent_items);
 }
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 3d9d608..2f79e36 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -743,7 +743,7 @@ x_window_open_page (GSCHEM_TOPLEVEL *w_current, const gchar *filename)
       gtk_widget_destroy (dialog);
       g_error_free (err);
     } else {
-      recent_files_add (fn);
+      gtk_recent_manager_add_item (recent_manager, g_filename_to_uri(fn, NULL, NULL));
     }
   } else {
     if (!quiet_mode)
@@ -871,8 +871,8 @@ x_window_save_page (GSCHEM_TOPLEVEL *w_current, PAGE *page, const gchar *filenam
     /* reset page CHANGED flag */
     page->CHANGED = 0;
 
-    /* update recent file list */
-    recent_files_add(filename);
+    /* add to recent file list */
+    gtk_recent_manager_add_item (recent_manager, g_filename_to_uri(filename, NULL, NULL));
   }
 
   /* log status of operation */

commit 5ce6132459b30cd8c228c71797ea04b90e9018d9
Author: Patrick Bernaud <patrickb@xxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Fix memory leak in g_get_package_attribute().
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

diff --git a/gnetlist/src/g_netlist.c b/gnetlist/src/g_netlist.c
index b3af8fa..14441cc 100644
--- a/gnetlist/src/g_netlist.c
+++ b/gnetlist/src/g_netlist.c
@@ -513,6 +513,7 @@ SCM g_get_package_attribute(SCM scm_uref, SCM scm_wanted_attrib)
     } else {
       scm_return_value = scm_makfrom0str ("unknown");
     }
+    g_free (return_value);
 
     free (uref);
     free (wanted_attrib);

commit 3b0905a748953a6b1cb72b747f096ccc7b936884
Author: Felix Ruoff <Felix@xxxxxxxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Fix warning on moving over menu-item without action
    
    Fix a warning at the info-dialog if the mouse moves over a menu-item
    which has no action defined, e.g. the top item of a submenu.
    
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

diff --git a/gschem/src/x_menus.c b/gschem/src/x_menus.c
index 63fe5a6..3d438c1 100644
--- a/gschem/src/x_menus.c
+++ b/gschem/src/x_menus.c
@@ -105,7 +105,6 @@ get_main_menu(GSCHEM_TOPLEVEL *w_current)
   char **raw_menu_name = g_malloc (sizeof(char *));
   char *menu_item_name;
   char *raw_menu_item_name;
-  char *menu_item_func;
   char *menu_item_hotkey_func;
   char *menu_item_stock;
   char *menu_item_keys;
@@ -149,11 +148,6 @@ get_main_menu(GSCHEM_TOPLEVEL *w_current)
 
       raw_menu_item_name = SCM_STRING_CHARS (scm_item_name);
 
-      if (scm_is_false (scm_item_func))
-        menu_item_func = "no-action";
-      else
-        menu_item_func = SCM_SYMBOL_CHARS (scm_item_func);
-
       if (scm_is_false (scm_item_hotkey_func))
         menu_item_hotkey_func = NULL;
       else
@@ -187,17 +181,21 @@ get_main_menu(GSCHEM_TOPLEVEL *w_current)
           menu_item_keys = "";
         }
 
-        action = gschem_action_new (menu_item_func,  /* Action name */
-                                    menu_item_name,  /* Text */
-                                    menu_item_name,  /* Tooltip */
-                                    menu_item_stock, /* Icon stock ID */
-                                    menu_item_keys); /* Accelerator string */
-        menu_item = gtk_action_create_menu_item (GTK_ACTION (action));
-        gtk_menu_append (GTK_MENU (menu), menu_item);
+        if(scm_is_false (scm_item_func)) {
+          menu_item = gtk_menu_item_new_with_mnemonic(menu_item_name);
+        } else {
+          action = gschem_action_new (SCM_SYMBOL_CHARS (scm_item_func),  /* Action name */
+                                      menu_item_name,  /* Text */
+                                      menu_item_name,  /* Tooltip */
+                                      menu_item_stock, /* Icon stock ID */
+                                      menu_item_keys); /* Accelerator string */
+          menu_item = gtk_action_create_menu_item (GTK_ACTION (action));
+          g_signal_connect (G_OBJECT(action), "activate",
+                            G_CALLBACK(g_menu_execute),
+                            w_current);
+        }
 
-        g_signal_connect (G_OBJECT(action), "activate",
-                          G_CALLBACK(g_menu_execute),
-                          w_current);
+        gtk_menu_append (GTK_MENU (menu), menu_item);
       }
 
       gtk_widget_show (menu_item);




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