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

This patch removes some empty lines, some curly brackets and
moves some variable declaration to the start of the function.
Changes are cosmetic.
---
 src/winspector.c |  106 ++++++++++++++++++++----------------------------------
 1 file changed, 39 insertions(+), 67 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 99bcd3a..8071a46 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -373,21 +373,18 @@ static int getBool(WMPropList *value)
 {
        char *val;
 
-       if (!WMIsPLString(value)) {
+       if (!WMIsPLString(value))
                return 0;
-       }
-       if (!(val = WMGetFromPLString(value))) {
+
+       if (!(val = WMGetFromPLString(value)))
                return 0;
-       }
 
        if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' 
|| val[0] == 't' || val[0] == '1'))
            || (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
-
                return 1;
        } else if ((val[1] == '\0'
                    && (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || 
val[0] == 'f' || val[0] == '0'))
                   || (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") 
== 0)) {
-
                return 0;
        } else {
                wwarning(_("can't convert \"%s\" to boolean"), val);
@@ -398,39 +395,31 @@ static int getBool(WMPropList *value)
 #define UPDATE_DEFAULTS    1
 #define IS_BOOLEAN         2
 
-/*
- *  Will insert the attribute = value; pair in window's list,
+/* Will insert the attribute = value; pair in window's list,
  * if it's different from the defaults.
- *  Defaults means either defaults database, or attributes saved
+ * Defaults means either defaults database, or attributes saved
  * for the default window "*". This is to let one revert options that are
- * global because they were saved for all windows ("*").
- *
- */
-
+ * global because they were saved for all windows ("*"). */
 static int
 insertAttribute(WMPropList *dict, WMPropList *window, WMPropList *attr, 
WMPropList *value, int flags)
 {
        WMPropList *def_win, *def_value = NULL;
-       int update = 0;
-       int modified = 0;
+       int update = 0, modified = 0;
 
        if (!(flags & UPDATE_DEFAULTS) && dict) {
-               if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL) 
{
+               if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL)
                        def_value = WMGetFromPLDictionary(def_win, attr);
-               }
        }
 
        /* If we could not find defaults in database, fall to hardcoded values.
-        * Also this is true if we save defaults for all windows
-        */
+        * Also this is true if we save defaults for all windows */
        if (!def_value)
                def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
 
-       if ((flags & IS_BOOLEAN))
+       if (flags & IS_BOOLEAN)
                update = (getBool(value) != getBool(def_value));
-       else {
+       else
                update = !WMIsPropListEqualTo(value, def_value);
-       }
 
        if (update) {
                WMPutInPLDictionary(window, attr, value);
@@ -444,34 +433,32 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
 {
        WWindow *wwin = panel->inspected;
        WDDomain *db = WDWindowAttributes;
-       WMPropList *dict = db->dictionary;
-       WMPropList *winDic, *appDic, *value, *key, *key2;
-       char *icon_file;
-       int flags = 0;
+       WMPropList *dict = NULL;
+       WMPropList *winDic, *appDic, *value, *key = NULL, *key2;
+       char *icon_file, *buf1, *buf2;
+       int flags = 0, i = 0;
        int different = 0, different2 = 0;
 
        /* Save will apply the changes and save them */
        applySettings(panel->applyBtn, panel);
 
-       if (WMGetButtonSelected(panel->instRb) != 0)
+       if (WMGetButtonSelected(panel->instRb) != 0) {
                key = WMCreatePLString(wwin->wm_instance);
-       else if (WMGetButtonSelected(panel->clsRb) != 0)
+       } else if (WMGetButtonSelected(panel->clsRb) != 0) {
                key = WMCreatePLString(wwin->wm_class);
-       else if (WMGetButtonSelected(panel->bothRb) != 0) {
-               char *buffer;
-
-               buffer = StrConcatDot(wwin->wm_instance, wwin->wm_class);
-               key = WMCreatePLString(buffer);
-               wfree(buffer);
+       } else if (WMGetButtonSelected(panel->bothRb) != 0) {
+               buf1 = StrConcatDot(wwin->wm_instance, wwin->wm_class);
+               key = WMCreatePLString(buf1);
+               wfree(buf1);
        } else if (WMGetButtonSelected(panel->defaultRb) != 0) {
                key = WMRetainPropList(AnyWindow);
                flags = UPDATE_DEFAULTS;
-       } else
-               key = NULL;
+       }
 
        if (!key)
                return;
 
+       dict = db->dictionary;
        if (!dict) {
                dict = WMCreatePLDictionary(NULL, NULL);
                if (dict) {
@@ -502,16 +489,11 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
                wfree(icon_file);
        }
 
-       {
-               int i = WMGetPopUpButtonSelectedItem(panel->wsP);
-
-               i--;
-
-               if (i >= 0 && i < panel->frame->screen_ptr->workspace_count) {
-                       value = 
WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name);
-                       different |= insertAttribute(dict, winDic, 
AStartWorkspace, value, flags);
-                       WMReleasePropList(value);
-               }
+       i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
+       if (i >= 0 && i < panel->frame->screen_ptr->workspace_count) {
+               value = 
WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name);
+               different |= insertAttribute(dict, winDic, AStartWorkspace, 
value, flags);
+               WMReleasePropList(value);
        }
 
        flags |= IS_BOOLEAN;
@@ -608,9 +590,8 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
                        different |= different2;
                } else {
                        WMRemoveFromPLDictionary(dict, key2);
-                       if (different2) {
+                       if (different2)
                                WMPutInPLDictionary(dict, key2, appDic);
-                       }
                }
                WMReleasePropList(key2);
                WMReleasePropList(appDic);
@@ -618,13 +599,10 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
                WApplication *wapp = wApplicationOf(wwin->main_window);
 
                if (wapp) {
-                       char *instance = wapp->main_window_desc->wm_instance;
-                       char *class = wapp->main_window_desc->wm_class;
-                       char *buffer;
-
-                       buffer = StrConcatDot(instance, class);
-                       key2 = WMCreatePLString(buffer);
-                       wfree(buffer);
+                       buf2 = StrConcatDot(wapp->main_window_desc->wm_instance,
+                                             wapp->main_window_desc->wm_class);
+                       key2 = WMCreatePLString(buf2);
+                       wfree(buf2);
 
                        if (WMIsPropListEqualTo(key, key2)) {
                                WMMergePLDictionaries(winDic, appDic, True);
@@ -644,9 +622,8 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
        }
 
        WMRemoveFromPLDictionary(dict, key);
-       if (different) {
+       if (different)
                WMPutInPLDictionary(dict, key, winDic);
-       }
 
        WMReleasePropList(key);
        WMReleasePropList(winDic);
@@ -726,31 +703,26 @@ static void applySettings(WMButton *button, 
InspectorPanel *panel)
                WSETUFLAG(wwin, skip_window_list, skip_window_list);
                UpdateSwitchMenu(wwin->screen_ptr, wwin, skip_window_list ? 
ACTION_REMOVE : ACTION_ADD);
        } else {
-               if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
+               if (WFLAGP(wwin, omnipresent) != old_omnipresent)
                        WMPostNotificationName(WMNChangedState, wwin, 
"omnipresent");
-               }
        }
 
        if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
-               if (WFLAGP(wwin, no_bind_keys)) {
+               if (WFLAGP(wwin, no_bind_keys))
                        XUngrabKey(dpy, AnyKey, AnyModifier, 
wwin->frame->core->window);
-               } else {
+               else
                        wWindowSetKeyGrabs(wwin);
-               }
        }
 
-       if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
+       if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse)
                wWindowResetMouseGrabs(wwin);
-       }
 
        wwin->frame->flags.need_texture_change = 1;
        wWindowConfigureBorders(wwin);
        wFrameWindowPaint(wwin->frame);
        wNETWMUpdateActions(wwin, False);
 
-       /*
-        * Can't apply emulate_appicon because it will probably cause problems.
-        */
+       /* Can't apply emulate_appicon because it will probably cause problems. 
*/
        if (wapp) {
                /* do application wide stuff */
                WSETUFLAG(wapp->main_window_desc, start_hidden, 
WMGetButtonSelected(panel->appChk[0]));
-- 
1.7.10.4


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

Reply via email to