Avoid duplicate icons when listing categories
This commit is contained in:
parent
becce0193e
commit
776a27bd10
102
src/desktop.c
102
src/desktop.c
@ -832,18 +832,18 @@ static void _alignment_vertical(Desktop * desktop)
|
|||||||
|
|
||||||
|
|
||||||
/* desktop_set_icons */
|
/* desktop_set_icons */
|
||||||
static void _icons_delete(Desktop * desktop);
|
|
||||||
static int _icons_applications(Desktop * desktop);
|
static int _icons_applications(Desktop * desktop);
|
||||||
static int _icons_categories(Desktop * desktop);
|
static int _icons_categories(Desktop * desktop);
|
||||||
static int _icons_files(Desktop * desktop);
|
static int _icons_files(Desktop * desktop);
|
||||||
static int _icons_files_add_home(Desktop * desktop);
|
static int _icons_files_add_home(Desktop * desktop);
|
||||||
static int _icons_homescreen(Desktop * desktop);
|
static int _icons_homescreen(Desktop * desktop);
|
||||||
|
static void _icons_reset(Desktop * desktop);
|
||||||
static void _icons_set_categories(Desktop * desktop, gpointer data);
|
static void _icons_set_categories(Desktop * desktop, gpointer data);
|
||||||
static void _icons_set_homescreen(Desktop * desktop, gpointer data);
|
static void _icons_set_homescreen(Desktop * desktop, gpointer data);
|
||||||
|
|
||||||
void desktop_set_icons(Desktop * desktop, DesktopIcons icons)
|
void desktop_set_icons(Desktop * desktop, DesktopIcons icons)
|
||||||
{
|
{
|
||||||
_icons_delete(desktop);
|
_icons_reset(desktop);
|
||||||
desktop->prefs.icons = icons;
|
desktop->prefs.icons = icons;
|
||||||
switch(icons)
|
switch(icons)
|
||||||
{
|
{
|
||||||
@ -866,23 +866,6 @@ void desktop_set_icons(Desktop * desktop, DesktopIcons icons)
|
|||||||
desktop_refresh(desktop);
|
desktop_refresh(desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _icons_delete(Desktop * desktop)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if(desktop->path != NULL)
|
|
||||||
free(desktop->path);
|
|
||||||
desktop->path = NULL;
|
|
||||||
desktop->path_cnt = 0;
|
|
||||||
for(i = 0; i < desktop->icon_cnt; i++)
|
|
||||||
{
|
|
||||||
desktopicon_set_immutable(desktop->icon[i], FALSE);
|
|
||||||
desktopicon_set_updated(desktop->icon[i], FALSE);
|
|
||||||
}
|
|
||||||
for(i = 0; i < _desktop_categories_cnt; i++)
|
|
||||||
_desktop_categories[i].show = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _icons_applications(Desktop * desktop)
|
static int _icons_applications(Desktop * desktop)
|
||||||
{
|
{
|
||||||
DesktopIcon * desktopicon;
|
DesktopIcon * desktopicon;
|
||||||
@ -1016,6 +999,23 @@ static int _icons_homescreen(Desktop * desktop)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _icons_reset(Desktop * desktop)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if(desktop->path != NULL)
|
||||||
|
free(desktop->path);
|
||||||
|
desktop->path = NULL;
|
||||||
|
desktop->path_cnt = 0;
|
||||||
|
for(i = 0; i < desktop->icon_cnt; i++)
|
||||||
|
{
|
||||||
|
desktopicon_set_immutable(desktop->icon[i], FALSE);
|
||||||
|
desktopicon_set_updated(desktop->icon[i], FALSE);
|
||||||
|
}
|
||||||
|
for(i = 0; i < _desktop_categories_cnt; i++)
|
||||||
|
_desktop_categories[i].show = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void _icons_set_categories(Desktop * desktop, gpointer data)
|
static void _icons_set_categories(Desktop * desktop, gpointer data)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1077,6 +1077,7 @@ int desktop_error(Desktop * desktop, char const * message, int ret)
|
|||||||
|
|
||||||
|
|
||||||
/* desktop_refresh */
|
/* desktop_refresh */
|
||||||
|
static void _current_cleanup(Desktop * desktop);
|
||||||
static int _current_loop(Desktop * desktop);
|
static int _current_loop(Desktop * desktop);
|
||||||
static int _current_loop_applications(Desktop * desktop);
|
static int _current_loop_applications(Desktop * desktop);
|
||||||
static int _current_loop_applications_path(Desktop * desktop,
|
static int _current_loop_applications_path(Desktop * desktop,
|
||||||
@ -1104,20 +1105,49 @@ void desktop_refresh(Desktop * desktop)
|
|||||||
#endif
|
#endif
|
||||||
if(desktop->refresh_source != 0)
|
if(desktop->refresh_source != 0)
|
||||||
g_source_remove(desktop->refresh_source);
|
g_source_remove(desktop->refresh_source);
|
||||||
if(desktop->path == NULL)
|
switch(desktop->prefs.icons)
|
||||||
{
|
{
|
||||||
desktop->refresh_source = g_idle_add(_current_idle, desktop);
|
case DESKTOP_ICONS_CATEGORIES:
|
||||||
return;
|
g_slist_foreach(desktop->apps, (GFunc)config_delete,
|
||||||
|
NULL);
|
||||||
|
g_slist_free(desktop->apps);
|
||||||
|
desktop->apps = NULL;
|
||||||
|
/* fallback */
|
||||||
|
case DESKTOP_ICONS_APPLICATIONS:
|
||||||
|
case DESKTOP_ICONS_HOMESCREEN:
|
||||||
|
case DESKTOP_ICONS_NONE:
|
||||||
|
desktop->refresh_source = g_idle_add(_current_idle,
|
||||||
|
desktop);
|
||||||
|
break;
|
||||||
|
case DESKTOP_ICONS_FILES:
|
||||||
|
if(desktop->path == NULL)
|
||||||
|
break;
|
||||||
|
if((desktop->refresh_dir = browser_vfs_opendir(
|
||||||
|
desktop->path, &st))
|
||||||
|
== NULL)
|
||||||
|
{
|
||||||
|
desktop_error(NULL, desktop->path, 1);
|
||||||
|
desktop->refresh_source = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
desktop->refresh_mti = st.st_mtime;
|
||||||
|
desktop->refresh_source = g_idle_add(_current_idle,
|
||||||
|
desktop);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
desktop->refresh_source = 0;
|
}
|
||||||
if((desktop->refresh_dir = browser_vfs_opendir(desktop->path, &st))
|
|
||||||
== NULL)
|
static void _current_cleanup(Desktop * desktop)
|
||||||
{
|
{
|
||||||
desktop_error(NULL, desktop->path, 0);
|
size_t i;
|
||||||
return;
|
|
||||||
}
|
for(i = 0; i < desktop->icon_cnt;)
|
||||||
desktop->refresh_mti = st.st_mtime;
|
if(desktopicon_get_immutable(desktop->icon[i]) == TRUE)
|
||||||
desktop->refresh_source = g_idle_add(_current_idle, desktop);
|
i++;
|
||||||
|
else if(desktopicon_get_updated(desktop->icon[i]) != TRUE)
|
||||||
|
_desktop_icon_remove(desktop, desktop->icon[i]);
|
||||||
|
else
|
||||||
|
desktopicon_set_updated(desktop->icon[i++], FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _current_loop(Desktop * desktop)
|
static int _current_loop(Desktop * desktop)
|
||||||
@ -1383,8 +1413,6 @@ static gboolean _current_idle(gpointer data)
|
|||||||
|
|
||||||
static gboolean _current_done(Desktop * desktop)
|
static gboolean _current_done(Desktop * desktop)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
switch(desktop->prefs.icons)
|
switch(desktop->prefs.icons)
|
||||||
{
|
{
|
||||||
case DESKTOP_ICONS_CATEGORIES:
|
case DESKTOP_ICONS_CATEGORIES:
|
||||||
@ -1393,13 +1421,7 @@ static gboolean _current_done(Desktop * desktop)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while(i < desktop->icon_cnt)
|
_current_cleanup(desktop);
|
||||||
if(desktopicon_get_immutable(desktop->icon[i]) == TRUE)
|
|
||||||
i++;
|
|
||||||
else if(desktopicon_get_updated(desktop->icon[i]) != TRUE)
|
|
||||||
_desktop_icon_remove(desktop, desktop->icon[i]);
|
|
||||||
else
|
|
||||||
desktopicon_set_updated(desktop->icon[i++], FALSE);
|
|
||||||
if(desktop->refresh_dir != NULL)
|
if(desktop->refresh_dir != NULL)
|
||||||
browser_vfs_closedir(desktop->refresh_dir);
|
browser_vfs_closedir(desktop->refresh_dir);
|
||||||
desktop->refresh_dir = NULL;
|
desktop->refresh_dir = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user