aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_browser.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-03 11:56:00 +0200
committerMax Kellermann <max@duempel.org>2008-10-03 11:56:00 +0200
commit4ca0f663a918fc04389ff4351b596209902bd11c (patch)
treef96185f6b9ad29c5d6095f5da8f9903b4923c2d4 /src/screen_browser.c
parente2c8e28ef7ccda32fb32792b086c40144df2a916 (diff)
downloadmpd-4ca0f663a918fc04389ff4351b596209902bd11c.tar.gz
mpd-4ca0f663a918fc04389ff4351b596209902bd11c.tar.xz
mpd-4ca0f663a918fc04389ff4351b596209902bd11c.zip
list_window: remove list_window_state_t
We do not need to save a stack of list window states. When we return to a parent directory, we just have to find the directory which we come from in the parent list. Note that this patch resets the cursor when going to the root directory, but I think it's not that important, and I will deal with that later.
Diffstat (limited to '')
-rw-r--r--src/screen_browser.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/screen_browser.c b/src/screen_browser.c
index da0dc897c..4457e7e59 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -164,6 +164,8 @@ browser_change_directory(struct screen_browser *browser, mpdclient_t *c,
{
mpd_InfoEntity *entity = NULL;
gchar *path = NULL;
+ char *old_path;
+ int idx;
if( entry!=NULL )
entity = entry->entity;
@@ -177,29 +179,33 @@ browser_change_directory(struct screen_browser *browser, mpdclient_t *c,
if( strcmp(parent, ".") == 0 )
parent[0] = '\0';
path = g_strdup(parent);
- list_window_reset(browser->lw);
- /* restore previous list window state */
- list_window_pop_state(browser->lw_state, browser->lw);
} else {
/* entry==NULL, then new_path ("" is root) */
path = g_strdup(new_path);
- list_window_reset(browser->lw);
- /* restore first list window state (pop while returning true) */
- while(list_window_pop_state(browser->lw_state, browser->lw));
}
} else if( entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY) {
/* enter sub */
mpd_Directory *dir = entity->info.directory;
path = utf8_to_locale(dir->path);
- /* save current list window state */
- list_window_push_state(browser->lw_state, browser->lw);
} else
return -1;
+ old_path = g_strdup(browser->filelist->path);
+
filelist_free(browser->filelist);
browser->filelist = mpdclient_filelist_get(c, path);
sync_highlights(c, browser->filelist);
- list_window_check_selected(browser->lw, filelist_length(browser->filelist));
+
+ idx = filelist_find_directory(browser->filelist, old_path);
+ g_free(old_path);
+
+ list_window_reset(browser->lw);
+ if (idx >= 0) {
+ list_window_set_selected(browser->lw, idx);
+ list_window_center(browser->lw,
+ filelist_length(browser->filelist), idx);
+ }
+
g_free(path);
return 0;
}