Commit 6e9ea5fc authored by Jens Georg's avatar Jens Georg

Add gsettings for transparency background

Signed-off-by: Jens Georg's avatarJens Georg <mail@jensge.org>

https://bugzilla.gnome.org/show_bug.cgi?id=716708
parent 6d1786b3
......@@ -161,7 +161,19 @@
<summary>background color</summary>
<description>A grayscale color for use as the background color.</description>
</key>
<key name="transparent-background-type" type="s">
<default>'checkered'</default>
<summary>background for transparent images</summary>
<description>The background to use for transparent images.</description>
</key>
<key name="transparent-background-color" type="s">
<default>'#444'</default>
<summary>color for solid transparency background</summary>
<description>Color to use if background for transparent images is set to solid color</description>
</key>
<key name="hide-photos-already-imported" type="b">
<default>false</default>
<summary>Selection state of “hide photos” option</summary>
......
......@@ -22,6 +22,8 @@ public enum FuzzyPropertyState {
public enum ConfigurableProperty {
AUTO_IMPORT_FROM_LIBRARY = 0,
BG_COLOR_NAME,
TRANSPARENT_BACKGROUND_TYPE,
TRANSPARENT_BACKGROUND_COLOR,
COMMIT_METADATA_TO_MASTERS,
DESKTOP_BACKGROUND_FILE,
DESKTOP_BACKGROUND_MODE,
......@@ -100,6 +102,12 @@ public enum ConfigurableProperty {
case BG_COLOR_NAME:
return "BG_COLOR_NAME";
case TRANSPARENT_BACKGROUND_TYPE:
return "TRANSPARENT_BACKGROUND_TYPE";
case TRANSPARENT_BACKGROUND_COLOR:
return "TRANSPARENT_BACKGROUND_COLOR";
case COMMIT_METADATA_TO_MASTERS:
return "COMMIT_METADATA_TO_MASTERS";
......@@ -452,6 +460,50 @@ public abstract class ConfigurationFacade : Object {
}
}
//
// transparent background type
//
public virtual string get_transparent_background_type() {
try {
return get_engine().get_string_property(ConfigurableProperty.TRANSPARENT_BACKGROUND_TYPE);
} catch (ConfigurationError err) {
on_configuration_error(err);
return "checkered";
}
}
public virtual void set_transparent_background_type(string type) {
try {
get_engine().set_string_property(ConfigurableProperty.TRANSPARENT_BACKGROUND_TYPE, type);
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
}
}
//
// transparent background color
//
public virtual string get_transparent_background_color() {
try {
return get_engine().get_string_property(ConfigurableProperty.TRANSPARENT_BACKGROUND_COLOR);
} catch (ConfigurationError err) {
on_configuration_error(err);
return "#444";
}
}
public virtual void set_transparent_background_color(string color_name) {
try {
get_engine().set_string_property(ConfigurableProperty.TRANSPARENT_BACKGROUND_COLOR, color_name);
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
}
}
//
// commit metadata to masters
//
......
......@@ -31,6 +31,8 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
schema_names[ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY] = FILES_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.BG_COLOR_NAME] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.TRANSPARENT_BACKGROUND_TYPE] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.TRANSPARENT_BACKGROUND_COLOR] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.COMMIT_METADATA_TO_MASTERS] = FILES_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.DESKTOP_BACKGROUND_FILE] = SYSTEM_DESKTOP_SCHEMA_NAME;
schema_names[ConfigurableProperty.DESKTOP_BACKGROUND_MODE] = SYSTEM_DESKTOP_SCHEMA_NAME;
......@@ -103,6 +105,8 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
key_names[ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY] = "auto-import";
key_names[ConfigurableProperty.BG_COLOR_NAME] = "background-color";
key_names[ConfigurableProperty.TRANSPARENT_BACKGROUND_TYPE] = "transparent-background-type";
key_names[ConfigurableProperty.TRANSPARENT_BACKGROUND_COLOR] = "transparent-background-color";
key_names[ConfigurableProperty.COMMIT_METADATA_TO_MASTERS] = "commit-metadata";
key_names[ConfigurableProperty.DESKTOP_BACKGROUND_FILE] = "picture-uri";
key_names[ConfigurableProperty.DESKTOP_BACKGROUND_MODE] = "picture-options";
......
......@@ -450,14 +450,32 @@ private static Cairo.Surface background_surface = null;
private Cairo.Surface get_background_surface() {
if (background_surface == null) {
string color_a;
string color_b;
var config = Config.Facade.get_instance();
var type = config.get_transparent_background_type();
switch (type) {
case "checkered":
color_a = "#808080";
color_b = "#ccc";
break;
case "solid":
color_a = color_b = config.get_transparent_background_color();
break;
default:
color_a = color_b = "#000";
break;
}
background_surface = new Cairo.ImageSurface(Cairo.Format.RGB24, 16, 16);
var ctx = new Cairo.Context(background_surface);
ctx.set_operator(Cairo.Operator.SOURCE);
set_source_color_from_string(ctx, "#808080");
set_source_color_from_string(ctx, color_a);
ctx.rectangle(0,0,8,8);
ctx.rectangle(8,8,8,8);
ctx.fill();
set_source_color_from_string(ctx, "#cccccc");
set_source_color_from_string(ctx, color_b);
ctx.rectangle(0,8,8,8);
ctx.rectangle(8,0,8,8);
ctx.fill();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment