logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: 80751fafa0b2600e17c8d880f267d8afd36c9108
parent: 871b245a7b498734d0246ae5c03897787cc428e2
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 11 May 2020 09:35:13 +0200

Add print button

Diffstat:

Mbadwolf.c24++++++++++++++++++++++++
Minterface.txt2++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -56,6 +56,7 @@ static gboolean javascriptCb_toggled(GtkButton *javascript, gpointer user_data); static gboolean auto_load_imagesCb_toggled(GtkButton *auto_load_images, gpointer user_data); static void backCb_clicked(GtkButton *back, gpointer user_data); static void forwardCb_clicked(GtkButton *forward, gpointer user_data); +static void printCb_clicked(GtkButton *forward, gpointer user_data); static gboolean SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data); static gboolean SearchEntryCb_previous__match(GtkSearchEntry *search, gpointer user_data); static gboolean SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer user_data); @@ -498,6 +499,18 @@ forwardCb_clicked(GtkButton *forward, gpointer user_data) webkit_web_view_go_forward(browser->webView); } +static void +printCb_clicked(GtkButton *print, gpointer user_data) +{ + (void)print; + struct Client *browser = (struct Client *)user_data; + + WebKitPrintOperation *print_operation = webkit_print_operation_new(browser->webView); + + webkit_print_operation_run_dialog(print_operation, GTK_WINDOW(browser->window)); +} + + static gboolean SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data) { @@ -584,6 +597,9 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat browser->location = gtk_entry_new(); gtk_widget_set_name(browser->location, "browser__location"); + GtkWidget *print = gtk_button_new_from_icon_name("document-print-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_name(browser->back, "browser__print"); + browser->statusbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(browser->statusbar, "browser__statusbar"); @@ -660,6 +676,11 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat TRUE, TRUE, BADWOLF_TOOLBAR_PADDING); + gtk_box_pack_start(GTK_BOX(browser->toolbar), + print, + FALSE, + FALSE, + BADWOLF_TOOLBAR_PADDING); gtk_container_set_focus_child(GTK_CONTAINER(browser->box), browser->toolbar); gtk_container_set_focus_child(GTK_CONTAINER(browser->toolbar), browser->location); @@ -707,6 +728,9 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat g_signal_connect( browser->auto_load_images, "toggled", G_CALLBACK(auto_load_imagesCb_toggled), browser); + /* signals for print button */ + g_signal_connect(print, "clicked", G_CALLBACK(printCb_clicked), browser); + /* signals for WebView widget */ g_signal_connect(browser->webView, "web-process-terminated", diff --git a/interface.txt b/interface.txt @@ -21,6 +21,8 @@ The Browser View contains the following items: - Potentially some future elements - Location entry linked to the WebKit WebView, with integrated progress indication also linked to the WebKit WebView - Potentially some future elements +- Print button +- Potentially some future elements The element focused by default is the location entry.