Clean up a bit

master
crondog 9 years ago
parent d1f6f45cb3
commit 70b24fbb1f

@ -444,13 +444,13 @@ void parse_json(const char *text) {
* *
* */ * */
json_object *result = json_tokener_parse(text); json_object *results = json_tokener_parse(text);
if (!result) { if (!results) {
sway_log(L_DEBUG, "xxx Failed to parse json"); sway_log(L_DEBUG, "xxx Failed to parse json");
return; return;
} }
if (json_object_array_length(result) < 1) { if (json_object_array_length(results) < 1) {
return; return;
} }
@ -459,14 +459,14 @@ void parse_json(const char *text) {
} }
status_line = create_list(); status_line = create_list();
int i; int i;
for (i = 0; i < json_object_array_length(result); ++i) { for (i = 0; i < json_object_array_length(results); ++i) {
json_object *full_text, *short_text, *color, *min_width, *align, *urgent; json_object *full_text, *short_text, *color, *min_width, *align, *urgent;
json_object *name, *instance, *separator, *separator_block_width; json_object *name, *instance, *separator, *separator_block_width;
json_object *json = json_object_array_get_idx(result, i); json_object *json = json_object_array_get_idx(results, i);
if (!json) { if (!json) {
continue; continue;
} }
@ -503,34 +503,45 @@ void parse_json(const char *text) {
if (min_width) { if (min_width) {
new->min_width = json_object_get_int(min_width); new->min_width = json_object_get_int(min_width);
} }
if (align) { if (align) {
new->align = strdup(json_object_get_string(align)); new->align = strdup(json_object_get_string(align));
} }
else {
new->align = strdup("left");
}
if (urgent) { if (urgent) {
new->urgent = json_object_get_int(urgent); new->urgent = json_object_get_int(urgent);
} }
if (name) { if (name) {
new->name = strdup(json_object_get_string(name)); new->name = strdup(json_object_get_string(name));
} }
if (instance) { if (instance) {
new->instance = strdup(json_object_get_string(instance)); new->instance = strdup(json_object_get_string(instance));
} }
if (separator) { if (separator) {
new->separator = json_object_get_int(separator); new->separator = json_object_get_int(separator);
} }
else { else {
new->separator = true; // i3bar spec new->separator = true; // i3bar spec
} }
if (separator_block_width) { if (separator_block_width) {
new->separator_block_width = json_object_get_int(separator_block_width); new->separator_block_width = json_object_get_int(separator_block_width);
} }
else { else {
new->separator_block_width = 9; // i3bar spec new->separator_block_width = 9; // i3bar spec
} }
list_add(status_line, new); list_add(status_line, new);
} }
json_object_put(results);
} }

Loading…
Cancel
Save