>From cd73144c80e80cb149d032eb4f093016bec0edc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Fri, 22 Jun 2012 16:39:46 +0200
Subject: [PATCH 01/11] Functions for the appicon list management

New functions:
static void add_appicon_to_appiconlist
static void remove_appicon_of_appiconlist

Adds the appicons and remove appiconf from the app_icon_list,
making the code more clear.
---
 src/appicon.c |   58 +++++++++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 24 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 546c3ac..09dd4d4 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -68,6 +68,8 @@ 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 add_appicon_to_appiconlist(WScreen *scr, WAppIcon *appicon);
+static void remove_appicon_of_appiconlist(WScreen *scr, WAppIcon *appicon);
 
 /* 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
@@ -114,12 +116,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char 
*command, char *wm_instance,
        dicon->yindex = -1;
        dicon->xindex = -1;
 
-       dicon->prev = NULL;
-       dicon->next = scr->app_icon_list;
-       if (scr->app_icon_list)
-               scr->app_icon_list->prev = dicon;
-
-       scr->app_icon_list = dicon;
+       /* Add the appicon to the appiconlist */
+       add_appicon_to_appiconlist(scr, dicon);
 
        if (command)
                dicon->command = wstrdup(command);
@@ -250,14 +248,8 @@ static WAppIcon *wAppIconCreate(WWindow * leader_win)
        /* When no_appicon is set we want to avoid having it on the list
         * because otherwise there will be a hole when the icons are
         * arranged with wArrangeIcons() */
-       if (!WFLAGP(leader_win, no_appicon)) {
-               aicon->prev = NULL;
-               aicon->next = scr->app_icon_list;
-               if (scr->app_icon_list)
-                       scr->app_icon_list->prev = aicon;
-
-               scr->app_icon_list = aicon;
-       }
+       if (!WFLAGP(leader_win, no_appicon))
+               add_appicon_to_appiconlist(scr, aicon);
 
        if (leader_win->wm_class)
                aicon->wm_class = wstrdup(leader_win->wm_class);
@@ -300,16 +292,8 @@ void wAppIconDestroy(WAppIcon * aicon)
        if (aicon->wm_class)
                wfree(aicon->wm_class);
 
-       if (aicon == scr->app_icon_list) {
-               if (aicon->next)
-                       aicon->next->prev = NULL;
-               scr->app_icon_list = aicon->next;
-       } else {
-               if (aicon->next)
-                       aicon->next->prev = aicon->prev;
-               if (aicon->prev)
-                       aicon->prev->next = aicon->next;
-       }
+       /* Remove the appicon of the appiconlist */
+       remove_appicon_of_appiconlist(scr, aicon);
 
        aicon->destroyed = 1;
        wrelease(aicon);
@@ -980,3 +964,29 @@ void create_appicon_from_dock(WWindow *wwin, WApplication 
*wapp, Window main_win
                save_appicon(wapp->app_icon, True);
        }
 }
+
+/* Add the appicon to the appiconlist */
+static void add_appicon_to_appiconlist(WScreen *scr, WAppIcon *appicon)
+{
+       appicon->prev = NULL;
+       appicon->next = scr->app_icon_list;
+       if (scr->app_icon_list)
+               scr->app_icon_list->prev = appicon;
+
+       scr->app_icon_list = appicon;
+}
+
+/* Remove the appicon of the appiconlist */
+static void remove_appicon_of_appiconlist(WScreen *scr, WAppIcon *appicon)
+{
+       if (appicon == scr->app_icon_list) {
+               if (appicon->next)
+                       appicon->next->prev = NULL;
+               scr->app_icon_list = appicon->next;
+       } else {
+               if (appicon->next)
+                       appicon->next->prev = appicon->prev;
+               if (appicon->prev)
+                       appicon->prev->next = appicon->next;
+       }
+}
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From cd73144c80e80cb149d032eb4f093016bec0edc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Fri, 22 Jun 2012 16:39:46 +0200
Subject: [PATCH 01/11] Functions for the appicon list management

New functions:
static void add_appicon_to_appiconlist
static void remove_appicon_of_appiconlist

Adds the appicons and remove appiconf from the app_icon_list,
making the code more clear.
---
 src/appicon.c |   58 +++++++++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 24 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 546c3ac..09dd4d4 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -68,6 +68,8 @@ 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 add_appicon_to_appiconlist(WScreen *scr, WAppIcon *appicon);
+static void remove_appicon_of_appiconlist(WScreen *scr, WAppIcon *appicon);
 
 /* 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
@@ -114,12 +116,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance,
 	dicon->yindex = -1;
 	dicon->xindex = -1;
 
-	dicon->prev = NULL;
-	dicon->next = scr->app_icon_list;
-	if (scr->app_icon_list)
-		scr->app_icon_list->prev = dicon;
-
-	scr->app_icon_list = dicon;
+	/* Add the appicon to the appiconlist */
+	add_appicon_to_appiconlist(scr, dicon);
 
 	if (command)
 		dicon->command = wstrdup(command);
@@ -250,14 +248,8 @@ static WAppIcon *wAppIconCreate(WWindow * leader_win)
 	/* When no_appicon is set we want to avoid having it on the list
 	 * because otherwise there will be a hole when the icons are
 	 * arranged with wArrangeIcons() */
-	if (!WFLAGP(leader_win, no_appicon)) {
-		aicon->prev = NULL;
-		aicon->next = scr->app_icon_list;
-		if (scr->app_icon_list)
-			scr->app_icon_list->prev = aicon;
-
-		scr->app_icon_list = aicon;
-	}
+	if (!WFLAGP(leader_win, no_appicon))
+		add_appicon_to_appiconlist(scr, aicon);
 
 	if (leader_win->wm_class)
 		aicon->wm_class = wstrdup(leader_win->wm_class);
@@ -300,16 +292,8 @@ void wAppIconDestroy(WAppIcon * aicon)
 	if (aicon->wm_class)
 		wfree(aicon->wm_class);
 
-	if (aicon == scr->app_icon_list) {
-		if (aicon->next)
-			aicon->next->prev = NULL;
-		scr->app_icon_list = aicon->next;
-	} else {
-		if (aicon->next)
-			aicon->next->prev = aicon->prev;
-		if (aicon->prev)
-			aicon->prev->next = aicon->next;
-	}
+	/* Remove the appicon of the appiconlist */
+	remove_appicon_of_appiconlist(scr, aicon);
 
 	aicon->destroyed = 1;
 	wrelease(aicon);
@@ -980,3 +964,29 @@ void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_win
 		save_appicon(wapp->app_icon, True);
 	}
 }
+
+/* Add the appicon to the appiconlist */
+static void add_appicon_to_appiconlist(WScreen *scr, WAppIcon *appicon)
+{
+	appicon->prev = NULL;
+	appicon->next = scr->app_icon_list;
+	if (scr->app_icon_list)
+		scr->app_icon_list->prev = appicon;
+
+	scr->app_icon_list = appicon;
+}
+
+/* Remove the appicon of the appiconlist */
+static void remove_appicon_of_appiconlist(WScreen *scr, WAppIcon *appicon)
+{
+	if (appicon == scr->app_icon_list) {
+		if (appicon->next)
+			appicon->next->prev = NULL;
+		scr->app_icon_list = appicon->next;
+	} else {
+		if (appicon->next)
+			appicon->next->prev = appicon->prev;
+		if (appicon->prev)
+			appicon->prev->next = appicon->next;
+	}
+}
-- 
1.7.10

Reply via email to