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

Simplify the application appicon creation

This patch removes all the appicon stuff from the application creation
to the appicon creation. Now, the application only calls one function
(create_appicon_for_application()) and this function do all the work.

The function do the same code than the code before this patch, but the
only change is that the "if" test to check if the appicon was found in
the docks now is negated, removing the return and doing the appicon_save
inside the function.

Finally, the old makeAppIconFor is now create_appicon_for_application().
This commit is contained in:
Rodolfo García Peñas (kix)
2013-01-22 21:18:15 +01:00
committed by Carlos R. Mafra
parent 97d7c32184
commit 70c9208e40
3 changed files with 19 additions and 24 deletions

View File

@@ -71,6 +71,7 @@ static void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char
static WAppIcon *wAppIconCreate(WWindow * leader_win); static WAppIcon *wAppIconCreate(WWindow * leader_win);
static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon); static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon);
static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon); static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon);
static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window);
/* This function is used if the application is a .app. It checks if it has an icon in it /* This function is used if the application is a .app. It checks if it has an icon in it
* like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
@@ -143,12 +144,13 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
return aicon; return aicon;
} }
void makeAppIconFor(WApplication *wapp) void create_appicon_for_application(WApplication *wapp, WWindow *wwin)
{ {
/* If app_icon, work is done, return */ /* Try to create an icon from the dock or clip */
if (wapp->app_icon) create_appicon_from_dock(wwin, wapp, wapp->main_window);
return;
/* If app_icon was not found, create it */
if (!wapp->app_icon) {
/* Create the icon */ /* Create the icon */
wapp->app_icon = wAppIconCreate(wapp->main_window_desc); wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
wIconUpdate(wapp->app_icon->icon, NULL); wIconUpdate(wapp->app_icon->icon, NULL);
@@ -156,6 +158,10 @@ void makeAppIconFor(WApplication *wapp)
/* Now, paint the icon */ /* Now, paint the icon */
if (!WFLAGP(wapp->main_window_desc, no_appicon)) if (!WFLAGP(wapp->main_window_desc, no_appicon))
paint_app_icon(wapp); paint_app_icon(wapp);
}
/* Save the app_icon in a file */
save_appicon(wapp->app_icon, False);
} }
void unpaint_app_icon(WApplication *wapp) void unpaint_app_icon(WApplication *wapp)
@@ -958,7 +964,7 @@ static WAppIcon *findDockIconFor(WDock *dock, Window main_window)
return aicon; return aicon;
} }
void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window) static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window)
{ {
WScreen *scr = wwin->screen_ptr; WScreen *scr = wwin->screen_ptr;
wapp->app_icon = NULL; wapp->app_icon = NULL;

View File

@@ -72,11 +72,10 @@ typedef struct WAppIcon {
WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
char *wm_class, int tile); char *wm_class, int tile);
void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window);
void wAppIconDestroy(WAppIcon *aicon); void wAppIconDestroy(WAppIcon *aicon);
void wAppIconPaint(WAppIcon *aicon); void wAppIconPaint(WAppIcon *aicon);
void wAppIconMove(WAppIcon *aicon, int x, int y); void wAppIconMove(WAppIcon *aicon, int x, int y);
void makeAppIconFor(WApplication * wapp); void create_appicon_for_application(WApplication *wapp, WWindow *wwin);
void removeAppIconFor(WApplication * wapp); void removeAppIconFor(WApplication * wapp);
void save_appicon(WAppIcon *aicon, Bool dock); void save_appicon(WAppIcon *aicon, Bool dock);
void paint_app_icon(WApplication *wapp); void paint_app_icon(WApplication *wapp);

View File

@@ -141,17 +141,7 @@ WApplication *wApplicationCreate(WWindow * wwin)
/* application descriptor */ /* application descriptor */
XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp); XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp);
/* First try to create an icon from the dock or clip */ create_appicon_for_application(wapp, wwin);
create_appicon_from_dock(wwin, wapp, main_window);
/*
* In case it was not found in the dock, make it from scratch.
* Note: makeAppIconFor() returns early if wapp->app_icon exists
*/
makeAppIconFor(wapp);
/* Save the app_icon in a file */
save_appicon(wapp->app_icon, False);
return wapp; return wapp;
} }