aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-01-06 16:41:30 -0700
committerGravatar Brendan Taylor <whateley@gmail.com>2011-01-06 16:42:32 -0700
commitb869e6a8e127ff674600a1141fc2bae9b77067cb (patch)
tree3260ef60a088fe9a116a40df5386cefe95a0a178
parent0e40979506f1c82e6cc9182416962370d787e9b3 (diff)
split the status bar into left-aligned and right-aligned parts (thanks k0ral)
-rw-r--r--AUTHORS1
-rw-r--r--README12
-rw-r--r--src/uzbl-core.c75
-rw-r--r--src/uzbl-core.h13
4 files changed, 63 insertions, 38 deletions
diff --git a/AUTHORS b/AUTHORS
index f7e4a16..6522237 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -52,6 +52,7 @@ In alphabetical order:
Jan Kolkmeier (jouz) - scrolling, link following
Jason Woofenden (JasonWoof) - geometry=maximized, link following
Jochen Sprickerhof - session.sh enhancements
+ k0ral - split status bar
Lars-Dominik Braun (PromyLOPh) - added ability to enable/disable the webkit page cache
Laurence Withers (lwithers) - talk_to_socket
Luca Bruno <lucab@debian.org> - bashims fixes
diff --git a/README b/README
index 98ae22c..051fe6b 100644
--- a/README
+++ b/README
@@ -291,8 +291,10 @@ file).
* `keycmd`: Holds the input buffer (callback: update input buffer).
* `show_status`: Show statusbar or not.
* `status_top`: statusbar on top?
-* `status_format`: Marked up, to be expanded string for statusbar (callback:
- update statusbar).
+* `status_format`: Marked up, to be expanded string for statusbar's left side
+ (callback: update statusbar).
+* `status_format_right`: Marked up, to be expanded string for statusbar's right side
+ (callback: update statusbar).
* `status_background`: color which can be used to override Gtk theme.
* `title_format_long`: titlebar string when no statusbar shown (will be
expanded).
@@ -470,10 +472,10 @@ that should be evaluated on every update need to be escaped:
set title_format_short = \\\@(date)\\\@
# the title will stay constant as a literal "@(date)@"
-The `status_format` variable can contain
+The `status_format` and `status_format_right` variables can contain
[Pango](http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html)
-markup . In the `status_format`, variables that might contain characters like
-`<`, `&` and `>`, should be wrapped in a `@[ ]@` substitution so that they don't
+markup . In these variables, expansions that might produce the characters `<`,
+`&` or `>` should be wrapped in `@[ ]@` substitutions so that they don't
interfere with the status bar's markup; see the sample config for examples.
### EXTERNAL SCRIPTS
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index 2a91563..4a1b071 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -85,6 +85,7 @@ const struct var_name_to_ptr_t {
{ "show_status", PTR_V_INT(uzbl.behave.show_status, 1, cmd_set_status)},
{ "status_top", PTR_V_INT(uzbl.behave.status_top, 1, move_statusbar)},
{ "status_format", PTR_V_STR(uzbl.behave.status_format, 1, NULL)},
+ { "status_format_right", PTR_V_STR(uzbl.behave.status_format_right, 1, NULL)},
{ "status_background", PTR_V_STR(uzbl.behave.status_background, 1, set_status_background)},
{ "title_format_long", PTR_V_STR(uzbl.behave.title_format_long, 1, NULL)},
{ "title_format_short", PTR_V_STR(uzbl.behave.title_format_short, 1, NULL)},
@@ -1873,42 +1874,43 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL *
return NULL;
}
-/*
- NOTE: we want to keep variables like b->title_format_long in their "unprocessed" state
- it will probably improve performance if we would "cache" the processed variant, but for now it works well enough...
-*/
-// this function may be called very early when the templates are not set (yet), hence the checks
void
update_title (void) {
Behaviour *b = &uzbl.behave;
- gchar *parsed;
- const gchar *current_title;
- /* this check is here because if we're starting up or shutting down it might not be a window */
- gboolean have_main_window = !uzbl.state.plug_mode && GTK_IS_WINDOW(uzbl.gui.main_window);
- if(have_main_window)
- current_title = gtk_window_get_title (GTK_WINDOW(uzbl.gui.main_window));
+ const gchar *title_format = b->title_format_long;
+ /* Update the status bar if shown */
if (b->show_status) {
- if (b->title_format_short && have_main_window) {
- parsed = expand(b->title_format_short, 0);
- if(!current_title || strcmp(current_title, parsed))
- gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
- g_free(parsed);
- }
- if (b->status_format && GTK_IS_LABEL(uzbl.gui.mainbar_label)) {
- parsed = expand(b->status_format, 0);
- gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), parsed);
+ title_format = b->title_format_short;
+
+ /* Left side */
+ if (b->status_format && GTK_IS_LABEL(uzbl.gui.mainbar_label_left)) {
+ gchar *parsed = expand(b->status_format, 0);
+ gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label_left), parsed);
g_free(parsed);
}
- } else {
- if (b->title_format_long && have_main_window) {
- parsed = expand(b->title_format_long, 0);
- if(!current_title || strcmp(current_title, parsed))
- gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
+
+ /* Right side */
+ if (b->status_format_right && GTK_IS_LABEL(uzbl.gui.mainbar_label_right)) {
+ gchar *parsed = expand(b->status_format_right, 0);
+ gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label_right), parsed);
g_free(parsed);
}
}
+
+ /* Update window title */
+ /* If we're starting up or shutting down there might not be a window yet. */
+ gboolean have_main_window = !uzbl.state.plug_mode && GTK_IS_WINDOW(uzbl.gui.main_window);
+ if (title_format && have_main_window) {
+ gchar *parsed = expand(title_format, 0);
+ const gchar *current_title = gtk_window_get_title (GTK_WINDOW(uzbl.gui.main_window));
+ /* xmonad hogs CPU if the window title updates too frequently, so we
+ * don't set it unless we need to. */
+ if(!current_title || strcmp(current_title, parsed))
+ gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
+ g_free(parsed);
+ }
}
void
@@ -1946,12 +1948,23 @@ create_mainbar () {
GUI *g = &uzbl.gui;
g->mainbar = gtk_hbox_new (FALSE, 0);
- g->mainbar_label = gtk_label_new ("");
- gtk_label_set_selectable((GtkLabel *)g->mainbar_label, TRUE);
- gtk_label_set_ellipsize(GTK_LABEL(g->mainbar_label), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC(g->mainbar_label), 0, 0);
- gtk_misc_set_padding (GTK_MISC(g->mainbar_label), 2, 2);
- gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label, TRUE, TRUE, 0);
+
+ /* Left panel */
+ g->mainbar_label_left = gtk_label_new ("");
+ gtk_label_set_selectable(GTK_LABEL(g->mainbar_label_left), TRUE);
+ gtk_misc_set_alignment (GTK_MISC(g->mainbar_label_left), 0, 0);
+ gtk_misc_set_padding (GTK_MISC(g->mainbar_label_left), 2, 2);
+
+ gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label_left, FALSE, FALSE, 0);
+
+ /* Right panel */
+ g->mainbar_label_right = gtk_label_new ("");
+ gtk_label_set_selectable(GTK_LABEL(g->mainbar_label_right), TRUE);
+ gtk_misc_set_alignment (GTK_MISC(g->mainbar_label_right), 1, 0);
+ gtk_misc_set_padding (GTK_MISC(g->mainbar_label_right), 2, 2);
+ gtk_label_set_ellipsize(GTK_LABEL(g->mainbar_label_right), PANGO_ELLIPSIZE_START);
+
+ gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label_right, TRUE, TRUE, 0);
g_object_connect((GObject*)g->mainbar,
"signal::key-press-event", (GCallback)key_press_cb, NULL,
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index 7076095..f81722d 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -51,8 +51,12 @@ typedef struct {
GtkPlug* plug;
GtkWidget* scrolled_win;
GtkWidget* vbox;
+
+ /* Mainbar */
GtkWidget* mainbar;
- GtkWidget* mainbar_label;
+ GtkWidget* mainbar_label_left;
+ GtkWidget* mainbar_label_right;
+
GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar
GtkScrollbar* scbar_h; // (These are still hidden)
GtkAdjustment* bar_v; // Information about document length
@@ -119,10 +123,15 @@ typedef struct {
/* behaviour */
typedef struct {
+ /* Status bar */
gchar* status_format;
+ gchar* status_format_right;
+ gchar* status_background;
+
+ /* Window title */
gchar* title_format_short;
gchar* title_format_long;
- gchar* status_background;
+
gchar* fifo_dir;
gchar* socket_dir;
gchar* cookie_handler;