From: "Rodolfo García Peñas (kix)" <[email protected]>

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().
---
 src/appicon.c     |   28 +++++++++++++++++-----------
 src/appicon.h     |    3 +--
 src/application.c |   12 +-----------
 3 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index c70d4df..573344c 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -71,6 +71,7 @@ static void wApplicationSaveIconPathFor(char *iconPath, char 
*wm_instance, char
 static WAppIcon *wAppIconCreate(WWindow * leader_win);
 static void add_to_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
  * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
@@ -143,19 +144,24 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char 
*command, char *wm_instance,
        return aicon;
 }
 
-void makeAppIconFor(WApplication *wapp)
+void create_appicon_for_application(WApplication *wapp, WWindow *wwin)
 {
-       /* If app_icon, work is done, return */
-       if (wapp->app_icon)
-               return;
+       /* Try to create an icon from the dock or clip */
+       create_appicon_from_dock(wwin, wapp, wapp->main_window);
 
-       /* Create the icon */
-       wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
-       wIconUpdate(wapp->app_icon->icon, NULL);
+       /* If app_icon was not found, create it */
+       if (!wapp->app_icon) {
+               /* Create the icon */
+               wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
+               wIconUpdate(wapp->app_icon->icon, NULL);
+
+               /* Now, paint the icon */
+               if (!WFLAGP(wapp->main_window_desc, no_appicon))
+                       paint_app_icon(wapp);
+       }
 
-       /* Now, paint the icon */
-       if (!WFLAGP(wapp->main_window_desc, no_appicon))
-               paint_app_icon(wapp);
+       /* Save the app_icon in a file */
+       save_appicon(wapp->app_icon, False);
 }
 
 void unpaint_app_icon(WApplication *wapp)
@@ -958,7 +964,7 @@ static WAppIcon *findDockIconFor(WDock *dock, Window 
main_window)
        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;
        wapp->app_icon = NULL;
diff --git a/src/appicon.h b/src/appicon.h
index 6f72c8e..d63d9a7 100644
--- a/src/appicon.h
+++ b/src/appicon.h
@@ -72,11 +72,10 @@ typedef struct WAppIcon {
 WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
                                char *wm_class, int tile);
 
-void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window);
 void wAppIconDestroy(WAppIcon *aicon);
 void wAppIconPaint(WAppIcon *aicon);
 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 save_appicon(WAppIcon *aicon, Bool dock);
 void paint_app_icon(WApplication *wapp);
diff --git a/src/application.c b/src/application.c
index b52a35f..abe1d2d 100644
--- a/src/application.c
+++ b/src/application.c
@@ -141,17 +141,7 @@ WApplication *wApplicationCreate(WWindow * wwin)
        /* application descriptor */
        XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp);
 
-       /* First try to create an icon from the dock or clip */
-       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);
+       create_appicon_for_application(wapp, wwin);
 
        return wapp;
 }
-- 
1.7.10.4


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

Reply via email to