mirror of
https://github.com/elementary/gala.git
synced 2024-10-27 00:12:08 +03:00
Remove background_sources
HashMap
This commit is contained in:
parent
43200bc0ff
commit
9be8b7d5f2
@ -29,7 +29,7 @@ namespace Gala {
|
||||
public signal void file_changed (string filename);
|
||||
|
||||
private Gee.HashMap<string,FileMonitor> file_monitors;
|
||||
private Gee.HashMap<string,BackgroundSource> background_sources;
|
||||
private BackgroundSource background_source;
|
||||
|
||||
private Animation animation;
|
||||
|
||||
@ -39,7 +39,6 @@ namespace Gala {
|
||||
|
||||
construct {
|
||||
file_monitors = new Gee.HashMap<string,FileMonitor> ();
|
||||
background_sources = new Gee.HashMap<string,BackgroundSource> ();
|
||||
}
|
||||
|
||||
public void monitor_file (string filename) {
|
||||
@ -83,25 +82,19 @@ namespace Gala {
|
||||
return animation;
|
||||
}
|
||||
|
||||
public BackgroundSource get_background_source (Meta.Display display, string settings_schema) {
|
||||
var background_source = background_sources[settings_schema];
|
||||
public BackgroundSource get_background_source (Meta.Display display) {
|
||||
if (background_source == null) {
|
||||
background_source = new BackgroundSource (display, settings_schema);
|
||||
background_source = new BackgroundSource (display);
|
||||
background_source.use_count = 1;
|
||||
background_sources[settings_schema] = background_source;
|
||||
} else
|
||||
background_source.use_count++;
|
||||
|
||||
return background_source;
|
||||
}
|
||||
|
||||
public void release_background_source (string settings_schema) {
|
||||
if (background_sources.has_key (settings_schema)) {
|
||||
var source = background_sources[settings_schema];
|
||||
if (--source.use_count == 0) {
|
||||
background_sources.unset (settings_schema);
|
||||
source.destroy ();
|
||||
}
|
||||
public void release_background_source () {
|
||||
if (--background_source.use_count == 0) {
|
||||
background_source.destroy ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
namespace Gala {
|
||||
public class BackgroundManager : Meta.BackgroundGroup {
|
||||
private const string GNOME_BACKGROUND_SCHEMA = "org.gnome.desktop.background";
|
||||
private const string GALA_BACKGROUND_SCHEMA = "io.elementary.desktop.background";
|
||||
private const string DIM_WALLPAPER_KEY = "dim-wallpaper-in-dark-style";
|
||||
private const double DIM_OPACITY = 0.55;
|
||||
@ -46,14 +45,14 @@ namespace Gala {
|
||||
}
|
||||
|
||||
construct {
|
||||
background_source = BackgroundCache.get_default ().get_background_source (display, GNOME_BACKGROUND_SCHEMA);
|
||||
background_source = BackgroundCache.get_default ().get_background_source (display);
|
||||
background_actor = create_background_actor ();
|
||||
|
||||
destroy.connect (on_destroy);
|
||||
}
|
||||
|
||||
private void on_destroy () {
|
||||
BackgroundCache.get_default ().release_background_source (GNOME_BACKGROUND_SCHEMA);
|
||||
BackgroundCache.get_default ().release_background_source ();
|
||||
background_source = null;
|
||||
|
||||
if (new_background_actor != null) {
|
||||
|
@ -39,8 +39,8 @@ namespace Gala {
|
||||
private uint[] hash_cache;
|
||||
private Meta.MonitorManager? monitor_manager;
|
||||
|
||||
public BackgroundSource (Meta.Display display, string settings_schema) {
|
||||
Object (display: display, settings: new Settings (settings_schema));
|
||||
public BackgroundSource (Meta.Display display) {
|
||||
Object (display: display);
|
||||
}
|
||||
|
||||
construct {
|
||||
@ -50,6 +50,8 @@ namespace Gala {
|
||||
monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
|
||||
monitor_manager.monitors_changed.connect (monitors_changed);
|
||||
|
||||
settings = new Settings ("org.gnome.desktop.background");
|
||||
|
||||
// unfortunately the settings sometimes tend to fire random changes even though
|
||||
// nothing actually happened. The code below is used to prevent us from spamming
|
||||
// new actors all the time, which lead to some problems in other areas of the code
|
||||
|
Loading…
Reference in New Issue
Block a user