"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/pathjumpui.cc" between
worker-4.0.1.tar.bz2 and worker-4.1.0.tar.bz2

About: Worker is a file manager for the X Window System with the classical two panel interface.

pathjumpui.cc  (worker-4.0.1.tar.bz2):pathjumpui.cc  (worker-4.1.0.tar.bz2)
skipping to change at line 51 skipping to change at line 51
#include "deeppathstore.hh" #include "deeppathstore.hh"
#include "bookmarkdbproxy.hh" #include "bookmarkdbproxy.hh"
#include "persdeeppathstore.hh" #include "persdeeppathstore.hh"
#include "prefixdb.hh" #include "prefixdb.hh"
#include "wconfig.h" #include "wconfig.h"
#include "pers_kvp.hh" #include "pers_kvp.hh"
#include <functional> #include <functional>
int PathJumpUI::s_pathjump_number = 1; int PathJumpUI::s_pathjump_number = 1;
static time_t get_newest_time( const std::list< std::pair< std::string, time_t >
> &paths )
{
time_t v = 0;
for ( auto &e : paths ) {
if ( e.second > v ) {
v = e.second;
}
}
return v;
}
static std::string convert_time_diff_to_string( time_t diff )
{
std::string t;
if ( diff < 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1104 ), (int)(
diff / 60 ) );
} else if ( diff < 2 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1103 ), (int)(
diff / 60 ) );
} else if ( diff < 1 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1104 ), (int)(
diff / 60 ) );
} else if ( diff < 2 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1105 ), (int)(
diff / 60 / 60 ) );
} else if ( diff < 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1106 ), (int)(
diff / 60 / 60 ) );
} else if ( diff < 2 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1107 ), (int)(
diff / 60 / 60 / 24 ) );
} else if ( diff < 7 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1108 ), (int)(
diff / 60 / 60 / 24 ) );
} else if ( diff < 2 * 7 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1109 ), (int)(
diff / 60 / 60 / 24 / 7 ) );
} else {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1110 ), (int)(
diff / 60 / 60 / 24 / 7 ) );
}
return t;
}
PathJumpUI::PathJumpUI( AGUIX &aguix, DeepPathStore &path_store, Worker &worker ) PathJumpUI::PathJumpUI( AGUIX &aguix, DeepPathStore &path_store, Worker &worker )
: m_aguix( aguix ), : m_aguix( aguix ),
m_worker( worker ), m_worker( worker ),
m_path_store( path_store ), m_path_store( path_store ),
m_current_depth( -1 ), m_current_depth( -1 ),
m_show_hidden_entries( false ), m_show_hidden_entries( false ),
m_entry_filter_mode( SHOW_ALL ), m_entry_filter_mode( SHOW_ALL ),
m_lv_dirty( false), m_lv_dirty( false),
m_byfilter_lv_dirty( false ), m_byfilter_lv_dirty( false ),
m_byprog_lv_dirty( false ),
m_current_time( 0 ), m_current_time( 0 ),
m_ignore_date_for_sorting( false ), m_ignore_date_for_sorting( false ),
m_oldest_time( 0 ) m_oldest_time( 0 )
{ {
std::list< std::pair< std::string, time_t > > paths = m_path_store.getPaths( ); std::list< std::pair< std::string, time_t > > paths = m_path_store.getPaths( );
int max_path_components = 0; int max_path_components = 0;
auto temp_store = worker.getPathsPers(); auto temp_store = worker.getPathsPers();
auto temp_prog_store = worker.getPathProgramsPers();
loff_t store_size = worker.getSizeOfPersPaths();
loff_t prog_store_size = worker.getSizeOfPersPathPrograms();
m_bookmarks = Worker::getBookmarkDBInstance().getNamesOfEntries( "" ); m_bookmarks = Worker::getBookmarkDBInstance().getNamesOfEntries( "" );
auto best_hits = worker.getDirHistPrefixDB().getAllBestHits(); auto best_hits = worker.getDirHistPrefixDB().getAllBestHits();
loff_t prefix_size = worker.getDirHistPrefixDB().getLastSize();
std::map< std::string, size_t > best_hits_pos; std::map< std::string, size_t > best_hits_pos;
size_t pos = 0; size_t pos = 0;
for ( auto &e : best_hits ) { for ( auto &e : best_hits ) {
m_best_hits.push_back( { .filter = e.first, m_best_hits.push_back( { .filter = e.first,
.path = std::get<0>( e.second ), .path = std::get<0>( e.second ),
.value = std::get<1>( e.second ), .value = std::get<1>( e.second ),
.visible = true, .visible = true,
.last_access = std::get<2>( e.second ) } ); .last_access = std::get<2>( e.second ) } );
best_hits_pos[ std::get<0>( e.second ) ] = pos++; best_hits_pos[ std::get<0>( e.second ) ] = pos++;
skipping to change at line 154 skipping to change at line 199
return true; return true;
} else if ( lhs.last_access == 0 && rhs.last_access > 0 ) { } else if ( lhs.last_access == 0 && rhs.last_access > 0 ) {
return false; return false;
} else if ( lhs.last_access > 0 && rhs.last_access > 0 ) { } else if ( lhs.last_access > 0 && rhs.last_access > 0 ) {
return lhs.last_access > rhs.last_access; return lhs.last_access > rhs.last_access;
} else { } else {
return lhs.value > rhs.value; return lhs.value > rhs.value;
} }
} ); } );
for ( auto &e : temp_prog_store ) {
auto paths = e.second.getPaths();
time_t last_access = get_newest_time( paths );
m_used_programs.push_back( { .program = e.first,
.last_access = last_access,
.visible = true } );
std::vector< program_path_entry > path_list;
for ( auto &path : paths ) {
path_list.push_back( { .path = path.first,
.last_access = path.second,
.exists = EXISTS_UNKNOWN } );
}
std::sort( path_list.begin(),
path_list.end(),
[]( auto &lhs, auto &rhs ) {
return lhs.last_access > rhs.last_access;
} );
m_program_paths[ e.first ] = path_list;
}
m_used_programs.sort( []( auto &lhs, auto &rhs ) {
return lhs.last_access > rhs.last_access;
} );
// without leading slash there could be this many components, // without leading slash there could be this many components,
// add one for the initial slash // add one for the initial slash
max_path_components++; max_path_components++;
m_win = std::unique_ptr<AWindow>( new AWindow( &m_aguix, m_win = std::unique_ptr<AWindow>( new AWindow( &m_aguix,
10, 10, 10, 10,
400, 400, 400, 400,
catalog.getLocale( 1301 ), catalog.getLocale( 1301 ),
AWindow::AWINDOW_DIALOG ) ); AWindow::AWINDOW_DIALOG ) );
m_win->create(); m_win->create();
skipping to change at line 355 skipping to change at line 430
m_panelize_b = co1_3->addWidget( new Button( &m_aguix, m_panelize_b = co1_3->addWidget( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 1034 ), catalog.getLocale( 1034 ),
0 ), 1, 0, AContainer::CO_FIX ) ; 0 ), 1, 0, AContainer::CO_FIX ) ;
m_checkb = (Button*)co1_3->add( new Button( &m_aguix, m_checkb = (Button*)co1_3->add( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 1115 ), catalog.getLocale( 1115 ),
0 ), 2, 0, AContainer::CO_FIX ); 0 ), 2, 0, AContainer::CO_FIX );
std::string cleanupstr = AGUIXUtils::formatStringToString( "%s (%s)",
catalog.getLocale
( 984 ),
AGUIXUtils::bytes
_to_human_readable_f( store_size ).c_str() );
m_cleanupb = (Button*)co1_3->add( new Button( &m_aguix, m_cleanupb = (Button*)co1_3->add( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 984 ), cleanupstr.c_str(),
0 ), 3, 0, AContainer::CO_FIX ); 0 ), 3, 0, AContainer::CO_FIX );
m_cancelb = (Button*)co1_3->add( new Button( &m_aguix, m_cancelb = (Button*)co1_3->add( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 633 ), catalog.getLocale( 633 ),
0 ), 4, 0, AContainer::CO_FIX ) ; 0 ), 4, 0, AContainer::CO_FIX ) ;
/****************** /******************
* By-filter view * * By-filter view *
******************/ ******************/
skipping to change at line 425 skipping to change at line 504
AContainer *sw1_co1_3 = sw1_co1->add( new AContainer( subwin2, 4, 1 ), 0, 2 ); AContainer *sw1_co1_3 = sw1_co1->add( new AContainer( subwin2, 4, 1 ), 0, 2 );
sw1_co1_3->setMinSpace( 5 ); sw1_co1_3->setMinSpace( 5 );
sw1_co1_3->setMaxSpace( -1 ); sw1_co1_3->setMaxSpace( -1 );
sw1_co1_3->setBorderWidth( 0 ); sw1_co1_3->setBorderWidth( 0 );
m_byfilter_jump_b = sw1_co1_3->addWidget( new Button( &m_aguix, m_byfilter_jump_b = sw1_co1_3->addWidget( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 761 ), catalog.getLocale( 761 ),
0 ), 0, 0, AContainer: :CO_FIX ); 0 ), 0, 0, AContainer: :CO_FIX );
std::string cleanupstr2 = AGUIXUtils::formatStringToString( "%s (%s)",
catalog.getLocal
e( 1235 ),
AGUIXUtils::byte
s_to_human_readable_f( prefix_size ).c_str() );
m_prefixcleanupb = sw1_co1_3->addWidget( new Button( &m_aguix, m_prefixcleanupb = sw1_co1_3->addWidget( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 1235 ), cleanupstr2.c_str(),
0 ), 2, 0, AContainer:: CO_FIX ); 0 ), 2, 0, AContainer:: CO_FIX );
m_byfilter_close_b = sw1_co1_3->addWidget( new Button( &m_aguix, m_byfilter_close_b = sw1_co1_3->addWidget( new Button( &m_aguix,
0, 0,
0, 0,
catalog.getLocale( 63 3 ), catalog.getLocale( 63 3 ),
0 ), 3, 0, AContainer ::CO_FIX ); 0 ), 3, 0, AContainer ::CO_FIX );
/****************************
* setup window per program *
****************************/
AWindow *subwin3 = new AWindow( &m_aguix, 0, 0, 10, 10, "" );
m_k1->add( subwin3 );
subwin3->create();
auto co3 = subwin3->setContainer( new AContainer( subwin3, 1, 3 ), true );
co3->setMaxSpace( 5 );
AContainer *co3_1 = co3->add( new AContainer( subwin3, 3, 1 ), 0, 0 );
co3_1->setMaxSpace( 5 );
co3_1->setBorderWidth( 0 );
co3_1->add( new Text( &m_aguix, 0, 0, catalog.getLocale( 793 ) ),
0, 0, AContainer::CO_FIX );
m_byprog_filter_t = co3_1->addWidget( new Text( &m_aguix, 0, 0, "" ),
1, 0, AContainer::CO_INCW );
msg = "";
if ( wconfig->getPathJumpAllowDirs().empty() ) {
msg = catalog.getLocale( 1221 );
}
co3_1->add( new Text( &m_aguix, 0, 0, msg.c_str() ),
2, 0, AContainer::CO_FIX );
AContainer *co3_5 = co3->add( new AContainer( subwin3, 2, 1 ), 0, 1 );
co3_5->setMaxSpace( 5 );
co3_5->setBorderWidth( 0 );
m_lv_progs = co3_5->addWidget( new FieldListView( &m_aguix,
0, 0,
100, 300, 0 ),
0, 0, AContainer::CO_MIN );
m_lv_progs->setNrOfFields( 2 );
m_lv_progs->setShowHeader( true );
m_lv_progs->setFieldText( 0, catalog.getLocale( 1325 ) );
m_lv_progs->setFieldText( 1, catalog.getLocale( 1112 ) );
m_lv_progs->setHBarState( 2 );
m_lv_progs->setVBarState( 2 );
m_lv_progs->setAcceptFocus( true );
m_lv_progs->setDisplayFocus( true );
m_lv_progs->setGlobalFieldSpace( 5 );
m_lv_prog_files = co3_5->addWidget( new FieldListView( &m_aguix,
0, 0,
400, 100, 0 ),
1, 0, AContainer::CO_MIN );
m_lv_prog_files->setNrOfFields( 3 );
m_lv_prog_files->setShowHeader( true );
m_lv_prog_files->setFieldText( 0, catalog.getLocale( 809 ) );
m_lv_prog_files->setFieldText( 1, catalog.getLocale( 809 ) );
m_lv_prog_files->setFieldText( 2, catalog.getLocale( 1112 ) );
m_lv_prog_files->setHBarState( 2 );
m_lv_prog_files->setVBarState( 2 );
m_lv_prog_files->setAcceptFocus( true );
m_lv_prog_files->setDisplayFocus( true );
m_lv_prog_files->setGlobalFieldSpace( 5 );
m_lv_prog_files->setFieldSpace( 0, 0 );
m_lv_prog_files->setFieldSpace( 1, 0 );
m_lv_prog_files->setFieldTextMerged( 0, true );
m_lv_prog_files->setFieldWidth( 0, m_aguix.getTextWidth( "?" ) );
m_lv_prog_files->setOnDemandCallback( [this]( FieldListView *lv,
int row,
int field,
struct FieldListView::on_deman
d_data &data )
{
updateProgFileLVData( row, field,
data );
} );
m_lv_prog_files->maximizeX();
AContainer *co3_3 = co3->add( new AContainer( subwin3, 4, 1 ), 0, 2 );
co3_3->setMinSpace( 5 );
co3_3->setMaxSpace( -1 );
co3_3->setBorderWidth( 0 );
m_byprog_jump_b = co3_3->addWidget( new Button( &m_aguix,
0,
0,
catalog.getLocale( 761 ),
0 ), 0, 0, AContainer::CO_FI
X );
std::string cleanupstr3 = AGUIXUtils::formatStringToString( "%s (%s)",
catalog.getLocal
e( 1324 ),
AGUIXUtils::byte
s_to_human_readable_f( prog_store_size ).c_str() );
m_byprog_clean_b = co3_3->addWidget( new Button( &m_aguix,
0,
0,
cleanupstr3.c_str(),
0 ), 2, 0, AContainer::CO_F
IX );
m_byprog_close_b = co3_3->addWidget( new Button( &m_aguix,
0,
0,
catalog.getLocale( 633 ),
0 ), 3, 0, AContainer::CO_F
IX );
co3_5->readLimits();
/********************* /*********************
* setup main window * * setup main window *
*********************/ *********************/
m_k1->setOption( m_subwin1, 0, catalog.getLocale( 1222 ) ); m_k1->setOption( m_subwin1, 0, catalog.getLocale( 1222 ) );
m_k1->setOption( subwin2, 1, catalog.getLocale( 1223 ) ); m_k1->setOption( subwin2, 1, catalog.getLocale( 1223 ) );
m_k1->setOption( subwin3, 2, catalog.getLocale( 1326 ) );
m_k1->maximize(); m_k1->maximize();
m_k1->contMaximize(); m_k1->contMaximize();
m_k1->show(); m_k1->show();
m_mainco->readLimits(); m_mainco->readLimits();
m_win->contMaximize( true ); m_win->contMaximize( true );
m_win->setDoTabCycling( true ); m_win->setDoTabCycling( true );
m_entry_filter_age = 0; m_entry_filter_age = 0;
} }
PathJumpUI::~PathJumpUI() PathJumpUI::~PathJumpUI()
{ {
} }
void PathJumpUI::checkExistResults() void PathJumpUI::checkExistResults()
{ {
if ( ! m_apply_state.done || m_existence_tests.empty() ) { if ( ! m_apply_state.done ||
( m_existence_tests.empty() &&
m_existence_tests_prog_path.empty() ) ) {
return; return;
} }
bool update_lv = false; bool update_lv = false;
bool update_lv_prog_files = false;
for ( auto it = m_existence_tests.begin(); for ( auto it = m_existence_tests.begin();
it != m_existence_tests.end(); it != m_existence_tests.end();
) { ) {
std::future_status status = std::get<0>( *it ).wait_for(std::chrono::dur ation<int>::zero()); std::future_status status = std::get<0>( *it ).wait_for(std::chrono::dur ation<int>::zero());
if ( status == std::future_status::ready ) { if ( status == std::future_status::ready ) {
bool res = std::get<0>( *it ).get(); bool res = std::get<0>( *it ).get();
if ( std::get<2>( *it ) == true ) { if ( std::get<2>( *it ) == true ) {
skipping to change at line 500 skipping to change at line 690
next_it++; next_it++;
m_existence_tests.erase( it ); m_existence_tests.erase( it );
it = next_it; it = next_it;
} else { } else {
it++; it++;
} }
} }
int prog_row = m_lv_progs->getActiveRow();
if ( m_lv_progs->isValidRow( prog_row ) ) {
auto current_program = m_lv_progs->getText( prog_row, 0 );
if ( m_program_paths.count( current_program ) > 0 ) {
auto &path_list = m_program_paths[ current_program ];
for ( auto it = m_existence_tests_prog_path.begin();
it != m_existence_tests_prog_path.end();
) {
std::future_status status = std::get<0>( *it ).wait_for(std::chr
ono::duration<int>::zero());
if ( status == std::future_status::ready ) {
bool res = std::get<0>( *it ).get();
if ( std::get<2>( *it ) == true ) {
int row = std::get<1>( *it );
if ( row >= 0 &&
row < (int)path_list.size() ) {
try {
if ( res ) {
path_list.at( row ).exists = EXISTS_YES;
} else {
path_list.at( row ).exists = EXISTS_NO;
}
m_lv_prog_files->clearOnDemandDataAvailableFlag(
row );
update_lv_prog_files = true;
} catch (...) {
}
}
}
auto next_it = it;
next_it++;
m_existence_tests_prog_path.erase( it );
it = next_it;
} else {
it++;
}
}
}
}
if ( update_lv ) { if ( update_lv ) {
m_lv->redraw(); m_lv->redraw();
} }
if ( update_lv_prog_files ) {
m_lv_prog_files->redraw();
}
} }
int PathJumpUI::mainLoop( bool start_in_filter_tab ) int PathJumpUI::mainLoop( initial_tab_t show_tab )
{ {
m_lv_dirty = true; m_lv_dirty = true;
m_byfilter_lv_dirty = true; m_byfilter_lv_dirty = true;
m_byprog_lv_dirty = true;
apply_filter( m_filter, NULL ); apply_filter( m_filter, NULL );
// do run2completion for the first call to have everything // do run2completion for the first call to have everything
// initialized // initialized
while ( ! m_apply_state.done ) { while ( ! m_apply_state.done ) {
apply_filter_next(); apply_filter_next();
} }
highlight_best_hit( m_dirname ); highlight_best_hit( m_dirname );
skipping to change at line 536 skipping to change at line 780
10000 ); 10000 );
int th = Worker::getPersKVPStore().getIntValue( "pathjumpwin-height", int th = Worker::getPersKVPStore().getIntValue( "pathjumpwin-height",
m_win->getHeight(), m_win->getHeight(),
10000 ); 10000 );
m_win->resize( tw, th ); m_win->resize( tw, th );
m_win->show(); m_win->show();
m_lv->takeFocus(); m_lv->takeFocus();
if ( start_in_filter_tab ) { switch ( show_tab ) {
m_k1->optionChange( 1 ); case SHOW_BY_FILTER:
m_byfilter_lv->takeFocus(); m_k1->optionChange( 1 );
m_byfilter_lv->takeFocus();
break;
case SHOW_BY_PROGRAM:
m_k1->optionChange( 2 );
m_lv_progs->takeFocus();
break;
default:
break;
} }
AGMessage *msg; AGMessage *msg;
int endmode = 0; int endmode = 0;
int persist_width = -1; int persist_width = -1;
int persist_height = -1; int persist_height = -1;
for ( ; endmode == 0; ) { for ( ; endmode == 0; ) {
if ( m_apply_state.done && m_existence_tests.empty() ) { if ( m_apply_state.done &&
m_existence_tests.empty() &&
m_existence_tests_prog_path.empty() ) {
msg = m_aguix.WaitMessage( NULL ); msg = m_aguix.WaitMessage( NULL );
} else { } else {
msg = m_aguix.GetMessage( NULL ); msg = m_aguix.GetMessage( NULL );
} }
checkExistResults(); checkExistResults();
if ( msg != NULL ) { if ( msg != NULL ) {
switch ( msg->type ) { switch ( msg->type ) {
case AG_CLOSEWINDOW: case AG_CLOSEWINDOW:
endmode = -1; endmode = -1;
break; break;
case AG_BUTTONCLICKED: case AG_BUTTONCLICKED:
if ( msg->button.button == m_okb ) { if ( msg->button.button == m_okb ) {
endmode = 1; endmode = 1;
} else if ( msg->button.button == m_byfilter_jump_b ) { } else if ( msg->button.button == m_byfilter_jump_b ) {
endmode = 1; endmode = 1;
} else if ( msg->button.button == m_byprog_jump_b ) {
endmode = 1;
} else if ( msg->button.button == m_cleanupb ) { } else if ( msg->button.button == m_cleanupb ) {
if ( storeCleanUp() == 0 ) { if ( storeCleanUp() == 0 ) {
endmode = -1; endmode = -1;
} }
} else if ( msg->button.button == m_prefixcleanupb ) { } else if ( msg->button.button == m_prefixcleanupb ) {
if ( prefixDBCleanUp() == 0 ) { if ( prefixDBCleanUp() == 0 ) {
endmode = -1; endmode = -1;
} }
} else if ( msg->button.button == m_byprog_clean_b ) {
if ( programDBCleanUp() == 0 ) {
endmode = -1;
}
} else if ( msg->button.button == m_checkb ) { } else if ( msg->button.button == m_checkb ) {
checkExistance(); checkExistance();
} else if ( msg->button.button == m_panelize_b ) { } else if ( msg->button.button == m_panelize_b ) {
endmode = 2; endmode = 2;
} else if ( msg->button.button == m_cancelb ) { } else if ( msg->button.button == m_cancelb ) {
endmode = -1; endmode = -1;
} else if ( msg->button.button == m_byfilter_close_b ) { } else if ( msg->button.button == m_byfilter_close_b ) {
endmode = -1; endmode = -1;
} else if ( msg->button.button == m_byprog_close_b ) {
endmode = -1;
} else if ( msg->button.button == m_plus1h_b ) { } else if ( msg->button.button == m_plus1h_b ) {
m_entry_filter_age += 1 * 60 * 60; m_entry_filter_age += 1 * 60 * 60;
apply_filter( m_filter, [this]( int matches ) { apply_filter( m_filter, [this]( int matches ) {
showData(); showData();
updateAgeText(); updateAgeText();
}); });
} else if ( msg->button.button == m_plus1d_b ) { } else if ( msg->button.button == m_plus1d_b ) {
m_entry_filter_age += 1 * 24 * 60 * 60; m_entry_filter_age += 1 * 24 * 60 * 60;
skipping to change at line 627 skipping to change at line 889
if ( m_breadcrumb_buttons[i] == msg->button.button ) { if ( m_breadcrumb_buttons[i] == msg->button.button ) {
m_current_depth = i; m_current_depth = i;
endmode = 1; endmode = 1;
} }
} }
} }
break; break;
case AG_KEYPRESSED: case AG_KEYPRESSED:
if ( msg->key.key == XK_BackSpace ) { if ( msg->key.key == XK_BackSpace ) {
if ( KEYSTATEMASK( msg->key.keystate ) == ShiftMask ) { if ( KEYSTATEMASK( msg->key.keystate ) == ShiftMask ) {
std::string &f = m_k1->getCurOption() == 1 ? m_byfilte std::string *f;
r_filter : m_filter;
f = ""; switch( m_k1->getCurOption() ) {
apply_filter( f, [this]( int matches ) { case 1:
f = &m_byfilter_filter;
break;
case 2:
f = &m_byprog_filter;
break;
default:
f = &m_filter;
break;
};
*f = "";
apply_filter( *f, [this]( int matches ) {
showData(); showData();
}); });
} else { } else {
std::string &f = m_k1->getCurOption() == 1 ? m_byfilte std::string *f;
r_filter : m_filter;
std::string cur_infix = f; switch( m_k1->getCurOption() ) {
case 1:
f = &m_byfilter_filter;
break;
case 2:
f = &m_byprog_filter;
break;
default:
f = &m_filter;
break;
};
std::string cur_infix = *f;
if ( cur_infix.length() > 0 ) { if ( cur_infix.length() > 0 ) {
cur_infix.resize( cur_infix.length() - 1 ); cur_infix.resize( cur_infix.length() - 1 );
f = cur_infix; *f = cur_infix;
apply_filter( f, [this]( int matches ) { apply_filter( *f, [this]( int matches ) {
showData(); showData();
}); });
} }
} }
} else if ( msg->key.key == XK_Return ) { } else if ( msg->key.key == XK_Return ) {
endmode = 1; endmode = 1;
} else if ( msg->key.key == XK_Escape ) { } else if ( msg->key.key == XK_Escape ) {
endmode = -1; endmode = -1;
} else if ( msg->key.key == XK_Left && } else if ( msg->key.key == XK_Left &&
m_k1->getCurOption() == 0 ) { m_k1->getCurOption() == 0 ) {
skipping to change at line 669 skipping to change at line 957
m_current_depth--; m_current_depth--;
} }
if ( m_entry_filter_mode != SHOW_ALL ) { if ( m_entry_filter_mode != SHOW_ALL ) {
post_filtering(); post_filtering();
showData(); showData();
} else { } else {
update_breadcrumb(); update_breadcrumb();
} }
} }
} else if ( msg->key.key == XK_Left &&
m_k1->getCurOption() == 2 ) {
m_lv_progs->takeFocus();
} else if ( msg->key.key == XK_Right && } else if ( msg->key.key == XK_Right &&
m_k1->getCurOption() == 0 ) { m_k1->getCurOption() == 0 ) {
if ( ! m_current_components.empty() ) { if ( ! m_current_components.empty() ) {
if ( KEYSTATEMASK( msg->key.keystate ) == ShiftMask ) { if ( KEYSTATEMASK( msg->key.keystate ) == ShiftMask ) {
m_current_depth = (int)( m_current_components.size () ); m_current_depth = (int)( m_current_components.size () );
} else { } else {
if ( m_current_depth < 0 ) { if ( m_current_depth < 0 ) {
m_current_depth = 0; m_current_depth = 0;
} else if ( m_current_depth <= (int)( m_current_co mponents.size() - 1 ) ) { } else if ( m_current_depth <= (int)( m_current_co mponents.size() - 1 ) ) {
m_current_depth++; m_current_depth++;
} }
} }
if ( m_entry_filter_mode != SHOW_ALL ) { if ( m_entry_filter_mode != SHOW_ALL ) {
post_filtering(); post_filtering();
showData(); showData();
} else { } else {
update_breadcrumb(); update_breadcrumb();
} }
} }
} else if ( msg->key.key == XK_Right &&
m_k1->getCurOption() == 2 ) {
m_lv_prog_files->takeFocus();
} else if ( msg->key.key == XK_Up ) { } else if ( msg->key.key == XK_Up ) {
if ( m_k1->getCurOption() == 0 ) { if ( m_k1->getCurOption() == 0 ) {
m_lv->takeFocus(); m_lv->takeFocus();
} else { } else if ( m_k1->getCurOption() == 1 ) {
m_byfilter_lv->takeFocus(); m_byfilter_lv->takeFocus();
} else if ( m_k1->getCurOption() == 2 ) {
m_lv_progs->takeFocus();
} }
} else if ( msg->key.key == XK_Down ) { } else if ( msg->key.key == XK_Down ) {
if ( m_k1->getCurOption() == 0 ) { if ( m_k1->getCurOption() == 0 ) {
m_lv->takeFocus(); m_lv->takeFocus();
} else { } else if ( m_k1->getCurOption() == 1 ) {
m_byfilter_lv->takeFocus(); m_byfilter_lv->takeFocus();
} else if ( m_k1->getCurOption() == 2 ) {
m_lv_progs->takeFocus();
} }
} else if ( msg->key.key == XK_Next ) { } else if ( msg->key.key == XK_Next ) {
} else if ( msg->key.key == XK_Prior ) { } else if ( msg->key.key == XK_Prior ) {
} else if ( msg->key.key == XK_Home && } else if ( msg->key.key == XK_Home &&
m_k1->getCurOption() == 0 ) { m_k1->getCurOption() == 0 ) {
// key is grabbed by listview so it has no effect at the m oment // key is grabbed by listview so it has no effect at the m oment
if ( ! m_current_components.empty() ) { if ( ! m_current_components.empty() ) {
m_current_depth = 0; m_current_depth = 0;
update_breadcrumb(); update_breadcrumb();
} }
skipping to change at line 722 skipping to change at line 1020
// key is grabbed by listview so it has no effect at the m oment // key is grabbed by listview so it has no effect at the m oment
if ( ! m_current_components.empty() ) { if ( ! m_current_components.empty() ) {
m_current_depth = m_current_components.size(); m_current_depth = m_current_components.size();
update_breadcrumb(); update_breadcrumb();
} }
} else if ( msg->key.key == XK_F1 ) { } else if ( msg->key.key == XK_F1 ) {
m_k1->optionChange( 0 ); m_k1->optionChange( 0 );
} else if ( msg->key.key == XK_F2 ) { } else if ( msg->key.key == XK_F2 ) {
m_k1->optionChange( 1 ); m_k1->optionChange( 1 );
m_byfilter_lv->takeFocus(); m_byfilter_lv->takeFocus();
} else if ( msg->key.key == XK_F3 ) {
m_k1->optionChange( 2 );
m_lv_progs->takeFocus();
} else if ( IsModifierKey( msg->key.key ) || } else if ( IsModifierKey( msg->key.key ) ||
IsCursorKey( msg->key.key ) || IsCursorKey( msg->key.key ) ||
IsPFKey( msg->key.key ) || IsPFKey( msg->key.key ) ||
IsFunctionKey( msg->key.key ) || IsFunctionKey( msg->key.key ) ||
IsMiscFunctionKey( msg->key.key ) || IsMiscFunctionKey( msg->key.key ) ||
( ( msg->key.key >= XK_BackSpace ) && ( msg->key.k ey <= XK_Escape ) ) ) { ( ( msg->key.key >= XK_BackSpace ) && ( msg->key.k ey <= XK_Escape ) ) ) {
} else if ( msg->key.key >= XK_0 && msg->key.key <= XK_9 && } else if ( msg->key.key >= XK_0 && msg->key.key <= XK_9 &&
KEYSTATEMASK( msg->key.keystate ) == ControlMask & & KEYSTATEMASK( msg->key.keystate ) == ControlMask & &
m_k1->getCurOption() == 0) { m_k1->getCurOption() == 0) {
if ( msg->key.key == XK_0 ) { if ( msg->key.key == XK_0 ) {
skipping to change at line 803 skipping to change at line 1104
} else if ( msg->key.key == XK_w && } else if ( msg->key.key == XK_w &&
KEYSTATEMASK( msg->key.keystate ) == ControlMa sk && KEYSTATEMASK( msg->key.keystate ) == ControlMa sk &&
m_k1->getCurOption() == 0 ) { m_k1->getCurOption() == 0 ) {
m_entry_filter_age += 7 * 24 * 60 * 60; m_entry_filter_age += 7 * 24 * 60 * 60;
apply_filter( m_filter, [this]( int matches ) { apply_filter( m_filter, [this]( int matches ) {
showData(); showData();
updateAgeText(); updateAgeText();
}); });
} else { } else {
std::string &f = m_k1->getCurOption() == 1 ? m_byfilte std::string *f;
r_filter : m_filter;
std::string cur_infix = f; switch( m_k1->getCurOption() ) {
case 1:
f = &m_byfilter_filter;
break;
case 2:
f = &m_byprog_filter;
break;
default:
f = &m_filter;
break;
};
std::string cur_infix = *f;
cur_infix += msg->key.keybuf; cur_infix += msg->key.keybuf;
apply_filter( cur_infix, [this]( int matches ) { apply_filter( cur_infix, [this]( int matches ) {
showData(); showData();
}); });
} }
} }
break; break;
case AG_FIELDLV_DOUBLECLICK: case AG_FIELDLV_DOUBLECLICK:
if ( msg->fieldlv.lv == m_lv || if ( msg->fieldlv.lv == m_lv ||
msg->fieldlv.lv == m_byfilter_lv ) { msg->fieldlv.lv == m_byfilter_lv ||
msg->fieldlv.lv == m_lv_progs ) {
// double click in lv, actual element is unimportant here // double click in lv, actual element is unimportant here
endmode = 1; endmode = 1;
} else if ( msg->fieldlv.lv == m_class_counts_lv ) { } else if ( msg->fieldlv.lv == m_class_counts_lv ) {
holdCurrentEntriesAndUpdateUI( msg->fieldlv.row + 1 ); holdCurrentEntriesAndUpdateUI( msg->fieldlv.row + 1 );
} }
break; break;
case AG_FIELDLV_ONESELECT: case AG_FIELDLV_ONESELECT:
case AG_FIELDLV_MULTISELECT: case AG_FIELDLV_MULTISELECT:
if ( msg->fieldlv.lv == m_lv ) { if ( msg->fieldlv.lv == m_lv ) {
handleMainLVRowChange( m_lv->getActiveRow() ); handleMainLVRowChange( m_lv->getActiveRow() );
} else if ( msg->fieldlv.lv == m_byfilter_lv ) { } else if ( msg->fieldlv.lv == m_byfilter_lv ) {
handleByFilterLVRowChange( m_byfilter_lv->getActiveRow() ); handleByFilterLVRowChange( m_byfilter_lv->getActiveRow() );
} else if ( msg->fieldlv.lv == m_lv_progs ) {
showPathsForProgram( m_lv_progs->getActiveRow() );
} else if ( msg->fieldlv.lv == m_class_counts_lv ) { } else if ( msg->fieldlv.lv == m_class_counts_lv ) {
handleMatchClassRow( msg->fieldlv.row ); handleMatchClassRow( msg->fieldlv.row );
} }
break; break;
case AG_CHOOSECLICKED: case AG_CHOOSECLICKED:
if ( msg->choose.button == m_show_all_cb ) { if ( msg->choose.button == m_show_all_cb ) {
m_show_hidden_entries = msg->choose.state; m_show_hidden_entries = msg->choose.state;
apply_filter( m_filter, [this]( int matches ) { apply_filter( m_filter, [this]( int matches ) {
showData(); showData();
}); });
skipping to change at line 886 skipping to change at line 1203
} }
if ( endmode == 1 ) { if ( endmode == 1 ) {
if ( ! NWC::FSEntry( getCurrentPath() ).entryExists() ) { if ( ! NWC::FSEntry( getCurrentPath() ).entryExists() ) {
endmode = 0; endmode = 0;
} }
} }
} }
m_selected_path = ""; m_selected_path = "";
m_selected_path_stored = false;
if ( endmode == 2 ) { if ( endmode == 2 ) {
} else if ( endmode == 1 ) { } else if ( endmode == 1 ) {
std::string res = ""; std::string res = "";
// finalize running filter // finalize running filter
while ( ! m_apply_state.done ) { while ( ! m_apply_state.done ) {
apply_filter_next(); apply_filter_next();
} }
skipping to change at line 907 skipping to change at line 1225
if ( m_current_depth <= 0 ) { if ( m_current_depth <= 0 ) {
res = "/"; res = "/";
} else { } else {
for ( unsigned int i = 0; i < m_current_components.size(); i++ ) { for ( unsigned int i = 0; i < m_current_components.size(); i++ ) {
if ( (int)i >= m_current_depth ) break; if ( (int)i >= m_current_depth ) break;
res += "/"; res += "/";
res += m_current_components[i]; res += m_current_components[i];
} }
} }
} else { } else if ( m_k1->getCurOption() == 1 ) {
res = m_current_entry_byfilter; res = m_current_entry_byfilter;
} else if ( m_k1->getCurOption() == 2 ) {
int row = m_lv_prog_files->getActiveRow();
if ( m_lv_prog_files->isValidRow( row ) ) {
res = m_lv_prog_files->getText( row, 1 );
}
} }
m_selected_path = res; m_selected_path = res;
std::string filter; std::string filter;
if ( m_k1->getCurOption() == 1 ) { if ( m_k1->getCurOption() == 1 ) {
if ( m_byfilter_lv->isValidRow( m_byfilter_lv->getActiveRow() ) ) { if ( m_byfilter_lv->isValidRow( m_byfilter_lv->getActiveRow() ) ) {
filter = m_byfilter_lv->getText( m_byfilter_lv->getActiveRow(), 0 ); filter = m_byfilter_lv->getText( m_byfilter_lv->getActiveRow(), 0 );
} }
} else { } else if ( m_k1->getCurOption() == 0 ) {
filter = m_filter; filter = m_filter;
} }
m_worker.setPathJumpInProgress( filter ); if ( filter.empty() ) {
m_worker.setPathJumpInProgress( true );
} else {
m_worker.setPathJumpInProgress( filter );
}
// check if this path is allowed to be tracked, than put its // check if this path is allowed to be tracked, than put its
// access into the prefixdb // access into the prefixdb
if ( ! filter.empty() && ! wconfig->getPathJumpAllowDirs().empty() ) { if ( ! wconfig->getPathJumpAllowDirs().empty() ) {
const std::list< std::string > &l = wconfig->getPathJumpAllowDirs(); const std::list< std::string > &l = wconfig->getPathJumpAllowDirs();
for ( std::list< std::string >::const_iterator it1 = l.begin(); for ( std::list< std::string >::const_iterator it1 = l.begin();
it1 != l.end(); it1 != l.end();
it1++ ) { it1++ ) {
if ( AGUIXUtils::starts_with( m_selected_path, *it1 ) ) { if ( AGUIXUtils::starts_with( m_selected_path, *it1 ) ) {
m_worker.storePathPersIfInProgress( m_selected_path ); m_selected_path_stored = m_worker.storePathPersIfInProgress( m_selected_path );
break; break;
} }
} }
} }
} }
if ( persist_height > 0 ) { if ( persist_height > 0 ) {
Worker::getPersKVPStore().setIntValue( "pathjumpwin-width", Worker::getPersKVPStore().setIntValue( "pathjumpwin-width",
persist_width ); persist_width );
} }
skipping to change at line 1132 skipping to change at line 1460
if ( ! current_entry_found ) { if ( ! current_entry_found ) {
m_byfilter_lv->setActiveRow( 0 ); m_byfilter_lv->setActiveRow( 0 );
handleByFilterLVRowChange( m_byfilter_lv->getActiveRow() ); handleByFilterLVRowChange( m_byfilter_lv->getActiveRow() );
} }
m_byfilter_lv_dirty = false; m_byfilter_lv_dirty = false;
m_byfilter_lv->showActive(); m_byfilter_lv->showActive();
m_byfilter_lv->redraw(); m_byfilter_lv->redraw();
} }
showProgramData();
}
void PathJumpUI::showProgramData()
{
if ( ! m_byprog_lv_dirty ) {
return;
}
// invalidate running futures
for ( auto &e : m_existence_tests_prog_path ) {
std::get<2>( e ) = false;
}
time_t now = time( NULL );
m_lv_progs->setSize( 0 );
m_lv_prog_files->setSize( 0 );
int pos = 0;
for ( auto it1 = m_used_programs.begin();
it1 != m_used_programs.end();
it1++, pos++ ) {
if ( it1->visible == true ) {
int row = m_lv_progs->addRow();
m_lv_progs->setText( row, 0, it1->program );
m_lv_progs->setText( row, 1, convert_time_diff_to_string( now - it1-
>last_access ) );
m_lv_progs->setPreColors( row, FieldListView::PRECOLOR_ONLYACTIVE );
}
}
m_lv_progs->setActiveRow( 0 );
showPathsForProgram( m_lv_progs->getActiveRow() );
m_byprog_lv_dirty = false;
m_lv_progs->showActive();
m_lv_progs->redraw();
} }
std::string PathJumpUI::getSelectedPath() void PathJumpUI::showPathsForProgram( int program_row )
{ {
time_t now = time( NULL );
m_lv_prog_files->setSize( 0 );
std::string program = m_lv_progs->getText( program_row, 0 );
if ( m_program_paths.count( program ) == 0 ) {
m_lv_prog_files->redraw();
return;
}
auto &path_list = m_program_paths[ program ];
for ( auto &e : path_list ) {
int row = m_lv_prog_files->addRow();
m_lv_prog_files->setText( row, 1, e.path );
m_lv_prog_files->setText( row, 2, convert_time_diff_to_string( now - e.l
ast_access ) );
m_lv_prog_files->setPreColors( row, FieldListView::PRECOLOR_ONLYACTIVE )
;
}
m_lv_prog_files->setActiveRow( 0 );
m_lv_prog_files->showActive();
m_lv_prog_files->redraw();
}
std::string PathJumpUI::getSelectedPath( bool &stored )
{
stored = m_selected_path_stored;
return m_selected_path; return m_selected_path;
} }
void PathJumpUI::setCurrentDirname( const std::string &dirname ) void PathJumpUI::setCurrentDirname( const std::string &dirname )
{ {
m_dirname = dirname; m_dirname = dirname;
} }
void PathJumpUI::setCurrentBasename( const std::string &basename ) void PathJumpUI::setCurrentBasename( const std::string &basename )
{ {
skipping to change at line 1239 skipping to change at line 1638
} }
m_byfilter_lv_dirty = true; m_byfilter_lv_dirty = true;
m_byfilter_filter_t->setText( filter.c_str() ); m_byfilter_filter_t->setText( filter.c_str() );
if ( finalize ) { if ( finalize ) {
finalize( 0 ); finalize( 0 );
} }
return; return;
} }
if ( m_k1->getCurOption() == 2 ) {
m_byprog_filter = filter;
StringMatcherFNMatch matcher;
matcher.setMatchString( "*" + filter + "*" );
matcher.setMatchCaseSensitive( false );
for ( auto &e : m_used_programs ) {
if ( matcher.match( e.program ) ) {
e.visible = true;
} else {
e.visible = false;
}
}
m_byprog_lv_dirty = true;
m_byprog_filter_t->setText( filter.c_str() );
if ( finalize ) {
finalize( 0 );
}
return;
}
m_apply_state = apply_filter_state(); m_apply_state = apply_filter_state();
m_filter = filter; m_filter = filter;
std::string visible_filter = m_filter; std::string visible_filter = m_filter;
visible_filter += "..."; visible_filter += "...";
m_infixtext->setText( visible_filter.c_str() ); m_infixtext->setText( visible_filter.c_str() );
m_apply_state.flmatch.setMatchString( filter ); m_apply_state.flmatch.setMatchString( filter );
m_apply_state.flmatch.setMatchCaseSensitive( false ); m_apply_state.flmatch.setMatchCaseSensitive( false );
skipping to change at line 1971 skipping to change at line 2393
} else { } else {
endmode = -1; endmode = -1;
} }
} }
delete win; delete win;
return endmode == 1 ? 0 : 1; return endmode == 1 ? 0 : 1;
} }
int PathJumpUI::programDBCleanUp()
{
auto win = new AWindow( &m_aguix,
10, 10,
400, 400,
catalog.getLocale( 1324 ),
AWindow::AWINDOW_DIALOG );
win->create();
auto co1 = win->setContainer( new AContainer( win, 1, 2 ), true );
co1->setMaxSpace( 5 );
auto co1_1 = co1->add( new AContainer( win, 8, 1 ), 0, 0 );
co1_1->setMaxSpace( 5 );
co1_1->setBorderWidth( 0 );
co1_1->add( new Text( &m_aguix, 0, 0, catalog.getLocale( 1229 ) ),
0, 0, AContainer::CO_FIXNR + AContainer::ACONT_CENTER );
auto sg = co1_1->addWidget( new StringGadget( &m_aguix, 0, 0, 5 * m_aguix.ge
tTextWidth( "W" ), "0", 0 ),
1, 0, AContainer::CO_FIX );
co1_1->add( new Text( &m_aguix, 0, 0, catalog.getLocale( 1230 ) ),
2, 0, AContainer::CO_FIXNR + AContainer::ACONT_CENTER );
auto weekb = co1_1->addWidget( new Button( &m_aguix, 0, 0, catalog.getLocale
( 1231 ), 0 ),
3, 0, AContainer::CO_FIX );
auto monthb = co1_1->addWidget( new Button( &m_aguix, 0, 0, catalog.getLocal
e( 1232 ), 0 ),
4, 0, AContainer::CO_FIX );
auto yearb = co1_1->addWidget( new Button( &m_aguix, 0, 0, catalog.getLocale
( 1233 ), 0 ),
5, 0, AContainer::CO_FIX );
auto neverb = co1_1->addWidget( new Button( &m_aguix, 0, 0, catalog.getLocal
e( 1236 ), 0 ),
6, 0, AContainer::CO_FIX );
auto co1_2 = co1->add( new AContainer( win, 2, 1 ), 0, 1 );
co1_2->setMinSpace( 5 );
co1_2->setMaxSpace( -1 );
co1_2->setBorderWidth( 0 );
auto checkb = co1_2->addWidget( new Button( &m_aguix,
0,
0,
catalog.getLocale( 1234 ),
0 ), 0, 0, AContainer::CO_FIX );
auto cancelb = co1_2->addWidget( new Button( &m_aguix,
0,
0,
catalog.getLocale( 8 ),
0 ), 1, 0, AContainer::CO_FIX )
;
win->contMaximize( true, true );
win->setDoTabCycling( true );
win->show();
AGMessage *msg;
int endmode = 0;
for ( ; endmode == 0; ) {
msg = m_aguix.WaitMessage( NULL );
if ( msg != NULL ) {
switch ( msg->type ) {
case AG_CLOSEWINDOW:
if ( msg->closewindow.window == win->getWindow() ) {
endmode = -1;
}
break;
case AG_BUTTONCLICKED:
if ( msg->button.button == weekb ) {
auto tstr = AGUIXUtils::formatStringToString( "7" );
sg->setText( tstr.c_str() );
} else if ( msg->button.button == monthb ) {
auto tstr = AGUIXUtils::formatStringToString( "31" );
sg->setText( tstr.c_str() );
} else if ( msg->button.button == yearb ) {
auto tstr = AGUIXUtils::formatStringToString( "365" );
sg->setText( tstr.c_str() );
} else if ( msg->button.button == neverb ) {
auto tstr = AGUIXUtils::formatStringToString( "-1" );
sg->setText( tstr.c_str() );
} else if ( msg->button.button == checkb ) {
endmode = 1;
} else if ( msg->button.button == cancelb ) {
endmode = -1;
}
break;
}
m_aguix.ReplyMessage( msg );
}
}
if ( endmode == 1 ) {
char *endptr;
int t = strtol( sg->getText(), &endptr, 10 );
if ( *endptr == '\0' && t >= -1 ) {
if ( cleanupProgramDB( win, t ) != 0 ) {
endmode = -1;
}
} else {
endmode = -1;
}
}
delete win;
return endmode == 1 ? 0 : 1;
}
int PathJumpUI::cleanup( AWindow *win, const std::string &base, time_t unused_si nce_days ) int PathJumpUI::cleanup( AWindow *win, const std::string &base, time_t unused_si nce_days )
{ {
std::string msg, bt; std::string msg, bt;
std::list< std::pair< std::string, time_t > > temp_paths = m_worker.getPaths Pers().getPaths(), std::list< std::pair< std::string, time_t > > temp_paths = m_worker.getPaths Pers().getPaths(),
non_existing_entries; non_existing_entries;
int non_existing = 0; int non_existing = 0;
size_t elements = temp_paths.size(); size_t elements = temp_paths.size();
size_t processed = 0; size_t processed = 0;
skipping to change at line 2136 skipping to change at line 2666
win->request( catalog.getLocale( 123 ), win->request( catalog.getLocale( 123 ),
catalog.getLocale( 1237), catalog.getLocale( 1237),
catalog.getLocale( 633 ) ); catalog.getLocale( 633 ) );
return 1; return 1;
} }
return 0; return 0;
} }
int PathJumpUI::cleanupProgramDB( AWindow *win, int unused_since_days )
{
std::string msg, bt;
std::list< std::string > removable_entries;
size_t processed = 0;
size_t matching_elements = 0;
time_t now = time( NULL );
for ( auto &p : m_used_programs ) {
processed++;
if ( p.last_access > now ) {
continue;
}
if ( unused_since_days < -1 ) {
continue;
}
if ( unused_since_days == -1 &&
p.last_access != 0 ) {
continue;
}
if ( unused_since_days >= 0 &&
p.last_access == 0 ) {
continue;
}
if ( unused_since_days >= 0 &&
now - p.last_access <= unused_since_days * 24 * 60 * 60 ) {
continue;
}
matching_elements++;
removable_entries.push_back( p.program );
}
if ( ! removable_entries.empty() ) {
msg = AGUIXUtils::formatStringToString( catalog.getLocale( 1238 ),
(int)matching_elements, (int)pro
cessed );
bt = catalog.getLocale( 11 );
bt += "|";
bt += catalog.getLocale( 8 );
int res = win->request( catalog.getLocale( 123 ),
msg.c_str(),
bt.c_str() );
if ( res == 0 ) {
for ( auto &program : removable_entries ) {
m_worker.removePathProgramPers( program );
}
} else {
return 1;
}
} else {
win->request( catalog.getLocale( 123 ),
catalog.getLocale( 1237),
catalog.getLocale( 633 ) );
return 1;
}
return 0;
}
int PathJumpUI::resetHeldEntries() int PathJumpUI::resetHeldEntries()
{ {
for ( auto &e : m_entries ) { for ( auto &e : m_entries ) {
e.m_always_ignore = false; e.m_always_ignore = false;
} }
return 0; return 0;
} }
void PathJumpUI::resetHeldEntriesAndUpdateUI() void PathJumpUI::resetHeldEntriesAndUpdateUI()
skipping to change at line 2451 skipping to change at line 3052
ignore = true; ignore = true;
} else { } else {
diff = m_current_time - diff; diff = m_current_time - diff;
} }
} catch (...) { } catch (...) {
} }
std::string t; std::string t;
if ( ! ignore ) { if ( ! ignore ) {
if ( diff < 60 ) { t = convert_time_diff_to_string( diff );
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1104 ),
(int)( diff / 60 ) );
} else if ( diff < 2 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1103 ),
(int)( diff / 60 ) );
} else if ( diff < 1 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1104 ),
(int)( diff / 60 ) );
} else if ( diff < 2 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1105 ),
(int)( diff / 60 / 60 ) );
} else if ( diff < 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1106 ),
(int)( diff / 60 / 60 ) );
} else if ( diff < 2 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1107 ),
(int)( diff / 60 / 60 / 24 ) );
} else if ( diff < 7 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1108 ),
(int)( diff / 60 / 60 / 24 ) );
} else if ( diff < 2 * 7 * 24 * 60 * 60 ) {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1109 ),
(int)( diff / 60 / 60 / 24 / 7 ) );
} else {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1110 ),
(int)( diff / 60 / 60 / 24 / 7 ) );
}
} }
data.text = t; data.text = t;
data.text_set = true; data.text_set = true;
} }
} }
void PathJumpUI::updateFilterLVData( int row, int field, void PathJumpUI::updateFilterLVData( int row, int field,
struct FieldListView::on_demand_data &data ) struct FieldListView::on_demand_data &data )
{ {
skipping to change at line 2530 skipping to change at line 3113
} else { } else {
t = AGUIXUtils::formatStringToString( catalog.getLocale( 1110 ), (int)( diff / 60 / 60 / 24 / 7 ) ); t = AGUIXUtils::formatStringToString( catalog.getLocale( 1110 ), (int)( diff / 60 / 60 / 24 / 7 ) );
} }
} }
data.text = t; data.text = t;
data.text_set = true; data.text_set = true;
} }
} }
void PathJumpUI::updateProgFileLVData( int row, int field,
struct FieldListView::on_demand_data &dat
a )
{
if ( field != 0 && field != 1 ) {
return;
}
int prog_row = m_lv_progs->getActiveRow();
if ( ! m_lv_progs->isValidRow( prog_row ) ) {
return;
}
auto current_program = m_lv_progs->getText( prog_row, 0 );
if ( m_program_paths.count( current_program ) == 0 ) {
return;
}
auto &path_list = m_program_paths[ current_program ];
if ( row < 0 ||
row >= (int)path_list.size() ) {
return;
}
try {
entry_existence_t e = path_list.at( row ).exists;
if ( field == 0 ) {
if ( e == EXISTS_UNKNOWN ) {
std::string path = path_list.at( row ).path;
auto f = std::async( std::launch::async,
[path] {
return NWC::FSEntry( path ).entryExists
();
} );
m_existence_tests_prog_path.push_back( std::make_tuple( std::mov
e( f ), row, true ) );
}
if ( e == EXISTS_YES ) {
data.text = "";
data.text_set = true;
} else if ( e == EXISTS_NO ) {
data.text = "";
data.text_set = true;
} else {
data.text = "?";
data.text_set = true;
}
} else if ( field == 1 ) {
if ( e == EXISTS_NO ) {
data.strike_out = true;
data.strike_out_set = true;
}
}
} catch (...) {
}
}
void PathJumpUI::checkExistance() void PathJumpUI::checkExistance()
{ {
std::list< std::string > non_existing_entries; std::list< std::string > non_existing_entries;
size_t elements = m_entries.size(); size_t elements = m_entries.size();
size_t processed = 0; size_t processed = 0;
time_t last_update = 0; time_t last_update = 0;
std::string orig_win_title = m_win->getTitle(); std::string orig_win_title = m_win->getTitle();
m_win->setCursor( AGUIX::WAIT_CURSOR ); m_win->setCursor( AGUIX::WAIT_CURSOR );
m_aguix.Flush(); m_aguix.Flush();
skipping to change at line 2684 skipping to change at line 3327
if ( status != std::future_status::ready ) { if ( status != std::future_status::ready ) {
auto f = std::move( std::get<0>( *it ) ); auto f = std::move( std::get<0>( *it ) );
m_worker.enqueueFuture( std::move( f ) ); m_worker.enqueueFuture( std::move( f ) );
} }
m_existence_tests.erase( it ); m_existence_tests.erase( it );
it = next_it; it = next_it;
} }
for ( auto it = m_existence_tests_prog_path.begin();
it != m_existence_tests_prog_path.end();
) {
std::future_status status = std::get<0>( *it ).wait_for( std::chrono::du
ration<int>::zero() );
auto next_it = it;
next_it++;
if ( status != std::future_status::ready ) {
auto f = std::move( std::get<0>( *it ) );
m_worker.enqueueFuture( std::move( f ) );
}
m_existence_tests_prog_path.erase( it );
it = next_it;
}
} }
 End of changes. 52 change blocks. 
59 lines changed or deleted 745 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)