Changeset 2060

Show
Ignore:
Timestamp:
03/01/10 13:37:15 (5 months ago)
Author:
tpgww
Message:

add action pane.clear_history for clearing goto histories

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/docs/ACTIONS

    r2042 r2060  
    100100pane.<filters>                  O       show menu of filtering-options for a pane 
    101101pane.activate                   O       make a pane active if it's not already so. Arg may be 1 or 2 or missing 
     102pane.clear_history              O       clear opened-directories history for pane(s). Arg may be 1 or 2 or 1,2 or "both" 
    102103pane.focus                              O       focus a filelist (mainly for start of chained filelist keybings) 
    103104pane.go_back                    O       display the dir that is before the current one in the corresponding history list. Arg may be 1 or 2 or missing 
  • trunk/src/e2_pane.c

    r2054 r2060  
    16891689@return TRUE if a combo is found 
    16901690*/ 
    1691 static gboolean _e2_pane_clear_history (gpointer from, E2_ActionRuntime *art) 
     1691static gboolean _e2_pane_clear_dirline_history (gpointer from, E2_ActionRuntime *art) 
    16921692{ 
    16931693        E2_PaneRuntime *rt = e2_pane_get_runtime (from, art->data, NULL); 
     
    17121712        } 
    17131713        return FALSE; 
     1714} 
     1715 
     1716/** 
     1717@brief clear the current forward-back history content 
     1718@param from the button, menu item etc which was activated 
     1719@param art action runtime data 
     1720 
     1721@return TRUE 
     1722*/ 
     1723static gboolean _e2_pane_clear_goto_history (gpointer from, E2_ActionRuntime *art) 
     1724{ 
     1725        gboolean retval = FALSE; 
     1726        const gchar *arg = NULL; 
     1727        E2_PaneRuntime *rt = e2_pane_get_runtime (from, art->data, &arg); 
     1728        if (rt != NULL) 
     1729        { 
     1730                rt->opendir_cur = 0; 
     1731                //do not clear the data, it's shared with app.dir_history 
     1732                g_list_free (rt->opendirs); 
     1733                rt->opendirs = NULL; 
     1734                retval = TRUE; 
     1735        } 
     1736        if (arg != NULL) 
     1737        { 
     1738                if (g_str_has_prefix (arg, "1")) 
     1739                        rt = &app.pane1; 
     1740                else if (g_str_has_prefix (arg, "2")) 
     1741                        rt = &app.pane2; 
     1742                else if ((strchr (arg, '1') != NULL && strchr (arg, '2') != NULL) 
     1743                                        || g_str_has_prefix (arg, _("both"))) 
     1744                { 
     1745                        rt = &app.pane1; 
     1746                        rt->opendir_cur = 0; 
     1747                        g_list_free (rt->opendirs); 
     1748                        rt->opendirs = NULL; 
     1749                        rt = &app.pane2; 
     1750                } 
     1751                rt->opendir_cur = 0; 
     1752                g_list_free (rt->opendirs); 
     1753                rt->opendirs = NULL; 
     1754                retval = TRUE; 
     1755        } 
     1756        return retval; 
    17141757} 
    17151758 
     
    17931836        } 
    17941837 
    1795 /* no need to "go back" to places visited in a prior session 
    1796         //CHECKME do this again after post-config window recreation ? 
    1797         gchar *history_name = g_strconcat (rt->name, "-history", NULL); 
    1798         e2_cache_list_register (history_name, &rt->history); 
    1799         if (rt->history != NULL)  //if history list found in cache 
    1800                 rt->opendir_cur = 0;    //g_list_length (rt->history); 
    1801         g_free (history_name); 
    1802 */ 
    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) 
     1838        if (e2_option_bool_get ("cache-history")) 
     1839        { 
     1840                gchar *history_name = g_strconcat (rt->name, "-history", NULL); 
     1841                e2_cache_list_register (history_name, &rt->opendirs); 
     1842                g_free (history_name); 
     1843                if (rt->opendirs != NULL) 
     1844                { 
     1845                        GList *node; 
     1846                        for (node = rt->opendirs; node != NULL; node = node->next) 
     1847                        { 
     1848                                gchar *dirpath = (gchar *)node->data; 
     1849                                E2_DirHistoryEntry *hist_entry = g_hash_table_lookup (app.dir_history, dirpath); 
     1850                                if (hist_entry == NULL) 
     1851                                {//need a new entry for the history cache 
     1852                                        hist_entry = ALLOCATE0 (E2_DirHistoryEntry); 
     1853                                        CHECKALLOCATEDWARNT (hist_entry, ); 
     1854                                        if (hist_entry != NULL) 
     1855                                        { 
     1856                                                g_strlcpy (hist_entry->path, dirpath, sizeof(hist_entry->path)); 
     1857                                                hist_entry->selrow = -1; 
     1858#ifdef E2_VFSTMP 
     1859                                                hist_entry->spacedata = view->spacedata; 
     1860#endif 
     1861                                                g_hash_table_insert (app.dir_history, dirpath, hist_entry); 
     1862                                        } 
     1863                                } 
     1864                                else 
    18181865                                { 
    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); 
     1866                                        g_free (dirpath); 
     1867                                        node->data = hist_entry; 
    18251868                                } 
    18261869                        } 
    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)); 
     1870                } 
     1871                history_name = g_strconcat (rt->name, "-current", NULL); 
     1872                e2_cache_int_register (history_name, (gint*)&rt->opendir_cur, 0); 
     1873                g_free (history_name); 
     1874                if (rt->opendirs == NULL) 
     1875                        rt->opendir_cur = 0; 
     1876                else if (startdir == NULL) 
     1877                { 
     1878                        g_free (rt->path); 
     1879                        rt->path = g_strdup (g_list_nth_data (rt->opendirs, rt->opendir_cur)); 
     1880                } 
    18431881        } 
    18441882 
     
    19922030                NULL, NULL}, 
    19932031        {g_strconcat(_A(8),".",_A(27),NULL), NULL,                  TRUE, E2_ACTION_TYPE_HISTORY, 0, NULL, NULL}, 
     2032        {g_strconcat(_A(13),".",_A(34),NULL),_e2_pane_clear_goto_history, TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL}, 
    19942033        {g_strconcat(_A(13),".",_A(49),NULL),_e2_pane_go_back,      TRUE, E2_ACTION_TYPE_HOVER, 0, hdata1, NULL}, 
    19952034        {g_strconcat(_A(13),".",_A(50),NULL),_e2_pane_go_forward,   TRUE, E2_ACTION_TYPE_HOVER, 0, hdata2, NULL}, 
     
    20092048        {g_strconcat(_A(13),".",_A(122),NULL),_e2_pane_select_space,  TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL}, 
    20102049#endif 
    2011         {g_strconcat(_A(5),".",_A(34),NULL),_e2_pane_clear_history,  TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL}, 
     2050        {g_strconcat(_A(5),".",_A(34),NULL),_e2_pane_clear_dirline_history, TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL}, 
    20122051        {g_strconcat(_A(7),".",_A(52),NULL),_e2_pane_focus_bottom,    TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL}, 
    20132052        {g_strconcat(_A(7),".",_A(53),NULL),_e2_pane_focus_top,       TRUE, E2_ACTION_TYPE_ITEM, 0, NULL, NULL},