summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Marçalo <raroma09@gmail.com>2023-11-29 17:38:07 +0000
committerRafael Marçalo <raroma09@gmail.com>2023-11-29 17:38:07 +0000
commit7920d9e7870948c1259b7620b84f2600dac5ada7 (patch)
treef7d490be5faec70442dad2c1b030d55bc9813362
parent025ce6afa7afacbadb08ec73bd22a9cf3dd7cea1 (diff)
Short title patch
-rw-r--r--config.def.h2
-rw-r--r--surf.17
-rw-r--r--surf.c31
3 files changed, 33 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h
index e5f217e..62fe666 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,5 +1,6 @@
/* modifier 0 means no modifier */
static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
+static int extendedtitle = 0; /* 0 to not append surf's toggle and page status to title. */
static char *fulluseragent = ""; /* Or override the whole user agent string */
static char *scriptfile = "~/.surf/script.js";
static char *styledir = "~/.surf/styles/";
@@ -183,6 +184,7 @@ static Key keys[] = {
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
{ 0, GDK_KEY_F11, togglefullscreen, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_e, toggletitle, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
diff --git a/surf.1 b/surf.1
index fa18bc8..b362d23 100644
--- a/surf.1
+++ b/surf.1
@@ -55,6 +55,13 @@ Enable the disk cache.
Reparents to window specified by
.IR xid .
.TP
+.B \-E [1|0]
+Show or hide
+.I indicators of operation
+and
+.I indicators of web page
+in the title.
+.TP
.B \-f
Start surf in windowed mode (not fullscreen).
.TP
diff --git a/surf.c b/surf.c
index 43e2021..1e04b04 100644
--- a/surf.c
+++ b/surf.c
@@ -238,6 +238,7 @@ static void toggle(Client *c, const Arg *a);
static void togglefullscreen(Client *c, const Arg *a);
static void togglecookiepolicy(Client *c, const Arg *a);
static void toggleinspector(Client *c, const Arg *a);
+static void toggletitle(Client *c, const Arg *a);
static void find(Client *c, const Arg *a);
static void search(Client *c, const Arg *a);
@@ -669,13 +670,19 @@ updatetitle(Client *c)
gettogglestats(c);
getpagestats(c);
- if (c->progress != 100)
- title = g_strdup_printf("[%i%%] %s:%s | %s",
- c->progress, togglestats, pagestats, name);
- else
- title = g_strdup_printf("%s:%s | %s",
- togglestats, pagestats, name);
-
+ if (c->progress != 100) {
+ if (!extendedtitle)
+ title = g_strdup_printf("[%i%%] %s", c->progress, name);
+ else
+ title = g_strdup_printf("[%i%%] %s:%s | %s",
+ c->progress, togglestats, pagestats, name);
+ } else {
+ if (!extendedtitle)
+ title = g_strdup_printf("%s", name);
+ else
+ title = g_strdup_printf("%s:%s | %s",
+ togglestats, pagestats, name);
+ }
gtk_window_set_title(GTK_WINDOW(c->win), title);
g_free(title);
} else {
@@ -1991,6 +1998,13 @@ toggleinspector(Client *c, const Arg *a)
}
void
+toggletitle(Client *c, const Arg *a)
+{
+ extendedtitle = !extendedtitle;
+ updatetitle(c);
+}
+
+void
find(Client *c, const Arg *a)
{
const char *s, *f;
@@ -2079,6 +2093,9 @@ main(int argc, char *argv[])
case 'e':
embed = strtol(EARGF(usage()), NULL, 0);
break;
+ case 'E':
+ extendedtitle = strtol(EARGF(usage()), NULL, 0);
+ break;
case 'f':
defconfig[RunInFullscreen].val.i = 0;
defconfig[RunInFullscreen].prio = 2;