>From ea65e4c3c1e729eb3b9abdd4a6994beb8d1cd744 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Mon, 18 Jun 2012 08:47:15 +0200
Subject: [PATCH 01/12] Icon functions moved to appicon.c
The icon functions wApplicationExtractDirPackIcon()
wApplicationSaveIconPathFor()
are moved to appicon.c from application.c.
This functions are Application Icon related and should be included in appicon.
---
src/appicon.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
src/appicon.h | 4 +++
src/application.c | 82 -----------------------------------------------------
src/application.h | 4 ---
4 files changed, 81 insertions(+), 86 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 0083944..c2707a8 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -26,6 +26,7 @@
#include <X11/Xutil.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
@@ -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 774c3e3..b9e9636 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 ca47203..c3c46d5 100644
--- a/src/application.c
+++ b/src/application.c
@@ -21,9 +21,7 @@
#include "wconfig.h"
#include <X11/Xlib.h>
-
#include <string.h>
-#include <unistd.h>
#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 31cbe68..1a95999 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 *);
--
1.7.10
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From ea65e4c3c1e729eb3b9abdd4a6994beb8d1cd744 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Mon, 18 Jun 2012 08:47:15 +0200
Subject: [PATCH 01/12] Icon functions moved to appicon.c
The icon functions wApplicationExtractDirPackIcon() wApplicationSaveIconPathFor()
are moved to appicon.c from application.c.
This functions are Application Icon related and should be included in appicon.
---
src/appicon.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
src/appicon.h | 4 +++
src/application.c | 82 -----------------------------------------------------
src/application.h | 4 ---
4 files changed, 81 insertions(+), 86 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 0083944..c2707a8 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -26,6 +26,7 @@
#include <X11/Xutil.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
@@ -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 774c3e3..b9e9636 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 ca47203..c3c46d5 100644
--- a/src/application.c
+++ b/src/application.c
@@ -21,9 +21,7 @@
#include "wconfig.h"
#include <X11/Xlib.h>
-
#include <string.h>
-#include <unistd.h>
#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 31cbe68..1a95999 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 *);
--
1.7.10