From a1e80f5411ba457fa7d1e19873974a36113f9c6f Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Thu, 21 Jun 2012 15:16:20 +0100 Subject: [PATCH] Unify save_appicon() and wAppIconSave() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having two similarly named functions for doing the same thing is confusing. In order to account for the extra check done by the late wAppIconSave(), add an argument "dock". Now there's only save_appicon(). And as pointed out by Rodolfo kix GarcĂ­a, the save_appicon_core() function can be removed too. Signed-off-by: Carlos R. Mafra --- src/appicon.c | 33 +++++++++------------------------ src/appicon.h | 3 +-- src/application.c | 2 +- src/dock.c | 8 ++++---- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index 6827c2f4..39994580 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -397,30 +397,25 @@ void wAppIconPaint(WAppIcon * aicon) 0, 0, wPreferences.icon_size, wPreferences.icon_size); } -/* Internal application to save the application icon */ -static void save_app_icon_core(WAppIcon *aicon) +/* Save the application icon, if it's a dockapp then use it with dock = True */ +void save_appicon(WAppIcon *aicon, Bool dock) { char *path; + if (!aicon) + return; + + if (dock && (!aicon->docked || aicon->attracted)) + return; + path = wIconStore(aicon->icon); if (!path) return; wApplicationSaveIconPathFor(path, aicon->wm_instance, aicon->wm_class); - wfree(path); } -/* Save the application icon */ -/* This function is used when the icon doesn't have window, like dock or clip */ -void wAppIconSave(WAppIcon *aicon) -{ - if (!aicon->docked || aicon->attracted) - return; - - save_app_icon_core(aicon); -} - #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance)) /* main_window may not have the full command line; try to find one which does */ @@ -930,16 +925,6 @@ static void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char UpdateDomainFile(WDWindowAttributes); } -/* Save the application icon */ -/* This function is used by normal windows */ -void save_app_icon(WApplication *wapp) -{ - if (!wapp->app_icon) - return; - - save_app_icon_core(wapp->app_icon); -} - static WAppIcon *findDockIconFor(WDock *dock, Window main_window) { WAppIcon *aicon = NULL; @@ -987,6 +972,6 @@ void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_win wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; wAppIconPaint(wapp->app_icon); - wAppIconSave(wapp->app_icon); + save_appicon(wapp->app_icon, True); } } diff --git a/src/appicon.h b/src/appicon.h index ec014935..1fbd9769 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -78,7 +78,6 @@ void wAppIconPaint(WAppIcon *aicon); void wAppIconMove(WAppIcon *aicon, int x, int y); void makeAppIconFor(WApplication * wapp); void removeAppIconFor(WApplication * wapp); -void save_app_icon(WApplication *wapp); +void save_appicon(WAppIcon *aicon, Bool dock); void paint_app_icon(WApplication *wapp); -void wAppIconSave(WAppIcon *aicon); #endif diff --git a/src/application.c b/src/application.c index f08f435d..4e34f359 100644 --- a/src/application.c +++ b/src/application.c @@ -151,7 +151,7 @@ WApplication *wApplicationCreate(WWindow * wwin) makeAppIconFor(wapp); /* Save the app_icon in a file */ - save_app_icon(wapp); + save_appicon(wapp->app_icon, False); return wapp; } diff --git a/src/dock.c b/src/dock.c index 155e1a80..0332d65f 100644 --- a/src/dock.c +++ b/src/dock.c @@ -548,7 +548,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry) wAppIconPaint(aicon); } } - wAppIconSave(aicon); + save_appicon(aicon, True); } WMFreeArray(selectedIcons); } @@ -1173,7 +1173,7 @@ static void dockIconPaint(WAppIcon *btn) wClipIconPaint(btn); else { wAppIconPaint(btn); - wAppIconSave(btn); + save_appicon(btn, True); } } @@ -1961,7 +1961,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y) MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core); wAppIconMove(icon, icon->x_pos, icon->y_pos); wAppIconPaint(icon); - wAppIconSave(icon); + save_appicon(icon, True); if (wPreferences.auto_arrange_icons) wArrangeIcons(dock->screen_ptr, True); @@ -2089,7 +2089,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, icon->icon->shadowed = 0; icon->icon->force_paint = 1; } - wAppIconSave(icon); + save_appicon(icon, True); } if (src->auto_collapse || src->auto_raise_lower)