1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 05:48:01 +01:00

New function save_app_icon

New function to save the icon "save_app_icon". This function is
created in appicon.c, because is related to app_icons. The contents
are from application.c. No important modifications are included in
this function. Removed the includes not needed.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-05-31 12:32:04 +02:00
committed by Carlos R. Mafra
parent 423b78811a
commit 1c1697dc40
3 changed files with 35 additions and 30 deletions

View File

@@ -26,6 +26,8 @@
#include <X11/Xutil.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
#include "WindowMaker.h"
#include "window.h"
@@ -759,3 +761,33 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event)
}
}
}
void save_app_icon(WWindow *wwin, WApplication *wapp)
{
char *tmp, *path;
struct stat dummy;
WScreen *scr = NULL;
if (!wapp->app_icon)
return;
scr = wwin->screen_ptr;
tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True);
/* If the icon was saved by us from the client supplied icon, but is
* missing, recreate it. */
if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL &&
stat(tmp, &dummy) != 0 && errno == ENOENT) {
wmessage(_("recreating missing icon '%s'"), tmp);
path = wIconStore(wapp->app_icon->icon);
if (path)
wfree(path);
wIconUpdate(wapp->app_icon->icon);
wAppIconPaint(wapp->app_icon);
}
/* if the displayed icon was supplied by the client, save the icon */
if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
wAppIconSave(wapp->app_icon);
}

View File

@@ -76,6 +76,7 @@ WAppIcon * wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
void wAppIconDestroy(WAppIcon *aicon);
void wAppIconPaint(WAppIcon *aicon);
void wAppIconMove(WAppIcon *aicon, int x, int y);
void save_app_icon(WWindow *wwin, WApplication *wapp);
Bool wAppIconChangeImage(WAppIcon *icon, char *file);
Bool wAppIconSave(WAppIcon *aicon);
#endif

View File

@@ -22,13 +22,8 @@
#include <X11/Xlib.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "WindowMaker.h"
#include "menu.h"
@@ -36,15 +31,12 @@
#ifdef USER_MENU
#include "usermenu.h"
#endif /* USER_MENU */
#include "icon.h"
#include "appicon.h"
#include "application.h"
#include "appmenu.h"
#include "properties.h"
#include "funcs.h"
#include "stacking.h"
#include "actions.h"
#include "defaults.h"
#include "workspace.h"
#include "dock.h"
@@ -349,29 +341,9 @@ WApplication *wApplicationCreate(WWindow * wwin)
if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted)
wArrangeIcons(scr, True);
if (wapp->app_icon) {
char *tmp, *path;
struct stat dummy;
/* Save the app_icon in a file */
save_app_icon(wwin, wapp);
tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True);
/* If the icon was saved by us from the client supplied icon, but is
* missing, recreate it. */
if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL &&
stat(tmp, &dummy) != 0 && errno == ENOENT) {
wmessage(_("recreating missing icon '%s'"), tmp);
path = wIconStore(wapp->app_icon->icon);
if (path) {
wfree(path);
}
wIconUpdate(wapp->app_icon->icon);
wAppIconPaint(wapp->app_icon);
}
/* if the displayed icon was supplied by the client, save the icon */
if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
wAppIconSave(wapp->app_icon);
}
return wapp;
}