summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c12
-rw-r--r--src/main.c33
-rw-r--r--src/main.h2
3 files changed, 26 insertions, 21 deletions
diff --git a/src/command.c b/src/command.c
index f582d1c..e282614 100644
--- a/src/command.c
+++ b/src/command.c
@@ -171,10 +171,10 @@ gboolean command_input(const Arg* arg)
) {
/* append the current url to the input message */
char* input = g_strconcat(arg->s, url, NULL);
- vb_echo_force(VB_MSG_NORMAL, input);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, input);
g_free(input);
} else {
- vb_echo_force(VB_MSG_NORMAL, arg->s);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, arg->s);
}
vb_set_mode(VB_MODE_COMMAND, FALSE);
@@ -340,7 +340,7 @@ gboolean command_inspect(const Arg* arg)
gboolean command_hints(const Arg* arg)
{
- vb_echo_force(VB_MSG_NORMAL, arg->s);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, arg->s);
/* mode will be set in hints_create - so we don't neet to do it here */
hints_create(NULL, arg->i, (arg->s ? strlen(arg->s) : 0));
@@ -367,7 +367,7 @@ gboolean command_yank(const Arg* arg)
text = gtk_clipboard_wait_for_text(SECONDARY_CLIPBOARD());
}
if (text) {
- vb_echo_force(VB_MSG_NORMAL, "Yanked: %s", text);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, "Yanked: %s", text);
g_free(text);
return TRUE;
@@ -385,7 +385,7 @@ gboolean command_yank(const Arg* arg)
}
if (a.s) {
vb_set_clipboard(&a);
- vb_echo_force(VB_MSG_NORMAL, "Yanked: %s", a.s);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, "Yanked: %s", a.s);
g_free(a.s);
return TRUE;
@@ -522,7 +522,7 @@ gboolean command_history(const Arg* arg)
return FALSE;
}
- vb_echo_force(VB_MSG_NORMAL, entry);
+ vb_echo_force(VB_MSG_NORMAL, FALSE, entry);
g_free(entry);
return TRUE;
diff --git a/src/main.c b/src/main.c
index 2b0edf7..87a01e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,9 +75,10 @@ static void vb_set_cookie(SoupCookie* cookie);
static const char* vb_get_cookies(SoupURI *uri);
static gboolean vb_hide_message();
static void vb_set_status(const StatusType status);
+void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char* message);
static void vb_destroy_client();
-void vb_echo_force(const MessageType type, const char *error, ...)
+void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...)
{
char message[255];
va_list arg_list;
@@ -86,9 +87,7 @@ void vb_echo_force(const MessageType type, const char *error, ...)
vsnprintf(message, 255, error, arg_list);
va_end(arg_list);
- vb_update_input_style(type);
- 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);
+ vb_inputbox_print(TRUE, type, hide, message);
}
void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
@@ -100,16 +99,7 @@ void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
vsnprintf(message, 255, error, arg_list);
va_end(arg_list);
- /* don't print message if the input is focussed */
- if (gtk_widget_is_focus(GTK_WIDGET(vb.gui.inputbox))) {
- return;
- }
-
- vb_update_input_style(type);
- gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), message);
- if (hide) {
- g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)vb_hide_message, NULL);
- }
+ vb_inputbox_print(FALSE, type, hide, message);
}
gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value)
@@ -644,6 +634,21 @@ static void vb_set_status(const StatusType status)
}
}
+void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char* message)
+{
+ /* don't print message if the input is focussed */
+ if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.inputbox))) {
+ return;
+ }
+
+ vb_update_input_style(type);
+ 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) {
+ g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)vb_hide_message, NULL);
+ }
+}
+
static void vb_run_user_script(WebKitWebFrame* frame)
{
char* js = NULL;
diff --git a/src/main.h b/src/main.h
index 517b2cc..a921e4b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -321,7 +321,7 @@ typedef struct {
extern VbCore core;
/* functions */
-void vb_echo_force(const MessageType type, const char *error, ...);
+void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...);
void vb_echo(const MessageType type, gboolean hide, const char *error, ...);
gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value);
gboolean vb_load_uri(const Arg* arg);