diff options
author | Daniel Carl <danielcarl@gmx.de> | 2013-03-29 15:33:34 +0100 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2013-03-29 15:33:34 +0100 |
commit | 9e86e5936c2116094a70efad0898978dda1cd4ec (patch) | |
tree | 8fb787f4867740b39c874e4e532555f5ab3624c5 /src | |
parent | a87e8ff1a9edbfa656715699dac20996fd60be74 (diff) |
Better performance for command history.
Don't set the input colors and font for every printed string. This operation
is a show stopper. Now we change the style only if the message type changes or
the related settings are changed.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 23 | ||||
-rw-r--r-- | src/main.h | 5 | ||||
-rw-r--r-- | src/setting.c | 3 |
3 files changed, 18 insertions, 13 deletions
@@ -325,9 +325,9 @@ void vb_update_statusbar() g_string_free(status, TRUE); } -void vb_update_status_style() +void vb_update_status_style(void) { - StatusType type = vb.state.status; + StatusType type = vb.state.status_type; vb_set_widget_font( vb.gui.eventbox, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type] ); @@ -339,8 +339,9 @@ void vb_update_status_style() ); } -void vb_update_input_style(MessageType type) +void vb_update_input_style(void) { + MessageType type = vb.state.input_type; vb_set_widget_font( vb.gui.inputbox, &vb.style.input_fg[type], &vb.style.input_bg[type], vb.style.input_font[type] ); @@ -353,7 +354,7 @@ void vb_update_urlbar(const char* uri) static gboolean vb_hide_message() { - vb_echo(VB_MSG_NORMAL, FALSE, ""); + vb_inputbox_print(FALSE, VB_MSG_NORMAL, FALSE, ""); return FALSE; } @@ -627,8 +628,8 @@ static const char* vb_get_cookies(SoupURI *uri) static void vb_set_status(const StatusType status) { - if (vb.state.status != status) { - vb.state.status = status; + if (vb.state.status_type != status) { + vb.state.status_type = status; /* update the statusbar style only if the status changed */ vb_update_status_style(); } @@ -641,7 +642,11 @@ void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, co return; } - vb_update_input_style(type); + /* apply input style only if the message type was changed */ + if (type != vb.state.input_type) { + vb.state.input_type = type; + vb_update_input_style(); + } gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), message); gtk_editable_set_position(GTK_EDITABLE(vb.gui.inputbox), strlen(message) > INPUT_LENGTH ? 0 : -1); if (hide) { @@ -762,8 +767,8 @@ static void vb_init_core(void) keybind_init(); vb_read_config(); - vb_update_status_style(); - vb_update_input_style(VB_MSG_NORMAL); + /* initially apply input style */ + vb_update_input_style(); /* make sure the main window and all its contents are visible */ gtk_widget_show_all(gui->window); @@ -239,7 +239,8 @@ typedef struct { char modkey; guint count; guint progress; - StatusType status; + StatusType status_type; + MessageType input_type; gboolean is_inspecting; SearchDirection search_dir; char* search_query; @@ -330,7 +331,7 @@ gboolean vb_set_mode(Mode mode, gboolean clean); void vb_set_widget_font(GtkWidget* widget, const VbColor* fg, const VbColor* bg, PangoFontDescription* font); void vb_update_statusbar(void); void vb_update_status_style(void); -void vb_update_input_style(MessageType type); +void vb_update_input_style(void); void vb_update_urlbar(const char* uri); #endif /* end of include guard: _MAIN_H */ diff --git a/src/setting.c b/src/setting.c index 8570c00..2594965 100644 --- a/src/setting.c +++ b/src/setting.c @@ -448,8 +448,7 @@ static gboolean setting_input_style(const Setting* s, const SettingType type) } } if (type != SETTING_GET) { - /* vb_update_input_style seems to take no immediatly effect */ - vb_echo(VB_MSG_NORMAL, FALSE, GET_TEXT()); + vb_update_input_style(); } return TRUE; |