mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 22:28:02 +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:
committed by
Carlos R. Mafra
parent
d7fe9a5bcd
commit
97d7c32184
@@ -240,8 +240,6 @@ void paint_app_icon(WApplication *wapp)
|
|||||||
|
|
||||||
void removeAppIconFor(WApplication *wapp)
|
void removeAppIconFor(WApplication *wapp)
|
||||||
{
|
{
|
||||||
char *file = NULL;
|
|
||||||
|
|
||||||
if (!wapp->app_icon)
|
if (!wapp->app_icon)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -257,16 +255,9 @@ void removeAppIconFor(WApplication *wapp)
|
|||||||
wapp->app_icon->icon->owner = NULL;
|
wapp->app_icon->icon->owner = NULL;
|
||||||
wapp->app_icon->icon->icon_win = None;
|
wapp->app_icon->icon->icon_win = None;
|
||||||
|
|
||||||
/* Update the icon images */
|
/* Set the icon image */
|
||||||
/* Search the icon using instance and class, without default icon */
|
set_icon_image_from_database(wapp->app_icon->icon, wapp->app_icon->wm_instance,
|
||||||
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);
|
wapp->app_icon->wm_class, wapp->app_icon->command);
|
||||||
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);
|
|
||||||
|
|
||||||
/* Paint it */
|
/* Paint it */
|
||||||
wAppIconPaint(wapp->app_icon);
|
wAppIconPaint(wapp->app_icon);
|
||||||
|
|||||||
37
src/icon.c
37
src/icon.c
@@ -113,7 +113,6 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
|
|||||||
{
|
{
|
||||||
WScreen *scr = wwin->screen_ptr;
|
WScreen *scr = wwin->screen_ptr;
|
||||||
WIcon *icon;
|
WIcon *icon;
|
||||||
char *file;
|
|
||||||
|
|
||||||
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y);
|
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y);
|
||||||
|
|
||||||
@@ -141,17 +140,9 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
|
|||||||
else
|
else
|
||||||
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
|
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;
|
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(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
|
||||||
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, 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_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
|
||||||
{
|
{
|
||||||
WIcon *icon;
|
WIcon *icon;
|
||||||
char *file = NULL;
|
|
||||||
|
|
||||||
icon = icon_create_core(scr, 0, 0);
|
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;
|
icon->tile_type = tile;
|
||||||
|
|
||||||
wIconUpdate(icon, NULL);
|
set_icon_image_from_database(icon, wm_instance, wm_class, command);
|
||||||
|
|
||||||
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
|
WMAddNotificationObserver(appearanceObserver, icon, WNIconAppearanceSettingsChanged, icon);
|
||||||
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, 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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile);
|
||||||
WIcon *icon_create_for_wwindow(WWindow *wwin);
|
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 wIconDestroy(WIcon *icon);
|
||||||
void wIconPaint(WIcon *icon);
|
void wIconPaint(WIcon *icon);
|
||||||
void wIconUpdate(WIcon *icon, RImage *image);
|
void wIconUpdate(WIcon *icon, RImage *image);
|
||||||
|
|||||||
Reference in New Issue
Block a user