From 6f60bf2a793e53d63580890e8fa1dbdb44c7a324 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 23 Nov 2013 04:46:32 +0100 Subject: [PATCH] Give the DesktopIcon class a better chance to find the pixmap for an application --- src/desktop.c | 12 ++++++++---- src/desktopicon.c | 7 +++++-- src/desktopicon.h | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/desktop.c b/src/desktop.c index 8b9b3c6..5780637 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -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; } diff --git a/src/desktopicon.c b/src/desktopicon.c index b826295..6990b0e 100644 --- a/src/desktopicon.c +++ b/src/desktopicon.c @@ -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, diff --git a/src/desktopicon.h b/src/desktopicon.h index ca4af5f..8bf4564 100644 --- a/src/desktopicon.h +++ b/src/desktopicon.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2010 Pierre Pronchery */ +/* Copyright (c) 2010-2013 Pierre Pronchery */ /* 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);