>From c0ec196d97d9f39510b01881589a8501d473f460 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 16:50:41 +0200
Subject: [PATCH 07/13] wIconCreateWithIconFile new interface

The function wIconCreateWithIconFile has now a new interface:

-WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile);
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+                              char *instance, char *class, int tile_type);

Now, wIconCreateWithIconFile has the same interface that wIconCreate():

+WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
+  char *instance, char *class, int tile_type);

To do this change, the lines to get the file name using instance and class,
was used before call wIconCreateWithIconFile(), then this function knows
the icon file. Now, the function to get the file are included inside
wIconCreateWithIconFile(), like wIconCreate(), therefore the interface
includes instance and class instead the file name.

command is also included, but not used yet (because is not used in the
original wIconCreateWithIconFile() call. The WWindow is always null,
because the dock don't have WWindow (now Window) associated.

This change is done to join the functions wIconCreate and
wIconCreateWithIconFile.
---
 src/appicon.c |   13 +------------
 src/icon.c    |   23 +++++++++++++++++------
 src/icon.h    |    3 ++-
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index c06a806..ebe0160 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char 
*path, char *wm_instance
 WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char 
*wm_instance, char *wm_class, int tile)
 {
        WAppIcon *dicon;
-       char *path;
 
        dicon = wmalloc(sizeof(WAppIcon));
        wretain(dicon);
@@ -127,18 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char 
*command, char *wm_instance,
        if (wm_instance)
                dicon->wm_instance = wstrdup(wm_instance);
 
-       path = wDefaultGetIconFile(wm_instance, wm_class, True);
-       if (!path && command) {
-               wApplicationExtractDirPackIcon(scr, command, wm_instance, 
wm_class);
-               path = wDefaultGetIconFile(wm_instance, wm_class, False);
-       }
-
-       if (path)
-               path = FindImage(wPreferences.icon_path, path);
+       dicon->icon = wIconCreateWithIconFile(NULL, scr, NULL, wm_instance, 
wm_class, tile);
 
-       dicon->icon = wIconCreateWithIconFile(scr, path, tile);
-       if (path)
-               wfree(path);
 #ifdef XDND
        wXDNDMakeAwareness(dicon->icon->core->window);
 #endif
diff --git a/src/icon.c b/src/icon.c
index 60da345..08fea3b 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -149,23 +149,34 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char 
*command,
        return icon;
 }
 
-WIcon *wIconCreateWithIconFile(WScreen * scr, char *iconfile, int tile)
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+                              char *instance, char *class, int tile_type)
 {
        WIcon *icon;
+       char *path = NULL;
 
        icon = wIconCreateCore(scr, 0, 0);
 
-       if (iconfile) {
-               icon->file_image = RLoadImage(scr->rcontext, iconfile, 0);
+       path = wDefaultGetIconFile(instance, class, True);
+       if (!path && command) {
+               wApplicationExtractDirPackIcon(scr, command, instance, class);
+               path = wDefaultGetIconFile(instance, class, False);
+       }
+
+        if (path)
+                path = FindImage(wPreferences.icon_path, path);
+
+       if (path) {
+               icon->file_image = RLoadImage(scr->rcontext, path, 0);
                if (!icon->file_image)
-                       wwarning(_("error loading image file \"%s\": %s"), 
iconfile, RMessageForError(RErrorCode));
+                       wwarning(_("error loading image file \"%s\": %s"), 
path, RMessageForError(RErrorCode));
 
                icon->file_image = wIconValidateIconSize(scr, icon->file_image, 
wPreferences.icon_size);
 
-               icon->file = wstrdup(iconfile);
+               icon->file = wstrdup(path);
        }
 
-       icon->tile_type = tile;
+       icon->tile_type = tile_type;
 
        wIconUpdate(icon);
 
diff --git a/src/icon.h b/src/icon.h
index 109f1d6..a888395 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,7 +54,8 @@ typedef struct WIcon {
                                         * color */
 } WIcon;
 
-WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile);
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+                              char *instance, char *class, int tile_type);
 WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
                   char *instance, char *class, int tile_type);
 
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From c0ec196d97d9f39510b01881589a8501d473f460 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 16:50:41 +0200
Subject: [PATCH 07/13] wIconCreateWithIconFile new interface

The function wIconCreateWithIconFile has now a new interface:

-WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile);
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+                              char *instance, char *class, int tile_type);

Now, wIconCreateWithIconFile has the same interface that wIconCreate():

+WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
+  char *instance, char *class, int tile_type);

To do this change, the lines to get the file name using instance and class,
was used before call wIconCreateWithIconFile(), then this function knows
the icon file. Now, the function to get the file are included inside
wIconCreateWithIconFile(), like wIconCreate(), therefore the interface
includes instance and class instead the file name.

command is also included, but not used yet (because is not used in the
original wIconCreateWithIconFile() call. The WWindow is always null,
because the dock don't have WWindow (now Window) associated.

This change is done to join the functions wIconCreate and
wIconCreateWithIconFile.
---
 src/appicon.c |   13 +------------
 src/icon.c    |   23 +++++++++++++++++------
 src/icon.h    |    3 ++-
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index c06a806..ebe0160 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance
 WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, char *wm_class, int tile)
 {
 	WAppIcon *dicon;
-	char *path;
 
 	dicon = wmalloc(sizeof(WAppIcon));
 	wretain(dicon);
@@ -127,18 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance,
 	if (wm_instance)
 		dicon->wm_instance = wstrdup(wm_instance);
 
-	path = wDefaultGetIconFile(wm_instance, wm_class, True);
-	if (!path && command) {
-		wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class);
-		path = wDefaultGetIconFile(wm_instance, wm_class, False);
-	}
-
-	if (path)
-		path = FindImage(wPreferences.icon_path, path);
+	dicon->icon = wIconCreateWithIconFile(NULL, scr, NULL, wm_instance, wm_class, tile);
 
-	dicon->icon = wIconCreateWithIconFile(scr, path, tile);
-	if (path)
-		wfree(path);
 #ifdef XDND
 	wXDNDMakeAwareness(dicon->icon->core->window);
 #endif
diff --git a/src/icon.c b/src/icon.c
index 60da345..08fea3b 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -149,23 +149,34 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
 	return icon;
 }
 
-WIcon *wIconCreateWithIconFile(WScreen * scr, char *iconfile, int tile)
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+			       char *instance, char *class, int tile_type)
 {
 	WIcon *icon;
+	char *path = NULL;
 
 	icon = wIconCreateCore(scr, 0, 0);
 
-	if (iconfile) {
-		icon->file_image = RLoadImage(scr->rcontext, iconfile, 0);
+	path = wDefaultGetIconFile(instance, class, True);
+	if (!path && command) {
+		wApplicationExtractDirPackIcon(scr, command, instance, class);
+		path = wDefaultGetIconFile(instance, class, False);
+	}
+
+        if (path)
+                path = FindImage(wPreferences.icon_path, path);
+
+	if (path) {
+		icon->file_image = RLoadImage(scr->rcontext, path, 0);
 		if (!icon->file_image)
-			wwarning(_("error loading image file \"%s\": %s"), iconfile, RMessageForError(RErrorCode));
+			wwarning(_("error loading image file \"%s\": %s"), path, RMessageForError(RErrorCode));
 
 		icon->file_image = wIconValidateIconSize(scr, icon->file_image, wPreferences.icon_size);
 
-		icon->file = wstrdup(iconfile);
+		icon->file = wstrdup(path);
 	}
 
-	icon->tile_type = tile;
+	icon->tile_type = tile_type;
 
 	wIconUpdate(icon);
 
diff --git a/src/icon.h b/src/icon.h
index 109f1d6..a888395 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -54,7 +54,8 @@ typedef struct WIcon {
 					 * color */
 } WIcon;
 
-WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile);
+WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
+			       char *instance, char *class, int tile_type);
 WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
 		   char *instance, char *class, int tile_type);
 
-- 
1.7.10

Reply via email to