Better performance for command history.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 29 Mar 2013 14:33:34 +0000 (15:33 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 29 Mar 2013 14:33:34 +0000 (15:33 +0100)
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.

src/main.c
src/main.h
src/setting.c

index 87a01e4..1939274 100644 (file)
@@ -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);
index a921e4b..b573e5d 100644 (file)
@@ -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 */
index 8570c00..2594965 100644 (file)
@@ -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;