Add logo as resource and configure about dialog to use logo from resource
This commit is contained in:
parent
b43b142a75
commit
5537c076a8
@ -1,6 +1,7 @@
|
|||||||
add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c)
|
add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c)
|
||||||
add_custom_command(DEPENDS
|
add_custom_command(DEPENDS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/*.glade
|
${CMAKE_CURRENT_SOURCE_DIR}/*.glade
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/resources.xml
|
||||||
OUTPUT
|
OUTPUT
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
||||||
COMMAND
|
COMMAND
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<property name="website">https://git.shimatta.de/mhu/gds-render</property>
|
<property name="website">https://git.shimatta.de/mhu/gds-render</property>
|
||||||
<property name="website_label" translatable="yes">Git Repository</property>
|
<property name="website_label" translatable="yes">Git Repository</property>
|
||||||
<property name="authors">Mario Hüttel <mario.huettel@gmx.net></property>
|
<property name="authors">Mario Hüttel <mario.huettel@gmx.net></property>
|
||||||
<property name="logo_icon_name">gds-render</property>
|
<property name="logo_icon_name"/>
|
||||||
<property name="license_type">gpl-2-0-only</property>
|
<property name="license_type">gpl-2-0-only</property>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<file compressed="true">about.glade</file>
|
<file compressed="true">about.glade</file>
|
||||||
<file>layer-widget.glade</file>
|
<file>layer-widget.glade</file>
|
||||||
<file>dialog.glade</file>
|
<file>dialog.glade</file>
|
||||||
|
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
||||||
|
16
main.c
16
main.c
@ -52,6 +52,8 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
|
|||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkDialog *dialog;
|
GtkDialog *dialog;
|
||||||
|
GdkPixbuf *logo_buf;
|
||||||
|
GError *error = NULL;
|
||||||
(void)user_data;
|
(void)user_data;
|
||||||
(void)action;
|
(void)action;
|
||||||
(void)parameter;
|
(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"));
|
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
|
||||||
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);
|
||||||
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), _app_version_string);
|
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_dialog_run(dialog);
|
||||||
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||||
|
Loading…
Reference in New Issue
Block a user