diff --git a/data/gala.gresource.xml b/data/gala.gresource.xml index 4d2ef777..800c3bae 100644 --- a/data/gala.gresource.xml +++ b/data/gala.gresource.xml @@ -20,4 +20,8 @@ close.svg resize.svg + + gala.css + texture.png + diff --git a/data/meson.build b/data/meson.build index 39e5d23b..b99cfc08 100644 --- a/data/meson.build +++ b/data/meson.build @@ -30,5 +30,3 @@ icons_dir = join_paths(get_option('datadir'), 'icons', 'hicolor') install_data('icons/32x32/multitasking-view.svg', install_dir: join_paths(icons_dir, '32x32', 'apps')) install_data('icons/48x48/multitasking-view.svg', install_dir: join_paths(icons_dir, '48x48', 'apps')) install_data('icons/64x64/multitasking-view.svg', install_dir: join_paths(icons_dir, '64x64', 'apps')) - -install_data(['gala.css', 'texture.png'], install_dir: pkgdata_dir) diff --git a/lib/Utils.vala b/lib/Utils.vala index 4550b13d..58321182 100644 --- a/lib/Utils.vala +++ b/lib/Utils.vala @@ -385,5 +385,16 @@ namespace Gala return texture; } + + static Gtk.CssProvider gala_css = null; + public static unowned Gtk.CssProvider? get_gala_css () + { + if (gala_css == null) { + gala_css = new Gtk.CssProvider (); + gala_css.load_from_resource ("/io/elementary/desktop/gala/gala.css"); + } + + return gala_css; + } } } diff --git a/plugins/notify/NormalNotification.vala b/plugins/notify/NormalNotification.vala index cedaa4b4..f9bafbbc 100644 --- a/plugins/notify/NormalNotification.vala +++ b/plugins/notify/NormalNotification.vala @@ -62,7 +62,7 @@ namespace Gala.Plugins.Notify style_path.append_type (typeof (Gtk.Label)); var label_style_context = new Gtk.StyleContext (); - label_style_context.add_provider (Notification.default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); + label_style_context.add_provider (Gala.Utils.get_gala_css (), Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); label_style_context.set_path (style_path); Gdk.RGBA color; diff --git a/plugins/notify/Notification.vala b/plugins/notify/Notification.vala index 7a71c79b..53676919 100644 --- a/plugins/notify/Notification.vala +++ b/plugins/notify/Notification.vala @@ -22,8 +22,6 @@ namespace Gala.Plugins.Notify { public abstract class Notification : Actor { - public static Gtk.CssProvider? default_css = null; - public const int WIDTH = 300; public const int ICON_SIZE = 48; public const int MARGIN = 12; @@ -119,21 +117,12 @@ namespace Gala.Plugins.Notify add_child (icon_container); add_child (close_button); - if (default_css == null) { - default_css = new Gtk.CssProvider (); - try { - default_css.load_from_path (Config.PKGDATADIR + "/gala.css"); - } catch (Error e) { - warning ("Loading default styles failed: %s", e.message); - } - } - var style_path = new Gtk.WidgetPath (); style_path.append_type (typeof (Gtk.Window)); style_path.append_type (typeof (Gtk.EventBox)); style_context = new Gtk.StyleContext (); - style_context.add_provider (default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); + style_context.add_provider (Gala.Utils.get_gala_css (), Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); style_context.add_class ("gala-notification"); style_context.set_path (style_path); style_context.set_scale (scale); diff --git a/plugins/notify/NotifyServer.vala b/plugins/notify/NotifyServer.vala index 240f397a..6d0c978f 100644 --- a/plugins/notify/NotifyServer.vala +++ b/plugins/notify/NotifyServer.vala @@ -304,13 +304,6 @@ namespace Gala.Plugins.Notify if (icon_fg_color != null) return icon_fg_color; - var default_css = new Gtk.CssProvider (); - try { - default_css.load_from_path (Config.PKGDATADIR + "/gala.css"); - } catch (Error e) { - warning ("Loading default styles failed: %s", e.message); - } - var style_path = new Gtk.WidgetPath (); style_path.append_type (typeof (Gtk.Window)); style_path.append_type (typeof (Gtk.EventBox)); @@ -318,7 +311,7 @@ namespace Gala.Plugins.Notify style_path.append_type (typeof (Gtk.Label)); var label_style_context = new Gtk.StyleContext (); - label_style_context.add_provider (default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); + label_style_context.add_provider (Gala.Utils.get_gala_css (), Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); label_style_context.set_path (style_path); label_style_context.add_class ("label"); label_style_context.set_state (Gtk.StateFlags.NORMAL); diff --git a/src/Background/SystemBackground.vala b/src/Background/SystemBackground.vala index a1257778..f41fddae 100644 --- a/src/Background/SystemBackground.vala +++ b/src/Background/SystemBackground.vala @@ -32,19 +32,22 @@ namespace Gala construct { - var path = InternalUtils.get_system_background_path (); + var background_file = GLib.File.new_for_uri ("resource:///io/elementary/desktop/gala/texture.png"); + unowned string custom_path = AppearanceSettings.get_default ().workspace_switcher_background; + if (custom_path != "" && FileUtils.test (custom_path, FileTest.IS_REGULAR)) { + background_file = GLib.File.new_for_path (custom_path); + } if (system_background == null) { system_background = new Meta.Background (meta_screen); system_background.set_color (DEFAULT_BACKGROUND_COLOR); - - system_background.set_file (File.new_for_path (path), GDesktop.BackgroundStyle.WALLPAPER); + system_background.set_file (background_file, GDesktop.BackgroundStyle.WALLPAPER); } background = system_background; var cache = Meta.BackgroundImageCache.get_default (); - var image = cache.load (File.new_for_path (path)); + var image = cache.load (background_file); if (image.is_loaded ()) { image = null; Idle.add(() => { diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index cad94dcb..c40ef626 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -118,21 +118,6 @@ namespace Gala Util.set_stage_input_region (screen, xregion); } - public static string get_system_background_path () - { - var filename = AppearanceSettings.get_default ().workspace_switcher_background; - var default_file = Config.PKGDATADIR + "/texture.png"; - - if (filename == "") { - filename = default_file; - } else if (!FileUtils.test (filename, FileTest.IS_REGULAR)) { - warning ("Failed to load %s", filename); - filename = default_file; - } - - return filename; - } - /** * Inserts a workspace at the given index. To ensure the workspace is not immediately * removed again when in dynamic workspaces, the window is first placed on it. diff --git a/src/ShadowEffect.vala b/src/ShadowEffect.vala index 3c0779b9..374b01ff 100644 --- a/src/ShadowEffect.vala +++ b/src/ShadowEffect.vala @@ -41,18 +41,12 @@ namespace Gala class construct { shadow_cache = new Gee.HashMap (); - var default_css = new Gtk.CssProvider (); - try { - default_css.load_from_path (Config.PKGDATADIR + "/gala.css"); - } catch (Error e) { - warning ("Loading default styles failed: %s", e.message); - } var style_path = new Gtk.WidgetPath (); var id = style_path.append_type (typeof (Gtk.Window)); style_context = new Gtk.StyleContext (); - style_context.add_provider (default_css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); + style_context.add_provider (Gala.Utils.get_gala_css (), Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); style_context.add_class ("decoration"); style_context.set_path (style_path); }