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