Changeset 2042

Show
Ignore:
Timestamp:
02/18/10 23:11:26 (5 months ago)
Author:
tpgww
Message:

re-introduce support for dir-history cacheing and combined menu

Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/docs/ACTIONS

    r1967 r2042  
    1313 
    1414bookmark.add                    O       add dir to bookmarks. Parameter1: pane1 or pane2 = use the dir shown in that pane, or else a specific path (absolute or relative) or else none = use active pane dir; parameter2: (optional) top = add to top of list; child = add as child of clicked bookmark 
    15 bookmark.delete                 O       remove dir from bookmarks. Parameter: a specific path or else use active pane directory;  
     15bookmark.delete                 O       remove dir from bookmarks. Parameter: a specific path or else use active pane directory; 
    1616children.<menu>                 N       create menu of running child processes. Selection from that menu adds that child's pid to the command line (always prepended if <Ctrl> is pressed at the time of selection) 
    1717children.list                   N       list in the output pane all the child processes of the running e2 instance 
     
    7575filelist.toggle_selected        O       toggle current selection-state of all items in a filelist 
    7676history.list                    N       list in the output pane all prior commands and actions in the session 
    77 option.set                              Y       set config option from string Parameter = string like "option-name=option-value" 
     77history.<menu>          O       show a menu of all directories in the forward/back history for the relevant filelist 
     78option.set                      Y       set config option from string Parameter = string like "option-name=option-value" 
    7879output.activate                 N       open the filetype item (if any) whose path or name is under the pointer in the active output tab 
    7980output.adjust_ratio             Y       adjust height of output pane relative to the main window. Parameter = 0.0 (hidden) to 1.0 (full window), may have ",*" appended to decimal, to cause toggling. In that case, the arg string or at least the * char must be quoted to stop interpretation into a list of files 
  • trunk/plugins/e2p_upgrade.c

    r2019 r2042  
    374374} 
    375375 
     376static void _e2p_upgrade_0_7_2 (void) 
     377{ 
     378        gchar *sed = _e2p_upgrade_get_sed (); 
     379        if (sed != NULL) 
     380        { 
     381                //context menu item add 
     382                gchar *oldstr1 = g_strconcat("\t",_("_Edit bookmarks.."),"|gtk-preferences|false|false|",_A(3),".",_C(1),"|",NULL); 
     383                gchar *newstr1 = g_strconcat(_("_History"),"|gtk-jump-to|false|false|",_A(8),".",_A(27),"|",NULL); 
     384 
     385                gchar *cfg_file = g_build_filename (e2_cl_options.config_dir, 
     386                        default_config_file, NULL); 
     387                gchar *local = F_FILENAME_TO_LOCALE (cfg_file); 
     388                gchar *command = g_strconcat ("cp -f ", local, " ", local, ".save;", 
     389                sed, 
     390#ifndef E2_VERSIONDOCS 
     391                        " -e '1s/", app.cfgfile_version, "/", VERSION RELEASE, "/'", 
     392#endif 
     393                        " -e '/",oldstr1,"$/a\\\n",newstr1,"'", 
     394                        " ",local,".save >",local,NULL); 
     395                if (!_e2p_upgrade_run (command, local)) 
     396                        printd (WARN, "failed to execute command to do upgrade 0.7.2"); 
     397                g_free (oldstr1); 
     398                g_free (newstr1); 
     399                g_free (cfg_file); 
     400                F_FREE (local, cfg_file); 
     401                g_free (command); 
     402                g_free (sed); 
     403        } 
     404        else 
     405                _e2p_upgrade_0_4_5 ();  //suggest default 
     406} 
     407 
    376408gboolean init_plugin (Plugin *p) 
    377409{ 
     
    412444                                _e2p_upgrade_0_5_1_1 (); 
    413445                        } 
     446                        if (strcmp (app.cfgfile_version,"0.7.2") < 0) 
     447                        { 
     448                                cancelled = FALSE; 
     449                                _e2p_upgrade_0_7_2 (); 
     450                        } 
    414451                } 
    415452                if (!cancelled) 
  • trunk/src/actions/e2_action.h

    r2008 r2042  
    4242        E2_ACTION_TYPE_COMMAND_LINE, 
    4343        E2_ACTION_TYPE_BOOKMARKS, 
     44        E2_ACTION_TYPE_HISTORY, 
    4445        E2_ACTION_TYPE_CHECK_ITEM,  //UNUSED 
    4546        E2_ACTION_TYPE_FILTERS, //UNUSED 
  • trunk/src/e2_context_menu.c

    r1694 r2042  
    464464                                        } 
    465465                                                break; 
     466                                        case E2_ACTION_TYPE_HISTORY: 
     467                                        { 
     468                                                GtkWidget *item = e2_menu_add (menu, label, icon, NULL, NULL, NULL); 
     469                                                E2_PaneRuntime *rt = e2_pane_get_runtime (curr_view->treeview, 
     470                                                        arg, NULL); 
     471                                                GtkWidget *submenu = e2_pane_visited_menu (rt); 
     472                                                gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); 
     473                                        } 
     474                                        break; 
    466475                                        case E2_ACTION_TYPE_FILE_ACTIONS: 
    467476                                                e2_context_menu_add_filetype_item (menu); 
     
    677686        g_strconcat("\t||false|false|",_A(21),"|",NULL), 
    678687        g_strconcat("\t",_("_Edit bookmarks.."),"|gtk-preferences|false|false|",_A(3),".",_C(1),"|",NULL), 
     688        g_strconcat(_("_History"),"|gtk-jump-to|false|false|",_A(8),".",_A(27),"|",NULL), 
    679689        g_strconcat("||false|false|",_A(21),"|",NULL), 
    680690        g_strconcat(_("_Edit filetype.."),"|gtk-preferences|false|false|",_A(3),".",_A(45),"|",NULL), 
  • trunk/src/e2_pane.c

    r2029 r2042  
    11/* $Id$ 
    22 
    3 Copyright (C) 2004-2009 tooar <tooar@emelfm2.net> 
     3Copyright (C) 2004-2010 tooar <tooar@emelfm2.net> 
    44 
    55This file is part of emelFM2. 
     
    779779} 
    780780 
     781/** 
     782@brief construct destroyable menu of all history for the pane associated with @rt 
     783 
     784@param rt pointer to pane data struct 
     785 
     786@return the menu widget (unshown) 
     787*/ 
     788GtkWidget *e2_pane_visited_menu (E2_PaneRuntime *rt) 
     789{ 
     790        guint curr = 0; 
     791        GtkWidget *menu = gtk_menu_new (); 
     792        //work backward so that "go back" items are at top 
     793        GList *member = g_list_last (rt->opendirs); 
     794        while (member != NULL) 
     795        { 
     796                GtkWidget *item; 
     797                if (strcmp ((gchar *)member->data, rt->view.dir) == 0) 
     798                        item = gtk_radio_menu_item_new_with_label (NULL, (gchar *)member->data); 
     799                else 
     800                        item = gtk_menu_item_new_with_label ((gchar *)member->data); 
     801                gtk_widget_show_all (item); 
     802                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); 
     803                g_object_set_data (G_OBJECT (item), "e2-history-pick", 
     804                        GUINT_TO_POINTER (curr)); 
     805                g_signal_connect (G_OBJECT (item), "activate", 
     806                        G_CALLBACK (_e2_pane_history_selected_cb), rt); 
     807                HISTORY_LOCK 
     808                member = member->prev; 
     809                HISTORY_UNLOCK 
     810                curr++; 
     811        } 
     812        return menu; 
     813} 
     814 
    781815  /*******************/ 
    782816 /***** actions *****/ 
     
    10361070static GtkWidget *_e2_pane_popup_forward (GtkWidget *from, E2_PaneRuntime *rt) 
    10371071{ 
    1038         guint curr = (rt->opendir_cur > 1) ? rt->opendir_cur - 1 : 0; 
    1039         if (curr == 0) 
    1040                 return NULL; 
     1072        if (rt->opendir_cur == 0) 
     1073                return NULL;    //nowhere to go in forward direction 
     1074        guint curr = rt->opendir_cur - 1; 
     1075        GtkWidget *menu = gtk_menu_new (); 
    10411076        GList *member = g_list_nth (rt->opendirs, curr); 
    1042  
    1043         GtkWidget *menu = gtk_menu_new (); 
    10441077        while (member != NULL) 
    10451078        { 
     
    17681801        g_free (history_name); 
    17691802*/ 
     1803        gchar *history_name = g_strconcat (rt->name, "-history", NULL); 
     1804        e2_cache_list_register (history_name, &rt->opendirs); 
     1805        g_free (history_name); 
     1806        if (rt->opendirs != NULL) 
     1807        { 
     1808                GList *node; 
     1809                for (node = rt->opendirs; node != NULL; node = node->next) 
     1810                { 
     1811                        gchar *dirpath = (gchar *)node->data; 
     1812                        E2_DirHistoryEntry *hist_entry = g_hash_table_lookup (app.dir_history, dirpath); 
     1813                        if (hist_entry == NULL) 
     1814                        {//need a new entry for the history cache 
     1815                                hist_entry = ALLOCATE0 (E2_DirHistoryEntry); 
     1816                                CHECKALLOCATEDWARNT (hist_entry, ); 
     1817                                if (hist_entry != NULL) 
     1818                                { 
     1819                                        g_strlcpy (hist_entry->path, dirpath, sizeof(hist_entry->path)); 
     1820                                        hist_entry->selrow = -1; 
     1821#ifdef E2_VFSTMP 
     1822                                        hist_entry->spacedata = view->spacedata; 
     1823#endif 
     1824                                        g_hash_table_insert (app.dir_history, dirpath, hist_entry); 
     1825                                } 
     1826                        } 
     1827                        else 
     1828                        { 
     1829                                g_free (dirpath); 
     1830                                node->data = hist_entry; 
     1831                        } 
     1832                } 
     1833        } 
     1834        history_name = g_strconcat (rt->name, "-current", NULL); 
     1835        e2_cache_int_register (history_name, (gint*)&rt->opendir_cur, 0); 
     1836        g_free (history_name); 
     1837        if (rt->opendirs == NULL) 
     1838                rt->opendir_cur = 0; 
     1839        else if (startdir == NULL) 
     1840        { 
     1841                g_free (rt->path); 
     1842                rt->path = g_strdup (g_list_nth_data (rt->opendirs, rt->opendir_cur)); 
     1843        } 
     1844 
    17701845        //register pane-specific actions 
    17711846        E2_Action actions[] = 
     
    18091884        //existing hooklists are cleared if appropriate in e2_window_recreate() 
    18101885        rt->pane_sw = e2_fileview_create_list (&rt->view); 
     1886        rt->inner_box = gtk_vbox_new (FALSE, 0); 
     1887        gtk_box_pack_start (GTK_BOX (rt->inner_box), rt->pane_sw, TRUE, TRUE, 0); 
    18111888        rt->outer_box = gtk_hbox_new (FALSE, 0); 
    1812         rt->inner_box = gtk_vbox_new (FALSE, 0); 
    1813         gtk_box_pack_start_defaults (GTK_BOX (rt->inner_box), rt->pane_sw); 
    1814         gtk_box_pack_start_defaults (GTK_BOX (rt->outer_box), rt->inner_box); 
     1889        gtk_box_pack_start (GTK_BOX (rt->outer_box), rt->inner_box, TRUE, TRUE, 0); 
    18151890 
    18161891        gtk_widget_show (rt->inner_box); 
     
    19161991                E2_ACTION_EXCLUDE_MENU | E2_ACTION_EXCLUDE_TOOLBAR, //CHECKME exclusions 
    19171992                NULL, NULL}, 
     1993        {g_strconcat(_A(8),".",_A(27),NULL), NULL,                  TRUE, E2_ACTION_TYPE_HISTORY, 0, NULL, NULL}, 
    19181994        {g_strconcat(_A(13),".",_A(49),NULL),_e2_pane_go_back,      TRUE, E2_ACTION_TYPE_HOVER, 0, hdata1, NULL}, 
    19191995        {g_strconcat(_A(13),".",_A(50),NULL),_e2_pane_go_forward,   TRUE, E2_ACTION_TYPE_HOVER, 0, hdata2, NULL}, 
  • trunk/src/e2_pane.h

    r2023 r2042  
    4343#endif 
    4444        E2_OptionSet *opt_transparent;  //for quick checks whether to interpret relative path strings 
    45         GList *opendirs;        /*list of paths of dirs previously opened (utf-8, 
     45        GList *opendirs;        /* effectively a list of paths of dirs previously opened (UTF-8, 
    4646                                                absolute for current namespace, with trailer). Used for 
    47                                                 "goto" buttons menu. List was cached, and then, data items 
    48                                                 were heaped copies of path strings. Now not cached, and 
    49                                                 shares data with app.dir_history. Unlike the latter, this 
    50                                                 list may have multiple entries for the same dir */ 
     47                                                "goto-buttons" menus. Actually, shares data with app.dir_history. 
     48                                                Unlike the latter, this list may have multiple entries for the 
     49                                                same dir */ 
    5150        guint opendir_cur;      //0-based index of current position in opendirs list 
    5251        GHookList hook_change_dir;      //data for functions to run during change-dir function, 
     
    7877void e2_pane_options_register (gint num); 
    7978 
     79GtkWidget *e2_pane_visited_menu (E2_PaneRuntime *rt); 
     80 
    8081#endif //ndef __E2_PANE_H__ 
  • trunk/src/e2_toolbar.c

    r2010 r2042  
    23282328                                } 
    23292329                                break; 
     2330                        case E2_ACTION_TYPE_HISTORY: 
     2331                                { 
     2332                                        E2_PaneRuntime *prt; 
     2333                                        button = _e2_toolbar_add_button (rt, bstyle, label, icon, tip, NULL); 
     2334                                        if (rt == app.bars[E2_BAR_PANE1]->rt) 
     2335                                                prt = &app.pane1; 
     2336                                        else if (rt == app.bars[E2_BAR_PANE2]->rt) 
     2337                                                prt = &app.pane2; 
     2338                                        else 
     2339                                                prt = curr_pane; 
     2340                                        GtkWidget *submenu = e2_pane_visited_menu (prt); 
     2341                                        if (submenu != NULL) 
     2342                                        { 
     2343                                                g_object_set_data_full (G_OBJECT (button), "menu", submenu, 
     2344                                                        (GDestroyNotify) gtk_widget_destroy); 
     2345                                                g_signal_connect (G_OBJECT (button), "button-press-event", 
     2346                                                        G_CALLBACK (e2_utils_generic_press_cb), NULL); 
     2347                                                g_signal_connect (G_OBJECT (button), "button-release-event", 
     2348                                                        G_CALLBACK (_e2_toolbar_menu_popup_cb), rt); 
     2349                                                g_signal_connect (G_OBJECT (button), "mnemonic-activate", 
     2350                                                        G_CALLBACK (_e2_toolbar_menu_popup_mnemonic_cb), rt); 
     2351                                        } 
     2352                                } 
     2353                                break; 
    23302354                        case E2_ACTION_TYPE_TOGGLE: 
    23312355                                {