Add logo as resource and configure about dialog to use logo from resource

This commit is contained in:
2019-03-21 22:22:35 +01:00
parent b43b142a75
commit 5537c076a8
4 changed files with 19 additions and 1 deletions

16
main.c
View File

@@ -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));