diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 94f08e1f6..ac72fa7ec 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,7 +1,15 @@ 1999-01-12 Miguel de Icaza + * glayout.c (run_cmd): Add run command. Add back FTP link + command. Add Mkdir command. Use standard key definitions. + + * gview.c: Use new standard keybindings + * gtkdtree.c: Now it uses the treestore code. + * treestore.c: New file format which includes the scan status of + the directories. + * treestore.c: Provide _opendir, _readdir, _closedir operations for the tree cache. diff --git a/gnome/glayout.c b/gnome/glayout.c index 17cca5ff9..9383e777a 100644 --- a/gnome/glayout.c +++ b/gnome/glayout.c @@ -15,6 +15,7 @@ #include "main.h" #include "gmain.h" #include "cmd.h" +#include "dialog.h" #include "boxes.h" #include "panelize.h" #include "gcmd.h" @@ -260,13 +261,24 @@ save_panel_types (void) } } +static void +run_cmd (void) +{ + char *cmd; + + cmd = input_dialog (_("Enter command to run"), _("Enter command to run"), ""); + if (cmd && *cmd){ + my_system (EXECUTE_AS_SHELL, shell, cmd); + } +} + void configure_box (void); GtkCheckMenuItem *gnome_toggle_snap (void); GnomeUIInfo gnome_panel_file_menu [] = { - { GNOME_APP_UI_ITEM, N_("_New window"), N_("Opens a new window"), gnome_open_panel }, - { GNOME_APP_UI_ITEM, N_("_New folder"), N_("Creates a folder"), mkdir_panel_cmd }, + GNOMEUIINFO_MENU_NEW_ITEM(N_("_New window"), N_("Opens a new window"), gnome_open_panel, NULL), + GNOMEUIINFO_MENU_NEW_ITEM(N_("_New folder"),N_("Creates a folder"), mkdir_panel_cmd, NULL), /* We want to make a new menu entry here... */ /* For example: */ /* New-> */ @@ -275,25 +287,27 @@ GnomeUIInfo gnome_panel_file_menu [] = { /* Gnumeric Spreadsheet */ /* Text Document */ /* etc... */ + { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("_Open"), N_("Open selected files"), NULL, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN }, + { GNOME_APP_UI_ITEM, N_("_Run"), N_("Runs a command"), run_cmd, NULL, + NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN, GDK_F2, 0 }, + { GNOME_APP_UI_ITEM, N_("_Open"), N_("Opens the selected files"), NULL }, + { GNOME_APP_UI_ITEM, N_("Open _FTP site"), N_("Opens an FTP site"), ftplink_cmd }, { GNOME_APP_UI_ITEM, N_("_Copy..."), N_("Copy files"), copy_cmd, NULL}, { GNOME_APP_UI_ITEM, N_("_Delete..."), N_("Delete files from disk"), delete_cmd }, { GNOME_APP_UI_ITEM, N_("_Move..."), N_("Rename or move files"), ren_cmd }, + { GNOME_APP_UI_ITEM, N_("_Make directory..."), N_("Creates a new directory"), mkdir_cmd }, { GNOME_APP_UI_SEPARATOR }, { GNOME_APP_UI_ITEM, N_("C_lose"), N_("Close this panel"), gnome_close_panel, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CLOSE }, + NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CLOSE, + GNOME_KEY_NAME_CLOSE, GNOME_KEY_MOD_CLOSE, NULL }, { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; GnomeUIInfo gnome_panel_edit_menu [] = { - { GNOME_APP_UI_ITEM, N_("_Cut"), N_("Cuts the selected files into the cut buffer."), NULL, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CUT }, - { GNOME_APP_UI_ITEM, N_("C_opy"), N_("Copies the selected files into the cut buffer."), NULL, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_COPY }, - { GNOME_APP_UI_ITEM, N_("_Paste"), N_("Pastes files from the cut buffer into the current directory"), NULL, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PASTE }, + GNOMEUIINFO_MENU_CUT_ITEM(NULL, NULL), + GNOMEUIINFO_MENU_COPY_ITEM(NULL, NULL), + GNOMEUIINFO_MENU_PASTE_ITEM(NULL, NULL), { GNOME_APP_UI_SEPARATOR }, { GNOME_APP_UI_ITEM, N_("_Select All"), N_("Select all files in the current Panel"), gnome_select_all_cmd }, { GNOME_APP_UI_ITEM, N_("_Select Files..."), N_("Select a group of files"), select_cmd }, @@ -301,8 +315,7 @@ GnomeUIInfo gnome_panel_edit_menu [] = { { GNOME_APP_UI_SEPARATOR }, { GNOME_APP_UI_ITEM, N_("_Rescan Directory"), N_("Rescan the directory contents"), reread_cmd }, { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("Preferences..."), N_("Configure the GNOME Midnight Commander"), gnome_configure_box, NULL, - NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PROP}, + GNOMEUIINFO_MENU_PREFERENCES_ITEM(gnome_configure_box, NULL), { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; @@ -456,7 +469,7 @@ create_container (Dlg_head *h, char *name, char *geometry) panel = panel_new (name); vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (vbox, 0); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); gnome_app_set_contents (GNOME_APP (app), vbox); gnome_app_create_menus_with_data (GNOME_APP (app), gnome_panel_menu, panel); diff --git a/gnome/gtkdtree.c b/gnome/gtkdtree.c index 7c12f9f3f..ec7923525 100644 --- a/gnome/gtkdtree.c +++ b/gnome/gtkdtree.c @@ -115,12 +115,8 @@ gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int leve for (; (dirent = tree_store_readdir (dir)) != NULL; ){ GtkCTreeNode *sibling; - struct stat s; char *text [1]; - int res; - res = mc_stat (dirent->name, &s); - text [0] = x_basename (dirent->name); /* Do not insert duplicates */ @@ -484,7 +480,11 @@ gtk_dtree_save_tree (void) mc_tree_store_save (); return FALSE; } - + +/* + * Callback routine invoked by the treestore code when the state + * of the treestore has been modified. + */ static void gtk_dtree_dirty_notify (int state) { @@ -498,7 +498,7 @@ gtk_dtree_dirty_notify (int state) } if (state) - dirty_tag = gtk_timeout_add (1000, (GtkFunction) gtk_dtree_save_tree, NULL); + dirty_tag = gtk_timeout_add (10 * 1000, (GtkFunction) gtk_dtree_save_tree, NULL); } static void diff --git a/gnome/gview.c b/gnome/gview.c index 334de9f5a..8a43cb535 100644 --- a/gnome/gview.c +++ b/gnome/gview.c @@ -286,49 +286,43 @@ gnome_monitor (GtkWidget *widget, WView *view) } GnomeUIInfo gview_file_menu [] = { - GNOMEUIINFO_ITEM_STOCK (N_("Goto line"), + GNOMEUIINFO_ITEM_STOCK (N_("_Goto line"), N_("Jump to a specified line number"), &gnome_goto_line, GNOME_STOCK_PIXMAP_JUMP_TO), - GNOMEUIINFO_ITEM (N_("Monitor file"), N_("Monitor file growing"), &gnome_monitor, NULL), - GNOMEUIINFO_ITEM_STOCK (N_("Close"), - N_("Close the viewer"), - &gview_quit, GNOME_STOCK_PIXMAP_QUIT), + GNOMEUIINFO_ITEM (N_("_Monitor file"), N_("Monitor file growing"), &gnome_monitor, NULL), + GNOMEUIINFO_MENU_CLOSE_ITEM(gview_quit, NULL), { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; GnomeUIInfo gview_search_menu [] = { - GNOMEUIINFO_ITEM_STOCK (N_("Search"), - N_("String search"), - gnome_normal_search_cmd, GNOME_STOCK_MENU_SEARCH), + GNOMEUIINFO_MENU_FIND_ITEM(gnome_normal_search_cmd, NULL), GNOMEUIINFO_ITEM_STOCK (N_("Regexp search"), N_("Regular expression search"), gnome_regexp_search_cmd, GNOME_STOCK_MENU_SEARCH), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_STOCK (N_("Search again..."), - N_("Continue searching"), - gnome_continue_search, GNOME_STOCK_MENU_SRCHRPL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_MENU_FIND_AGAIN_ITEM(gnome_continue_search, NULL), { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; GnomeUIInfo gview_mode_menu [] = { #define WRAP_POS 0 - GNOMEUIINFO_TOGGLEITEM (N_("Wrap"), N_("Wrap the text"), gnome_toggle_wrap, NULL), + GNOMEUIINFO_TOGGLEITEM (N_("_Wrap"), N_("Wrap the text"), gnome_toggle_wrap, NULL), #if 0 /* Can not use this one yet, as it destroys the viewer, need to fix that */ - GNOMEUIINFO_TOGGLEITEM ("Parsed view", NULL, gnome_toggle_parse, NULL), + GNOMEUIINFO_TOGGLEITEM ("_Parsed view", NULL, gnome_toggle_parse, NULL), #endif #define FORMAT_POS 1 - GNOMEUIINFO_TOGGLEITEM (N_("Formatted"), NULL, gnome_toggle_format, NULL), + GNOMEUIINFO_TOGGLEITEM (N_("_Formatted"), NULL, gnome_toggle_format, NULL), #define HEX_POS 2 - GNOMEUIINFO_TOGGLEITEM (N_("Hex"), NULL, gnome_toggle_hex, NULL), + GNOMEUIINFO_TOGGLEITEM (N_("_Hex"), NULL, gnome_toggle_hex, NULL), { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; GnomeUIInfo gview_top_menu [] = { - { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gview_file_menu }, - { GNOME_APP_UI_SUBTREE, N_("Search"), NULL, &gview_search_menu }, - { GNOME_APP_UI_SUBTREE, N_("Mode"), NULL, &gview_mode_menu }, + { GNOME_APP_UI_SUBTREE, N_("_File"), NULL, &gview_file_menu }, + { GNOME_APP_UI_SUBTREE, N_("_Search"), NULL, &gview_search_menu }, + { GNOME_APP_UI_SUBTREE, N_("_Mode"), NULL, &gview_mode_menu }, { GNOME_APP_UI_ENDOFINFO, 0, 0 } }; diff --git a/src/ChangeLog b/src/ChangeLog index f19430c24..c63da857f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +1999-01-12 Miguel de Icaza + + * treestore.c (tree_store_save): Add signature for version 2.0 of + the file format. + 1999-01-11 Miguel de Icaza * util.c: Provide workarounds for Linux kernel bug. diff --git a/src/main.c b/src/main.c index 3da1a2581..13aec346d 100644 --- a/src/main.c +++ b/src/main.c @@ -2834,6 +2834,10 @@ mc_tree_store_save () int main (int argc, char *argv []) { +#ifdef HAVE_GNOME + /* Just to time things */ + printf ("GNU Midnight Commander " VERSION "\n"); +#endif /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ setlocale (LC_ALL, ""); bindtextdomain ("mc", LOCALEDIR); diff --git a/src/tree.h b/src/tree.h index 877a08c6c..f028910ae 100644 --- a/src/tree.h +++ b/src/tree.h @@ -53,9 +53,9 @@ WTree *tree_new (int is_panel, int y, int x, int lines, int cols); extern WTree *the_tree; #ifdef OS2_NT -# define MC_TREE "mc.tre" +# define MC_TREE "mcn.tre" #else -# define MC_TREE ".mc/tree" +# define MC_TREE ".mc/Tree" #endif #endif diff --git a/src/treestore.c b/src/treestore.c index 5bc5699e7..de94a7754 100644 --- a/src/treestore.c +++ b/src/treestore.c @@ -45,12 +45,15 @@ #include #include #include "fs.h" +#include "../vfs/vfs.h" #include "util.h" #include "treestore.h" #ifdef OS2_NT # include #endif +#define TREE_SIGNATURE "Midnight Commander TreeStore v 2.0" + static TreeStore ts; void (*tree_store_dirty_notify)(int state) = NULL; @@ -197,24 +200,50 @@ int tree_store_load (char *name) { FILE *file; - char buffer [MC_MAXPATHLEN], oldname[MC_MAXPATHLEN]; + char buffer [MC_MAXPATHLEN + 20], oldname[MC_MAXPATHLEN]; char *different; int len, common; - + int do_load; + g_return_if_fail (name != NULL); if (ts.loaded) return TRUE; file = fopen (name, "r"); + if (file){ + fgets (buffer, sizeof (buffer), file); + + if (strncmp (buffer, TREE_SIGNATURE, strlen (TREE_SIGNATURE)) != 0){ + fclose (file); + do_load = FALSE; + } else + do_load = TRUE; + } else + do_load = FALSE; + + if (do_load){ ts.loaded = TRUE; - + /* File open -> read contents */ oldname [0] = 0; while (fgets (buffer, MC_MAXPATHLEN, file)){ - char *name = decode (buffer); + tree_entry *e; + int scanned; + char *name; + + /* Skip invalid records */ + if ((buffer [0] != '0' && buffer [0] != '1')) + continue; + if (buffer [1] != ':') + continue; + + scanned = buffer [0] == '1'; + + name = decode (buffer+2); + len = strlen (name); #ifdef OS2_NT /* .ado: Drives for NT and OS/2 */ @@ -236,11 +265,13 @@ tree_store_load (char *name) different = strtok (NULL, ""); if (different){ strcpy (oldname + common, different); - tree_store_add_entry (oldname); + e = tree_store_add_entry (oldname); + e->scanned = scanned; } } } else { - tree_store_add_entry (name); + e = tree_store_add_entry (name); + e->scanned = scanned; strcpy (oldname, name); } } @@ -302,6 +333,8 @@ tree_store_save (char *name) if (!file) return errno; + fprintf (file, "%s\n", TREE_SIGNATURE); + current = ts.tree_first; while (current){ int i, common; @@ -310,12 +343,12 @@ tree_store_save (char *name) if (current->prev && (common = str_common (current->prev->name, current->name)) > 2){ char *encoded = encode (current->name + common); - i = fprintf (file, "%d %s\n", common, encoded); + i = fprintf (file, "%d:%d %s\n", current->scanned, common, encoded); free (encoded); } else { char *encoded = encode (current->name); - i = fprintf (file, "%s\n", encoded); + i = fprintf (file, "%d:%s\n", current->scanned, encoded); free (encoded); }