-CFLAGS += -std=c11 -Wno-unused-parameter -D_XOPEN_SOURCE="700"
+CFLAGS += -Wno-unused-parameter -Wunknown-warning-option -D_XOPEN_SOURCE="700"
LIBS = `pkg-config --cflags --libs gtk+-3.0 glib-2.0 webkit2gtk-4.0`
PREFIX = /usr/local
bindir = $(DESTDIR)$(PREFIX)/bin
} cfg;
gint clients = 0;
-struct Client **client_arr;
int cooperative_pipe_fp = 0;
gchar *fifopath;
webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
// TODO: Shift everything left if over certain amount
- num_closed++;
- if (num_closed > cfg_max_tabs_closed) {
- memmove(closed_tabs, closed_tabs,
- cfg_max_tabs_closed - 1);
- num_closed = cfg_max_tabs_closed;
- } else {
- closed_tabs =
- realloc(closed_tabs,
+ if (uri != NULL) {
+ num_closed++;
+ if (num_closed > cfg_max_tabs_closed) {
+ memmove(closed_tabs, closed_tabs,
+ cfg_max_tabs_closed - 1);
+ num_closed = cfg_max_tabs_closed;
+ } else {
+ closed_tabs = realloc(
+ closed_tabs,
num_closed * sizeof(closed_tabs[0]));
- if (!closed_tabs) allocfail();
+ if (!closed_tabs) allocfail();
+ }
+ closed_tabs[num_closed - 1] = strdup(uri);
}
- closed_tabs[num_closed - 1] = strdup(uri);
}
- free(c);
clients--;
+ free(c);
quit_if_nothing_active();
}
c->web_view =
webkit_web_view_new_with_user_content_manager(ucm);
+
+ c->settings = webkit_web_view_get_settings(
+ WEBKIT_WEB_VIEW(c->web_view));
+ if (cfg.verbose)
+ webkit_settings_set_enable_write_console_messages_to_stdout(
+ c->settings, true);
+ webkit_settings_set_enable_developer_extras(c->settings, TRUE);
} else {
c->web_view = webkit_web_view_new_with_related_view(related_wv);
}
- c->settings =
- webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view));
- if (cfg.verbose)
- webkit_settings_set_enable_write_console_messages_to_stdout(
- c->settings, true);
- webkit_settings_set_enable_developer_extras(c->settings, TRUE);
-
g_signal_connect(G_OBJECT(c->web_view), "notify::favicon",
G_CALLBACK(changed_favicon), c);
g_signal_connect(G_OBJECT(c->web_view), "notify::title",
c->location = gtk_entry_new();
gtk_entry_set_placeholder_text(GTK_ENTRY(c->location), "URL");
+ char *location_symbol;
+ if (cfg.private) {
+ location_symbol = "security-high-symbolic";
+ gtk_entry_set_icon_tooltip_markup(
+ GTK_ENTRY(c->location), GTK_ENTRY_ICON_PRIMARY,
+ "You are in private mode. No history, caches, or "
+ "cookies will be saved beyond this session.");
+ } else {
+ location_symbol = "text-x-generic-symbolic";
+ }
+
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
GTK_ENTRY_ICON_PRIMARY,
- "text-x-generic-symbolic");
+ location_symbol);
gtk_box_pack_start(GTK_BOX(locbox), c->location, TRUE, TRUE, 0);
c->wsearch = gtk_entry_new();
"system-search-symbolic");
gtk_box_pack_start(GTK_BOX(locbox), c->wsearch, FALSE, TRUE, 0);
- if (cfg.private) {
- GtkWidget *privindicator = gtk_label_new("Private mode");
- gtk_widget_set_tooltip_text(
- privindicator,
- "You are in private mode. No history, caches, or "
- "cookies will be saved beyond this session.");
- gtk_box_pack_end(GTK_BOX(locbox), privindicator, FALSE, FALSE,
- 5);
- }
-
g_signal_connect(G_OBJECT(c->location), "key-press-event",
G_CALLBACK(key_location), c);
g_signal_connect(G_OBJECT(c->location), "icon-release",
set_uri(uri, c);
clients++;
- client_arr = realloc(client_arr, (clients + 1) * sizeof(client_arr[0]));
- if (!client_arr) allocfail();
-
- client_arr[clients] = c;
if (uri == NULL) gtk_widget_grab_focus(c->location);
// 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);
gboolean
crashed_web_view(WebKitWebView *web_view, gpointer data)
{
- struct Client *c = (struct Client *)data;
-
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
GtkWidget *dialog = gtk_message_dialog_new(
GTK_WINDOW(mw.win), flags, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
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);
webkit_web_context_add_path_to_sandbox(wc, p, TRUE);
g_free(p);
- WebKitProcessModel model =
- WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES;
- webkit_web_context_set_process_model(wc, model);
+ webkit_web_context_set_process_model(
+ wc, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
p = g_build_filename(g_get_user_data_dir(), "chorizo", "web-extensions",
NULL);
{
if (webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view))) {
gtk_widget_show(c->isearch_box);
- gtk_widget_show(c->isearch);
gtk_widget_grab_focus(c->isearch);
}
}
return TRUE;
} else if (GDK_KEY_f == key) {
isearch_init(c, 1);
- return FALSE;
+ return TRUE;
} else if (GDK_KEY_q == key) {
client_destroy(NULL, c);
return TRUE;
if ((GDK_KEY_KP_Enter == key) || (GDK_KEY_Return == key)) {
int direction = (((GdkEventKey *)event)->state &
GDK_SHIFT_MASK) ?
- -1 :
- 1;
+ -1 :
+ 1;
isearch(c, 0);
isearch(c, -1);
isearch(c, direction);
mainwindow_setup(void)
{
mw.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(mw.win), 800, 600);
+ gtk_window_set_default_size(GTK_WINDOW(mw.win), 1200, 900);
g_signal_connect(G_OBJECT(mw.win), "destroy", gtk_main_quit, NULL);
gchar *priv = (cfg.private) ? "-private" : "";
gtk_style_context_add_provider_for_screen(
gdk_screen_get_default(), GTK_STYLE_PROVIDER(css),
GTK_STYLE_PROVIDER_PRIORITY_USER);
+
+ gtk_widget_show_all(mw.win);
}
void
show_web_view(WebKitWebView *web_view, gpointer data)
{
struct Client *c = (struct Client *)data;
- gint idx;
(void)web_view;
+ gint idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
- gtk_widget_show_all(mw.win);
-
- // TODO: Fix this hack
- for (int i = 1; i <= clients; i++)
- gtk_widget_hide(client_arr[i]->isearch_box);
+ gtk_widget_show_all(GTK_WIDGET(
+ gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.notebook), idx)));
gtk_widget_hide(c->isearch_box);
if (c->focus_new_tab) {
- idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
if (idx != -1)
gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.notebook),
idx);
downloadmanager_setup();
mainwindow_setup();
- client_arr = malloc(sizeof(struct Client *));
- if (!client_arr) allocfail();
-
if (optind >= argc) {
client_new(cfg_home_uri, NULL, TRUE, TRUE);
} else {
-.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)
+.Dd $Mdocdate$
+.Dt CHORIZO 1
+.Os
+.
+.Sh NAME
+.Nm chorizo-usage
+.Nd extended usage hints
+.
+.Sh UI ELEMENTS
+.Ss DOWNLOAD MANAGER
+The download manager lets you view in-progress and completed downloads.
+Launch it with ^y. To manage downloads, just click on them.
+.
+.Ss THE TAB STACK
+Tabs are presented vertically on the left side of the window.
+Tabs can be dragged to be reordered,
+and middle clicked to close.
+Muted tabs are given the "[M]" prefix.
+.
+.Ss THE URL AND SEARCH BARS
+At the bottom of the screen are the URL and the search bars.
+Focus the URL bar with ^s, and the search bar with ^d.
+.
+.Ss THE ISEARCH BAR
+Hit ^f to open up the isearch bar.
+This lets you search for text within the page.
+Enter and shift-enter will cycle through matches.
+Escape or ^g will close it.
+.
+.Sh USER CONTENT
+.Ss JAVASCRIPT
+When a new web process is launched,
+.Pa ~/.local/share/chorizo/user-scripts
+is scanned for files with the .js suffix.
+These scripts will be run every time a page is loaded.
+.Pp
+The chorizo repository contains the following optional scripts:
+.Bl -tag
+.It hints.js
+Provides link hints.
+Press "f" to activate link hints for opening in the current tab,
+or "F" for a new tab.
+After entering the according code,
+press enter to confirm or escape to abort.
+.It privacy-redirect.js
+Redirects social media sites to privacy respecting alternatives.
+.It darkreader.js
+Makes webpages dark.
+.El
+.Pp
+These scripts are installed by default to
+.Pa /usr/local/share/chorizo/user-scripts
+.
+.Ss CSS
+When a new web process is launched,
+.Pa ~/.local/share/chorizo/user-styles
+is scanned for files with the .css suffix.
+These styles will be applied every time a page is loaded.
+.
+.Ss WEB EXTENSIONS
+When a new web process is launched,
+.Pa ~/.local/share/chorizo/web-extensions
+for webkit2gtk web extensions.
+See
+http://blog.igalia.com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/
+for more informatino.
+.Pp
+NB: these are different than Firefox/Chromium WebExtensions.
+.Pp
+The chorizo repository contains the following optional web extensions:
+.Bl -tag
+.It we_adblock.so
+Generic adblocker.
+Reads patterns from
+.Pa ~/.config/chorizo/adblock
+Each line can contain a regular expression.
+These expressions match case insesitively,
+and anchors like ^https?://.... can be used.
+.Pp
+Eg:
+*foo.* is the same as .*FOO.*
+.Pp
+See
+https://developer.gnome.org/glib/stable/glib-regex-syntax.html
+for more information.
+Lines starting with "#" are ignored.
+.El
+.Pp
+These web extensions are installed by default to
+.Pa /usr/local/share/chorizo/web-extensions
+.
+.Sh TRUSTED CERTIFICATES
+By default,
+.Nm
+trusts whatever CAs are trusted by Webkit.
+If you wish to trust additional certificates,
+and you cannot add it to the system-wide store,
+then you can store the certificate in
+.Pa ~/.local/share/chorizo/certs/
+The filename must be the same as the hostname.
+.Pp
+NB: 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.
+.
+.Sh SEE ALSO
+.Xr chorizo 1
-.TH "chorizo" "1" "2021-10-11"
-.P
-.SH NAME
-chorizo - simple web browser
-.P
-.SH SYNOPSIS
-\fBchorizo\fR - [-C] [\fIURI .\&.\&.\&\fR]
-.P
-.SH DESCRIPTION
-\fBchorizo\fR is a simple web browser using GTK+ 3, GLib and WebKit2GTK+.\&
-.P
-.SH OPTIONS
-In addition to the standard arguments of GTK+ 3, \fBchorizo\fR knows about the
-following options:
-.P
-\fB-C\fR
-.RS 4
-Disables cooperative instances.\&
-.P
-.RE
-\fB-p\fR
-.RS 4
-Launch a private window.\&
-.P
-.RE
-\fB-v\fR
-.RS 4
-Print version and exit.\&
-.P
-.RE
-After these options there can be any number of URIs specified to open.\&
-.P
-.SH ENVIRONMENT
-In addition to the standard variables of GTK+ 3, \fBchorizo\fR knows about the
-following environment variable:
-.P
-\fBCHORIZO_FIFO_SUFFIX\fR
-.RS 4
-Cooperative instances are implemented using a named pipe in the file
-system.\& The name of this pipe usually is (at least on modern systems following
-XDG standards: /var/run/user/$UID/chorizo.\&fifo-$CHORIZO_FIFO_SUFFIX
-.P
-\fB$UID\fR is the id of your user.\& \fB$CHORIZO_FIFO_SUFFIX\fR defaults to \fBmain\fR.\& If you
-change this variable, you can launch several independent cooperative instances
-of \fBchorizo\fR.\&
-.P
-.RE
-.SH FILES
-XDG variables will be used to construct these paths.\&
-\fB~/.\&config/chorizo/chorizo.\&ini\fR
-.RS 4
-Configuration file.\& See \fBchorizo-config\fR(5).\&
-.P
-.RE
-\fB~/.\&config/chorizo/adblock\fR
-.RS 4
-Adblock patterns.\& See \fBchorizo-usage\fR(1).\&
-.P
-.RE
-\fB~/.\&local/share/chorizo/certs\fR
-.RS 4
-Directory where trusted certificates are stored.\& See \fBchorizo-usage\fR(1).\&
-.P
-.RE
-\fB~/.\&local/share/chorizo/cookies.\&db\fR
-.RS 4
-Database where cookies are stored.\& It is kept in the same format as Firefox,
-so the file can easily be copied over.\&
-.P
-.RE
-\fB~/.\&local/share/chorizo/user-scripts\fR
-.RS 4
-Directory to store user-supplied JavaScript snippets.\& See \fBchorizo-usage\fR(1).\&
-.P
-.RE
-\fB~/.\&local/share/chorizo/user-styles\fR
-.RS 4
-Directory to store user-supplied CSS snippets.\& See \fBchorizo-usage\fR(1).\&
-.P
-.RE
-\fB~/.\&local/share/chorizo/web-extensions\fR
-.RS 4
-Sets the directory where WebKit will look for web extensions.\& See
-\fBchorizo-usage\fR(1).\&
-.P
-.RE
-\fB~/.\&cache/chorizo\fR
-\fB~/.\&cache/webkitgtk\fR
-.RS 4
-General caches.\&
-.P
-.RE
-\fB~/.\&local/share/webkitgtk\fR
-.RS 4
-WebKitGTK will dump its caches and local storage here.\& It is probably wise to
-clean those directories regularly or to mount them as \fBtmpfs\fR(5).\&
-.P
-.RE
-.SH LICENSE
-\fBchorizo\fR is released under the MIT license.\& See the accompanying LICENSE file.\&
-.P
-.SH HISTORY
-chorizo is a fork of the lariza browser by Peter Hofmann.\& The project was
-started in June 2014.\& This fork is maintained by Armaan Bhojwani.\&
-.P
-.SH SEE ALSO
-\fBchorizo-usage\fR(1), \fBchorizo-config\fR(5)
+.Dd $Mdocdate$
+.Dt CHORIZO 1
+.Os
+.
+.Sh NAME
+.Nm chorizo
+.Nd simple web browser
+.
+.Sh SYNOPSIS
+.Nm chorizo
+.Op Fl cpvV
+.Ar URL
+.
+.Sh DESCRIPTION
+.Nm
+is a simple web browser based on GTK+3 and WebKit2GTK+.
+.Pp
+The options are as follows:
+.Bl -tag
+.It Fl c
+Disable cooperative instances.
+.It Fl p
+Open in private mode.
+.It Fl v
+Print version and exit.
+.It Fl V
+Launch in verbose mode.
+.El
+.Pp
+After these options, an arbitary number of URIs can be provided to open.
+.
+.Sh ENVIRONMENT
+.Bl -tag
+.It Ev CHORIZO_FIFO_SUFFIX
+Suffix for named pipe. Useful for seperating coopertative instances.
+.El
+.
+.Sh FILES
+.Pp
+These paths are constructed using XDG environment variables.
+.Bl -tag
+.It Pa ~/.config/chorizo/adblock
+Adblock patterns.
+.It Pa ~/.local/share/chorizo/certs
+Directory where trusted certificates are stored.
+.It Pa ~/.local/share/chorizo/cookies.db
+Cookie databse. Same format as Firefox.
+.It Pa ~/.local/share/chorizo/user-scripts/
+Directory to stop user-supplied JavaScript snippets.
+.It Pa ~/.local/share/chorizo/user-styles/
+Directory to stop user-supplied CSS snippets.
+.It Pa ~/.local/share/chorizo/web-extensions/
+Directory to stop user-supplied web extensions.
+.It Pa ~/.cache/chorizo/
+.It Pa ~/.cache/webkitgtk/
+General caches.
+.It Pa ~/.local/share/webkitgtk/
+WebkitGTK's dumping ground.
+.El
+.
+.Sh SEE ALSO
+.Xr chorizo-usage 1
+.
+.Sh HISTORY
+.Nm
+is a fork of the lariza browser by Peter Hoffman.
+The project was started in June 2014,
+and was forked into Chorizo in May 2021.
+
+This fork is maintained by Armaan Bhojwani.
gchar *cfg_search_engine = "https://searx.be/search?q=";
// Max number of closed tabs
-int cfg_max_tabs_closed = 16;
+size_t cfg_max_tabs_closed = 16;
// Tab width in chars
int cfg_tab_width = 15;