From 21f3f52374dab21bb21f798d0130222725446f2e Mon Sep 17 00:00:00 2001 From: David Shea Date: Mar 01 2016 16:08:57 +0000 Subject: Move the widgets pixmaps into resources. This removes all public functions from widgets-common.c, so demote it to undocumented and non-introspected. This also removes the need for the ANACONDA_WIDGETS_DATA environment variable (and the associated test), since this way there is no filesystem location to override. --- diff --git a/Makefile.am b/Makefile.am index 4ac73cc..2352b21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -168,7 +168,6 @@ updates: runglade: ANACONDA_DATA=$(srcdir)/data \ ANACONDA_WIDGETS_OVERRIDES=$(srcdir)/widgets/python \ - ANACONDA_WIDGETS_DATA=$(srcdir)/widgets/data \ ANACONDA_INSTALL_CLASSES=$(srcdir)/pyanaconda/installclasses \ PYTHONPATH=$(srcdir):$(builddir)/pyanaconda/isys/.libs:$(srcdir)/widgets/python/:$(builddir)/widgets/src/.libs/ \ LD_LIBRARY_PATH=$(builddir)/widgets/src/.libs \ diff --git a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py index 5cd3402..bee1328 100644 --- a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py +++ b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py @@ -30,7 +30,6 @@ gi.require_version("Pango", "1.0") from gi.repository import Gtk, Pango -import os from pyanaconda import localization from pyanaconda.iutil import strip_accents from pyanaconda.ui.gui.utils import set_treeview_selection, timed_action, override_cell_property @@ -60,9 +59,8 @@ class LangLocaleHandler(object): def initialize(self): # Render an arrow for the chosen language - datadir = os.environ.get("ANACONDA_WIDGETS_DATA", "/usr/share/anaconda") - self._right_arrow = Gtk.Image.new_from_file(os.path.join(datadir, "pixmaps", "right-arrow-icon.png")) - self._left_arrow = Gtk.Image.new_from_file(os.path.join(datadir, "pixmaps", "left-arrow-icon.png")) + self._right_arrow = Gtk.Image.new_from_resource("/org/fedoraproject/anaconda/widgets/right-arrow-icon.png") + self._left_arrow = Gtk.Image.new_from_resource("/org/fedoraproject/anaconda/wdigets/left-arrow-icon.png") override_cell_property(self._langSelectedColumn, self._langSelectedRenderer, "pixbuf", self._render_lang_selected) diff --git a/tests/pyanaconda_tests/lang_locale_handler_test.py b/tests/pyanaconda_tests/lang_locale_handler_test.py deleted file mode 100644 index 7da6054..0000000 --- a/tests/pyanaconda_tests/lang_locale_handler_test.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (C) 2015 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties 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, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): Alexander Todorov -# - -from pyanaconda.ui.gui.spokes.lib.lang_locale_handler import LangLocaleHandler -import unittest -import mock -import os - -@unittest.skipUnless(os.environ.get("DISPLAY"), "DISPLAY is not defined") -class LLH(unittest.TestCase): - def setUp(self): - self.llh = LangLocaleHandler() - self.llh._languageStoreFilter = mock.Mock() - self.llh._langSelectedRenderer = mock.Mock() - self.llh._langSelectedColumn = mock.Mock() - self.llh._add_language = mock.Mock() - - self.orig_anaconda_widgets_data = os.environ.get("ANACONDA_WIDGETS_DATA", "") - if not "ANACONDA_WIDGETS_DATA" in os.environ: - widgets_data = os.path.dirname(os.path.abspath(__file__)) - widgets_data = os.path.dirname(os.path.dirname(widgets_data)) - widgets_data = os.path.join(widgets_data, "widgets", "data") - # pylint: disable=environment-modify - os.environ["ANACONDA_WIDGETS_DATA"] = widgets_data - - def tearDown(self): - # pylint: disable=environment-modify - os.environ["ANACONDA_WIDGETS_DATA"] = self.orig_anaconda_widgets_data - - def anaconda_widgets_data_test(self): - """Test if ANACONDA_WIDGETS_DATA is used if specified.""" - self.llh.initialize() - self.assertEqual(self.llh._right_arrow.get_property('file').find("/usr/share/anaconda"), -1) - self.assertEqual(self.llh._left_arrow.get_property('file').find("/usr/share/anaconda"), -1) diff --git a/tests/testenv.sh b/tests/testenv.sh index 5446c0d..efee692 100644 --- a/tests/testenv.sh +++ b/tests/testenv.sh @@ -39,4 +39,3 @@ export UIPATH="${top_srcdir}/pyanaconda/ui/gui/" export GLADE_CATALOG_SEARCH_PATH="${top_srcdir}/widgets/glade" export GLADE_MODULE_SEARCH_PATH="${top_builddir}/widgets/src/.libs" export ANACONDA_DATA="${top_srcdir}/data" -export ANACONDA_WIDGETS_DATA="${top_srcdir}/widgets/data" diff --git a/widgets/Makefile.am b/widgets/Makefile.am index 7afcf19..2c343e6 100644 --- a/widgets/Makefile.am +++ b/widgets/Makefile.am @@ -21,7 +21,7 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src python glade doc data +SUBDIRS = src python glade doc MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in config.sub \ configure depcomp install-sh ltmain.sh missing py-compile \ diff --git a/widgets/configure.ac b/widgets/configure.ac index 36bc7b9..1a7a0e6 100644 --- a/widgets/configure.ac +++ b/widgets/configure.ac @@ -84,9 +84,7 @@ AC_CONFIG_FILES([Makefile doc/Makefile glade/Makefile src/Makefile - python/Makefile - data/Makefile - data/pixmaps/Makefile]) + python/Makefile]) AC_OUTPUT # Gently advise the user about the build failures they are about to encounter diff --git a/widgets/data/Makefile.am b/widgets/data/Makefile.am deleted file mode 100644 index 771075f..0000000 --- a/widgets/data/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (C) 2012 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties 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, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): Vratislav Podzimek -# - -SUBDIRS = pixmaps - -MAINTAINERCLEANFILES = Makefile.in diff --git a/widgets/data/pixmaps/Makefile.am b/widgets/data/pixmaps/Makefile.am deleted file mode 100644 index fb9ee01..0000000 --- a/widgets/data/pixmaps/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# pixmaps/Makefile.am for anaconda -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . -# -# Author: David Cantrell - -pixmapsdir = $(datadir)/anaconda/pixmaps -dist_pixmaps_DATA = $(srcdir)/*.png $(srcdir)/*.svg - -MAINTAINERCLEANFILES = Makefile.in diff --git a/widgets/data/pixmaps/anaconda-selected-icon.svg b/widgets/data/pixmaps/anaconda-selected-icon.svg deleted file mode 100644 index e2faa03..0000000 --- a/widgets/data/pixmaps/anaconda-selected-icon.svg +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - image/svg+xml - - Gnome Symbolic Icon Theme - - - - - - - Gnome Symbolic Icon Theme - - - - - - - - - - - - - - diff --git a/widgets/data/pixmaps/dialog-warning-symbolic.svg b/widgets/data/pixmaps/dialog-warning-symbolic.svg deleted file mode 100644 index 8349c5d..0000000 --- a/widgets/data/pixmaps/dialog-warning-symbolic.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - image/svg+xml - - Gnome Symbolic Icon Theme - - - - - - - Gnome Symbolic Icon Theme - - - - - - - - - - - - - diff --git a/widgets/doc/AnacondaWidgets-docs.xml b/widgets/doc/AnacondaWidgets-docs.xml index 20990c4..016b5f1 100644 --- a/widgets/doc/AnacondaWidgets-docs.xml +++ b/widgets/doc/AnacondaWidgets-docs.xml @@ -42,11 +42,6 @@ - - Utility Functions - - - Object Hierarchy diff --git a/widgets/src/DiskOverview.c b/widgets/src/DiskOverview.c index 5242d5e..fd31daa 100644 --- a/widgets/src/DiskOverview.c +++ b/widgets/src/DiskOverview.c @@ -214,7 +214,6 @@ static void set_icon(AnacondaDiskOverview *widget, const char *icon_name) { GError *err = NULL; GIcon *base_icon, *emblem_icon, *icon; GEmblem *emblem = NULL; - gchar *file; if (!icon_name) return; @@ -230,9 +229,7 @@ static void set_icon(AnacondaDiskOverview *widget, const char *icon_name) { return; } - file = g_strdup_printf("%s/pixmaps/anaconda-selected-icon.svg", anaconda_get_widgets_datadir()); - emblem_icon = g_icon_new_for_string(file, &err); - g_free(file); + emblem_icon = g_icon_new_for_string("resource://" ANACONDA_RESOURCE_PATH "anaconda-selected-icon.svg", &err); if (!emblem_icon) { fprintf(stderr, "could not create emblem: %s\n", err->message); g_error_free(err); diff --git a/widgets/src/Makefile.am b/widgets/src/Makefile.am index 6d3ff7d..e88cfa8 100644 --- a/widgets/src/Makefile.am +++ b/widgets/src/Makefile.am @@ -31,8 +31,7 @@ GISOURCES = BaseWindow.c \ SpokeWindow.c \ StandaloneWindow.c \ LayoutIndicator.c \ - BaseStandalone.c \ - widgets-common.c + BaseStandalone.c GIHDRS = BaseWindow.h \ DiskOverview.h \ @@ -42,12 +41,11 @@ GIHDRS = BaseWindow.h \ SpokeWindow.h \ StandaloneWindow.h \ LayoutIndicator.h \ - BaseStandalone.h \ - widgets-common.h + BaseStandalone.h -NONGISOURCES = +NONGISOURCES = widgets-common.c -NONGIHDRS = +NONGIHDRS = widgets-common.h SOURCES = $(GISOURCES) $(NONGISOURCES) diff --git a/widgets/src/MountpointSelector.c b/widgets/src/MountpointSelector.c index 131894c..db3cf59 100644 --- a/widgets/src/MountpointSelector.c +++ b/widgets/src/MountpointSelector.c @@ -212,7 +212,6 @@ static void format_name_label(AnacondaMountpointSelector *widget, const char *va } static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountpoint) { - gchar *file; GtkStyleContext *context; mountpoint->priv = G_TYPE_INSTANCE_GET_PRIVATE(mountpoint, @@ -235,15 +234,13 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp gtk_widget_set_margin_start(GTK_WIDGET(mountpoint->priv->grid), 30); /* Create the icon. We don't need to check if it returned NULL since - * gtk_image_new_from_file will just display a broken image icon in that + * gtk_image_new_from_resource will just display a broken image icon in that * case. That's good enough error notification. */ if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR) - file = g_strdup_printf("%s/pixmaps/right-arrow-icon.png", anaconda_get_widgets_datadir()); + mountpoint->priv->arrow = gtk_image_new_from_resource(ANACONDA_RESOURCE_PATH "right-arrow-icon.png"); else - file = g_strdup_printf("%s/pixmaps/left-arrow-icon.png", anaconda_get_widgets_datadir()); - mountpoint->priv->arrow = gtk_image_new_from_file(file); - g_free(file); + mountpoint->priv->arrow = gtk_image_new_from_resource(ANACONDA_RESOURCE_PATH "left-arrow-icon.png"); gtk_widget_set_no_show_all(GTK_WIDGET(mountpoint->priv->arrow), TRUE); /* Set some properties. */ diff --git a/widgets/src/SpokeSelector.c b/widgets/src/SpokeSelector.c index 6ebeec9..4990f73 100644 --- a/widgets/src/SpokeSelector.c +++ b/widgets/src/SpokeSelector.c @@ -198,7 +198,6 @@ static void set_icon(AnacondaSpokeSelector *widget, const char *icon_name) { GtkIconTheme *icon_theme; GtkIconInfo *icon_info; GdkPixbuf *pixbuf; - gchar *file; if (!icon_name) return; @@ -214,9 +213,7 @@ static void set_icon(AnacondaSpokeSelector *widget, const char *icon_name) { return; } - file = g_strdup_printf("%s/pixmaps/dialog-warning-symbolic.svg", anaconda_get_widgets_datadir()); - emblem_icon = g_icon_new_for_string(file, &err); - g_free(file); + emblem_icon = g_icon_new_for_string("resource://" ANACONDA_RESOURCE_PATH "dialog-warning-symbolic.svg", &err); if (!emblem_icon) { fprintf(stderr, "could not create emblem: %s\n", err->message); g_error_free(err); diff --git a/widgets/src/SpokeWindow.c b/widgets/src/SpokeWindow.c index 9479086..b80e992 100644 --- a/widgets/src/SpokeWindow.c +++ b/widgets/src/SpokeWindow.c @@ -22,7 +22,6 @@ #include "BaseWindow.h" #include "SpokeWindow.h" #include "intl.h" -#include "widgets-common.h" #include #include diff --git a/widgets/src/resources/anaconda-selected-icon.svg b/widgets/src/resources/anaconda-selected-icon.svg new file mode 100644 index 0000000..e2faa03 --- /dev/null +++ b/widgets/src/resources/anaconda-selected-icon.svg @@ -0,0 +1,141 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + diff --git a/widgets/src/resources/dialog-warning-symbolic.svg b/widgets/src/resources/dialog-warning-symbolic.svg new file mode 100644 index 0000000..8349c5d --- /dev/null +++ b/widgets/src/resources/dialog-warning-symbolic.svg @@ -0,0 +1,30 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + diff --git a/widgets/src/widgets-common.c b/widgets/src/widgets-common.c index d965d79..8444656 100644 --- a/widgets/src/widgets-common.c +++ b/widgets/src/widgets-common.c @@ -23,28 +23,3 @@ #include "config.h" #include "widgets-common.h" - -#include -#include - -/** - * anaconda_get_widgets_datadir: - * - * Return the directory containing the anaconda widgets data files. - * - * The widgets data directory contains the pixmaps used by the anaconda - * widgets. This directory defaults to ${prefix}/share/anaconda/pixmaps, but - * it may be overriden at runtime using the ANACONDA_WIDGETS_DATA environment - * variable. - * - * Returns: the widgets data directory. - */ -const gchar *anaconda_get_widgets_datadir(void) { - gchar *env_value; - - env_value = getenv("ANACONDA_WIDGETS_DATA"); - if (env_value == NULL) - return WIDGETS_DATADIR; - else - return env_value; -} diff --git a/widgets/src/widgets-common.h b/widgets/src/widgets-common.h index 5dd7c1b..b3b3cd1 100644 --- a/widgets/src/widgets-common.h +++ b/widgets/src/widgets-common.h @@ -20,13 +20,6 @@ #ifndef _WIDGETS_COMMON_H #define _WIDGETS_COMMON_H -#include -#include - -G_BEGIN_DECLS - -const gchar *anaconda_get_widgets_datadir(void); - -G_END_DECLS +#define ANACONDA_RESOURCE_PATH "/org/fedoraproject/anaconda/widgets/" #endif