diff --git a/src/appicon.c b/src/appicon.c index 00839443..c2707a85 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,7 @@ /**** Global variables ****/ extern Cursor wCursor[WCUR_LAST]; extern WPreferences wPreferences; +extern WDDomain *WDWindowAttributes; #define MOD_MASK wPreferences.modifier_mask @@ -65,6 +67,41 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event); static void iconDblClick(WObjDescriptor * desc, XEvent * event); static void iconExpose(WObjDescriptor * desc, XEvent * event); +/* This function is used if the application is a .app. It checks if it has an icon in it + * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff + */ +void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance, char *wm_class) +{ + char *iconPath = NULL; + char *tmp = NULL; + + if (strstr(path, ".app")) { + tmp = wmalloc(strlen(path) + 16); + + if (scr->flags.supports_tiff) { + strcpy(tmp, path); + strcat(tmp, ".tiff"); + if (access(tmp, R_OK) == 0) + iconPath = tmp; + } + + if (!iconPath) { + strcpy(tmp, path); + strcat(tmp, ".xpm"); + if (access(tmp, R_OK) == 0) + iconPath = tmp; + } + + if (!iconPath) + wfree(tmp); + + if (iconPath) { + wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class); + wfree(iconPath); + } + } +} + WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, char *wm_class, int tile) { WAppIcon *dicon; @@ -844,6 +881,46 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event) } } +/* This function save the application icon and store the path in the Dictionary */ +void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_class) +{ + WMPropList *dict = WDWindowAttributes->dictionary; + WMPropList *adict, *key, *iconk; + WMPropList *val; + char *tmp; + + tmp = get_name_for_instance_class(wm_instance, wm_class); + key = WMCreatePLString(tmp); + wfree(tmp); + + adict = WMGetFromPLDictionary(dict, key); + iconk = WMCreatePLString("Icon"); + + if (adict) { + val = WMGetFromPLDictionary(adict, iconk); + } else { + /* no dictionary for app, so create one */ + adict = WMCreatePLDictionary(NULL, NULL); + WMPutInPLDictionary(dict, key, adict); + WMReleasePropList(adict); + val = NULL; + } + + if (!val) { + val = WMCreatePLString(iconPath); + WMPutInPLDictionary(adict, iconk, val); + WMReleasePropList(val); + } else { + val = NULL; + } + + WMReleasePropList(key); + WMReleasePropList(iconk); + + if (val && !wPreferences.flags.noupdates) + UpdateDomainFile(WDWindowAttributes); +} + void save_app_icon(WWindow *wwin, WApplication *wapp) { char *tmp, *path; diff --git a/src/appicon.h b/src/appicon.h index 774c3e34..b9e96364 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -80,6 +80,10 @@ void makeAppIconFor(WApplication * wapp); void removeAppIconFor(WApplication * wapp); void save_app_icon(WWindow *wwin, WApplication *wapp); void paint_app_icon(WApplication *wapp); +void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, + char *wm_class); +void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, + char *wm_class); Bool wAppIconChangeImage(WAppIcon *icon, char *file); Bool wAppIconSave(WAppIcon *aicon); diff --git a/src/application.c b/src/application.c index ca472031..c3c46d5b 100644 --- a/src/application.c +++ b/src/application.c @@ -21,9 +21,7 @@ #include "wconfig.h" #include - #include -#include #include "WindowMaker.h" #include "menu.h" @@ -35,8 +33,6 @@ #include "application.h" #include "appmenu.h" #include "properties.h" -#include "stacking.h" -#include "actions.h" #include "workspace.h" #include "dock.h" @@ -44,8 +40,6 @@ extern XContext wAppWinContext; extern XContext wWinContext; -extern WPreferences wPreferences; -extern WDDomain *WDWindowAttributes; /******** Local variables ********/ @@ -107,81 +101,6 @@ static void extractIcon(WWindow * wwin) wfree(progname); } } - -void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_class) -{ - WMPropList *dict = WDWindowAttributes->dictionary; - WMPropList *adict, *key, *iconk; - WMPropList *val; - char *tmp; - - tmp = get_name_for_instance_class(wm_instance, wm_class); - key = WMCreatePLString(tmp); - wfree(tmp); - - adict = WMGetFromPLDictionary(dict, key); - iconk = WMCreatePLString("Icon"); - - if (adict) { - val = WMGetFromPLDictionary(adict, iconk); - } else { - /* no dictionary for app, so create one */ - adict = WMCreatePLDictionary(NULL, NULL); - WMPutInPLDictionary(dict, key, adict); - WMReleasePropList(adict); - val = NULL; - } - - if (!val) { - val = WMCreatePLString(iconPath); - WMPutInPLDictionary(adict, iconk, val); - WMReleasePropList(val); - } else { - val = NULL; - } - - WMReleasePropList(key); - WMReleasePropList(iconk); - - if (val && !wPreferences.flags.noupdates) - UpdateDomainFile(WDWindowAttributes); -} - -/* This function is used if the application is a .app. It checks if it has an icon in it - * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff - */ -void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance, char *wm_class) -{ - char *iconPath = NULL; - char *tmp = NULL; - - if (strstr(path, ".app")) { - tmp = wmalloc(strlen(path) + 16); - - if (scr->flags.supports_tiff) { - strcpy(tmp, path); - strcat(tmp, ".tiff"); - if (access(tmp, R_OK) == 0) - iconPath = tmp; - } - - if (!iconPath) { - strcpy(tmp, path); - strcat(tmp, ".xpm"); - if (access(tmp, R_OK) == 0) - iconPath = tmp; - } - - if (!iconPath) - wfree(tmp); - - if (iconPath) { - wApplicationSaveIconPathFor(iconPath, wm_instance, wm_class); - wfree(iconPath); - } - } -} - static void app_icon_create_from_docks(WWindow *wwin, WApplication *wapp, Window main_window) { WScreen *scr = wwin->screen_ptr; @@ -381,4 +300,3 @@ void wApplicationDeactivate(WApplication *wapp) } #endif } - diff --git a/src/application.h b/src/application.h index 31cbe680..1a959993 100644 --- a/src/application.h +++ b/src/application.h @@ -48,10 +48,6 @@ typedef struct WApplication { WApplication *wApplicationCreate(struct WWindow *wwin); WApplication *wApplicationOf(Window window); void wApplicationDestroy(WApplication *wapp); -void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, - char *wm_class); -void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, - char *wm_class); void wAppBounce(WApplication *); void wAppBounceWhileUrgent(WApplication *);