Skip to content

Commit

Permalink
- Added "--kiosk" execution parameter;
Browse files Browse the repository at this point in the history
- Bugfixes in bookmark completion model.
  • Loading branch information
aarnt committed Nov 21, 2021
1 parent fc5ff73 commit 9f879bb
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 67 deletions.
61 changes: 34 additions & 27 deletions badwolf.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ GtkTreeModel *bookmarks_completion_model;

gboolean g_dark_mode = FALSE;
gboolean g_kiosk_mode = FALSE;
static gchar *dark_mode_css = "a { color: #40ECD0 !important; }" //lightgreen

static gchar *dark_mode_css = "a { color: #40ECD0 !important; }"
"article, aside, body, blockquote, dd, dl, dt, form, "
"h1, h2, h3, h4, h5, header, div, iframe, input, label, "
"li, option, p, pre, root, select, span, table, td, th, tr, ul "
Expand Down Expand Up @@ -339,16 +340,7 @@ WebViewCb_create(WebKitWebView *related_web_view,

browser = new_browser(old_browser->window, NULL, old_browser);

/*if(badwolf_new_tab(GTK_NOTEBOOK(old_browser->window->notebook), browser, FALSE) < 0)
return NULL;
else
return browser->webView;
*/

//struct Window *window = (struct Window *)user_data;
//struct Client *browser = new_browser(window, NULL, related_web_view);

gint newtab=badwolf_new_tab(GTK_NOTEBOOK(old_browser->window->notebook), browser, FALSE);
gint newtab=badwolf_new_tab(GTK_NOTEBOOK(old_browser->window->notebook), browser, FALSE, FALSE);
if(newtab == 0)
{
WebKitSettings *oldSettings = webkit_web_view_get_settings(related_web_view);
Expand Down Expand Up @@ -455,7 +447,8 @@ WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view,
(void)web_view;
(void)certificate;
(void)errors;
struct Client *browser = (struct Client *)user_data;

struct Client *browser = (struct Client *)user_data;
gchar *error_details = detail_tls_certificate_flags(errors);
gint dialog_response;

Expand Down Expand Up @@ -830,7 +823,7 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b
bookmarks_completion_setup(location_completion, location_completion_model);
gtk_entry_set_completion(GTK_ENTRY(browser->location), location_completion);

g_signal_connect(G_OBJECT(location_completion), "match-selected", G_CALLBACK(locationCompletion_match_selected), browser); //(gpointer)NULL);
g_signal_connect(G_OBJECT(location_completion), "match-selected", G_CALLBACK(locationCompletion_match_selected), browser);
}

gtk_entry_set_text(GTK_ENTRY(browser->location), target_url);
Expand Down Expand Up @@ -943,12 +936,14 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b
*/

int
badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch)
badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch, bool force_kiosk_mode)
{
gint current_page = gtk_notebook_get_current_page(notebook);
if (g_kiosk_mode == TRUE && force_kiosk_mode == FALSE) return -2;

gint current_page = gtk_notebook_get_current_page(notebook);
gchar *title = _("New tab");

if(browser == NULL || isKioskMode()) return -2;
if(browser == NULL) return -2;

gtk_widget_show_all(browser->box);

Expand Down Expand Up @@ -978,7 +973,7 @@ new_tabCb_clicked(GtkButton *new_tab, gpointer user_data)
struct Window *window = (struct Window *)user_data;
struct Client *browser = new_browser(window, NULL, NULL);

badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, TRUE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, TRUE, FALSE);
}

static void
Expand Down Expand Up @@ -1178,14 +1173,26 @@ main(int argc, char *argv[])
if(argc == 1)
{
browser = new_browser(window, NULL, NULL);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE, FALSE);
}
else
{
for(int i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "--kiosk")==0)
{
g_kiosk_mode = TRUE;
if (argc == 2)
{
browser = new_browser(window, NULL, NULL);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE, TRUE);
break;
}
continue;
}

browser = new_browser(window, argv[i], NULL);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE, g_kiosk_mode);
}
}

Expand Down Expand Up @@ -1253,7 +1260,7 @@ WebViewCb_button_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_
{
if (strlen(gtk_label_get_text(GTK_LABEL(oldBrowser->statuslabel)))==0) return FALSE;

gint newtab=badwolf_new_tab(GTK_NOTEBOOK(oldBrowser->window->notebook), browser, TRUE);
gint newtab=badwolf_new_tab(GTK_NOTEBOOK(oldBrowser->window->notebook), browser, TRUE, FALSE);
if(newtab == 0)
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(browser->javascript), jsEnabled);
Expand Down Expand Up @@ -1301,18 +1308,20 @@ locationCompletion_match_selected(GtkEntryCompletion *widget,
gpointer user_data)
{
(void)widget;
(void)model;
(void)iter;

const gchar *location = NULL;
gtk_tree_model_get(model, iter, 0, &location, -1);
if (location == NULL) return FALSE;

struct Client *browser = (struct Client *)user_data;

if (openProtocolOnExternalApp(g_strdup(gtk_entry_get_text(GTK_ENTRY(browser->location)))))
if (openProtocolOnExternalApp(g_strdup(location)))
{
return TRUE;
}

webkit_web_view_load_uri(browser->webView,
badwolf_ensure_uri_scheme(gtk_entry_get_text(GTK_ENTRY(browser->location)), TRUE));
badwolf_ensure_uri_scheme(location, TRUE));

if(browser != NULL)
gtk_widget_grab_focus (GTK_WIDGET (browser->webView));
Expand Down Expand Up @@ -1367,9 +1376,6 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num,
{
(void)page_num;
struct Window *window = (struct Window *)user_data;
//struct Client *browser = (struct Client *)user_data;
//struct Window *window = browser->window;

GtkWidget *label = gtk_notebook_get_tab_label(notebook, page);

// TODO: Maybe find a better way to store the title
Expand Down Expand Up @@ -1443,6 +1449,7 @@ set_kiosk_mode(struct Client *browser)
}
}
}

/*
* Toggles between DARK and NORMAL modes, calling the stylesheet
* method and refreshing the webpage
Expand Down
2 changes: 1 addition & 1 deletion badwolf.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ void set_dark_mode(WebKitWebView *web_view);
void webView_tab_label_change(struct Client *browser, const gchar *title);
struct Client *
new_browser(struct Window *window, const gchar *target_url, struct Client *old_browser);
int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch);
int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch, bool force_kiosk_mode);
gint badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child);
#endif /* BADWOLF_H_INCLUDED */
8 changes: 4 additions & 4 deletions keybindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ about_dialogCb_activate_link(GtkAboutDialog *about_dialog, gchar *uri, gpointer
(void)about_dialog;
struct Window *window = (struct Window *)user_data;

badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL), TRUE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL), TRUE, FALSE);
gtk_window_close(GTK_WINDOW(about_dialog));

return TRUE;
Expand Down Expand Up @@ -114,7 +114,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nbrowser->javascript), jsEnabled);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nbrowser->auto_load_images), imgEnabled);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), nbrowser, FALSE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), nbrowser, FALSE, FALSE);
gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook),
gtk_notebook_get_current_page(notebook)+1);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *
gtk_main_quit();
return TRUE;
case GDK_KEY_t:
badwolf_new_tab(notebook, new_browser(window, NULL, NULL), TRUE);
badwolf_new_tab(notebook, new_browser(window, NULL, NULL), TRUE, FALSE);
return TRUE;
}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ open_site_on_new_tab(struct Window *window, const gchar *url, gboolean jsEnabled

if (nbrowser != NULL)
{
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), nbrowser, FALSE);
badwolf_new_tab(GTK_NOTEBOOK(window->notebook), nbrowser, FALSE, FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nbrowser->javascript), jsEnabled);
gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook),
gtk_notebook_get_current_page(notebook)+1);
Expand Down
70 changes: 35 additions & 35 deletions po/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Badwolf 1.2.0+g5781624.main\n"
"Project-Id-Version: Badwolf 1.2.1+gfc5ff73.main\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2021-11-20 17:14-0300\n"
"POT-Creation-Date: 2021-11-20 23:37-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -77,23 +77,23 @@ msgstr ""
msgid "Bookmarks: unable to parse file \"%s\"\n"
msgstr ""

#: badwolf.c:1078
#: badwolf.c:1073
#, c-format
msgid "Buildtime WebKit version: %d.%d.%d\n"
msgstr ""

#: badwolf.c:475
#: badwolf.c:468
msgid "Continue"
msgstr ""

#: badwolf.c:420
#: badwolf.c:412
msgid ""
"Couldn't verify the TLS certificate to ensure a better security of the "
"connection. You might want to verify your machine and network.\n"
"\n"
msgstr ""

#: badwolf.c:133
#: badwolf.c:134
msgid "Crashed"
msgstr ""

Expand All @@ -105,131 +105,131 @@ msgstr ""
msgid "Downloads"
msgstr ""

#: badwolf.c:443
#: badwolf.c:435
msgid "Error: Some unknown error occurred validating the certificate.\n"
msgstr ""

#: badwolf.c:424
#: badwolf.c:416
msgid "Error: The X509 Certificate Authority is unknown.\n"
msgstr ""

#: badwolf.c:437
#: badwolf.c:429
msgid "Error: The certificate has been revoked.\n"
msgstr ""

#: badwolf.c:434
#: badwolf.c:426
msgid "Error: The certificate has expired. Check your system's clock.\n"
msgstr ""

#: badwolf.c:440
#: badwolf.c:432
msgid "Error: The certificate is considered to be insecure.\n"
msgstr ""

#: badwolf.c:431
#: badwolf.c:423
msgid "Error: The certificate isn't valid yet. Check your system's clock.\n"
msgstr ""

#: badwolf.c:427
#: badwolf.c:419
msgid "Error: The given identity doesn't match the expected one.\n"
msgstr ""

#: downloads.c:217 downloads.c:220
msgid "LRRH Downloads"
msgstr ""

#: badwolf.c:949
#: badwolf.c:944
msgid "New tab"
msgstr ""

#: badwolf.c:1154
#: badwolf.c:1149
msgid "Open new tab"
msgstr ""

#: badwolf.c:137
#: badwolf.c:138
msgid "Out of Memory"
msgstr ""

#: badwolf.c:1076
#: badwolf.c:1071
#, c-format
msgid "Running Badwolf version: %s\n"
msgstr ""

#: badwolf.c:1083
#: badwolf.c:1078
#, c-format
msgid "Runtime WebKit version: %d.%d.%d\n"
msgstr ""

#: badwolf.c:472
#: badwolf.c:465
#, c-format
msgid "TLS Error for %s."
msgstr ""

#: badwolf.c:475
#: badwolf.c:468
msgid "Temporarily Add Exception"
msgstr ""

#: badwolf.c:692
#: badwolf.c:685
msgid "Toggle javascript"
msgstr ""

#: badwolf.c:697
#: badwolf.c:690
msgid "Toggle loading images automatically"
msgstr ""

#: badwolf.c:141
#: badwolf.c:142
msgid "Unknown Crash"
msgstr ""

#: badwolf.c:695
#: badwolf.c:688
msgid "_IMG"
msgstr ""

#: badwolf.c:690
#: badwolf.c:683
msgid "_JS"
msgstr ""

#: badwolf.c:1019
#: badwolf.c:1014
#, c-format
msgid "badwolf: content-filter loaded, adding to content-manager…\n"
msgstr ""

#: badwolf.c:1039 badwolf.c:1046
#: badwolf.c:1034 badwolf.c:1041
#, c-format
msgid "badwolf: failed to compile content-filters.json, err: [%d] %s\n"
msgstr ""

#: badwolf.c:1007 badwolf.c:1012
#: badwolf.c:1002 badwolf.c:1007
#, c-format
msgid "badwolf: failed to load content-filter, err: [%d] %s\n"
msgstr ""

#: badwolf.c:1110
#: badwolf.c:1105
#, c-format
msgid "content-filters file set to: %s\n"
msgstr ""

#: badwolf.c:839
#: badwolf.c:832
msgid "search in current page"
msgstr ""

#: badwolf.c:132
#: badwolf.c:133
msgid "the web process crashed.\n"
msgstr ""

#: badwolf.c:136
#: badwolf.c:137
msgid "the web process exceeded the memory limit.\n"
msgstr ""

#: badwolf.c:140
#: badwolf.c:141
msgid "the web process terminated for an unknown reason.\n"
msgstr ""

#: badwolf.c:1095
#: badwolf.c:1090
#, c-format
msgid "webkit-web-extension directory set to: %s\n"
msgstr ""

#. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext.
#: badwolf.c:1203
#: badwolf.c:1210
msgid "ø"
msgstr ""

0 comments on commit 9f879bb

Please sign in to comment.