lib: Add GResource support and load close/resize button images from it

This commit is contained in:
Rico Tzschichholz 2017-07-18 15:12:22 +02:00
parent 80f2ac39de
commit b839b2f356
7 changed files with 50 additions and 3 deletions

View File

@ -12,4 +12,5 @@ AM_CPPFLAGS = \
-DPKGLIBDIR=\"$(pkglibdir)\" \
-DPLUGINDIR=\"$(pkglibdir)/plugins\" \
-DSCHEMA=\"org.pantheon.desktop.gala\" \
-DRESOURCEPATH=\"/org/pantheon/desktop/gala\" \
$(NULL)

View File

@ -148,6 +148,23 @@ MUTTER_LDFLAGS=""
PLUGIN_LDFLAGS="-module -avoid-version"
AC_SUBST([PLUGIN_LDFLAGS])
# -----------------------------------------------------------
# GLib Resources
# -----------------------------------------------------------
AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[the glib-compile-resources program])
AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[])
if test -z "$GLIB_COMPILE_RESOURCES"; then
AC_MSG_ERROR([glib-compile-resources not found])
fi
AC_ARG_VAR([XMLLINT],[the xmllint program])
AC_PATH_PROG([XMLLINT],[xmllint],[])
if test -z "$XMLLINT"; then
AC_MSG_ERROR([xmllint not found])
fi
# -----------------------------------------------------------
# Optional Dependencies
# -----------------------------------------------------------

View File

@ -3,7 +3,7 @@ SUBDIRS = \
$(NULL)
stylesdir = $(pkgdatadir)
styles_DATA = gala.css texture.png close.svg resize.svg
styles_DATA = gala.css texture.png
applicationsdir = $(datadir)/applications
applications_DATA = gala.desktop gala-wayland.desktop gala-other.desktop gala-multitaskingview.desktop
@ -35,6 +35,7 @@ EXTRA_DIST = \
gala-wayland.desktop \
gala-other.desktop.in \
gala-multitaskingview.desktop.in \
gala.gresource.xml \
texture.png \
close.svg \
resize.svg \

23
data/gala.gresource.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 Rico Tzschichholz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http: www.gnu.org/licenses/>.
-->
<gresources>
<gresource prefix="/org/pantheon/desktop/gala">
<file alias="buttons/close.svg" compressed="true" preprocess="xml-stripblanks">close.svg</file>
<file alias="buttons/resize.svg" compressed="true" preprocess="xml-stripblanks">resize.svg</file>
</gresource>
</gresources>

View File

@ -4,6 +4,7 @@ VAPIDIR = $(top_srcdir)/vapi
BUILT_SOURCES = \
libgala_la_vala.stamp \
gala-resources.c \
$(NULL)
libgalaincludedir = $(includedir)/gala
@ -59,6 +60,9 @@ nodist_libgala_la_SOURCES = \
$(libgala_la_VALASOURCES:.vala=.c) \
$(NULL)
gala-resources.c: $(top_srcdir)/data/gala.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(top_srcdir)/data $(top_srcdir)/data/gala.gresource.xml)
$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(top_srcdir)/data --generate --c-name gala $<
gala.h gala.vapi: libgala_la_vala.stamp
libgala_la_vala.stamp: $(libgala_la_VALASOURCES) Makefile

View File

@ -283,7 +283,7 @@ namespace Gala
{
if (close_pixbuf == null) {
try {
close_pixbuf = new Gdk.Pixbuf.from_file_at_scale (Config.PKGDATADIR + "/close.svg", -1, 36, true);
close_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (Config.RESOURCEPATH + "/buttons/close.svg", -1, 36, true);
} catch (Error e) {
warning (e.message);
return null;
@ -331,7 +331,7 @@ namespace Gala
{
if (resize_pixbuf == null) {
try {
resize_pixbuf = new Gdk.Pixbuf.from_file_at_scale (Config.PKGDATADIR + "/resize.svg", -1, 36, true);
resize_pixbuf = new Gdk.Pixbuf.from_resource_at_scale (Config.RESOURCEPATH + "/buttons/resize.svg", -1, 36, true);
} catch (Error e) {
warning (e.message);
return null;

View File

@ -25,4 +25,5 @@ namespace Config
public const string VERSION_INFO;
public const string PLUGINDIR;
public const string SCHEMA;
public const string RESOURCEPATH;
}