From eed939f4c87c7016be8c3e913cdb1f620b29256f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 23 Jun 2015 01:55:37 +0200 Subject: install PNG icon and use it to set GTK's window icon * it is installed into the package's data dir. It is always installed, even for Curses builds. This means when packaging for Debian, the icon could be part of the "sciteco-common" package. If there will ever be more GTK-specific files that need to be installed, this will probably change and the icon will be installed for GTK builds only and become part of the "sciteco-gtk" Debian package. * if the icon could not be loaded, we fail silently. * will not work with windows builds. On Windows, we should just use the icon resource linked into the binary rather than loading the image from file. --- Makefile.am | 10 +++++----- src/Makefile.am | 6 +++++- src/interface-gtk.cpp | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index b3061b8..ddd8ed4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,11 +8,11 @@ noinst_HEADERS = compat/bsd/sys/cdefs.h \ EXTRA_DIST = README TODO -# The icons are not installed currently. -# This should be left up to the Linux distro -# packager. -EXTRA_DIST += ico/sciteco-48.png \ - ico/sciteco.ico +# Only the PNG icon is installed as it is +# required by the GTK UI. +# Other uses are left to the distro package manager. +dist_pkgdata_DATA += ico/sciteco-48.png +EXTRA_DIST += ico/sciteco.ico # Distribute entire scintilla directory and # do some manual cleanup diff --git a/src/Makefile.am b/src/Makefile.am index 739aefd..384d8f3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,11 @@ if CLANG AM_CXXFLAGS += -Wno-mismatched-tags endif -AM_CPPFLAGS = -D'SCITECOLIBDIR="@scitecolibdir@"' +# These paths can be changed at install-time and +# should not be written into config.h: +AM_CPPFLAGS = -D'SCITECODATADIR="$(pkgdatadir)"' \ + -D'SCITECOLIBDIR="@scitecolibdir@"' + if NEED_COMPAT AM_CPPFLAGS += -I@top_srcdir@/compat endif diff --git a/src/interface-gtk.cpp b/src/interface-gtk.cpp index e01a2eb..ebc7cb1 100644 --- a/src/interface-gtk.cpp +++ b/src/interface-gtk.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include "gtk-info-popup.h" @@ -346,8 +347,21 @@ InterfaceGtk::widget_set_font(GtkWidget *widget, const gchar *font_name) void InterfaceGtk::event_loop_impl(void) { + GdkPixbuf *icon; GThread *thread; + /* + * Assign an icon to the window. + * If the file could not be found, we fail silently. + * On Windows, it may be better to load the icon compiled + * as a resource into the binary. + */ + icon = gdk_pixbuf_new_from_file(SCITECODATADIR G_DIR_SEPARATOR_S + "sciteco-48.png", + NULL); + if (icon) + gtk_window_set_icon(GTK_WINDOW(window), icon); + /* * When changing views, the new widget is not * added immediately to avoid flickering in the GUI. -- cgit v1.2.3