add custom style toggle
This commit is contained in:
parent
c4581f3fd5
commit
8aa43e81fc
45
config.h
45
config.h
|
@ -16,7 +16,6 @@
|
||||||
// Plugins
|
// Plugins
|
||||||
#define LIBRE_REDIRECT_ENABLED true
|
#define LIBRE_REDIRECT_ENABLED true
|
||||||
#define READABILITY_ENABLED true
|
#define READABILITY_ENABLED true
|
||||||
#define CUSTOM_STYLE_ENABLED true
|
|
||||||
#define CUSTOM_USER_AGENT false
|
#define CUSTOM_USER_AGENT false
|
||||||
/*
|
/*
|
||||||
To disable plugins:
|
To disable plugins:
|
||||||
|
@ -57,6 +56,7 @@ typedef enum {
|
||||||
refresh_force,
|
refresh_force,
|
||||||
back_to_home,
|
back_to_home,
|
||||||
toggle_fullscreen,
|
toggle_fullscreen,
|
||||||
|
toggle_custom_style,
|
||||||
zoomin,
|
zoomin,
|
||||||
zoomout,
|
zoomout,
|
||||||
zoom_reset,
|
zoom_reset,
|
||||||
|
@ -78,27 +78,28 @@ static struct {
|
||||||
unsigned key;
|
unsigned key;
|
||||||
func id;
|
func id;
|
||||||
} shortcut[] = {
|
} shortcut[] = {
|
||||||
{ CTRL, KEY(h), goback },
|
{ CTRL, KEY(h), goback },
|
||||||
{ CTRL, KEY(j), goforward },
|
{ CTRL, KEY(j), goforward },
|
||||||
{ CTRL, KEY(r), refresh },
|
{ CTRL, KEY(r), refresh },
|
||||||
{ CTRL, KEY(R), refresh_force },
|
{ CTRL, KEY(R), refresh_force },
|
||||||
{ CTRL, KEY(H), back_to_home },
|
{ CTRL, KEY(H), back_to_home },
|
||||||
{ CTRL, KEY(equal), zoomin },
|
{ CTRL, KEY(equal), zoomin },
|
||||||
{ CTRL, KEY(minus), zoomout },
|
{ CTRL, KEY(minus), zoomout },
|
||||||
{ CTRL, KEY(0), zoom_reset },
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
{ CTRL, KEY(KP_Page_Up), prev_tab },
|
{ CTRL, KEY(KP_Page_Up), prev_tab },
|
||||||
{ CTRL, KEY(KP_Page_Down), next_tab },
|
{ CTRL, KEY(KP_Page_Down), next_tab },
|
||||||
{ CTRL, KEY(Page_Up), prev_tab }, // working hypothesis: Page_UP vs KP_Page_Up might depend on whether the user has a numpad
|
{ CTRL, KEY(Page_Up), prev_tab }, // working hypothesis: Page_UP vs KP_Page_Up might depend on whether the user has a numpad
|
||||||
{ CTRL, KEY(Page_Down), next_tab },
|
{ CTRL, KEY(Page_Down), next_tab },
|
||||||
{ CTRL, KEY(t), new_tab },
|
{ CTRL, KEY(t), new_tab },
|
||||||
{ CTRL, KEY(w), close_tab },
|
{ CTRL, KEY(w), close_tab },
|
||||||
{ 0x0, KEY(F11), toggle_fullscreen },
|
{ 0x0, KEY(F11), toggle_fullscreen },
|
||||||
{ CTRL, KEY(l), show_searchbar },
|
{ CTRL, KEY(S), toggle_custom_style },
|
||||||
{ CTRL, KEY(semicolon), hide_bar },
|
{ CTRL, KEY(l), show_searchbar },
|
||||||
{ CTRL, KEY(f), show_finder },
|
{ CTRL, KEY(semicolon), hide_bar },
|
||||||
{ CTRL, KEY(n), finder_next },
|
{ CTRL, KEY(f), show_finder },
|
||||||
{ CTRL, KEY(N), finder_prev },
|
{ CTRL, KEY(n), finder_next },
|
||||||
{ CTRL, KEY(p), prettify }
|
{ CTRL, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(p), prettify }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Old controls: {
|
/* Old controls: {
|
||||||
|
|
|
@ -23,8 +23,9 @@ int shortcut_expand(const char* uri, char* output)
|
||||||
"!fnf",
|
"!fnf",
|
||||||
"!fnc",
|
"!fnc",
|
||||||
"!hn",
|
"!hn",
|
||||||
"!hnb"
|
"!hnb",
|
||||||
"!x",
|
"!ww",
|
||||||
|
"!x"
|
||||||
};
|
};
|
||||||
|
|
||||||
char* expansions[] = {
|
char* expansions[] = {
|
||||||
|
@ -34,7 +35,8 @@ int shortcut_expand(const char* uri, char* output)
|
||||||
"https://forum.nunosempere.com/comments",
|
"https://forum.nunosempere.com/comments",
|
||||||
"https://news.ycombinator.com",
|
"https://news.ycombinator.com",
|
||||||
"https://news.ycombinator.com/best",
|
"https://news.ycombinator.com/best",
|
||||||
"https://twitter.com",
|
"https://web.whatsapp.com",
|
||||||
|
"https://twitter.com"
|
||||||
};
|
};
|
||||||
|
|
||||||
// len = sizeof(shortcuts) / sizeof(shortcuts[0]);
|
// len = sizeof(shortcuts) / sizeof(shortcuts[0]);
|
||||||
|
|
11
rosenrot.c
11
rosenrot.c
|
@ -17,6 +17,7 @@ static struct {
|
||||||
Bar_entry_mode entry_mode;
|
Bar_entry_mode entry_mode;
|
||||||
} bar;
|
} bar;
|
||||||
static int num_tabs = 0;
|
static int num_tabs = 0;
|
||||||
|
static int custom_style_enabled = 1;
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
|
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
|
||||||
|
@ -71,7 +72,7 @@ void redirect_if_annoying(WebKitWebView* view, const char* uri)
|
||||||
}
|
}
|
||||||
void set_custom_style(WebKitWebView* view)
|
void set_custom_style(WebKitWebView* view)
|
||||||
{
|
{
|
||||||
if (CUSTOM_STYLE_ENABLED) {
|
if (custom_style_enabled) {
|
||||||
char* style_js = malloc(STYLE_N + 1);
|
char* style_js = malloc(STYLE_N + 1);
|
||||||
read_style_js(style_js);
|
read_style_js(style_js);
|
||||||
webkit_web_view_evaluate_javascript(view, style_js, -1, NULL, "rosenrot-style-plugin", NULL, NULL, NULL);
|
webkit_web_view_evaluate_javascript(view, style_js, -1, NULL, "rosenrot-style-plugin", NULL, NULL, NULL);
|
||||||
|
@ -302,7 +303,6 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case toggle_fullscreen:
|
case toggle_fullscreen:
|
||||||
if (is_fullscreen)
|
if (is_fullscreen)
|
||||||
gtk_window_unfullscreen(window);
|
gtk_window_unfullscreen(window);
|
||||||
|
@ -310,7 +310,12 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
gtk_window_fullscreen(window);
|
gtk_window_fullscreen(window);
|
||||||
is_fullscreen = !is_fullscreen;
|
is_fullscreen = !is_fullscreen;
|
||||||
break;
|
break;
|
||||||
|
case toggle_custom_style: /* Ctrl s + Ctrl Shift R to reload */
|
||||||
|
if (custom_style_enabled)
|
||||||
|
custom_style_enabled = 0;
|
||||||
|
else
|
||||||
|
custom_style_enabled = 1;
|
||||||
|
break;
|
||||||
case show_searchbar:
|
case show_searchbar:
|
||||||
toggle_bar(notebook, _SEARCH);
|
toggle_bar(notebook, _SEARCH);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user