]> git.sur5r.net Git - i3/i3/commitdiff
ipc: make 'layout' a string
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 2 Jun 2011 15:12:18 +0000 (17:12 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 2 Jun 2011 15:12:18 +0000 (17:12 +0200)
src/ipc.c
src/load_layout.c
testcases/t/16-nestedcons.t

index bdf1dfea5670923a732ee15469bb4702e7f08671..fa3513bc352ee74dba2879ff644d981c265943f5 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -202,7 +202,23 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
     y(integer, (con == focused));
 
     ystr("layout");
     y(integer, (con == focused));
 
     ystr("layout");
-    y(integer, con->layout);
+    switch (con->layout) {
+        case L_DEFAULT:
+            ystr("default");
+            break;
+        case L_STACKED:
+            ystr("stacked");
+            break;
+        case L_TABBED:
+            ystr("tabbed");
+            break;
+        case L_DOCKAREA:
+            ystr("dockarea");
+            break;
+        case L_OUTPUT:
+            ystr("output");
+            break;
+    }
 
     ystr("border");
     switch (con->border_style) {
 
     ystr("border");
     switch (con->border_style) {
index 7e57e94dde56a6308e479eaa3fdc69bb65a34337..6fe0a0869241f654a172d355cbae2920e7f7d1fe 100644 (file)
@@ -131,6 +131,21 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) {
                 json_node->border_style = BS_NORMAL;
             else LOG("Unhandled \"border\": %s\n", buf);
             free(buf);
                 json_node->border_style = BS_NORMAL;
             else LOG("Unhandled \"border\": %s\n", buf);
             free(buf);
+        } else if (strcasecmp(last_key, "layout") == 0) {
+            char *buf = NULL;
+            asprintf(&buf, "%.*s", (int)len, val);
+            if (strcasecmp(buf, "default") == 0)
+                json_node->layout = L_DEFAULT;
+            else if (strcasecmp(buf, "stacked") == 0)
+                json_node->layout = L_STACKED;
+            else if (strcasecmp(buf, "tabbed") == 0)
+                json_node->layout = L_TABBED;
+            else if (strcasecmp(buf, "dockarea") == 0)
+                json_node->layout = L_DOCKAREA;
+            else if (strcasecmp(buf, "output") == 0)
+                json_node->layout = L_OUTPUT;
+            else LOG("Unhandled \"layout\": %s\n", buf);
+            free(buf);
         }
     }
     return 1;
         }
     }
     return 1;
@@ -142,6 +157,7 @@ static int json_int(void *ctx, long long val) {
 static int json_int(void *ctx, long val) {
 #endif
     LOG("int %d for key %s\n", val, last_key);
 static int json_int(void *ctx, long val) {
 #endif
     LOG("int %d for key %s\n", val, last_key);
+    // TODO: remove this after the next preview release
     if (strcasecmp(last_key, "layout") == 0) {
         json_node->layout = val;
     }
     if (strcasecmp(last_key, "layout") == 0) {
         json_node->layout = val;
     }
index 954732ddd07cf7877d1901e2fa61e0bc0cd34e7d..8d25482b5630ae735fd004410492b35ddf39ba0c 100644 (file)
@@ -26,7 +26,7 @@ my $expected = {
     geometry => ignore(),
     swallows => ignore(),
     percent => 0,
     geometry => ignore(),
     swallows => ignore(),
     percent => 0,
-    layout => 0,
+    layout => 'default',
     focus => ignore(),
     focused => 0,
     urgent => 0,
     focus => ignore(),
     focused => 0,
     urgent => 0,