1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 14:08:06 +01:00

New function set_icon_image_from_database

The new function set_icon_image_from_database() removes the dup code
from these functions:

icon.c:icon_create_for_dock()
icon.c:icon_create_for_wwindow()
appicon.c:removeAppIconFor()

The only different change is that in the functions icon_create_for_dock()
and icon_create_for_wwindow(), the icon->tile_type assignment is done
before set the icon image filename and icon image, but this variable
is not used in these functions (is used in wIconUpdate function) but in both
functions the icon->tile_type assignment is done before wIconUpdate(), like
the code previous to this patch, so there is no problem moving icon->tile_type.
This commit is contained in:
Rodolfo García Peñas (kix)
2013-01-22 21:18:14 +01:00
committed by Carlos R. Mafra
parent d7fe9a5bcd
commit 97d7c32184
3 changed files with 20 additions and 33 deletions

View File

@@ -240,8 +240,6 @@ void paint_app_icon(WApplication *wapp)
void removeAppIconFor(WApplication *wapp)
{
char *file = NULL;
if (!wapp->app_icon)
return;
@@ -257,16 +255,9 @@ void removeAppIconFor(WApplication *wapp)
wapp->app_icon->icon->owner = NULL;
wapp->app_icon->icon->icon_win = None;
/* Update the icon images */
/* Search the icon using instance and class, without default icon */
file = get_icon_filename(wapp->app_icon->icon->core->screen_ptr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, wapp->app_icon->command, False);
if (file) {
wapp->app_icon->icon->file = wstrdup(file);
wapp->app_icon->icon->file_image = get_rimage_from_file(wapp->app_icon->icon->core->screen_ptr, wapp->app_icon->icon->file, wPreferences.icon_size);
wfree(file);
}
wIconUpdate(wapp->app_icon->icon, NULL);
/* Set the icon image */
set_icon_image_from_database(wapp->app_icon->icon, wapp->app_icon->wm_instance,
wapp->app_icon->wm_class, wapp->app_icon->command);
/* Paint it */
wAppIconPaint(wapp->app_icon);

View File

@@ -113,7 +113,6 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
{
WScreen *scr = wwin->screen_ptr;
WIcon *icon;
char *file;
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y);
@@ -141,17 +140,9 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
else
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
/* Get the application icon, default included */
file = get_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, True);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
wfree(file);
}
icon->tile_type = TILE_NORMAL;
wIconUpdate(icon, NULL);
set_icon_image_from_database(icon, wwin->wm_instance, wwin->wm_class, NULL);
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
@@ -162,21 +153,11 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
WIcon *icon;
char *file = NULL;
icon = icon_create_core(scr, 0, 0);
/* Search the icon using instance and class, without default icon */
file = get_icon_filename(scr, wm_instance, wm_class, command, False);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(scr, icon->file, wPreferences.icon_size);
wfree(file);
}
icon->tile_type = tile;
wIconUpdate(icon, NULL);
set_icon_image_from_database(icon, wm_instance, wm_class, command);
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
@@ -908,3 +889,17 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event)
}
}
}
void set_icon_image_from_database(WIcon *icon, char *wm_instance, char *wm_class, char *command)
{
char *file = NULL;
file = get_icon_filename(icon->core->screen_ptr, wm_instance, wm_class, command, False);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(icon->core->screen_ptr, icon->file, wPreferences.icon_size);
wfree(file);
}
wIconUpdate(icon, NULL);
}

View File

@@ -56,6 +56,7 @@ typedef struct WIcon {
WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile);
WIcon *icon_create_for_wwindow(WWindow *wwin);
void set_icon_image_from_database(WIcon *icon, char *wm_instance, char *wm_class, char *command);
void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
void wIconUpdate(WIcon *icon, RImage *image);