summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands.c7
-rw-r--r--src/commands.h1
-rw-r--r--src/config.h5
-rw-r--r--src/dwb.c9
-rw-r--r--src/dwb.h4
-rw-r--r--src/view.c31
-rw-r--r--util/keys.in3
-rw-r--r--util/settings.in1
8 files changed, 42 insertions, 19 deletions
diff --git a/src/commands.c b/src/commands.c
index b7aa5bcb..4be29ade 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -885,4 +885,11 @@ commands_presentation_mode(KeyMap *km, Arg *arg) {
commands_toggle_bars(km, arg);
return STATUS_OK;
}
+DwbStatus
+commands_toggle_protected(KeyMap *km, Arg *arg) {
+ GList *gl = dwb.state.nummod == 0 ? dwb.state.fview : g_list_nth(dwb.state.views, dwb.state.nummod);
+ VIEW(gl)->status->protect = !VIEW(gl)->status->protect;
+ dwb_tab_label_set_text(gl, NULL);
+ return STATUS_OK;
+}
/*}}}*/
diff --git a/src/commands.h b/src/commands.h
index 5452d7fe..ec8ebf9e 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -95,5 +95,6 @@ DwbStatus commands_command_mode(KeyMap *, Arg *);
DwbStatus commands_only(KeyMap *, Arg *);
DwbStatus commands_toggle_bars(KeyMap *, Arg *);
DwbStatus commands_presentation_mode(KeyMap *, Arg *);
+DwbStatus commands_toggle_protected(KeyMap *, Arg *);
#endif
diff --git a/src/config.h b/src/config.h
index 46790301..3f1ce10a 100644
--- a/src/config.h
+++ b/src/config.h
@@ -157,6 +157,7 @@ static KeyValue KEYS[] = {
{ "toggle_topbar", { "xt", 0 }, },
{ "toggle_bottombar", { "xb", 0 }, },
{ "presentation_mode", { "F12", GDK_CONTROL_MASK }, },
+ { "protect", { "P", GDK_CONTROL_MASK }, },
};
/* FUNCTION_MAP{{{*/
@@ -171,6 +172,8 @@ static FunctionMap FMAP [] = {
(Func) commands_toggle_bars, NULL, ALWAYS_SM, { .n = BAR_VIS_STATUS } },
{ { "presentation_mode", "Toggle presentation mode" }, 1,
(Func) commands_presentation_mode, NULL, ALWAYS_SM, { .n = BAR_VIS_STATUS | BAR_VIS_TOP } },
+ { { "protect", "Protect/unprotect this tab" }, 1,
+ (Func) commands_toggle_protected, NULL, ALWAYS_SM, { .n = 0 } },
{ { "allow_cookie", "Cookie allowed", }, 1,
(Func)commands_allow_cookie, "No new domain in current context", POST_SM, },
{ { "bookmark", "Bookmark current page", }, 1,
@@ -593,6 +596,8 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL, COLOR_CHAR, { .p = "#505050" }, (S_Func) dwb_reload_layout, },
{ { "tab-number-color", "Color of the number in the tab", },
SETTING_GLOBAL, COLOR_CHAR, { .p = "#7ac5cd" }, (S_Func) dwb_reload_layout, },
+ { { "tab-protected-color", "Color of the number in the tab", },
+ SETTING_GLOBAL, COLOR_CHAR, { .p = "#ff0000" }, (S_Func) dwb_reload_layout, },
{ { "hide-tabbar", "Whether to hide the tabbar (never, always, tiled)", },
SETTING_GLOBAL, CHAR, { .p = "never" }, (S_Func) dwb_set_hide_tabbar, },
{ { "tabbed-browsing", "Whether to enable tabbed browsing", },
diff --git a/src/dwb.c b/src/dwb.c
index 09698091..d53ab856 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -64,9 +64,6 @@ static gboolean dwb_handle_channel(GIOChannel *c, GIOCondition condition, void *
static gboolean dwb_eval_key(GdkEventKey *);
-
-static void dwb_tab_label_set_text(GList *, const char *);
-
static void dwb_save_quickmark(const char *);
static void dwb_open_quickmark(const char *);
@@ -1645,12 +1642,13 @@ dwb_open_quickmark(const char *key) {
}/*}}}*/
/* dwb_tab_label_set_text {{{*/
-static void
+void
dwb_tab_label_set_text(GList *gl, const char *text) {
View *v = gl->data;
const char *uri = text ? text : webkit_web_view_get_title(WEBKIT_WEB_VIEW(v->web));
+ const char *color = !v->status->protect ? dwb.color.tab_number_color : dwb.color.tab_protected_color;
char *escaped = g_markup_printf_escaped("[<span foreground=\"%s\">%d</span>] %s",
- dwb.color.tab_number_color,
+ color,
g_list_position(dwb.state.views, gl),
uri ? uri : "about:blank");
gtk_label_set_markup(GTK_LABEL(v->tablabel), escaped);
@@ -2676,6 +2674,7 @@ dwb_init_style() {
DWB_COLOR_PARSE(&dwb.color.prompt, GET_CHAR("prompt-color"));
dwb.color.tab_number_color = GET_CHAR("tab-number-color");
+ dwb.color.tab_protected_color = GET_CHAR("tab-protected-color");
dwb.color.allow_color = GET_CHAR("status-allowed-color");
dwb.color.block_color = GET_CHAR("status-blocked-color");
diff --git a/src/dwb.h b/src/dwb.h
index c852e38b..a49352aa 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -528,6 +528,7 @@ struct _ViewStatus {
GSList *allowed_plugins;
PluginBlockerStatus pb_status;
GSList *plugin_refs;
+ gboolean protect;
};
struct _View {
GtkWidget *vbox;
@@ -570,6 +571,7 @@ struct _Color {
char *settings_bg_color;
char *settings_fg_color;
char *tab_number_color;
+ char *tab_protected_color;
char *allow_color;
char *block_color;
};
@@ -715,6 +717,7 @@ void dwb_set_normal_message(GList *, gboolean, const char *, ...);
void dwb_set_error_message(GList *, const char *, ...);
gboolean dwb_confirm(GList *, char *, ...);
void dwb_set_status_text(GList *, const char *, DwbColor *, PangoFontDescription *);
+void dwb_tab_label_set_text(GList *, const char *);
void dwb_set_status_bar_text(GtkWidget *, const char *, DwbColor *, PangoFontDescription *, gboolean);
void dwb_update_status_text(GList *gl, GtkAdjustment *);
void dwb_update_status(GList *gl);
@@ -785,5 +788,6 @@ void dwb_set_open_mode(Open);
DwbStatus dwb_set_clipboard(const char *text, GdkAtom atom);
DwbStatus dwb_open_in_editor(void);
+gboolean dwb_confirm(GList *gl, char *prompt, ...);
#endif
diff --git a/src/view.c b/src/view.c
index 71260b80..5cff584c 100644
--- a/src/view.c
+++ b/src/view.c
@@ -840,6 +840,7 @@ view_create_web_view() {
status->allowed_plugins = NULL;
status->plugin_refs = NULL;
status->pb_status = 0;
+ status->protect = false;
for (int i=0; i<SIG_LAST; i++)
status->signals[i] = 0;
@@ -1007,25 +1008,29 @@ view_push_master(Arg *arg) {
/* view_remove (void) {{{*/
void
-view_remove(GList *g) {
- GList *gl = NULL;
+view_remove(GList *gl) {
if (!dwb.state.views->next) {
return;
}
- if (g || dwb.state.nummod == 0) {
- gl = g != NULL ? g : dwb.state.fview;
- if (gl == dwb.state.fview) {
- if ( !(dwb.state.fview = dwb.state.fview->prev) ) {
- dwb.state.fview = g_list_first(dwb.state.views)->next;
- if (dwb.state.bar_visible & BAR_VIS_TOP)
- gtk_widget_show_all(dwb.gui.topbox);
- }
- }
- }
- else if (dwb.state.nummod) {
+ /* FIXME: if dwb.state.nummod == 0, the wrong tab is closed */
+ if (dwb.state.nummod) {
gl = g_list_nth(dwb.state.views, dwb.state.nummod);
}
+ else if (gl == NULL)
+ gl = dwb.state.fview;
View *v = gl->data;
+ /* Check for protected tab */
+ if (v->status->protect && !dwb_confirm(dwb.state.fview, "Really close tab %d [y/n]?", g_list_position(dwb.state.views, gl))) {
+ CLEAR_COMMAND_TEXT(dwb.state.fview);
+ return;
+ }
+ if (gl == dwb.state.fview) {
+ if ( !(dwb.state.fview = dwb.state.fview->prev) ) {
+ dwb.state.fview = g_list_first(dwb.state.views)->next;
+ if (dwb.state.bar_visible & BAR_VIS_TOP)
+ gtk_widget_show_all(dwb.gui.topbox);
+ }
+ }
if (gl == dwb.state.views) {
if (dwb.state.views->next) {
gtk_widget_reparent(VIEW(dwb.state.views->next)->vbox, dwb.gui.left);
diff --git a/util/keys.in b/util/keys.in
index da763238..90b99ca1 100644
--- a/util/keys.in
+++ b/util/keys.in
@@ -85,8 +85,9 @@ push_master Push to master area
toggle_bottomstack Toggle bottomstack
fullscreen Toggle fullscreen
toggle_bars Toggle tabbar and statusbar
-toggle_topbar Toggle tabbar
toggle_bottombar Toggle bottombar
+toggle_topbar Toggle tabbar
+protect Protect/unprotect tab
presentation_mode Toggle presentation mode
# completion Completion
diff --git a/util/settings.in b/util/settings.in
index d31d1bc4..64650cf5 100644
--- a/util/settings.in
+++ b/util/settings.in
@@ -61,6 +61,7 @@ tab-active-fg-color text Foreground color of the active tab
tab-normal-bg-color text Background color of the normal tab
tab-normal-fg-color text Foreground color of the normal tab
tab-number-color text Color of the tabnumber
+tab-protected-color text Color of the tabnumber for protected tabs
# lt Layout
background-tabs checkbox Whether to open tabs in background