From b327b2147a28a2a81cf591875d3f4aee2aa971d4 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 15 Sep 2011 23:14:52 +0000 Subject: convert show_status to a getter --- src/commands.c | 2 +- src/uzbl-core.c | 7 ++----- src/uzbl-core.h | 1 - src/variables.c | 16 +++++++--------- src/variables.h | 3 +++ tests/test-command.c | 10 ++++++---- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/commands.c b/src/commands.c index 8717bd8..27b6606 100644 --- a/src/commands.c +++ b/src/commands.c @@ -108,7 +108,7 @@ void toggle_status (WebKitWebView* page, GArray *argv, GString *result) { (void)page; (void)argv; (void)result; - int current_status = uzbl.behave.show_status; + int current_status = get_show_status(); set_show_status(!current_status); } diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 8449c28..05be103 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -743,7 +743,7 @@ update_title(void) { const gchar *title_format = b->title_format_long; /* Update the status bar if shown */ - if (b->show_status) { + if (get_show_status()) { title_format = b->title_format_short; gchar *parsed = expand(b->status_format, 0); @@ -1098,10 +1098,7 @@ main (int argc, char* argv[]) { settings_init(); /* Update status bar */ - if (!uzbl.behave.show_status) - gtk_widget_hide(uzbl.gui.status_bar); - else - update_title(); + update_title(); /* WebInspector */ set_up_inspector(); diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 1beb11f..35533f7 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -137,7 +137,6 @@ typedef struct { gchar* status_format; gchar* status_format_right; gchar* status_background; - gboolean show_status; gboolean status_top; /* Window title */ diff --git a/src/variables.c b/src/variables.c index 272ca50..8f4f611 100644 --- a/src/variables.c +++ b/src/variables.c @@ -526,17 +526,15 @@ set_geometry(const gchar *geometry) { void set_show_status(int show_status) { - /* todo: use gtk_widget_set_visible */ - uzbl.behave.show_status = show_status; - - if (!uzbl.behave.show_status) - gtk_widget_hide(uzbl.gui.status_bar); - else - gtk_widget_show(uzbl.gui.status_bar); - + gtk_widget_set_visible(uzbl.gui.status_bar, show_status); update_title(); } +int +get_show_status() { + return gtk_widget_get_visible(uzbl.gui.status_bar); +} + void set_status_top(int status_top) { if (!uzbl.gui.scrolled_win && !uzbl.gui.status_bar) @@ -687,7 +685,7 @@ const struct var_name_to_ptr_t { { "verbose", PTR_V_INT(uzbl.state.verbose, 1, NULL)}, { "print_events", PTR_V_INT(uzbl.state.events_stdout, 1, NULL)}, - { "show_status", PTR_V_INT(uzbl.behave.show_status, 1, set_show_status)}, + { "show_status", PTR_V_INT_GETSET(show_status)}, { "status_top", PTR_V_INT(uzbl.behave.status_top, 1, set_status_top)}, { "status_format", PTR_V_STR(uzbl.behave.status_format, 1, NULL)}, { "status_format_right", PTR_V_STR(uzbl.behave.status_format_right, 1, NULL)}, diff --git a/src/variables.h b/src/variables.h index ea3bdcf..4f85474 100644 --- a/src/variables.h +++ b/src/variables.h @@ -34,4 +34,7 @@ int get_zoom_type(); gchar *get_geometry(); void set_geometry(const gchar *); +int get_show_status(); +void set_show_status(int); + #endif diff --git a/tests/test-command.c b/tests/test-command.c index 07f053c..db08097 100644 --- a/tests/test-command.c +++ b/tests/test-command.c @@ -25,6 +25,7 @@ #include #include #include +#include extern UzblCore uzbl; @@ -170,7 +171,7 @@ test_set_variable (struct EventFixture *ef, const void *data) { ASSERT_EVENT(ef, "VARIABLE_SET zoom_level float 0.25"); - g_assert_cmpfloat(0.25, ==, uzbl.behave.zoom_level); + g_assert_cmpfloat(0.25, ==, get_var_value_float("zoom_level")); /* set a constant int (nothing should happen) */ int old_major = uzbl.info.webkit_major; @@ -248,15 +249,16 @@ test_scroll (void) { void test_toggle_status (void) { - g_assert(!uzbl.behave.show_status); + /* status bar is not shown (for whatever reason) */ + g_assert(!get_show_status()); /* status bar can be toggled on */ parse_cmd_line("toggle_status", NULL); - g_assert(uzbl.behave.show_status); + g_assert(get_show_status()); /* status bar can be toggled back off */ parse_cmd_line("toggle_status", NULL); - g_assert(!uzbl.behave.show_status); + g_assert(!get_show_status()); } void -- cgit v1.2.3