mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +01:00
get_default_icon_filename rewritten
The function get_default_icon_filename(), now get_icon_filename(), was working in a bad way. Before this patch, the function always searched the default icon in the second search: - file_name = wDefaultGetIconFile(winstance, wclass, True); + file_name = wDefaultGetIconFile(winstance, wclass, False); For this reason, the argument default_icon didn't work. This patch change it. Now, if the default_icon is false, the function can return NULL, then other functions can do the correct work. For example, now wDefaultGetImage() doesn't need do nothing, because the default_icon is set to True. get_icon_filename() checks if the icon exists in the disk before returning it (except for default icon in get_default_image_path(scr).
This commit is contained in:
committed by
Carlos R. Mafra
parent
6bc48464e9
commit
c3a1c76b44
@@ -50,7 +50,7 @@ RImage * wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int max_s
|
|||||||
int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class);
|
int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class);
|
||||||
void wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file);
|
void wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file);
|
||||||
RImage *get_default_image(WScreen *scr);
|
RImage *get_default_image(WScreen *scr);
|
||||||
char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, char *command,
|
char *get_icon_filename(WScreen *scr, char *winstance, char *wclass, char *command,
|
||||||
Bool default_icon);
|
Bool default_icon);
|
||||||
RImage *get_rimage_from_file(WScreen *scr, char *file_name, int max_size);
|
RImage *get_rimage_from_file(WScreen *scr, char *file_name, int max_size);
|
||||||
#endif /* WMDEFAULTS_H_ */
|
#endif /* WMDEFAULTS_H_ */
|
||||||
|
|||||||
@@ -1467,7 +1467,7 @@ static WMPixmap *getWindowMakerIconImage(WMScreen *scr)
|
|||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
|
|
||||||
/* Get the Logo icon, without the default icon */
|
/* Get the Logo icon, without the default icon */
|
||||||
path = get_default_icon_filename(NULL, "Logo", "WMPanel", NULL, False);
|
path = get_icon_filename(NULL, "Logo", "WMPanel", NULL, False);
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
RColor gray;
|
RColor gray;
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
|
|||||||
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
|
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
|
||||||
|
|
||||||
/* Get the application icon, default included */
|
/* Get the application icon, default included */
|
||||||
file = get_default_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, True);
|
file = get_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, True);
|
||||||
if (file) {
|
if (file) {
|
||||||
icon->file = wstrdup(file);
|
icon->file = wstrdup(file);
|
||||||
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
|
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
|
||||||
@@ -169,7 +169,7 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char
|
|||||||
icon = icon_create_core(scr, 0, 0);
|
icon = icon_create_core(scr, 0, 0);
|
||||||
|
|
||||||
/* Search the icon using instance and class, without default icon */
|
/* Search the icon using instance and class, without default icon */
|
||||||
file = get_default_icon_filename(scr, wm_instance, wm_class, command, False);
|
file = get_icon_filename(scr, wm_instance, wm_class, command, False);
|
||||||
if (file) {
|
if (file) {
|
||||||
icon->file = wstrdup(file);
|
icon->file = wstrdup(file);
|
||||||
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
|
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
|
||||||
|
|||||||
@@ -376,8 +376,8 @@ static WMPropList *get_generic_value(char *instance, char *class,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the file name of the image, using instance and class */
|
/* Get the file name of the image, using instance and class */
|
||||||
char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, char *command,
|
char *get_icon_filename(WScreen *scr, char *winstance, char *wclass, char *command,
|
||||||
Bool default_icon)
|
Bool default_icon)
|
||||||
{
|
{
|
||||||
char *file_name = NULL;
|
char *file_name = NULL;
|
||||||
char *file_path = NULL;
|
char *file_path = NULL;
|
||||||
@@ -389,13 +389,11 @@ char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, cha
|
|||||||
if (file_name)
|
if (file_name)
|
||||||
file_path = FindImage(wPreferences.icon_path, file_name);
|
file_path = FindImage(wPreferences.icon_path, file_name);
|
||||||
|
|
||||||
/* If the specific (or generic if default_icon is True) icon filename
|
/* If the specific icon filename is not found, and command is specified,
|
||||||
* is not found, and command is specified, then include the .app icons
|
* then include the .app icons and re-do the search. */
|
||||||
* 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 || !file_path ) && scr && command) {
|
if ((!file_name || !file_path ) && scr && command) {
|
||||||
wApplicationExtractDirPackIcon(scr, command, winstance, wclass);
|
wApplicationExtractDirPackIcon(scr, command, winstance, wclass);
|
||||||
file_name = wDefaultGetIconFile(winstance, wclass, True);
|
file_name = wDefaultGetIconFile(winstance, wclass, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the full path for the image file */
|
/* Get the full path for the image file */
|
||||||
@@ -403,21 +401,15 @@ char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, cha
|
|||||||
file_path = FindImage(wPreferences.icon_path, file_name);
|
file_path = FindImage(wPreferences.icon_path, file_name);
|
||||||
|
|
||||||
if (!file_path)
|
if (!file_path)
|
||||||
wwarning(_("could not find icon file \"%s\""), file_name);
|
wwarning(_("icon \"%s\" doesn't exist, check your config files"), file_name);
|
||||||
|
|
||||||
/* FIXME: Here, if file_path don't exists, then the icon is in the
|
/* FIXME: Here, if file_path don't exists, then the icon is in the
|
||||||
* "icon database" (WDWindowAttributes->dictionary), but the icon
|
* "icon database" (WDWindowAttributes->dictionary), but the icon
|
||||||
* is not en disk. Therefore, we should remove it from the icon
|
* is not en disk. Therefore, we should remove it from the icon
|
||||||
* database.
|
* database. Is possible to do that using wDefaultChangeIcon() */
|
||||||
* OTOH, probably the correct message should be "could not find the
|
|
||||||
* icon file %s, please, check your configuration files", because
|
|
||||||
* the icons are loaded in the icon database from the configuration
|
|
||||||
* files
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Don't wfree(file_name) here, because is a pointer to the icon
|
/* Don't wfree(file_name) here, because is a pointer to the icon
|
||||||
* dictionary (WDWindowAttributes->dictionary) value.
|
* dictionary (WDWindowAttributes->dictionary) value. */
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_path && default_icon)
|
if (!file_path && default_icon)
|
||||||
@@ -482,14 +474,7 @@ RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int max_si
|
|||||||
char *file_name = NULL;
|
char *file_name = NULL;
|
||||||
|
|
||||||
/* Get the file name of the image, using instance and class */
|
/* Get the file name of the image, using instance and class */
|
||||||
file_name = get_default_icon_filename(scr, winstance, wclass, NULL, True);
|
file_name = get_icon_filename(scr, winstance, wclass, NULL, True);
|
||||||
|
|
||||||
/* 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);
|
return get_rimage_from_file(scr, file_name, max_size);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user