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().

Signed-off-by: Carlos R. Mafra <[email protected]>
---
 src/appicon.c     |   37 +++++++++++++++----------------------
 src/appicon.h     |    3 +--
 src/application.c |    2 +-
 src/dock.c        |    8 ++++----
 4 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 6827c2f..d236313 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -68,6 +68,7 @@ static void iconDblClick(WObjDescriptor * desc, XEvent * 
event);
 static void iconExpose(WObjDescriptor * desc, XEvent * event);
 static void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, 
char *wm_class);
 static WAppIcon *wAppIconCreate(WWindow * leader_win);
+static void save_appicon_core(WAppIcon *aicon);
 
 /* 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
@@ -397,8 +398,20 @@ void wAppIconPaint(WAppIcon * aicon)
                               0, 0, wPreferences.icon_size, 
wPreferences.icon_size);
 }
 
+/* Save the application icon, if it's a dockapp then use it with dock = True */
+void save_appicon(WAppIcon *aicon, Bool dock)
+{
+       if (!aicon)
+               return;
+
+       if (dock && (!aicon->docked || aicon->attracted))
+               return;
+
+       save_appicon_core(aicon);
+}
+
 /* Internal application to save the application icon */
-static void save_app_icon_core(WAppIcon *aicon)
+static void save_appicon_core(WAppIcon *aicon)
 {
        char *path;
 
@@ -411,16 +424,6 @@ static void save_app_icon_core(WAppIcon *aicon)
        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 +933,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 +980,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 ec01493..1fbd976 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 f08f435..4e34f35 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 155e1a8..0332d65 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)
-- 
1.7.7


-- 
To unsubscribe, send mail to [email protected].

Reply via email to