logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: b83e68106620bc9832354c51a75e67c58e423e59
parent: f91e67e3c7f57fc61bad0dbad337ebf70111ec31
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 16 Dec 2019 22:30:25 +0100

keybindings.c: Grab link activation in About

Diffstat:

Mkeybindings.c53+++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/keybindings.c b/keybindings.c @@ -1,24 +1,49 @@ +// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +// Copyright © 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +// SPDX-License-Identifier: BSD-3-Clause + #include "keybindings.h" #include "badwolf.h" #include <glib/gi18n.h> /* _() */ +static gboolean +about_dialogCb_activate_link(GtkAboutDialog *about_dialog, gchar *uri, gpointer user_data) +{ + (void)about_dialog; + struct Window *window = (struct Window *)user_data; + + badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL)); + + gtk_widget_destroy(GTK_WIDGET(about_dialog)); + + return TRUE; +} + static void -badwolf_about_dialog(GtkWindow *main_window) +badwolf_about_dialog(GtkWindow *main_window, gpointer user_data) { - // clang-format off - gtk_show_about_dialog( - main_window, - "license", "SPDX-License-Identifier: BSD-3-Clause", - "copyright", "2019 Haelwenn (lanodan) Monnier <contact+badwolf@hacktivis.me>", - "website", homepage, - "comments", _("Minimalist and privacy-oriented WebKitGTK+ browser"), - "version", version, - //FIXME: "logo-icon-name", g_get_application_name(), - NULL - ); - // clang-format on + struct Window *window = (struct Window *)user_data; + GtkWidget *about_dialog = gtk_about_dialog_new(); + + gtk_window_set_transient_for(GTK_WINDOW(about_dialog), main_window); + gtk_window_set_destroy_with_parent(GTK_WINDOW(about_dialog), TRUE); + + gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about_dialog), + "SPDX-License-Identifier: BSD-3-Clause"); + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about_dialog), + "2019 Haelwenn (lanodan) Monnier <contact+badwolf@hacktivis.me>"); + gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about_dialog), homepage); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about_dialog), + _("Minimalist and privacy-oriented WebKitGTK+ browser")); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about_dialog), version); + + g_signal_connect( + about_dialog, "activate-link", G_CALLBACK(about_dialogCb_activate_link), window); + + (void)gtk_dialog_run(GTK_DIALOG(about_dialog)); + gtk_widget_destroy(about_dialog); } static void @@ -113,7 +138,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * { switch(((GdkEventKey *)event)->keyval) { - case GDK_KEY_F1: badwolf_about_dialog(GTK_WINDOW(window->main_window)); return TRUE; + case GDK_KEY_F1: badwolf_about_dialog(GTK_WINDOW(window->main_window), window); return TRUE; } }