surf-short-title-20210206-7dcce9e.diff - sites - public wiki contents of suckle… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
surf-short-title-20210206-7dcce9e.diff (3637B) | |
--- | |
1 From d5437333d64ff5eb7aaab19e4d42b11d6773a7b0 Mon Sep 17 00:00:00 2001 | |
2 From: Harsh Parekh <[email protected]> | |
3 Date: Sat, 6 Feb 2021 08:33:49 -0500 | |
4 Subject: [PATCH] Hide status from title. | |
5 | |
6 You can pass -E 1 to show the extended title. | |
7 --- | |
8 config.def.h | 2 ++ | |
9 surf.1 | 7 +++++++ | |
10 surf.c | 31 ++++++++++++++++++++++++------- | |
11 3 files changed, 33 insertions(+), 7 deletions(-) | |
12 | |
13 diff --git a/config.def.h b/config.def.h | |
14 index be168ab..2783e4d 100644 | |
15 --- a/config.def.h | |
16 +++ b/config.def.h | |
17 @@ -1,5 +1,6 @@ | |
18 /* modifier 0 means no modifier */ | |
19 static int surfuseragent = 1; /* Append Surf version to default Web… | |
20 +static int extendedtitle = 0; /* 0 to not append surf's toggle and … | |
21 static char *fulluseragent = ""; /* Or override the whole user agent s… | |
22 static char *scriptfile = "~/.surf/script.js"; | |
23 static char *styledir = "~/.surf/styles/"; | |
24 @@ -176,6 +177,7 @@ static Key keys[] = { | |
25 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { … | |
26 { 0, GDK_KEY_F11, togglefullscreen, { 0 … | |
27 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 }… | |
28 + { MODKEY|GDK_SHIFT_MASK, GDK_KEY_e, toggletitle, { … | |
29 | |
30 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = Car… | |
31 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = Fra… | |
32 diff --git a/surf.1 b/surf.1 | |
33 index 45c31bb..0e15c61 100644 | |
34 --- a/surf.1 | |
35 +++ b/surf.1 | |
36 @@ -55,6 +55,13 @@ Enable the disk cache. | |
37 Reparents to window specified by | |
38 .IR xid . | |
39 .TP | |
40 +.B \-E [1|0] | |
41 +Show or hide | |
42 +.I indicators of operation | |
43 +and | |
44 +.I indicators of web page | |
45 +in the title. | |
46 +.TP | |
47 .B \-f | |
48 Start surf in windowed mode (not fullscreen). | |
49 .TP | |
50 diff --git a/surf.c b/surf.c | |
51 index ac832ff..bca0b91 100644 | |
52 --- a/surf.c | |
53 +++ b/surf.c | |
54 @@ -234,6 +234,7 @@ static void toggle(Client *c, const Arg *a); | |
55 static void togglefullscreen(Client *c, const Arg *a); | |
56 static void togglecookiepolicy(Client *c, const Arg *a); | |
57 static void toggleinspector(Client *c, const Arg *a); | |
58 +static void toggletitle(Client *c, const Arg *a); | |
59 static void find(Client *c, const Arg *a); | |
60 | |
61 /* Buttons */ | |
62 @@ -649,13 +650,19 @@ updatetitle(Client *c) | |
63 gettogglestats(c); | |
64 getpagestats(c); | |
65 | |
66 - if (c->progress != 100) | |
67 - title = g_strdup_printf("[%i%%] %s:%s | %s", | |
68 - c->progress, togglestats, pagestats, na… | |
69 - else | |
70 - title = g_strdup_printf("%s:%s | %s", | |
71 - togglestats, pagestats, name); | |
72 - | |
73 + if (c->progress != 100) { | |
74 + if (!extendedtitle) | |
75 + title = g_strdup_printf("[%i%%] %s", c->progress, name); | |
76 + else | |
77 + title = g_strdup_printf("[%i%%] %s:%s | %s", | |
78 + c->progress, togglestat… | |
79 + } else { | |
80 + if (!extendedtitle) | |
81 + title = g_strdup_printf("%s", name); | |
82 + else | |
83 + title = g_strdup_printf("%s:%s | %s", | |
84 + togglestats, pagestats,… | |
85 + } | |
86 gtk_window_set_title(GTK_WINDOW(c->win), title); | |
87 g_free(title); | |
88 } else { | |
89 @@ -1953,6 +1960,13 @@ toggleinspector(Client *c, const Arg *a) | |
90 webkit_web_inspector_show(c->inspector); | |
91 } | |
92 | |
93 +void | |
94 +toggletitle(Client *c, const Arg *a) | |
95 +{ | |
96 + extendedtitle = !extendedtitle; | |
97 + updatetitle(c); | |
98 +} | |
99 + | |
100 void | |
101 find(Client *c, const Arg *a) | |
102 { | |
103 @@ -2042,6 +2056,9 @@ main(int argc, char *argv[]) | |
104 case 'e': | |
105 embed = strtol(EARGF(usage()), NULL, 0); | |
106 break; | |
107 + case 'E': | |
108 + extendedtitle = strtol(EARGF(usage()), NULL, 0); | |
109 + break; | |
110 case 'f': | |
111 defconfig[RunInFullscreen].val.i = 0; | |
112 defconfig[RunInFullscreen].prio = 2; | |
113 -- | |
114 2.30.0 | |
115 |