PointerAlignment: Right
ReflowComments: false
-SortIncludes: false
-SortUsingDeclarations: false # Unknown to clang-format-4.0
+SortIncludes: true
+SortUsingDeclarations: true # Unknown to clang-format-4.0
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
install: all
mkdir -p $(bindir) \
$(mandir)/man1 \
- $(mandir)/man7 \
$(libdir)/chorizo/web-extensions \
$(datadir)/chorizo/user-scripts
cp chorizo $(bindir)/
cp chorizo.1 $(mandir)/man1/
- cp chorizo-usage.7 $(mandir)/man7/
makewhatis /usr/local/man
cp -r extensions/*.so $(libdir)/chorizo/web-extensions/
rm -rf $(bindir)/chorizo \
$(libdir)/chorizo \
$(mandir)/man1/chorizo* \
- $(mandir)/man7/chorizo* \
$(datadir)/chorizo
reinstall: uninstall install
void trust_user_certs(WebKitWebContext *);
struct Client {
- GtkWidget *jsbutton;
GtkWidget *location;
+ GtkWidget *search;
+ GtkWidget *search_switch;
+ GtkWidget *isearch;
GtkWidget *tabicon;
GtkWidget *tablabel;
GtkWidget *vbox;
exit(EXIT_FAILURE);
}
-void
-togglejs(GtkButton *jsbutton, gpointer data)
-{
- struct Client *c = (struct Client *)data;
- webkit_settings_set_enable_javascript(
- c->settings,
- !webkit_settings_get_enable_javascript(c->settings));
- webkit_web_view_set_settings(WEBKIT_WEB_VIEW(c->web_view), c->settings);
-}
-
void
client_destroy(GtkWidget *widget, gpointer data)
{
c->settings =
webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view));
- webkit_settings_set_enable_javascript(c->settings, cfg_js_default);
if (cfg.verbose)
webkit_settings_set_enable_write_console_messages_to_stdout(
c->settings, true);
G_CALLBACK(decide_policy), NULL);
g_signal_connect(G_OBJECT(c->web_view), "key-press-event",
G_CALLBACK(key_web_view), c);
- g_signal_connect(G_OBJECT(c->web_view), "button-release-event",
- G_CALLBACK(key_web_view), c);
g_signal_connect(G_OBJECT(c->web_view), "scroll-event",
G_CALLBACK(key_web_view), c);
g_signal_connect(G_OBJECT(c->web_view), "mouse-target-changed",
G_CALLBACK(crashed_web_view), c);
GtkWidget *locbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- c->jsbutton = gtk_toggle_button_new_with_label("JS");
- gtk_widget_set_tooltip_text(c->jsbutton, "Toggle JavaScript execution");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c->jsbutton),
- cfg_js_default);
- g_signal_connect(G_OBJECT(c->jsbutton), "toggled", G_CALLBACK(togglejs),
- c);
c->location = gtk_entry_new();
+ gtk_entry_set_placeholder_text(GTK_ENTRY(c->location), "Web address");
gtk_box_pack_start(GTK_BOX(locbox), c->location, TRUE, TRUE, 0);
+ c->search = gtk_entry_new();
+ gtk_entry_set_placeholder_text(GTK_ENTRY(c->search), "Search");
+ gtk_box_pack_start(GTK_BOX(locbox), c->search, FALSE, TRUE, 0);
+
if (cfg.private) {
GtkWidget *privindicator = gtk_label_new("Private mode");
gtk_widget_set_tooltip_text(
gtk_box_pack_end(GTK_BOX(locbox), privindicator, FALSE, FALSE,
5);
}
- gtk_box_pack_start(GTK_BOX(locbox), c->jsbutton, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(c->location), "key-press-event",
G_CALLBACK(key_location), c);
c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start(GTK_BOX(c->vbox), locbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(c->vbox), c->web_view, TRUE, TRUE, 0);
+
+ GtkWidget *overlay = gtk_overlay_new();
+ c->isearch = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(c->vbox), overlay);
+ gtk_container_add(GTK_CONTAINER(overlay), c->isearch);
+ gtk_widget_set_halign (overlay, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (overlay, GTK_ALIGN_CENTER);
+ gtk_widget_show_all(overlay);
+
gtk_container_set_focus_child(GTK_CONTAINER(c->vbox), c->web_view);
c->tabicon = gtk_image_new_from_icon_name("text-html",
c->tablabel = gtk_label_new("chorizo");
gtk_label_set_ellipsize(GTK_LABEL(c->tablabel), PANGO_ELLIPSIZE_END);
- gtk_label_set_width_chars(GTK_LABEL(c->tablabel), 20);
+ gtk_label_set_width_chars(GTK_LABEL(c->tablabel), cfg_tab_width);
gtk_widget_set_has_tooltip(c->tablabel, TRUE);
/*
//No g_get_user_state_dir unfortunately
gchar *state_env = getenv("XDG_STATE_DIR");
gchar *state_dir = (state_env) ?
- state_env :
- g_build_filename(g_get_home_dir(),
+ state_env :
+ g_build_filename(g_get_home_dir(),
".local", "state",
"chorizo", NULL);
WebKitWebContext *wc;
WebKitCookieManager *cm;
wc = (cfg.private) ? webkit_web_context_new_ephemeral() :
- webkit_web_context_get_default();
+ webkit_web_context_get_default();
p = g_build_filename(g_get_user_config_dir(), "chorizo", "adblock",
NULL);
search(c, direction);
}
}
+
gboolean
key_common(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_notebook_next_page(
GTK_NOTEBOOK(mw.notebook));
return TRUE;
- } else if (GDK_KEY_p == key) {
- gboolean on =
- webkit_settings_get_enable_javascript(
- c->settings);
- webkit_settings_set_enable_javascript(
- c->settings, !on);
- webkit_web_view_set_settings(
- WEBKIT_WEB_VIEW(c->web_view),
- c->settings);
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(c->jsbutton), !on);
} else if (GDK_KEY_d == key) {
gtk_widget_grab_focus(c->location);
gtk_entry_set_text(GTK_ENTRY(c->location),
}
return FALSE;
}
+
gboolean
key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_entry_set_progress_fraction(GTK_ENTRY(c->location),
0);
}
- } else if (event->type == GDK_BUTTON_RELEASE) {
- GdkModifierType modifiers =
- gtk_accelerator_get_default_mod_mask();
- switch (((GdkEventButton *)event)->button) {
- case 1:
- if ((((GdkEventButton *)event)->state & modifiers) ==
- GDK_CONTROL_MASK &&
- c->hover_uri != NULL) {
- client_new(c->hover_uri, NULL, TRUE, FALSE);
- return TRUE;
- }
- break;
- case 8:
- webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
- return TRUE;
- case 9:
- webkit_web_view_go_forward(
- WEBKIT_WEB_VIEW(c->web_view));
- return TRUE;
- }
} else if (event->type == GDK_SCROLL) {
event->scroll.delta_y *= cfg_scroll_lines;
if (((GdkEventScroll *)event)->state & GDK_CONTROL_MASK) {
mw.notebook = gtk_notebook_new();
gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
+ gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mw.notebook), GTK_POS_LEFT);
gtk_container_add(GTK_CONTAINER(mw.win), mw.notebook);
g_signal_connect(G_OBJECT(mw.notebook), "switch-page",
G_CALLBACK(notebook_switch_page), NULL);
+
+ GtkCssProvider *css = gtk_css_provider_new();
+ const char *css_data = "notebook header.left * { \
+ margin: 0; \
+ padding-top: 0; \
+ padding-bottom: 0; \
+ }";
+ gtk_css_provider_load_from_data(css, css_data, strlen(css_data), NULL);
+ gtk_style_context_add_provider_for_screen(
+ gdk_screen_get_default(), GTK_STYLE_PROVIDER(css),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
}
void
{
mainwindow_title(idx);
}
+
gboolean
quit_if_nothing_active(void)
{
gtk_main();
remove(fifopath);
}
- for (int i = 0; i < clients; i++) { free(&(client_arr[i])); }
exit(EXIT_SUCCESS);
}
--- /dev/null
+.TH "chorizo-usage" "1" "2021-10-11"
+.P
+.SH NAME
+chorizo-usage - extended usage hints
+.P
+.SH DESCRIPTION
+\fBchorizo\fR is a simple web browser using GTK+ 3, GLib and WebKit2GTK+.\& This
+manpage contains additional hints and pointers regarding its usage.\&
+.P
+.SH DOWNLOAD MANAGER
+Open the download manager using the appropriate hotkey.\& A new window listing
+your downloads will appear.\& Clicking on an item will remove it from the list and
+\fB\fRif needed\fB\fR cancel the download.\&
+.P
+There's no file manager integration, nor does \fBchorizo\fR delete, overwrite or
+resume downloads.\& If a file already exists, it won't be touched.\& Instead, the
+new file name will have a suffix such as \fB.\&1\fR, \fB.\&2\fR, \fB.\&3\fR, and so on.\&
+.P
+.SH USER-SUPPLIED JAVASCRIPT FILES
+When a page is being loaded, the directory \fI~/.\&local/share/chorizo/user-scripts\fR
+will be scanned and each file in it ending with \fB.\&js\fR will be run as a
+JavaScript file in the context of said page.\&
+.P
+\fBchorizo\fR comes with the following scripts:
+.P
+\fBhints.\&js\fR
+.RS 4
+Press \fBf\fR (open link in current window) or \fBF\fR (open in new window) to
+activate link hints.\& After typing the characters for one of them, press
+\fBEnter\fR to confirm.\& Press \fBEscape\fR to abort.\&
+.P
+.RE
+\fBprivacy-redirect.\&js\fR
+.RS 4
+Redirects YouTube, Reddit, etc to privacy respecting alternatives.\&
+.P
+.RE
+\fBdarkreader.\&js\fR
+.RS 4
+See https://darkreader.\&org.\&
+.P
+.RE
+Those bundled scripts are automatically installed on \fBmake install\fR.\& To use
+them, though, make sure to link them to the directory mentioned above.\&
+.P
+.SH USER-SUPPLIED CSS FILES
+User supplied CSS files will be scanned for from
+\fI~/.\&local/share/chorizo/user-styles\fR, and be applied every time a page
+loads.\& The rules in these files override any rules provided by the website.\&
+.P
+.SH WEB EXTENSIONS
+On startup, WebKit checks \fI~/.\&local/share/chorizo/web-extensions\fR for any \fB.\&so\fR
+files.\& See
+<http://blogs.\&igalia.\&com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/>
+this blog post for further information on these extensions.\&
+.P
+\fBchorizo\fR comes with the following extensions:
+.P
+\fBwe_adblock.\&so\fR
+.RS 4
+Generic adblock.\& Reads patterns from the file \fI~/.\&config/chorizo/adblock\fR.\& Each
+line can contain a regular expression.\& These expressions match
+case-insensitive and partially, i.\&e.\&\fB*foo.\&*\fR is the same as \fB.\&*FOO.\&*\fR and
+you can use anchors like \fB^https?\&://.\&.\&.\&\fR.\& Please refer to
+https://developer.\&gnome.\&org/glib/stable/glib-regex-syntax.\&html the GLib
+reference for more details.\& Lines starting with "#" are ignored.\&
+.P
+Those bundled web extensions are automatically compiled when you run \fBmake\fR
+and installed on \fBmake install\fR.\& To use them, though, make sure to link them
+to the directory mentioned above.\&
+.P
+.RE
+.SH TRUSTED CERTIFICATES
+By default, \fBchorizo\fR trusts whatever CAs are trusted by WebKit.\& If you wish to
+trust additional certificates, such as self-signed certificates, the first thing
+you should do is try to add the appropriate CAs to your system-wide store.\&
+.P
+If you wish to add simple exceptions, you can grab the certificate and store it
+in the directory \fI~/.\&local/share/chorizo/certs\fR.\& The filename must be equal to
+the hostname:
+.P
+.RS 4
+$ echo | openssl s_client -connect foo.\&de:443 | openssl x509 >foo.\&de
+.P
+.RE
+This tells \fBchorizo\fR to trust the given certificate when connecting to host
+\fBfoo.\&de\fR.\&
+.P
+Note: This is NOT equal to certificate pinning.\& WebKit ignores user-specified
+certificates if the server's certificate can be validated by any system-wide CA.\&
+.P
+.SH SEE ALSO
+\fBchorizo\fR(1), \fBchorizo-config\fR(5)
+++ /dev/null
-.TH "chorizo-usage" "7" "2021-10-11"
-.P
-.SH NAME
-chorizo-usage - extended usage hints
-.P
-.SH DESCRIPTION
-\fBchorizo\fR is a simple web browser using GTK+ 3, GLib and WebKit2GTK+.\& This
-manpage contains additional hints and pointers regarding its usage.\&
-.P
-.SH DOWNLOAD MANAGER
-Open the download manager using the appropriate hotkey.\& A new window listing
-your downloads will appear.\& Clicking on an item will remove it from the list and
-\fB\fRif needed\fB\fR cancel the download.\&
-.P
-There's no file manager integration, nor does \fBchorizo\fR delete, overwrite or
-resume downloads.\& If a file already exists, it won't be touched.\& Instead, the
-new file name will have a suffix such as \fB.\&1\fR, \fB.\&2\fR, \fB.\&3\fR, and so on.\&
-.P
-.SH USER-SUPPLIED JAVASCRIPT FILES
-When a page is being loaded, the directory \fI~/.\&local/share/chorizo/user-scripts\fR
-will be scanned and each file in it ending with \fB.\&js\fR will be run as a
-JavaScript file in the context of said page.\&
-.P
-\fBchorizo\fR comes with the following scripts:
-.P
-\fBhints.\&js\fR
-.RS 4
-Press \fBf\fR (open link in current window) or \fBF\fR (open in new window) to
-activate link hints.\& After typing the characters for one of them, press
-\fBEnter\fR to confirm.\& Press \fBEscape\fR to abort.\&
-.P
-.RE
-\fBprivacy-redirect.\&js\fR
-.RS 4
-Redirects YouTube, Reddit, etc to privacy respecting alternatives.\&
-.P
-.RE
-\fBdarkreader.\&js\fR
-.RS 4
-See https://darkreader.\&org.\&
-.P
-.RE
-Those bundled scripts are automatically installed on \fBmake install\fR.\& To use
-them, though, make sure to link them to the directory mentioned above.\&
-.P
-.SH USER-SUPPLIED CSS FILES
-User supplied CSS files will be scanned for from
-\fI~/.\&local/share/chorizo/user-styles\fR, and be applied every time a page
-loads.\& The rules in these files override any rules provided by the website.\&
-.P
-.SH WEB EXTENSIONS
-On startup, WebKit checks \fI~/.\&local/share/chorizo/web-extensions\fR for any \fB.\&so\fR
-files.\& See
-<http://blogs.\&igalia.\&com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/>
-this blog post for further information on these extensions.\&
-.P
-\fBchorizo\fR comes with the following extensions:
-.P
-\fBwe_adblock.\&so\fR
-.RS 4
-Generic adblock.\& Reads patterns from the file \fI~/.\&config/chorizo/adblock\fR.\& Each
-line can contain a regular expression.\& These expressions match
-case-insensitive and partially, i.\&e.\&\fB*foo.\&*\fR is the same as \fB.\&*FOO.\&*\fR and
-you can use anchors like \fB^https?\&://.\&.\&.\&\fR.\& Please refer to
-https://developer.\&gnome.\&org/glib/stable/glib-regex-syntax.\&html the GLib
-reference for more details.\& Lines starting with "#" are ignored.\&
-.P
-Those bundled web extensions are automatically compiled when you run \fBmake\fR
-and installed on \fBmake install\fR.\& To use them, though, make sure to link them
-to the directory mentioned above.\&
-.P
-.RE
-.SH TRUSTED CERTIFICATES
-By default, \fBchorizo\fR trusts whatever CAs are trusted by WebKit.\& If you wish to
-trust additional certificates, such as self-signed certificates, the first thing
-you should do is try to add the appropriate CAs to your system-wide store.\&
-.P
-If you wish to add simple exceptions, you can grab the certificate and store it
-in the directory \fI~/.\&local/share/chorizo/certs\fR.\& The filename must be equal to
-the hostname:
-.P
-.RS 4
-$ echo | openssl s_client -connect foo.\&de:443 | openssl x509 >foo.\&de
-.P
-.RE
-This tells \fBchorizo\fR to trust the given certificate when connecting to host
-\fBfoo.\&de\fR.\&
-.P
-Note: This is NOT equal to certificate pinning.\& WebKit ignores user-specified
-certificates if the server's certificate can be validated by any system-wide CA.\&
-.P
-.SH SEE ALSO
-\fBchorizo\fR(1), \fBchorizo-config\fR(5)
gchar *cfg_search_engine = "https://searx.be/search?q=";
//Search engine
int cfg_max_tabs_closed = 16;
-
+//Tab width in chars
+int cfg_tab_width = 15;
#endif
gtk_widget_destroy(chooser);
- remove(uri + 7);
+ remove(uri + 7); // Remove before overwrite
tb = gtk_tool_button_new(NULL, NULL);
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "network-receive");
gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), uri);
download_get_path(struct DownloadItem *payload)
{
const char *path = webkit_download_get_destination(payload->download);
- // Offset by 7 to remove "file://"
return path += 7;
}
download_copy_path(GtkMenuItem *tb, gpointer data)
{
const char *path = download_get_path((struct DownloadItem *)data);
- gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
- path + 7, strlen(path) - 7);
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), path,
+ strlen(path));
}
void
// This is NOT a core component of chorizo, but an optional user script.
-// Please refer to chorizo.usage(1) for more information on user scripts.
-
+// Please refer to chorizo-usage(1) for more information on user scripts.
+//
// Press "f" (open link in current window) or "F" (open in new window)
// to activate link hints. After typing the characters for one of them,
// press Enter to confirm. Press Escape to abort.
// This is an "80% solution". It works for many web sites, but has
// flaws. For more background on this topic, see this blog post:
// https://www.uninformativ.de/blog/postings/2020-02-24/0/POSTING-en.html
-
+//
// Based on the following, but modified for chorizo and personal taste:
//
// easy links for surf
function update_highlights_or_abort() {
var submatch;
- var col_sel, col_unsel;
var longest_id = 0;
- if (document.chorizo_hints.state === "follow_new") {
- col_unsel = "#DAFFAD";
- col_sel = "#FF5D00";
- } else {
- col_unsel = "#A7FFF5";
- col_sel = "#33FF00";
- }
+ const color = (document.chorizo_hints.state === "follow_new") ? "#ffccff"
+ : "#99ffcc";
for (var id in document.chorizo_hints.labels) {
var label = document.chorizo_hints.labels[id];
- var bgcol = col_unsel;
longest_id = Math.max(longest_id, id.length);
submatch = id.match("^" + document.chorizo_hints.box.value);
if (submatch !== null) {
var href_suffix = "";
- var box_shadow_inner = "#B00000";
if (id === document.chorizo_hints.box.value) {
- bgcol = col_sel;
- box_shadow_inner = "red";
if (label.elem.tagName.toLowerCase() === "a")
- href_suffix = ": <span style='font-size: 75%'>" +
+ href_suffix = ": <span>" +
label.elem.href + "</span>";
}
label.span.style.visibility = "visible";
save_parent_style(label);
- label.elem.style.boxShadow = "0 0 5pt 2pt black, 0 0 0 2pt " +
- box_shadow_inner + " inset";
+ label.elem.style.boxShadow = "0 0 5px 5px red";
} else {
label.span.style.visibility = "hidden";
reset_parent_style(label);
label.span.innerHTML = id;
reset_parent_style(label);
}
- label.span.style.backgroundColor = bgcol;
+ label.span.style.backgroundColor = color;
}
if (document.chorizo_hints.box.value.length > longest_id)
} while (n !== 0);
var span = document.createElement("span");
- span.style.border = "black 1pt solid";
+ span.style.border = "black 1px solid";
span.style.color = "black";
span.style.fontFamily = "monospace";
- span.style.fontSize = "10pt";
+ span.style.fontSize = "10px";
span.style.fontWeight = "normal";
- span.style.margin = "0px 2pt";
+ span.style.margin = "0px 2px";
+ span.style.padding = "1px 5px";
span.style.position = "absolute";
span.style.textTransform = "lowercase";
span.style.visibility = "hidden";
// placement results, but we can *only* do this for <a> ...
var tag_name = elem.tagName.toLowerCase();
if (tag_name === "a") {
- span.style.borderTopLeftRadius = "10pt";
- span.style.borderBottomLeftRadius = "10pt";
- span.style.padding = "0px 2pt 0px 5pt";
+ span.style.borderRadius = "2px";
elem.appendChild(span);
} else {
- span.style.borderRadius = "10pt";
- span.style.padding = "0px 5pt";
+ span.style.borderRadius = "10px";
elem.parentNode.insertBefore(span, elem);
}