From: "Rodolfo García Peñas (kix)" <[email protected]>
There is a but in wmaker with icon files set in config files, but
that doesn't exist in the disk. For example, if the config files have:
etc/WindowMaker/WMWindowAttributes:
xcalc = {AlwaysUserIcon = Yes;Icon = "HP-16C-48.xpm";};
share/WindowMaker/IconSets/Default.iconset:
xcalc = {AlwaysUserIcon = Yes;Icon = "HP-16C-48.xpm";};
But the icon "HP-16C-48.xpm" doesn't exist in the disk, wmaker do:
1. Load the config file in memory, in a database
2. When the application is launched, wmaker try to find their icon in
the database (using wDefaultGetIconFile), the icon is found: HP-16C-48.xpm
3. When WindowMaker try to find the full path for the icon, using FindImage(),
WindowMaker cannot find the icon, and returns NULL.
Even, if the user set the default_icon boolean variable to True, wmaker
finds in the database the wrong icon.
This patch check that the icon exist, in the database AND in the disk. If the
icon doesn't exist in the disk, and the default_icon variable is set to True,
then windowmaker load the default icon, using the function get_default_image()
because this function search the default icon directly.
The function get_default_image() is moved from icon.c to wdefaults.c because
is now used in both places. This function is now splitted, to find the file
(get_default_image_path) path and the file image (get_default_image)
---
src/defaults.h | 2 ++
src/icon.c | 22 ----------------------
src/wdefaults.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/src/defaults.h b/src/defaults.h
index 2541f20..4104f84 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -41,6 +41,7 @@ void wDefaultFillAttributes(char *instance, char *class,
WWindowAttributes *attr, WWindowAttributes *mask,
Bool useGlobalDefault);
+char *get_default_image_path(WScreen *scr);
char *wDefaultGetIconFile(char *instance, char *class, Bool default_icon);
RImage * wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int
max_size);
@@ -48,6 +49,7 @@ RImage * wDefaultGetImage(WScreen *scr, char *winstance, char
*wclass, int max_s
int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class);
void wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file);
+RImage *get_default_image(WScreen *scr);
char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass,
char *command,
Bool default_icon);
RImage *get_rimage_from_file(WScreen *scr, char *file_name, int max_size);
diff --git a/src/icon.c b/src/icon.c
index 46b9a79..20b7303 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -73,7 +73,6 @@ static void get_rimage_icon_from_x11(WIcon *icon);
static void icon_update_pixmap(WIcon *icon, RImage *image);
static void unset_icon_image(WIcon *icon);
-static RImage *get_default_image(WScreen *scr);
/****** Notification Observers ******/
static void appearanceObserver(void *self, WMNotification * notif)
@@ -693,27 +692,6 @@ static void get_pixmap_icon_from_default_icon(WIcon *icon)
icon_update_pixmap(icon, icon->file_image);
}
-/* This function creates the RImage using the default icon */
-static RImage *get_default_image(WScreen *scr)
-{
- RImage *image = NULL;
- char *path, *file;
-
- /* Get the default icon */
- file = wDefaultGetIconFile(NULL, NULL, True);
- if (file) {
- path = FindImage(wPreferences.icon_path, file);
- image = get_rimage_from_file(scr, path, wPreferences.icon_size);
-
- if (!image)
- wwarning(_("could not find default icon \"%s\""), file);
-
- wfree(file);
- }
-
- return image;
-}
-
/* Get the Pixmap from the WIcon of the WWindow */
static void get_pixmap_icon_from_icon_win(WIcon *icon)
{
diff --git a/src/wdefaults.c b/src/wdefaults.c
index 8a4cdab..532b19e 100644
--- a/src/wdefaults.c
+++ b/src/wdefaults.c
@@ -385,11 +385,15 @@ char *get_default_icon_filename(WScreen *scr, char
*winstance, char *wclass, cha
/* Get the file name of the image, using instance and class */
file_name = wDefaultGetIconFile(winstance, wclass, default_icon);
+ /* Check if the file really exists in the disk */
+ if (file_name)
+ file_path = FindImage(wPreferences.icon_path, file_name);
+
/* If the specific (or generic if default_icon is True) icon filename
* is not found, and command is specified, then include the .app icons
* and re-do the search, but now always including the default icon
* so the icon is found always. The .app is selected before default */
- if (!file_name && scr && command) {
+ if ((!file_name || !file_path ) && scr && command) {
wApplicationExtractDirPackIcon(scr, command, winstance, wclass);
file_name = wDefaultGetIconFile(winstance, wclass, True);
}
@@ -416,6 +420,9 @@ char *get_default_icon_filename(WScreen *scr, char
*winstance, char *wclass, cha
*/
}
+ if (!file_path && default_icon)
+ file_path = get_default_image_path(scr);
+
return file_path;
}
@@ -437,14 +444,52 @@ RImage *get_rimage_from_file(WScreen *scr, char
*file_name, int max_size)
return image;
}
-RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int
max_size)
+/* This function returns the default icon's full path
+ * If the path for an icon is not found, returns NULL */
+char *get_default_image_path(WScreen *scr)
+{
+ char *path = NULL, *file = NULL;
+
+ /* Get the default icon */
+ file = wDefaultGetIconFile(NULL, NULL, True);
+ if (file)
+ path = FindImage(wPreferences.icon_path, file);
+
+ return path;
+}
+
+/* This function creates the RImage using the default icon */
+RImage *get_default_image(WScreen *scr)
+{
+ RImage *image = NULL;
+ char *path = NULL;
+
+ /* Get the filename full path */
+ path = get_default_image_path(scr);
+ if (!path)
+ return NULL;
+
+ /* Get the default icon */
+ image = get_rimage_from_file(scr, path, wPreferences.icon_size);
+ if (!image)
+ wwarning(_("could not find default icon \"%s\""), path);
+
+ return image;
+}
+
+RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int
max_size)
{
char *file_name = NULL;
/* Get the file name of the image, using instance and class */
file_name = get_default_icon_filename(scr, winstance, wclass, NULL,
True);
- if (!file_name)
- return NULL;
+
+ /* If no filename, is because the winstance and wclass in the database
+ * returns a invalid icon (config file error), then should be removed
FIXME! */
+ if (!file_name) {
+ wwarning(_("icon \"%s\" doesn't exist, check your config
files"), file_name);
+ file_name = get_default_image_path(scr);
+ }
return get_rimage_from_file(scr, file_name, max_size);
}
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].