Bring the separate handlers on par with the original code
At least from my understanding at the moment.
This commit is contained in:
parent
fd233fa9e2
commit
7979661917
|
@ -78,6 +78,7 @@ struct _Desktop
|
|||
GdkRectangle workarea;
|
||||
|
||||
/* icons */
|
||||
DesktopAlignment alignment;
|
||||
GtkIconTheme * theme;
|
||||
unsigned int icons_size;
|
||||
DesktopIconWindow ** icons;
|
||||
|
@ -184,9 +185,6 @@ static void _desktop_draw_background(Desktop * desktop, GdkColor * color,
|
|||
char const * filename, DesktopHows how, gboolean extend);
|
||||
#endif
|
||||
|
||||
static int _desktop_icon_add(Desktop * desktop, DesktopIcon * icon);
|
||||
static int _desktop_icon_remove(Desktop * desktop, DesktopIcon * icon);
|
||||
|
||||
/* callbacks */
|
||||
static gboolean _desktop_on_preferences_closex(gpointer data);
|
||||
static void _desktop_on_preferences_monitors_changed(gpointer data);
|
||||
|
@ -405,6 +403,7 @@ static int _on_message(void * data, uint32_t value1, uint32_t value2,
|
|||
case DESKTOP_MESSAGE_SET_ALIGNMENT:
|
||||
alignment = value2;
|
||||
desktop_set_alignment(desktop, alignment);
|
||||
desktop_icons_align(desktop);
|
||||
break;
|
||||
case DESKTOP_MESSAGE_SET_ICONS:
|
||||
icons = value2;
|
||||
|
@ -590,8 +589,9 @@ static GdkFilterReturn _event_property(XPropertyEvent * xevent,
|
|||
/* desktop_delete */
|
||||
void desktop_delete(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if(desktop->refresh_source != 0)
|
||||
g_source_remove(desktop->refresh_source);
|
||||
desktop_icons_remove_all(desktop);
|
||||
if(desktop->handler != NULL)
|
||||
desktophandler_delete(desktop->handler);
|
||||
if(desktop->folder != NULL)
|
||||
|
@ -602,11 +602,6 @@ void desktop_delete(Desktop * desktop)
|
|||
mime_delete(desktop->mime);
|
||||
if(desktop->desktop != NULL)
|
||||
gtk_widget_destroy(desktop->desktop);
|
||||
if(desktop->refresh_source != 0)
|
||||
g_source_remove(desktop->refresh_source);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
desktopiconwindow_delete(desktop->icons[i]);
|
||||
free(desktop->icons);
|
||||
if(desktop->font != NULL)
|
||||
pango_font_description_free(desktop->font);
|
||||
object_delete(desktop);
|
||||
|
@ -669,6 +664,13 @@ GdkPixbuf * desktop_get_folder(Desktop * desktop)
|
|||
}
|
||||
|
||||
|
||||
/* desktop_get_handler */
|
||||
DesktopHandler * desktop_get_handler(Desktop * desktop)
|
||||
{
|
||||
return desktop->handler;
|
||||
}
|
||||
|
||||
|
||||
/* desktop_get_home */
|
||||
String const * desktop_get_home(Desktop * desktop)
|
||||
{
|
||||
|
@ -749,64 +751,9 @@ GtkWidget * desktop_get_window(Desktop * desktop)
|
|||
|
||||
|
||||
/* desktop_set_alignment */
|
||||
static void _alignment_horizontal(Desktop * desktop);
|
||||
static void _alignment_vertical(Desktop * desktop);
|
||||
|
||||
void desktop_set_alignment(Desktop * desktop, DesktopAlignment alignment)
|
||||
{
|
||||
switch(alignment)
|
||||
{
|
||||
case DESKTOP_ALIGNMENT_VERTICAL:
|
||||
_alignment_vertical(desktop);
|
||||
break;
|
||||
case DESKTOP_ALIGNMENT_HORIZONTAL:
|
||||
_alignment_horizontal(desktop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void _alignment_horizontal(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int x = desktop->workarea.x;
|
||||
unsigned int y = desktop->workarea.y;
|
||||
unsigned int width = x + desktop->workarea.width;
|
||||
unsigned int iwidth;
|
||||
unsigned int iheight;
|
||||
|
||||
desktop_get_icon_size(desktop, &iwidth, &iheight, NULL);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
if(x + iwidth > width)
|
||||
{
|
||||
y += iheight;
|
||||
x = desktop->workarea.x;
|
||||
}
|
||||
desktopiconwindow_move(desktop->icons[i], x, y);
|
||||
x += iwidth;
|
||||
}
|
||||
}
|
||||
|
||||
static void _alignment_vertical(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int x = desktop->workarea.x;
|
||||
unsigned int y = desktop->workarea.y;
|
||||
unsigned int height = desktop->workarea.y + desktop->workarea.height;
|
||||
unsigned int iwidth;
|
||||
unsigned int iheight;
|
||||
|
||||
desktop_get_icon_size(desktop, &iwidth, &iheight, NULL);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
if(y + iheight > height)
|
||||
{
|
||||
x += iwidth;
|
||||
y = desktop->workarea.y;
|
||||
}
|
||||
desktopiconwindow_move(desktop->icons[i], x, y);
|
||||
y += iheight;
|
||||
}
|
||||
desktop->alignment = alignment;
|
||||
}
|
||||
|
||||
|
||||
|
@ -854,28 +801,6 @@ int desktop_set_layout(Desktop * desktop, DesktopLayout layout)
|
|||
|
||||
|
||||
/* useful */
|
||||
/* desktop_cleanup */
|
||||
void desktop_cleanup(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
DesktopIcon * icon;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt;)
|
||||
{
|
||||
icon = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
if(desktopicon_get_immutable(icon) == TRUE)
|
||||
i++;
|
||||
else if(desktopicon_get_updated(icon) != TRUE)
|
||||
_desktop_icon_remove(desktop, icon);
|
||||
else
|
||||
{
|
||||
desktopicon_set_updated(icon, FALSE);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* desktop_error */
|
||||
int desktop_error(Desktop * desktop, char const * message, char const * error,
|
||||
int ret)
|
||||
|
@ -899,8 +824,6 @@ int desktop_serror(Desktop * desktop, char const * message, int ret)
|
|||
|
||||
|
||||
/* desktop_refresh */
|
||||
static void _refresh_reset(Desktop * desktop);
|
||||
/* callbacks */
|
||||
static gboolean _refresh_on_idle(gpointer data);
|
||||
|
||||
void desktop_refresh(Desktop * desktop)
|
||||
|
@ -913,26 +836,18 @@ void desktop_refresh(Desktop * desktop)
|
|||
desktop->refresh_source = g_idle_add(_refresh_on_idle, desktop);
|
||||
}
|
||||
|
||||
static void _refresh_reset(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
DesktopIcon * icon;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
icon = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
desktopicon_set_immutable(icon, FALSE);
|
||||
desktopicon_set_updated(icon, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* callbacks */
|
||||
static gboolean _refresh_on_idle(gpointer data)
|
||||
{
|
||||
Desktop * desktop = data;
|
||||
size_t i;
|
||||
DesktopIcon * icon;
|
||||
|
||||
desktop->refresh_source = 0;
|
||||
_refresh_reset(desktop);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
icon = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
desktopicon_set_updated(icon, FALSE);
|
||||
}
|
||||
desktophandler_refresh(desktop->handler);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1124,27 +1039,83 @@ static gboolean _reset_on_idle(gpointer data)
|
|||
/* desktop_icon_add */
|
||||
void desktop_icon_add(Desktop * desktop, DesktopIcon * icon, gboolean align)
|
||||
{
|
||||
if(_desktop_icon_add(desktop, icon) == 0 && align)
|
||||
DesktopIconWindow * window;
|
||||
DesktopIconWindow ** p;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\", %s)\n", __func__,
|
||||
desktopicon_get_name(icon),
|
||||
align ? "TRUE" : "FALSE");
|
||||
#endif
|
||||
if((p = realloc(desktop->icons, sizeof(*p) * (desktop->icons_cnt + 1)))
|
||||
== NULL)
|
||||
{
|
||||
desktop_perror(desktop, desktopicon_get_name(icon), 1);
|
||||
return;
|
||||
}
|
||||
desktop->icons = p;
|
||||
if((window = desktopiconwindow_new(icon)) == NULL)
|
||||
{
|
||||
desktop_serror(desktop, desktopicon_get_name(icon), 1);
|
||||
return;
|
||||
}
|
||||
desktop->icons[desktop->icons_cnt++] = window;
|
||||
desktopicon_set_background(icon, &desktop->background);
|
||||
desktopicon_set_font(icon, desktop->font);
|
||||
desktopicon_set_foreground(icon, &desktop->foreground);
|
||||
if(align)
|
||||
desktop_icons_align(desktop);
|
||||
desktopiconwindow_show(window);
|
||||
}
|
||||
|
||||
|
||||
/* desktop_icon_remove */
|
||||
void desktop_icon_remove(Desktop * desktop, DesktopIcon * icon)
|
||||
int desktop_icon_remove(Desktop * desktop, DesktopIcon * icon, gboolean align)
|
||||
{
|
||||
if(_desktop_icon_remove(desktop, icon) == 0)
|
||||
desktop_icons_align(desktop);
|
||||
size_t i;
|
||||
DesktopIcon * j;
|
||||
DesktopIconWindow ** p;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
j = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
if(j != icon)
|
||||
continue;
|
||||
desktopiconwindow_delete(desktop->icons[i]);
|
||||
for(desktop->icons_cnt--; i < desktop->icons_cnt; i++)
|
||||
desktop->icons[i] = desktop->icons[i + 1];
|
||||
if((p = realloc(desktop->icons, sizeof(*p)
|
||||
* (desktop->icons_cnt)))
|
||||
!= NULL)
|
||||
desktop->icons = p; /* we can ignore errors... */
|
||||
else if(desktop->icons_cnt == 0)
|
||||
desktop->icons = NULL; /* ...except when it's not one */
|
||||
if(align)
|
||||
desktop_icons_align(desktop);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* desktop_icons_align */
|
||||
static int _align_compare(const void * a, const void * b);
|
||||
static void _align_horizontal(Desktop * desktop);
|
||||
static void _align_vertical(Desktop * desktop);
|
||||
|
||||
void desktop_icons_align(Desktop * desktop)
|
||||
{
|
||||
qsort(desktop->icons, desktop->icons_cnt, sizeof(void *),
|
||||
_align_compare);
|
||||
desktop_set_alignment(desktop, desktop->prefs.alignment);
|
||||
switch(desktop->alignment)
|
||||
{
|
||||
case DESKTOP_ALIGNMENT_VERTICAL:
|
||||
_align_vertical(desktop);
|
||||
break;
|
||||
case DESKTOP_ALIGNMENT_HORIZONTAL:
|
||||
_align_horizontal(desktop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int _align_compare(const void * a, const void * b)
|
||||
|
@ -1175,6 +1146,74 @@ static int _align_compare(const void * a, const void * b)
|
|||
return strcmp(desktopicon_get_name(icona), desktopicon_get_name(iconb));
|
||||
}
|
||||
|
||||
static void _align_horizontal(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int x = desktop->workarea.x;
|
||||
unsigned int y = desktop->workarea.y;
|
||||
unsigned int width = x + desktop->workarea.width;
|
||||
unsigned int iwidth;
|
||||
unsigned int iheight;
|
||||
|
||||
desktop_get_icon_size(desktop, &iwidth, &iheight, NULL);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
if(x + iwidth > width)
|
||||
{
|
||||
y += iheight;
|
||||
x = desktop->workarea.x;
|
||||
}
|
||||
desktopiconwindow_move(desktop->icons[i], x, y);
|
||||
x += iwidth;
|
||||
}
|
||||
}
|
||||
|
||||
static void _align_vertical(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
unsigned int x = desktop->workarea.x;
|
||||
unsigned int y = desktop->workarea.y;
|
||||
unsigned int height = desktop->workarea.y + desktop->workarea.height;
|
||||
unsigned int iwidth;
|
||||
unsigned int iheight;
|
||||
|
||||
desktop_get_icon_size(desktop, &iwidth, &iheight, NULL);
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
if(y + iheight > height)
|
||||
{
|
||||
x += iwidth;
|
||||
y = desktop->workarea.y;
|
||||
}
|
||||
desktopiconwindow_move(desktop->icons[i], x, y);
|
||||
y += iheight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* desktop_icons_cleanup */
|
||||
void desktop_icons_cleanup(Desktop * desktop, gboolean align)
|
||||
{
|
||||
size_t i;
|
||||
DesktopIcon * icon;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt;)
|
||||
{
|
||||
icon = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
if(desktopicon_get_immutable(icon) == TRUE)
|
||||
i++;
|
||||
else if(desktopicon_get_updated(icon) != TRUE)
|
||||
desktop_icon_remove(desktop, icon, FALSE);
|
||||
else
|
||||
{
|
||||
desktopicon_set_updated(icon, FALSE);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if(align)
|
||||
desktop_icons_align(desktop);
|
||||
}
|
||||
|
||||
|
||||
/* desktop_icons_lookup */
|
||||
DesktopIcon * desktop_icons_lookup(Desktop * desktop, String const * name)
|
||||
|
@ -1199,6 +1238,19 @@ DesktopIcon * desktop_icons_lookup(Desktop * desktop, String const * name)
|
|||
}
|
||||
|
||||
|
||||
/* desktop_icons_remove_all */
|
||||
void desktop_icons_remove_all(Desktop * desktop)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
desktopiconwindow_delete(desktop->icons[i]);
|
||||
desktop->icons_cnt = 0;
|
||||
free(desktop->icons);
|
||||
desktop->icons = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* desktop_select_all */
|
||||
void desktop_select_all(Desktop * desktop)
|
||||
{
|
||||
|
@ -2214,54 +2266,6 @@ static void _background_monitors(Desktop * desktop, char const * filename,
|
|||
}
|
||||
|
||||
|
||||
/* desktop_icon_add */
|
||||
static int _desktop_icon_add(Desktop * desktop, DesktopIcon * icon)
|
||||
{
|
||||
DesktopIconWindow * window;
|
||||
DesktopIconWindow ** p;
|
||||
|
||||
if((p = realloc(desktop->icons, sizeof(*p) * (desktop->icons_cnt + 1)))
|
||||
== NULL)
|
||||
return -desktop_perror(desktop, desktopicon_get_name(icon), 1);
|
||||
desktop->icons = p;
|
||||
if((window = desktopiconwindow_new(icon)) == NULL)
|
||||
return -desktop_serror(desktop, desktopicon_get_name(icon), 1);
|
||||
desktop->icons[desktop->icons_cnt++] = window;
|
||||
desktopicon_set_background(icon, &desktop->background);
|
||||
desktopicon_set_font(icon, desktop->font);
|
||||
desktopicon_set_foreground(icon, &desktop->foreground);
|
||||
desktopiconwindow_show(window);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* desktop_icon_remove */
|
||||
static int _desktop_icon_remove(Desktop * desktop, DesktopIcon * icon)
|
||||
{
|
||||
size_t i;
|
||||
DesktopIcon * j;
|
||||
DesktopIconWindow ** p;
|
||||
|
||||
for(i = 0; i < desktop->icons_cnt; i++)
|
||||
{
|
||||
j = desktopiconwindow_get_icon(desktop->icons[i]);
|
||||
if(j != icon)
|
||||
continue;
|
||||
desktopiconwindow_delete(desktop->icons[i]);
|
||||
for(desktop->icons_cnt--; i < desktop->icons_cnt; i++)
|
||||
desktop->icons[i] = desktop->icons[i + 1];
|
||||
if((p = realloc(desktop->icons, sizeof(*p)
|
||||
* (desktop->icons_cnt)))
|
||||
!= NULL)
|
||||
desktop->icons = p; /* we can ignore errors... */
|
||||
else if(desktop->icons_cnt == 0)
|
||||
desktop->icons = NULL; /* ...except when it's not one */
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* desktop_on_preferences_closex */
|
||||
static gboolean _desktop_on_preferences_closex(gpointer data)
|
||||
|
|
|
@ -55,6 +55,7 @@ void desktop_delete(Desktop * desktop);
|
|||
int desktop_get_drag_data(Desktop * desktop, GtkSelectionData * seldata);
|
||||
GdkPixbuf * desktop_get_file(Desktop * desktop);
|
||||
GdkPixbuf * desktop_get_folder(Desktop * desktop);
|
||||
DesktopHandler * desktop_get_handler(Desktop * desktop);
|
||||
String const * desktop_get_home(Desktop * desktop);
|
||||
void desktop_get_icon_size(Desktop * desktop, unsigned int * width,
|
||||
unsigned int * height, unsigned int * size);
|
||||
|
@ -77,11 +78,12 @@ void desktop_refresh(Desktop * desktop);
|
|||
void desktop_reset(Desktop * desktop);
|
||||
|
||||
void desktop_icon_add(Desktop * desktop, DesktopIcon * icon, gboolean align);
|
||||
void desktop_icon_remove(Desktop * desktop, DesktopIcon * icon);
|
||||
int desktop_icon_remove(Desktop * desktop, DesktopIcon * icon, gboolean align);
|
||||
|
||||
void desktop_cleanup(Desktop * desktop);
|
||||
void desktop_icons_align(Desktop * desktop);
|
||||
void desktop_icons_cleanup(Desktop * desktop, gboolean align);
|
||||
DesktopIcon * desktop_icons_lookup(Desktop * desktop, String const * name);
|
||||
void desktop_icons_remove_all(Desktop * desktop);
|
||||
void desktop_icons_sort(Desktop * desktop);
|
||||
|
||||
void desktop_select_all(Desktop * desktop);
|
||||
|
|
|
@ -58,36 +58,42 @@ typedef struct _DesktopCategory
|
|||
char const * icon;
|
||||
} DesktopCategory;
|
||||
|
||||
typedef struct _DesktopHandlerApplications
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
GSList * apps;
|
||||
DesktopCategory * category;
|
||||
} DesktopHandlerApplications;
|
||||
|
||||
typedef struct _DesktopHandlerCategories
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
GSList * apps;
|
||||
} DesktopHandlerCategories;
|
||||
|
||||
typedef struct _DesktopHandlerFiles
|
||||
{
|
||||
char * path;
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
gboolean show_hidden;
|
||||
GtkWidget * menu;
|
||||
} DesktopHandlerFiles;
|
||||
|
||||
struct _DesktopHandler
|
||||
{
|
||||
Desktop * desktop;
|
||||
DesktopIcons icons;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
char * path;
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
gboolean show_hidden;
|
||||
GtkWidget * menu;
|
||||
} files;
|
||||
struct
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
DesktopCategory * category;
|
||||
GSList * apps;
|
||||
} applications;
|
||||
struct
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
GSList * apps;
|
||||
} categories;
|
||||
DesktopHandlerApplications applications;
|
||||
DesktopHandlerCategories categories;
|
||||
DesktopHandlerFiles files;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
@ -104,24 +110,6 @@ struct _DesktopHandler
|
|||
|
||||
#define IDLE_LOOP_ICON_CNT 16 /* number of icons added in a loop */
|
||||
|
||||
static DesktopCategory _desktop_categories[] =
|
||||
{
|
||||
{ FALSE, "Audio", N_("Audio"), "gnome-mime-audio", },
|
||||
{ FALSE, "Development", N_("Development"),"applications-development"},
|
||||
{ FALSE, "Education", N_("Education"),"applications-science" },
|
||||
{ FALSE, "Game", N_("Games"), "applications-games" },
|
||||
{ FALSE, "Graphics", N_("Graphics"), "applications-graphics" },
|
||||
{ FALSE, "AudioVideo", N_("Multimedia"),"applications-multimedia"},
|
||||
{ FALSE, "Network", N_("Network"), "applications-internet" },
|
||||
{ FALSE, "Office", N_("Office"), "applications-office" },
|
||||
{ FALSE, "Settings", N_("Settings"), "gnome-settings" },
|
||||
{ FALSE, "System", N_("System"), "applications-system" },
|
||||
{ FALSE, "Utility", N_("Utilities"),"applications-utilities"},
|
||||
{ FALSE, "Video", N_("Video"), "video" }
|
||||
};
|
||||
static const size_t _desktop_categories_cnt = sizeof(_desktop_categories)
|
||||
/ sizeof(*_desktop_categories);
|
||||
|
||||
|
||||
#include "handler/applications.c"
|
||||
#include "handler/categories.c"
|
||||
|
@ -161,7 +149,7 @@ void desktophandler_set_icons(DesktopHandler * handler, DesktopIcons icons)
|
|||
{
|
||||
if(handler->icons != icons)
|
||||
{
|
||||
desktop_cleanup(handler->desktop);
|
||||
desktop_icons_remove_all(handler->desktop);
|
||||
_set_icons_destroy(handler);
|
||||
handler->icons = icons;
|
||||
_set_icons_init(handler);
|
||||
|
|
|
@ -48,15 +48,17 @@ static void _desktophandler_applications_init(DesktopHandler * handler)
|
|||
handler->u.applications.refresh_dir = NULL;
|
||||
handler->u.applications.refresh_mtime = 0;
|
||||
handler->u.applications.refresh_source = 0;
|
||||
handler->u.applications.category = NULL;
|
||||
handler->u.applications.apps = NULL;
|
||||
handler->u.applications.category = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_HORIZONTAL);
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Back"), NULL))
|
||||
== NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, _("Back"), 1);
|
||||
return;
|
||||
}
|
||||
desktopicon_set_callback(desktopicon, _applications_init_on_back, NULL);
|
||||
desktopicon_set_callback(desktopicon, _applications_init_on_back,
|
||||
handler);
|
||||
desktopicon_set_first(desktopicon, TRUE);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
desktop_get_icon_size(handler->desktop, NULL, NULL, &size);
|
||||
|
@ -69,12 +71,13 @@ static void _desktophandler_applications_init(DesktopHandler * handler)
|
|||
|
||||
static void _applications_init_on_back(Desktop * desktop, gpointer data)
|
||||
{
|
||||
(void) data;
|
||||
DesktopHandler * handler = data;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
desktop_set_icons(desktop, DESKTOP_ICONS_HOMESCREEN);
|
||||
desktop_set_icons(desktop, (handler->u.applications.category != NULL)
|
||||
? DESKTOP_ICONS_CATEGORIES : DESKTOP_ICONS_HOMESCREEN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,6 +91,7 @@ static void _desktophandler_applications_destroy(DesktopHandler * handler)
|
|||
g_slist_foreach(handler->u.applications.apps, (GFunc)mimehandler_delete,
|
||||
NULL);
|
||||
g_slist_free(handler->u.applications.apps);
|
||||
handler->u.applications.apps = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,8 +153,7 @@ static gboolean _applications_on_refresh_done(DesktopHandler * handler)
|
|||
{
|
||||
handler->u.applications.refresh_source = 0;
|
||||
_applications_on_refresh_done_applications(handler);
|
||||
desktop_cleanup(handler->desktop);
|
||||
desktop_icons_align(handler->desktop);
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,26 @@
|
|||
|
||||
/* DesktopHandlerCategories */
|
||||
/* private */
|
||||
/* variables */
|
||||
static DesktopCategory _desktop_categories[] =
|
||||
{
|
||||
{ FALSE, "Audio", N_("Audio"), "gnome-mime-audio", },
|
||||
{ FALSE, "Development", N_("Development"),"applications-development"},
|
||||
{ FALSE, "Education", N_("Education"),"applications-science" },
|
||||
{ FALSE, "Game", N_("Games"), "applications-games" },
|
||||
{ FALSE, "Graphics", N_("Graphics"), "applications-graphics" },
|
||||
{ FALSE, "AudioVideo", N_("Multimedia"),"applications-multimedia"},
|
||||
{ FALSE, "Network", N_("Network"), "applications-internet" },
|
||||
{ FALSE, "Office", N_("Office"), "applications-office" },
|
||||
{ FALSE, "Settings", N_("Settings"), "gnome-settings" },
|
||||
{ FALSE, "System", N_("System"), "applications-system" },
|
||||
{ FALSE, "Utility", N_("Utilities"),"applications-utilities"},
|
||||
{ FALSE, "Video", N_("Video"), "video" }
|
||||
};
|
||||
static const size_t _desktop_categories_cnt = sizeof(_desktop_categories)
|
||||
/ sizeof(*_desktop_categories);
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static void _desktophandler_categories_init(DesktopHandler * handler);
|
||||
static void _desktophandler_categories_destroy(DesktopHandler * handler);
|
||||
|
@ -49,6 +69,7 @@ static void _desktophandler_categories_init(DesktopHandler * handler)
|
|||
handler->u.categories.refresh_mtime = 0;
|
||||
handler->u.categories.refresh_source = 0;
|
||||
handler->u.categories.apps = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_HORIZONTAL);
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Back"), NULL))
|
||||
== NULL)
|
||||
{
|
||||
|
@ -153,8 +174,7 @@ static gboolean _categories_on_refresh_done(DesktopHandler * handler)
|
|||
{
|
||||
handler->u.categories.refresh_source = 0;
|
||||
_categories_on_refresh_done_categories(handler);
|
||||
desktop_cleanup(handler->desktop);
|
||||
desktop_icons_align(handler->desktop);
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -219,12 +239,16 @@ static void _categories_on_refresh_done_categories_open(Desktop * desktop,
|
|||
gpointer data)
|
||||
{
|
||||
DesktopCategory * dc = data;
|
||||
DesktopHandler * handler;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, _(dc->name));
|
||||
#endif
|
||||
/* FIXME need an extra argument for applications (category) */
|
||||
desktop_set_icons(desktop, DESKTOP_ICONS_APPLICATIONS);
|
||||
handler = desktop_get_handler(desktop);
|
||||
desktophandler_set_icons(handler, DESKTOP_ICONS_APPLICATIONS);
|
||||
/* FIXME really need an extra argument for applications (category) */
|
||||
handler->u.applications.category = dc;
|
||||
desktop_refresh(desktop);
|
||||
}
|
||||
|
||||
static int _categories_on_refresh_loop(DesktopHandler * handler)
|
||||
|
|
|
@ -54,6 +54,7 @@ static void _desktophandler_files_init(DesktopHandler * handler)
|
|||
handler->u.files.refresh_mtime = 0;
|
||||
handler->u.files.refresh_source = 0;
|
||||
handler->u.files.menu = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_VERTICAL);
|
||||
/* FIXME let it be configured again */
|
||||
handler->u.files.show_hidden = FALSE;
|
||||
/* check for errors */
|
||||
|
@ -266,6 +267,8 @@ static int _files_on_refresh_loop_opendir(DesktopHandler * handler);
|
|||
|
||||
static void _desktophandler_files_refresh(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.files.refresh_source != 0)
|
||||
g_source_remove(handler->u.files.refresh_source);
|
||||
if(handler->u.files.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.files.refresh_dir);
|
||||
handler->u.files.refresh_dir = NULL;
|
||||
|
@ -293,11 +296,10 @@ static gboolean _desktophandler_files_on_refresh(gpointer data)
|
|||
|
||||
static gboolean _files_on_refresh_done(DesktopHandler * handler)
|
||||
{
|
||||
desktop_cleanup(handler->desktop);
|
||||
if(handler->u.files.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.files.refresh_dir);
|
||||
handler->u.files.refresh_dir = NULL;
|
||||
desktop_icons_align(handler->desktop);
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
handler->u.files.refresh_source = g_timeout_add(1000,
|
||||
_files_on_refresh_done_timeout, handler);
|
||||
return FALSE;
|
||||
|
@ -308,13 +310,19 @@ static gboolean _files_on_refresh_done_timeout(gpointer data)
|
|||
DesktopHandler * handler = data;
|
||||
struct stat st;
|
||||
|
||||
handler->u.files.refresh_source = 0;
|
||||
if(handler->u.files.path == NULL)
|
||||
{
|
||||
handler->u.files.refresh_source = 0;
|
||||
return FALSE;
|
||||
}
|
||||
if(browser_vfs_stat(handler->u.files.path, &st) != 0)
|
||||
{
|
||||
handler->u.files.refresh_source = 0;
|
||||
return desktop_perror(NULL, handler->u.files.path, FALSE);
|
||||
}
|
||||
if(st.st_mtime == handler->u.files.refresh_mtime)
|
||||
return TRUE;
|
||||
handler->u.files.refresh_source = 0;
|
||||
desktop_refresh(handler->desktop);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user