diff options
Diffstat (limited to 'apps/plugins/shortcuts/shortcuts_view.c')
-rw-r--r-- | apps/plugins/shortcuts/shortcuts_view.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index 2a7970bebe..187ed740a1 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c | |||
@@ -32,7 +32,7 @@ enum sc_list_action_type | |||
32 | SCLA_USB, | 32 | SCLA_USB, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | 35 | static size_t root_len; | |
36 | static char *link_filename; | 36 | static char *link_filename; |
37 | static bool user_file; | 37 | static bool user_file; |
38 | 38 | ||
@@ -175,6 +175,42 @@ bool goto_entry(char *file_or_dir) | |||
175 | } | 175 | } |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | static bool callback_show_item(char *name, int attr, struct tree_context *tc) | ||
179 | { | ||
180 | (void)name; | ||
181 | if(attr & ATTR_DIRECTORY) | ||
182 | { | ||
183 | if ((tc->browse->flags & BROWSE_SELECTED) == 0 && | ||
184 | rb->strlen(tc->currdir) < root_len) | ||
185 | { | ||
186 | tc->is_browsing = false; /* exit immediately */ | ||
187 | } | ||
188 | } | ||
189 | |||
190 | return true; | ||
191 | } | ||
192 | |||
193 | bool open_browse(char *path, char *buf, size_t bufsz) | ||
194 | { | ||
195 | struct browse_context browse = { | ||
196 | .dirfilter = rb->global_settings->dirfilter, | ||
197 | .flags = BROWSE_DIRFILTER| BROWSE_SELECTONLY | BROWSE_NO_CONTEXT_MENU, | ||
198 | .title = path, | ||
199 | .icon = Icon_Plugin, | ||
200 | .root = path, | ||
201 | .buf = buf, | ||
202 | .bufsize = bufsz, | ||
203 | .callback_show_item = callback_show_item, | ||
204 | }; | ||
205 | root_len = 0; | ||
206 | char *name = rb->strrchr(path, '/'); | ||
207 | if (name) | ||
208 | root_len = name - path; | ||
209 | rb->rockbox_browse(&browse); | ||
210 | |||
211 | return (browse.flags & BROWSE_SELECTED); | ||
212 | } | ||
213 | |||
178 | int goto_entry(char *file_or_dir) | 214 | int goto_entry(char *file_or_dir) |
179 | { | 215 | { |
180 | DEBUGF("Trying to go to '%s'...\n", file_or_dir); | 216 | DEBUGF("Trying to go to '%s'...\n", file_or_dir); |
@@ -202,14 +238,18 @@ int goto_entry(char *file_or_dir) | |||
202 | } | 238 | } |
203 | else | 239 | else |
204 | { | 240 | { |
205 | /* Set the browsers dirfilter to the global setting | 241 | if (!is_dir) |
206 | * This is required in case the plugin was launched | 242 | { |
207 | * from the plugins browser, in which case the | 243 | rb->set_current_file(file_or_dir); |
208 | * dirfilter is set to only display .rock files */ | 244 | return LOOP_EXIT; |
209 | rb->set_dirfilter(rb->global_settings->dirfilter); | 245 | } |
210 | 246 | char tmp_buf[MAX_PATH]; | |
211 | /* Change directory to the entry selected by the user */ | 247 | if (open_browse(file_or_dir, tmp_buf, sizeof(tmp_buf))) |
212 | rb->set_current_file(file_or_dir); | 248 | { |
249 | DEBUGF("Trying to load '%s'...\n", tmp_buf); | ||
250 | rb->set_current_file(tmp_buf); | ||
251 | return LOOP_EXIT; | ||
252 | } | ||
213 | } | 253 | } |
214 | return PLUGIN_OK; | 254 | return PLUGIN_OK; |
215 | } | 255 | } |