useful when there is no clip around

renameWSCommand is based on renameCallback from dock.c

Signed-off-by: Amadeusz Sławiński <am...@asmblr.net>
---
 src/workspace.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/workspace.c b/src/workspace.c
index 380ffec..e83393c 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -50,12 +50,13 @@
 #include "xinerama.h"
 #include "event.h"
 #include "wsmap.h"
+#include "dialog.h"
 
 #define MC_NEW          0
 #define MC_DESTROY_LAST 1
 #define MC_LAST_USED    2
 /* index of the first workspace menu entry */
-#define MC_WORKSPACE1   3
+#define MC_WORKSPACE1   4
 
 #define WORKSPACE_NAME_DISPLAY_PADDING 32
 
@@ -679,6 +680,24 @@ static void newWSCommand(WMenu *menu, WMenuEntry *foo)
                wWorkspaceChange(menu->frame->screen_ptr, ws);
 }
 
+static void renameWSCommand(WMenu *menu, WMenuEntry *foo)
+{
+       char buffer[128];
+       int wspace;
+       char *name;
+
+       (void) foo;
+
+       wspace = menu->frame->screen_ptr->current_workspace;
+
+       name = wstrdup(menu->frame->screen_ptr->workspaces[wspace]->name);
+
+       snprintf(buffer, sizeof(buffer), _("Type the name for workspace %i:"), 
wspace + 1);
+       if (wInputDialog(menu->frame->screen_ptr, _("Rename Workspace"), 
buffer, &name))
+               wWorkspaceRename(menu->frame->screen_ptr, wspace, name);
+
+       wfree(name);
+}
 void wWorkspaceRename(WScreen *scr, int workspace, const char *name)
 {
        char buf[MAX_WORKSPACENAME_WIDTH + 1];
@@ -748,6 +767,7 @@ WMenu *wWorkspaceMenuMake(WScreen * scr, Bool titled)
 
        wMenuAddCallback(wsmenu, _("New"), newWSCommand, NULL);
        wMenuAddCallback(wsmenu, _("Destroy Last"), deleteWSCommand, NULL);
+       wMenuAddCallback(wsmenu, _("Rename Workspace"), renameWSCommand, NULL);
 
        entry = wMenuAddCallback(wsmenu, _("Last Used"), lastWSCommand, NULL);
        entry->rtext = GetShortcutKey(wKeyBindings[WKBD_LASTWORKSPACE]);
-- 
2.4.6


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to