From: Michael Stapelberg Date: Fri, 7 Jan 2011 19:48:01 +0000 (+0100) Subject: ipc: change 'orientation' to human readable string instead of raw integer value X-Git-Tag: tree-pr2~130 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=186d2c7bfa7f0eceaa361f95914104e97f123d6a;p=i3%2Fi3 ipc: change 'orientation' to human readable string instead of raw integer value --- diff --git a/src/ipc.c b/src/ipc.c index f953f9ae..a0dd64cc 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -178,7 +178,17 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) { y(integer, con->type); ystr("orientation"); - y(integer, con->orientation); + switch (con->orientation) { + case NO_ORIENTATION: + ystr("none"); + break; + case HORIZ: + ystr("horizontal"); + break; + case VERT: + ystr("vertical"); + break; + } ystr("percent"); y(double, con->percent); diff --git a/testcases/t/22-split.t b/testcases/t/22-split.t index fdf7bb21..dde9cba1 100644 --- a/testcases/t/22-split.t +++ b/testcases/t/22-split.t @@ -12,10 +12,10 @@ my $tmp = get_unused_workspace(); $i3->command("workspace $tmp")->recv; my $ws = get_ws($tmp); -is($ws->{orientation}, 1, 'orientation horizontal by default'); +is($ws->{orientation}, 'horizontal', 'orientation horizontal by default'); $i3->command('split v')->recv; $ws = get_ws($tmp); -is($ws->{orientation}, 2, 'split v changes workspace orientation'); +is($ws->{orientation}, 'vertical', 'split v changes workspace orientation'); ###################################################################### # Open two containers, split, open another container. Then verify @@ -45,7 +45,7 @@ $second = $content->[1]; is(@{$first->{nodes}}, 0, 'first container has no children'); isnt($second->{name}, $old_name, 'second container was replaced'); -is($second->{orientation}, 1, 'orientation is horizontal'); +is($second->{orientation}, 'horizontal', 'orientation is horizontal'); is(@{$second->{nodes}}, 2, 'second container has 2 children'); is($second->{nodes}->[0]->{name}, $old_name, 'found old second container'); @@ -61,10 +61,10 @@ $tmp = get_unused_workspace(); $i3->command("workspace $tmp")->recv; $ws = get_ws($tmp); -is($ws->{orientation}, 1, 'orientation horizontal by default'); +is($ws->{orientation}, 'horizontal', 'orientation horizontal by default'); $i3->command('split v')->recv; $ws = get_ws($tmp); -is($ws->{orientation}, 2, 'split v changes workspace orientation'); +is($ws->{orientation}, 'vertical', 'split v changes workspace orientation'); $i3->command('open')->recv; my @content = @{get_ws_content($tmp)};