data: Add gala.css and texture.png to GResource

This commit is contained in:
Corentin Noël 2018-12-27 19:40:20 +01:00
parent 7f1e392e03
commit fe52fb1288
9 changed files with 26 additions and 49 deletions

View File

@ -20,4 +20,8 @@
<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>
<gresource prefix="/io/elementary/desktop/gala">
<file compressed="true">gala.css</file>
<file>texture.png</file>
</gresource>
</gresources>

View File

@ -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)

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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(() => {

View File

@ -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.

View File

@ -41,18 +41,12 @@ namespace Gala
class construct
{
shadow_cache = new Gee.HashMap<string,Shadow> ();
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);
}