diff options
author | Michal Mazurek <akfaew@jasminek.net> | 2012-06-11 22:22:40 +0200 |
---|---|---|
committer | Michal Mazurek <akfaew@jasminek.net> | 2012-06-16 17:15:37 +0200 |
commit | fd3ac688b5bf7ee21810cf8554b86922fe9ed4ed (patch) | |
tree | ff6a3c70e8ec26a7b4acd206c78c65e5da2f6ccf | |
parent | 5926a08309ff46ef410fee6a9035f0ad14040af0 (diff) | |
download | xombrero-fd3ac688b5bf7ee21810cf8554b86922fe9ed4ed.tar.gz |
add statusbar_style
-rw-r--r-- | settings.c | 61 | ||||
-rw-r--r-- | xombrero.1 | 7 | ||||
-rw-r--r-- | xombrero.c | 17 | ||||
-rw-r--r-- | xombrero.h | 6 |
4 files changed, 86 insertions, 5 deletions
diff --git a/settings.c b/settings.c index e3cdc50..2e90ec2 100644 --- a/settings.c +++ b/settings.c @@ -61,6 +61,7 @@ char *include_config = NULL; /* runtime settings */ int show_tabs = XT_DS_SHOW_TABS; /* show tabs on notebook */ int tab_style = XT_DS_TAB_STYLE; /* tab bar style */ +int statusbar_style = XT_DS_STATUSBAR_STYLE; /* status bar style */ int show_url = XT_DS_SHOW_URL; /* show url toolbar on notebook */ int show_statusbar = XT_DS_SHOW_STATUSBAR; /* vimperator style status bar */ int ctrl_click_focus = XT_DS_CTRL_CLICK_FOCUS; /* ctrl click gets focus */ @@ -117,6 +118,7 @@ char *get_download_dir(struct settings *); char *get_default_script(struct settings *); char *get_runtime_dir(struct settings *); char *get_tab_style(struct settings *); +char *get_statusbar_style(struct settings *); char *get_edit_mode(struct settings *); char *get_download_mode(struct settings *); char *get_work_dir(struct settings *); @@ -162,6 +164,8 @@ int set_runtime_dir(struct settings *, char *); int set_tabbar_font(char *value); int set_tab_style(struct settings *, char *); int set_tab_style_rt(char *); +int set_statusbar_style(struct settings *, char *); +int set_statusbar_style_rt(char *); int set_edit_mode(struct settings *, char *); int set_work_dir(struct settings *, char *); int set_auto_load_images(char *); @@ -339,6 +343,12 @@ struct special s_tab_style = { NULL }; +struct special s_statusbar_style = { + set_statusbar_style, + get_statusbar_style, + NULL +}; + struct special s_edit_mode = { set_edit_mode, get_edit_mode, @@ -421,6 +431,7 @@ struct settings rs[] = { { "statusbar_elems", XT_S_STR, 0, NULL, &statusbar_elems, NULL, NULL, NULL }, { "tab_style", XT_S_STR, 0, NULL, NULL,&s_tab_style, NULL, set_tab_style_rt }, { "userstyle", XT_S_STR, 0, NULL, NULL,&s_userstyle, NULL, set_userstyle_rt }, + { "statusbar_style", XT_S_STR, 0, NULL, NULL,&s_statusbar_style, NULL, set_statusbar_style_rt }, { "userstyle_global", XT_S_INT, 0, &userstyle_global, NULL, NULL, NULL, set_userstyle_global }, { "url_regex", XT_S_STR, 0, NULL, &url_regex, NULL, NULL, set_url_regex }, { "window_height", XT_S_INT, 0, &window_height, NULL, NULL, NULL, NULL }, @@ -2156,6 +2167,56 @@ set_tab_style_rt(char *value) return (0); } +char * +get_statusbar_style(struct settings *s) +{ + if (statusbar_style == XT_STATUSBAR_URL) + return (g_strdup("url")); + else + return (g_strdup("title")); +} + +int +set_statusbar_style(struct settings *s, char *val) +{ + if (!strcmp(val, "url")) + statusbar_style = XT_STATUSBAR_URL; + else if (!strcmp(val, "title")) + statusbar_style = XT_STATUSBAR_TITLE; + else + return (1); + + return (0); +} + +int +set_statusbar_style_rt(char *value) +{ + struct tab *t; + const gchar *page_uri; + + if (value == NULL || strlen(value) == 0) { + if (statusbar_style == XT_DS_STATUSBAR_STYLE) + return (0); + statusbar_style = XT_DS_STATUSBAR_STYLE; + } else { + if (!strcmp(value, "url")) + statusbar_style = XT_STATUSBAR_URL; + else if (!strcmp(value, "title")) + statusbar_style = XT_STATUSBAR_TITLE; + } + + /* apply changes */ + TAILQ_FOREACH(t, &tabs, entry) { + if (statusbar_style == XT_STATUSBAR_TITLE) + set_status(t, "%s", get_title(t, FALSE)); + else if ((page_uri = get_uri(t)) != NULL) + set_status(t, "%s", page_uri); + } + + return (0); +} + int set_url_regex(char *value) { diff --git a/xombrero.1 b/xombrero.1 index d223e9b..83d6d38 100644 --- a/xombrero.1 +++ b/xombrero.1 @@ -1441,6 +1441,13 @@ zoom amount 100%. Set the status bar font. E.g. .Pa statusbar_font = monospace normal 9 . +.It Cm statusbar_style +Set the status bar style to either +.Cm url +- display the current url, or +.Cm title +- display the page title. The default is +.Cm url . .It Cm tab_style Set the tab style to either .Cm normal diff --git a/xombrero.c b/xombrero.c index bdfe23a..02c7dab 100644 --- a/xombrero.c +++ b/xombrero.c @@ -4166,13 +4166,17 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t) h->time = time(NULL); } - set_status(t, "%s", (char *)uri); + if (statusbar_style == XT_STATUSBAR_URL) + set_status(t, "%s", (char *)uri); + else + set_status(t, "%s", (char *)get_title(t, FALSE)); gtk_widget_set_sensitive(GTK_WIDGET(t->stop), FALSE); #if GTK_CHECK_VERSION(2, 20, 0) gtk_spinner_stop(GTK_SPINNER(t->spinner)); gtk_widget_hide(t->spinner); #endif break; + #if WEBKIT_CHECK_VERSION(1, 1, 18) case WEBKIT_LOAD_FAILED: /* 4 */ @@ -4181,7 +4185,7 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t) get_title(t, FALSE)); gtk_label_set_text(GTK_LABEL(t->tab_elems.label), get_title(t, FALSE)); - set_status(t, get_title(t, FALSE), XT_STATUS_URI); + set_status(t, "%s", (char *)get_title(t, FALSE)); gtk_window_set_title(GTK_WINDOW(main_window), get_title(t, TRUE)); } else { @@ -5176,10 +5180,13 @@ webview_hover_cb(WebKitWebView *wv, gchar *title, gchar *uri, struct tab *t) if (uri) set_status(t, "Link: %s", uri); else { - const gchar *page_uri; + if (statusbar_style == XT_STATUSBAR_URL) { + const gchar *page_uri; - if ((page_uri = get_uri(t)) != NULL) - set_status(t, "%s", page_uri); + if ((page_uri = get_uri(t)) != NULL) + set_status(t, "%s", page_uri); + } else + set_status(t, "%s", (char *)get_title(t, FALSE)); } } diff --git a/xombrero.h b/xombrero.h index 3412ef2..6430c38 100644 --- a/xombrero.h +++ b/xombrero.h @@ -359,6 +359,7 @@ gboolean match_uri(const gchar *uri, const gchar *key); int valid_url_type(char *); void expand_tilde(char *, size_t, const char *); char *html_escape(const char *val); +void set_status(struct tab *t, gchar *fmt, ...); void load_webkit_string(struct tab *, const char *, gchar *); void button_set_stockid(GtkWidget *, char *); @@ -554,6 +555,9 @@ int fork_exec(struct tab *, char *, const gchar *, char *, int); #define XT_TABS_NORMAL (0) #define XT_TABS_COMPACT (1) +#define XT_STATUSBAR_URL (0) +#define XT_STATUSBAR_TITLE (1) + #define XT_EM_HYBRID (0) #define XT_EM_VI (1) @@ -574,6 +578,7 @@ int fork_exec(struct tab *, char *, const gchar *, char *, int); /* runtime default settings */ #define XT_DS_SHOW_TABS (1) #define XT_DS_TAB_STYLE XT_TABS_NORMAL +#define XT_DS_STATUSBAR_STYLE XT_STATUSBAR_URL #define XT_DS_SHOW_URL (1) #define XT_DS_SHOW_STATUSBAR (0) #define XT_DS_CTRL_CLICK_FOCUS (0) @@ -729,6 +734,7 @@ extern SoupURI *proxy_uri; extern int show_tabs; extern int tab_style; +extern int statusbar_style; extern int show_url; extern int show_statusbar; extern int ctrl_click_focus; |