[awesome-menu] item_list_fill_file() now returns a Bool and support for ~ as directory
This commit is contained in:
parent
9d14cca8e0
commit
df8e3abf50
|
@ -190,10 +190,10 @@ get_last_word(char *text)
|
||||||
return last_word;
|
return last_word;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Bool
|
||||||
item_list_fill_file(const char *directory)
|
item_list_fill_file(const char *directory)
|
||||||
{
|
{
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX], *special_opendir_name = NULL;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *dirinfo;
|
struct dirent *dirinfo;
|
||||||
item_t *item;
|
item_t *item;
|
||||||
|
@ -202,12 +202,21 @@ item_list_fill_file(const char *directory)
|
||||||
item_list_wipe(&globalconf.items);
|
item_list_wipe(&globalconf.items);
|
||||||
|
|
||||||
if(a_strlen(directory))
|
if(a_strlen(directory))
|
||||||
|
{
|
||||||
|
if(directory[0] == '~')
|
||||||
|
special_opendir_name = getenv("HOME");
|
||||||
a_strcpy(cwd, sizeof(cwd), directory);
|
a_strcpy(cwd, sizeof(cwd), directory);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
a_strcpy(cwd, sizeof(cwd), ".");
|
a_strcpy(cwd, sizeof(cwd), ".");
|
||||||
|
|
||||||
if(!(dir = opendir(cwd)))
|
if(special_opendir_name)
|
||||||
return;
|
{
|
||||||
|
if(!(dir = opendir(special_opendir_name)))
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
else if(!(dir = opendir(cwd)))
|
||||||
|
return False;
|
||||||
|
|
||||||
while((dirinfo = readdir(dir)))
|
while((dirinfo = readdir(dir)))
|
||||||
{
|
{
|
||||||
|
@ -221,6 +230,8 @@ item_list_fill_file(const char *directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -266,6 +277,7 @@ compute_match(const char *word)
|
||||||
if(word[len - 1] == '/'
|
if(word[len - 1] == '/'
|
||||||
|| word[len - 1] == ' ')
|
|| word[len - 1] == ' ')
|
||||||
item_list_fill_file(word);
|
item_list_fill_file(word);
|
||||||
|
|
||||||
for(item = globalconf.items; item; item = item->next)
|
for(item = globalconf.items; item; item = item->next)
|
||||||
if(!a_strncmp(word, item->data, a_strlen(word)))
|
if(!a_strncmp(word, item->data, a_strlen(word)))
|
||||||
item->match = True;
|
item->match = True;
|
||||||
|
|
Loading…
Reference in New Issue