This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.

The branch, next has been updated
       via  931f248717cef514a3674617e4ce4262c7d9c126 (commit)
       via  8331c7aae04685feb9fbe444049d6359adba32dc (commit)
       via  2a4a41203a2ffeb41913c61b871df3b9cd7650a9 (commit)
       via  5d09a25297e134f6aaf2cfa0a546cfe1cfba708e (commit)
      from  3bd9e8358fe30ce6b35022e82ef558a4181815e6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/931f248717cef514a3674617e4ce4262c7d9c126

commit 931f248717cef514a3674617e4ce4262c7d9c126
Author: David Maciejak <[email protected]>
Date:   Mon Sep 1 12:58:21 2014 +0700

    wmaker: merge reading menu duplicate code
    
    This patch is adding a readMenu function to be called from
    readMenuPipe and readMenuFile, saving about 20 lines of code.

diff --git a/src/rootmenu.c b/src/rootmenu.c
index a922f5ea..7644e9e2 100644
--- a/src/rootmenu.c
+++ b/src/rootmenu.c
@@ -4,6 +4,7 @@
  *
  *  Copyright (c) 1997-2003 Alfredo K. Kojima
  *  Copyright (c) 1998-2003 Dan Pascu
+ *  Copyright (c) 2014 Window Maker Team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -60,7 +61,6 @@
 
 #define MAX_SHORTCUT_LENGTH 32
 
-
 static WMenu *readMenuPipe(WScreen * scr, char **file_name);
 static WMenu *readPLMenuPipe(WScreen * scr, char **file_name);
 static WMenu *readMenuFile(WScreen *scr, const char *file_name);
@@ -1048,19 +1048,13 @@ static WMenu *parseCascade(WScreen * scr, WMenu * menu, 
WMenuParser parser)
        return NULL;
 }
 
-static WMenu *readMenuFile(WScreen *scr, const char *file_name)
+static WMenu *readMenu(WScreen *scr, const char *flat_file, FILE *file)
 {
        WMenu *menu = NULL;
-       FILE *file = NULL;
        WMenuParser parser;
-       char *command, *params, *shortcut, *title;
+       char *title, *command, *params, *shortcut;
 
-       file = fopen(file_name, "rb");
-       if (!file) {
-               werror(_("%s:could not open menu file"), file_name);
-               return NULL;
-       }
-       parser = WMenuParserCreate(file_name, file, DEF_CONFIG_PATHS);
+       parser = WMenuParserCreate(flat_file, file, DEF_CONFIG_PATHS);
        menu_parser_register_macros(parser);
 
        while (WMenuParserGetLine(parser, &title, &command, &params, 
&shortcut)) {
@@ -1080,14 +1074,29 @@ static WMenu *readMenuFile(WScreen *scr, const char 
*file_name)
                        freeline(title, command, params, shortcut);
                        break;
                } else {
-                       WMenuParserError(parser, _("invalid menu file, MENU 
command is missing") );
+                       WMenuParserError(parser, _("invalid menu, no menu title 
given") );
                        freeline(title, command, params, shortcut);
                        break;
                }
+
                freeline(title, command, params, shortcut);
        }
 
        WMenuParserDelete(parser);
+       return menu;
+}
+
+static WMenu *readMenuFile(WScreen *scr, const char *file_name)
+{
+       WMenu *menu = NULL;
+       FILE *file = NULL;
+
+       file = fopen(file_name, "rb");
+       if (!file) {
+               werror(_("%s:could not open menu file"), file_name);
+               return NULL;
+       }
+       menu = readMenu(scr, file_name, file);
        fclose(file);
 
        return menu;
@@ -1130,8 +1139,6 @@ static WMenu *readMenuPipe(WScreen * scr, char 
**file_name)
 {
        WMenu *menu = NULL;
        FILE *file = NULL;
-       WMenuParser parser;
-       char *command, *params, *shortcut, *title;
        char *filename;
        char flat_file[MAXLINE];
        int i;
@@ -1149,35 +1156,7 @@ static WMenu *readMenuPipe(WScreen * scr, char 
**file_name)
                werror(_("%s:could not open menu file"), filename);
                return NULL;
        }
-       parser = WMenuParserCreate(flat_file, file, DEF_CONFIG_PATHS);
-       menu_parser_register_macros(parser);
-
-       while (WMenuParserGetLine(parser, &title, &command, &params, 
&shortcut)) {
-
-               if (command == NULL || !command[0]) {
-                       WMenuParserError(parser, _("missing command in menu 
config") );
-                       freeline(title, command, params, shortcut);
-                       break;
-               }
-               if (strcasecmp(command, "MENU") == 0) {
-                       menu = wMenuCreate(scr, M_(title), True);
-                       menu->on_destroy = removeShortcutsForMenu;
-                       if (!parseCascade(scr, menu, parser)) {
-                               wMenuDestroy(menu, True);
-                               menu = NULL;
-                       }
-                       freeline(title, command, params, shortcut);
-                       break;
-               } else {
-                       WMenuParserError(parser, _("no title given for the root 
menu") );
-                       freeline(title, command, params, shortcut);
-                       break;
-               }
-
-               freeline(title, command, params, shortcut);
-       }
-
-       WMenuParserDelete(parser);
+       menu = readMenu(scr, flat_file, file);
        pclose(file);
 
        return menu;

http://repo.or.cz/w/wmaker-crm.git/commit/8331c7aae04685feb9fbe444049d6359adba32dc

commit 8331c7aae04685feb9fbe444049d6359adba32dc
Author: David Maciejak <[email protected]>
Date:   Tue Sep 2 11:19:09 2014 +0700

    WINGs: merge bagtree duplicate code
    
    This patch is adding a new static function treeDeleteNode to factorize some 
code.

diff --git a/WINGs/bagtree.c b/WINGs/bagtree.c
index 25ac0805..4b3062ca 100644
--- a/WINGs/bagtree.c
+++ b/WINGs/bagtree.c
@@ -420,10 +420,8 @@ void WMInsertInBag(WMBag * self, int index, void *item)
        self->count++;
 }
 
-int WMRemoveFromBag(WMBag * self, void *item)
+static int treeDeleteNode(WMBag * self, W_Node *ptr)
 {
-       W_Node *ptr = treeFind(self->root, self->nil, item);
-
        if (ptr != self->nil) {
                W_Node *tmp;
 
@@ -439,11 +437,15 @@ int WMRemoveFromBag(WMBag * self, void *item)
                if (self->destructor)
                        self->destructor(ptr->data);
                wfree(ptr);
-
                return 1;
-       } else {
-               return 0;
        }
+       return 0;
+}
+
+int WMRemoveFromBag(WMBag * self, void *item)
+{
+       W_Node *ptr = treeFind(self->root, self->nil, item);
+       return treeDeleteNode(self, ptr);
 }
 
 int WMEraseFromBag(WMBag * self, int index)
@@ -470,29 +472,7 @@ int WMEraseFromBag(WMBag * self, int index)
 int WMDeleteFromBag(WMBag * self, int index)
 {
        W_Node *ptr = treeSearch(self->root, self->nil, index);
-
-       if (ptr != self->nil) {
-               W_Node *tmp;
-
-               self->count--;
-
-               tmp = treeSuccessor(ptr, self->nil);
-               while (tmp != self->nil) {
-                       tmp->index--;
-                       tmp = treeSuccessor(tmp, self->nil);
-               }
-
-               ptr = rbTreeDelete(self, ptr);
-               if (self->destructor)
-                       self->destructor(ptr->data);
-               wfree(ptr);
-
-               wassertrv(self->count == 0 || self->root->index >= 0, 1);
-
-               return 1;
-       } else {
-               return 0;
-       }
+       return treeDeleteNode(self, ptr);
 }
 
 void *WMGetFromBag(WMBag * self, int index)

http://repo.or.cz/w/wmaker-crm.git/commit/2a4a41203a2ffeb41913c61b871df3b9cd7650a9

commit 2a4a41203a2ffeb41913c61b871df3b9cd7650a9
Author: David Maciejak <[email protected]>
Date:   Tue Sep 2 11:17:31 2014 +0700

    WINGs: merge hashtable duplicate code
    
    This patch is adding a new static function hashGetItem to factorize some 
code.

diff --git a/WINGs/hashtable.c b/WINGs/hashtable.c
index c4c82144..2620c784 100644
--- a/WINGs/hashtable.c
+++ b/WINGs/hashtable.c
@@ -154,7 +154,7 @@ unsigned WMCountHashTable(WMHashTable * table)
        return table->itemCount;
 }
 
-void *WMHashGet(WMHashTable * table, const void *key)
+static HashItem *hashGetItem(WMHashTable *table, const void *key)
 {
        unsigned h;
        HashItem *item;
@@ -177,44 +177,32 @@ void *WMHashGet(WMHashTable * table, const void *key)
                        item = item->next;
                }
        }
-       if (item)
-               return (void *)item->data;
-       else
+       return item;
+}
+
+void *WMHashGet(WMHashTable * table, const void *key)
+{
+       HashItem *item;
+
+       item = hashGetItem(table, key);
+       if (!item)
                return NULL;
+       return (void *)item->data;
 }
 
 Bool WMHashGetItemAndKey(WMHashTable * table, const void *key, void **retItem, 
void **retKey)
 {
-       unsigned h;
        HashItem *item;
 
-       h = HASH(table, key);
-       item = table->table[h];
-
-       if (table->callbacks.keyIsEqual) {
-               while (item) {
-                       if ((*table->callbacks.keyIsEqual) (key, item->key)) {
-                               break;
-                       }
-                       item = item->next;
-               }
-       } else {
-               while (item) {
-                       if (key == item->key) {
-                               break;
-                       }
-                       item = item->next;
-               }
-       }
-       if (item) {
-               if (retKey)
-                       *retKey = (void *)item->key;
-               if (retItem)
-                       *retItem = (void *)item->data;
-               return True;
-       } else {
+       item = hashGetItem(table, key);
+       if (!item)
                return False;
-       }
+
+       if (retKey)
+               *retKey = (void *)item->key;
+       if (retItem)
+               *retItem = (void *)item->data;
+       return True;
 }
 
 void *WMHashInsert(WMHashTable * table, const void *key, const void *data)

http://repo.or.cz/w/wmaker-crm.git/commit/5d09a25297e134f6aaf2cfa0a546cfe1cfba708e

commit 5d09a25297e134f6aaf2cfa0a546cfe1cfba708e
Author: David Maciejak <[email protected]>
Date:   Mon Sep 1 12:48:36 2014 +0700

    wmaker: improve key shortcut labelling
    
    This patch is improving the key shortcut labelling in the root menu.
    It modifies the GetShortcutString function to save some cycles
    as wXModifierFromKey is already doing all the string comparisons.
    This patch introduces a new function called wXModifierToShortcutLabel
    that is checking the return value from wXModifierFromKey.
    Not sure why Control was set as a special key, as keyboards could
    have 2 controls but also 2 shift keys.

diff --git a/src/misc.c b/src/misc.c
index 3d78c930..6856baf6 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -731,49 +731,28 @@ static char *keysymToString(KeySym keysym, unsigned int 
state)
 char *GetShortcutString(const char *shortcut)
 {
        char *buffer = NULL;
-       char *k;
-       int control = 0;
-       char *tmp, *text;
+       char *k, *tmp, *text;
 
        tmp = text = wstrdup(shortcut);
 
        /* get modifiers */
        while ((k = strchr(text, '+')) != NULL) {
                int mod;
+               char *lbl;
 
                *k = 0;
                mod = wXModifierFromKey(text);
                if (mod < 0) {
                        return wstrdup("bug");
                }
-
-               if (strcasecmp(text, "Meta") == 0) {
-                       buffer = wstrappend(buffer, "M+");
-               } else if (strcasecmp(text, "Alt") == 0) {
-                       buffer = wstrappend(buffer, "A+");
-               } else if (strcasecmp(text, "Shift") == 0) {
-                       buffer = wstrappend(buffer, "Sh+");
-               } else if (strcasecmp(text, "Mod1") == 0) {
-                       buffer = wstrappend(buffer, "M1+");
-               } else if (strcasecmp(text, "Mod2") == 0) {
-                       buffer = wstrappend(buffer, "M2+");
-               } else if (strcasecmp(text, "Mod3") == 0) {
-                       buffer = wstrappend(buffer, "M3+");
-               } else if (strcasecmp(text, "Mod4") == 0) {
-                       buffer = wstrappend(buffer, "M4+");
-               } else if (strcasecmp(text, "Mod5") == 0) {
-                       buffer = wstrappend(buffer, "M5+");
-               } else if (strcasecmp(text, "Control") == 0) {
-                       control = 1;
-               } else {
+               lbl = wXModifierToShortcutLabel(mod);
+               if (lbl)
+                       buffer = wstrappend(buffer, lbl);
+               else
                        buffer = wstrappend(buffer, text);
-               }
                text = k + 1;
        }
 
-       if (control) {
-               buffer = wstrappend(buffer, "^");
-       }
        buffer = wstrappend(buffer, text);
        wfree(tmp);
 
diff --git a/src/xmodifier.c b/src/xmodifier.c
index e114f650..05ac6572 100644
--- a/src/xmodifier.c
+++ b/src/xmodifier.c
@@ -262,6 +262,34 @@ static void x_reset_modifier_mapping(Display * display)
        XFreeModifiermap(x_modifier_keymap);
 }
 
+char *wXModifierToShortcutLabel(int mask)
+{
+       if (mask < 0)
+               return NULL;
+
+       if (mask == ShiftMask)
+               return "Sh+";
+       if (mask ==  ControlMask)
+               return "^";
+       if (mask ==  AltMask)
+               return "A+";
+       if (mask ==  Mod1Mask)
+               return "M1+";
+       if (mask ==  Mod2Mask)
+               return "M2+";
+       if (mask ==  Mod3Mask)
+               return "M3+";
+       if (mask ==  Mod4Mask)
+               return "M4+";
+       if (mask ==  Mod5Mask)
+               return "M5+";
+       if (mask ==  MetaMask)
+               return "M+";
+
+       wwarning("Can't convert keymask to shortcut label");
+       return NULL;
+}
+
 int wXModifierFromKey(const char *key)
 {
        if (strcasecmp(key, "SHIFT") == 0 && ShiftMask != 0)
diff --git a/src/xmodifier.h b/src/xmodifier.h
index 89e67572..757b1906 100644
--- a/src/xmodifier.h
+++ b/src/xmodifier.h
@@ -22,5 +22,6 @@
 
 void wXModifierInitialize(void);
 int  wXModifierFromKey(const char *key);
+char *wXModifierToShortcutLabel(int mask);
 
 #endif /* _XMODIFIER_H_INCLUDED */

-----------------------------------------------------------------------

Summary of changes:
 WINGs/bagtree.c   |   38 +++++++------------------------
 WINGs/hashtable.c |   50 ++++++++++++++++--------------------------
 src/misc.c        |   33 +++++----------------------
 src/rootmenu.c    |   63 +++++++++++++++++-----------------------------------
 src/xmodifier.c   |   28 +++++++++++++++++++++++
 src/xmodifier.h   |    1 +
 6 files changed, 84 insertions(+), 129 deletions(-)


repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
-- 
wmaker-crm.git ("The Window Maker window manager")


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

Reply via email to