>From ae7b28c25ab1f22b900e2a1cab2352ae4458e1cb 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 17:03:13 +0200
Subject: [PATCH 08/13] wIconCreate*() unify inside code
The code inside wIconCreate() and wIconCreateForDock() should be
the same, and this code is duplicated with the functions
get_default_icon_filename() to get the icon file name and
get_default_icon_rimage() to get the RImage struct.
---
src/icon.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 08fea3b..351bd8a 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -125,12 +125,17 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char
*command,
#else
icon->show_title = 1;
#endif
- icon->file_image = wDefaultGetImage(scr, instance, class,
wPreferences.icon_size);
-
- file = wDefaultGetIconFile(instance, class, False);
+ /* Get the file name */
+ file = get_default_icon_filename(scr, instance, class, command, False);
if (file)
icon->file = wstrdup(file);
+ /* Load the icon using the file name */
+ icon->file_image = get_default_icon_rimage(scr, file,
wPreferences.icon_size);
+ if (file)
+ wfree(file);
+
+ /* Set the icon name */
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (icon->icon_name)
wwin->flags.net_has_icon_title = 1;
@@ -153,34 +158,24 @@ WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen
*scr, char *command,
char *instance, char *class, int tile_type)
{
WIcon *icon;
- char *path = NULL;
+ char *file = NULL;
icon = wIconCreateCore(scr, 0, 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"),
path, RMessageForError(RErrorCode));
-
- icon->file_image = wIconValidateIconSize(scr, icon->file_image,
wPreferences.icon_size);
+ /* Get the file name */
+ file = get_default_icon_filename(scr, instance, class, command, False);
+ if (file)
+ icon->file = wstrdup(file);
- icon->file = wstrdup(path);
- }
+ /* Load the icon using the file name */
+ icon->file_image = get_default_icon_rimage(scr, file,
wPreferences.icon_size);
+ if (file)
+ wfree(file);
icon->tile_type = tile_type;
wIconUpdate(icon);
-
WMAddNotificationObserver(appearanceObserver, icon,
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon,
WNIconTileSettingsChanged, icon);
--
1.7.10
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From ae7b28c25ab1f22b900e2a1cab2352ae4458e1cb 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 17:03:13 +0200
Subject: [PATCH 08/13] wIconCreate*() unify inside code
The code inside wIconCreate() and wIconCreateForDock() should be
the same, and this code is duplicated with the functions
get_default_icon_filename() to get the icon file name and
get_default_icon_rimage() to get the RImage struct.
---
src/icon.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 08fea3b..351bd8a 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -125,12 +125,17 @@ WIcon *wIconCreate(WWindow *wwin, WScreen *scr, char *command,
#else
icon->show_title = 1;
#endif
- icon->file_image = wDefaultGetImage(scr, instance, class, wPreferences.icon_size);
-
- file = wDefaultGetIconFile(instance, class, False);
+ /* Get the file name */
+ file = get_default_icon_filename(scr, instance, class, command, False);
if (file)
icon->file = wstrdup(file);
+ /* Load the icon using the file name */
+ icon->file_image = get_default_icon_rimage(scr, file, wPreferences.icon_size);
+ if (file)
+ wfree(file);
+
+ /* Set the icon name */
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (icon->icon_name)
wwin->flags.net_has_icon_title = 1;
@@ -153,34 +158,24 @@ WIcon *wIconCreateWithIconFile(WWindow *wwin, WScreen *scr, char *command,
char *instance, char *class, int tile_type)
{
WIcon *icon;
- char *path = NULL;
+ char *file = NULL;
icon = wIconCreateCore(scr, 0, 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"), path, RMessageForError(RErrorCode));
-
- icon->file_image = wIconValidateIconSize(scr, icon->file_image, wPreferences.icon_size);
+ /* Get the file name */
+ file = get_default_icon_filename(scr, instance, class, command, False);
+ if (file)
+ icon->file = wstrdup(file);
- icon->file = wstrdup(path);
- }
+ /* Load the icon using the file name */
+ icon->file_image = get_default_icon_rimage(scr, file, wPreferences.icon_size);
+ if (file)
+ wfree(file);
icon->tile_type = tile_type;
wIconUpdate(icon);
-
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
--
1.7.10