Give the DesktopIcon class a better chance to find the pixmap for an application

This commit is contained in:
Pierre Pronchery 2013-11-23 04:46:32 +01:00
parent c4dfa9d515
commit 6f60bf2a79
3 changed files with 16 additions and 8 deletions

View File

@ -921,7 +921,7 @@ static int _icons_homescreen(Desktop * desktop)
for(p = paths; *p != NULL; p++)
if(access(*p, R_OK) == 0
&& (desktopicon = desktopicon_new_application(
desktop, *p)) != NULL)
desktop, *p, DATADIR)) != NULL)
_desktop_icon_add(desktop, desktopicon);
#endif
return 0;
@ -1136,7 +1136,9 @@ static int _current_loop_applications_do(Desktop * desktop)
continue;
if(string_find(q, desktop->category->category) == NULL)
continue;
if((icon = desktopicon_new_application(desktop, path)) == NULL)
/* FIXME forward the corresponding datadir */
if((icon = desktopicon_new_application(desktop, path, NULL))
== NULL)
continue;
_desktop_icon_add(desktop, icon);
free(path);
@ -1333,7 +1335,8 @@ static void _done_categories(Desktop * desktop)
path = config_get(config, NULL, "path");
if((q = config_get(config, section, "Categories")) == NULL)
{
icon = desktopicon_new_application(desktop, path);
icon = desktopicon_new_application(desktop, path,
NULL);
_desktop_icon_add(desktop, icon);
continue;
}
@ -1343,7 +1346,8 @@ static void _done_categories(Desktop * desktop)
&& string_find(q, dc->category) == NULL; i++);
if(dc->category == NULL)
{
icon = desktopicon_new_application(desktop, path);
icon = desktopicon_new_application(desktop, path,
NULL);
_desktop_icon_add(desktop, icon);
continue;
}

View File

@ -184,7 +184,8 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
/* desktopicon_new_application */
DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path)
DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path,
char const * datadir)
{
DesktopIcon * desktopicon;
Config * config;
@ -225,9 +226,11 @@ DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path)
return NULL;
}
/* image */
if(datadir == NULL)
datadir = DATADIR;
if((len = strlen(icon)) > 4 && (strcmp(&icon[len - 4], ".png") == 0
|| strcmp(&icon[len - 4], ".xpm") == 0)
&& (buf = string_new_append(DATADIR, "/pixmaps/",
&& (buf = string_new_append(datadir, "/pixmaps/",
icon, NULL)) != NULL)
{
image = gdk_pixbuf_new_from_file_at_size(buf,

View File

@ -1,5 +1,5 @@
/* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
/* Copyright (c) 2010-2013 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Browser */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,7 +46,8 @@ typedef void (*DesktopIconCallback)(Desktop * desktop, gpointer data);
/* functions */
DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
char const * url);
DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path);
DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path,
char const * datadir);
DesktopIcon * desktopicon_new_category(Desktop * desktop, char const * name,
char const * icon);
void desktopicon_delete(DesktopIcon * desktopicon);