This patch updates the menu creation in dock.c

This patch changes these functions:

- makeWorkspaceMenu
- makeClipOptionsMenu
- makeDockPositionMenu

Moving the menu_map to the function where is called.

The function dockMenuCreate() is not updated yet, because the
function calls the menu mapping first. I will do it in next patches.

Signed-off-by: Rodolfo García Peñas (kix) <[email protected]>
---
 src/dock.c | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/dock.c b/src/dock.c
index 5213ab0..1d2c63f 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -978,7 +978,7 @@ static void updateWorkspaceMenu(WMenu *menu, WAppIcon *icon)
                wMenuRealize(menu);
 }
 
-static WMenu *makeWorkspaceMenu(WScreen *scr)
+static WMenu *makeWorkspaceMenu(void)
 {
        WMenu *menu;
 
@@ -986,11 +986,9 @@ static WMenu *makeWorkspaceMenu(WScreen *scr)
        if (!menu)
                wwarning(_("could not create workspace submenu for Clip menu"));
 
-       menu_map(menu, scr);
        wMenuAddCallback(menu, "", switchWSCommand, (void *)w_global.clip.icon);
 
        menu->flags.realized = 0;
-       wMenuRealize(menu);
 
        return menu;
 }
@@ -1035,7 +1033,7 @@ static void updateClipOptionsMenu(WMenu *menu, WDock 
*dock)
 }
 
 
-static WMenu *makeClipOptionsMenu(WScreen *scr)
+static WMenu *makeClipOptionsMenu(void)
 {
        WMenu *menu;
        WMenuEntry *entry;
@@ -1046,8 +1044,6 @@ static WMenu *makeClipOptionsMenu(WScreen *scr)
                return NULL;
        }
 
-       menu_map(menu, scr);
-
        entry = wMenuAddCallback(menu, _("Keep on Top"), toggleLoweredCallback, 
NULL);
        entry->flags.indicator = 1;
        entry->flags.indicator_on = 1;
@@ -1074,7 +1070,6 @@ static WMenu *makeClipOptionsMenu(WScreen *scr)
        entry->flags.indicator_type = MI_CHECK;
 
        menu->flags.realized = 0;
-       wMenuRealize(menu);
 
        return menu;
 }
@@ -1173,7 +1168,7 @@ static void updateDockPositionMenu(WMenu *menu, WDock 
*dock)
        entry->clientdata = dock;
 }
 
-static WMenu *makeDockPositionMenu(WScreen *scr)
+static WMenu *makeDockPositionMenu(void)
 {
        /* When calling this, the dock is being created, so scr->dock is still 
not set
         * Therefore the callbacks' clientdata and the indicators can't be set,
@@ -1187,8 +1182,6 @@ static WMenu *makeDockPositionMenu(WScreen *scr)
                return NULL;
        }
 
-       menu_map(menu, scr);
-
        entry = wMenuAddCallback(menu, _("Normal"), 
setDockPositionNormalCallback, NULL);
        entry->flags.indicator = 1;
        entry->flags.indicator_type = MI_DIAMOND;
@@ -1202,7 +1195,6 @@ static WMenu *makeDockPositionMenu(WScreen *scr)
        entry->flags.indicator_type = MI_DIAMOND;
 
        menu->flags.realized = 0;
-       wMenuRealize(menu);
 
        return menu;
 }
@@ -1223,21 +1215,32 @@ static WMenu *dockMenuCreate(WScreen *scr, int type)
        menu_map(menu, scr);
        if (type == WM_DOCK) {
                entry = wMenuAddCallback(menu, _("Dock position"), NULL, NULL);
-               if (w_global.dock.pos_menu == NULL)
-                       w_global.dock.pos_menu = makeDockPositionMenu(scr);
+               if (w_global.dock.pos_menu == NULL) {
+                       w_global.dock.pos_menu = makeDockPositionMenu();
+                       if (w_global.dock.pos_menu) {
+                               menu_map(w_global.dock.pos_menu, scr);
+                               wMenuRealize(w_global.dock.pos_menu);
+                       }
+               }
+
                wMenuEntrySetCascade(menu, entry, w_global.dock.pos_menu);
 
-               if (!wPreferences.flags.nodrawer) {
+               if (!wPreferences.flags.nodrawer)
                        entry = wMenuAddCallback(menu, _("Add a drawer"), 
addADrawerCallback, NULL);
-               }
        } else {
                if (type == WM_CLIP)
                        entry = wMenuAddCallback(menu, _("Clip Options"), NULL, 
NULL);
                else /* if (type == WM_DRAWER) */
                        entry = wMenuAddCallback(menu, _("Drawer options"), 
NULL, NULL);
 
-               if (w_global.clip.opt_menu == NULL)
-                       w_global.clip.opt_menu = makeClipOptionsMenu(scr);
+               if (w_global.clip.opt_menu == NULL) {
+                       w_global.clip.opt_menu = makeClipOptionsMenu();
+
+                       if (w_global.clip.opt_menu) {
+                               menu_map(w_global.clip.opt_menu, scr);
+                               wMenuRealize(w_global.clip.opt_menu);
+                       }
+               }
 
                wMenuEntrySetCascade(menu, entry, w_global.clip.opt_menu);
 
@@ -1268,9 +1271,13 @@ static WMenu *dockMenuCreate(WScreen *scr, int type)
                        entry = wMenuAddCallback(menu, _("Move Icon To"), NULL, 
NULL);
                        wfree(entry->text);
                        entry->text = _("Move Icon To"); /* can be: Move Icons 
to */
-                       w_global.clip.submenu = makeWorkspaceMenu(scr);
-                       if (w_global.clip.submenu)
+                       w_global.clip.submenu = makeWorkspaceMenu();
+
+                       if (w_global.clip.submenu) {
+                               menu_map(w_global.clip.submenu, scr);
+                               wMenuRealize(w_global.clip.submenu);
                                wMenuEntrySetCascade(menu, entry, 
w_global.clip.submenu);
+                       }
                }
 
                entry = wMenuAddCallback(menu, _("Remove Icon"), 
removeIconsCallback, NULL);
-- 
1.8.4.rc3


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

Reply via email to