[Vimprobable-users] [PATCH 2/2] Allow autohiding of inputbar when empty.
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
From: Greg L. <gre...@gm...> - 2012-05-06 08:32:35
|
--- config.h | 1 + main.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index 6e712ed..e5b629b 100644 --- a/config.h +++ b/config.h @@ -42,6 +42,7 @@ static const char statusfont[] = "monospace bold 8"; /* font for stat #define ENABLE_INCREMENTAL_SEARCH #define ENABLE_GTK_PROGRESS_BAR #define ENABLE_WGET_PROGRESS_BAR +#define ENABLE_AUTOHIDE_INPUTBAR static const int progressbartick = 20; static const char progressborderleft = '['; static const char progressbartickchar = '='; diff --git a/main.c b/main.c index 1b3d133..e57abbf 100644 --- a/main.c +++ b/main.c @@ -163,6 +163,11 @@ static void new_generic_request(SoupSession *soup_ses, SoupMessage *soup_msg, gp static void update_cookie_jar(SoupCookieJar *jar, SoupCookie *old, SoupCookie *new); static void handle_cookie_request(SoupMessage *soup_msg, gpointer unused); #endif +#ifdef ENABLE_GTK_PROGRESS_BAR +#ifdef ENABLE_AUTOHIDE_INPUTBAR +static gboolean gtk_progress_visible = FALSE; +#endif +#endif /* callbacks */ void window_destroyed_cb(GtkWidget *window, gpointer func_data) { @@ -178,6 +183,16 @@ void webview_progress_changed_cb(WebKitWebView *webview, int progress, gpointer user_data) { #ifdef ENABLE_GTK_PROGRESS_BAR gtk_entry_set_progress_fraction(GTK_ENTRY(inputbox), progress == 100 ? 0 : (double)progress/100); +#ifdef ENABLE_AUTOHIDE_INPUTBAR + if(progress == 100) + gtk_progress_visible = False; + else + gtk_progress_visible = True; + if(!gtk_progress_visible && !echo_active && !gtk_widget_has_focus(inputbox)) + gtk_widget_hide(inputbox); + else + gtk_widget_show(inputbox); +#endif #endif update_state(); } @@ -377,14 +392,14 @@ webview_keypress_cb(WebKitWebView *webview, GdkEventKey *event) { } case ModePassThrough: if (IS_ESCAPE(event)) { - clear_echo(); set(&a); + clear_echo(); return TRUE; } break; case ModeSendKey: - clear_echo(); set(&a); + clear_echo(); break; } return FALSE; @@ -515,9 +530,9 @@ inputbox_activate_cb(GtkEntry *entry, gpointer user_data) { update_state(); } else return; + gtk_widget_grab_focus(GTK_WIDGET(webview)); if (!echo_active) clear_echo(); - gtk_widget_grab_focus(GTK_WIDGET(webview)); } gboolean @@ -1021,6 +1036,9 @@ echo(const Arg *arg) { /* TA: Always free arg->s here, rather than relying on the caller to do * this. */ +#ifdef ENABLE_AUTOHIDE_INPUTBAR + gtk_widget_show(inputbox); +#endif if (arg->s) g_free(arg->s); return TRUE; @@ -1043,7 +1061,15 @@ clear_echo() { gdk_color_parse(urlboxbgcolor[index], &color); gtk_widget_modify_base(inputbox, GTK_STATE_NORMAL, urlboxbgcolor[index] ? &color : NULL); gtk_entry_set_text(GTK_ENTRY(inputbox), ""); - + +#ifdef ENABLE_AUTOHIDE_INPUTBAR +#ifdef ENABLE_GTK_PROGRESS_BAR + if(!gtk_progress_visible && !echo_active && !gtk_widget_has_focus(inputbox)) + gtk_widget_hide(inputbox); +#else + gtk_widget_hide(inputbox); +#endif +#endif return TRUE; } @@ -1058,6 +1084,9 @@ input(const Arg *arg) { /* to avoid things like :open URL :open URL2 or :open :open URL */ clear_echo(); +#ifdef ENABLE_AUTOHIDE_INPUTBAR + gtk_widget_show(inputbox); +#endif gtk_editable_insert_text(GTK_EDITABLE(inputbox), arg->s, -1, &pos); if (arg->i & InsertCurrentURL && (url = webkit_web_view_get_uri(webview))) gtk_editable_insert_text(GTK_EDITABLE(inputbox), url, -1, &pos); @@ -1426,8 +1455,8 @@ set(const Arg *arg) { search_handle = NULL; webkit_web_view_unmark_text_matches(webview); } - clear_echo(); gtk_widget_grab_focus(GTK_WIDGET(webview)); + clear_echo(); break; case ModePassThrough: a.s = g_strdup("-- PASS THROUGH --"); -- 1.7.5.4 |