From 5537c076a83efe13b2e05fb7ecdba98f866a7704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 21 Mar 2019 22:22:35 +0100 Subject: [PATCH] Add logo as resource and configure about dialog to use logo from resource --- glade/CMakeLists.txt | 1 + glade/about.glade | 2 +- glade/resources.xml | 1 + main.c | 16 ++++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/glade/CMakeLists.txt b/glade/CMakeLists.txt index 19dcf2f..7e98584 100644 --- a/glade/CMakeLists.txt +++ b/glade/CMakeLists.txt @@ -1,6 +1,7 @@ add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c) add_custom_command(DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.glade + ${CMAKE_CURRENT_SOURCE_DIR}/resources.xml OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resources.c COMMAND diff --git a/glade/about.glade b/glade/about.glade index a0a6784..b21402d 100644 --- a/glade/about.glade +++ b/glade/about.glade @@ -10,7 +10,7 @@ https://git.shimatta.de/mhu/gds-render Git Repository Mario Hüttel <mario.huettel@gmx.net> - gds-render + gpl-2-0-only diff --git a/glade/resources.xml b/glade/resources.xml index e33bed3..97ba844 100644 --- a/glade/resources.xml +++ b/glade/resources.xml @@ -5,6 +5,7 @@ about.glade layer-widget.glade dialog.glade + ../icon/gds-render.svg diff --git a/main.c b/main.c index 3a419d5..5d6de63 100644 --- a/main.c +++ b/main.c @@ -52,6 +52,8 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_ { GtkBuilder *builder; GtkDialog *dialog; + GdkPixbuf *logo_buf; + GError *error = NULL; (void)user_data; (void)action; (void)parameter; @@ -60,6 +62,20 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_ dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog")); gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), _app_version_string); + + /* Load icon from resource */ + logo_buf = gdk_pixbuf_new_from_resource_at_scale("/logo.svg", 100, 100, TRUE, &error); + if (logo_buf) { + /* Set logo */ + gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), logo_buf); + + /* Pixbuf is now owned by about dialog. Unref */ + g_object_unref(logo_buf); + } else if (error) { + fprintf(stderr, "Logo could not be displayed: %s\n", error->message); + g_error_free(error); + } + gtk_dialog_run(dialog); gtk_widget_destroy(GTK_WIDGET(dialog));