Patch: Make gpe-edit remember the path when opening files

Martin Thierer <[email protected]> Wed, 26 Jul 2006 09:25:57 +0200
Newsgroups gmane.comp.handhelds.gpe
Message-ID <[email protected]>
Some time ago I've created bug 1435 
(http://www.handhelds.org/~bugzilla/show_bug.cgi?id=1435) and attached a 
patch that make gpe-edit remember the path where the last file was opened 
instead of always defaulting to the home directory.

Now Erik Hovland suggested to repost the patch here. A quick check in CVS 
suggests that the functionality has not been added to gpe-edit yet.

The patch is against version 0.29, but I just checked that it still applies 
cleanly (with some offset), to hte latest version from CVS.

Thanks!

Bye

Martin

_______________________________________________
GPE mailing list
[email protected]
http://handhelds.org/mailman/listinfo/gpe
gpe-edit-remember-path.patch (text/x-diff, 895 B)
--- gpe-edit-0.29.old/main.c	2005-12-16 18:22:39.000000000 +0100
+++ gpe-edit-0.29/main.c	2005-12-16 18:22:44.000000000 +0100
@@ -254,6 +254,25 @@
 select_open_file (void)
 {
   file_selector = gtk_file_selection_new (_("Open File ..."));
+  
+  if(filename != NULL)
+  {
+    gchar *dir, *dir_with_sep;
+    gint path_len;
+
+    dir = g_path_get_dirname(filename);
+    path_len = strlen(dir);
+    dir_with_sep = (gchar *) g_malloc(path_len+2);
+    
+    strncpy(dir_with_sep, dir, path_len);
+    dir_with_sep[path_len] = G_DIR_SEPARATOR;
+    dir_with_sep[path_len+1] = '\0';
+    
+    gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_selector), dir_with_sep);
+    
+    g_free(dir_with_sep);
+    g_free(dir);    
+  }
 
   gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
 			     "clicked", GTK_SIGNAL_FUNC (open_file_from_filesel), NULL);