summaryrefslogtreecommitdiff
path: root/src/themes/theme.vala
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-03-05 12:19:59 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-03-05 12:19:59 +0100
commit98f3ef2689de06e8ab8b46a91acfa7dd2056a3a6 (patch)
treeb98e438ac1082925e12af6dfec6d9ebeb4e3035e /src/themes/theme.vala
parenta824c3e5bdab686901b02667609282e7d596a6af (diff)
Imported Upstream version 0.5.1
Diffstat (limited to 'src/themes/theme.vala')
-rw-r--r--src/themes/theme.vala61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/themes/theme.vala b/src/themes/theme.vala
index 269a574..1956046 100644
--- a/src/themes/theme.vala
+++ b/src/themes/theme.vala
@@ -38,6 +38,7 @@ public class Theme : GLib.Object {
public double max_zoom {get; private set; default=1.2;}
public double zoom_range {get; private set; default=0.2;}
public double transition_time {get; private set; default=0.5;}
+ public double wobble {get; private set; default=0.0;}
public double fade_in_time {get; private set; default=0.2;}
public double fade_out_time {get; private set; default=0.1;}
public double fade_in_zoom {get; private set; default=1.0;}
@@ -49,6 +50,7 @@ public class Theme : GLib.Object {
public double active_radius {get; private set; default=45.0;}
public double slice_radius {get; private set; default=32.0;}
public double slice_gap {get; private set; default=14.0;}
+ public bool has_slice_captions {get; private set; default=false;}
public bool caption {get; private set; default=false;}
public string caption_font {get; private set; default="sans 12";}
public int caption_width {get; private set; default=100;}
@@ -182,6 +184,9 @@ public class Theme : GLib.Object {
case "transitiontime":
transition_time = double.parse(attr_content);
break;
+ case "wobble":
+ wobble = double.parse(attr_content);
+ break;
case "fadeintime":
fade_in_time = double.parse(attr_content);
break;
@@ -403,8 +408,15 @@ public class Theme : GLib.Object {
if (element_name == "slice_layer") {
string file = "";
double scale = 1.0;
- bool is_icon = false;
+ SliceLayer.Type type = SliceLayer.Type.FILE;
+ SliceLayer.Visibility visibility = SliceLayer.Visibility.ANY;
bool colorize = false;
+ string slice_caption_font = "sans 8";
+ int slice_caption_width = 50;
+ int slice_caption_height = 20;
+ int pos_x = 0;
+ int pos_y = 0;
+ Color slice_caption_color = new Color.from_rgb(1.0f, 1.0f, 1.0f);
for (Xml.Attr* attribute = layer->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
@@ -419,13 +431,46 @@ public class Theme : GLib.Object {
break;
case "type":
if (attr_content == "icon")
- is_icon = true;
+ type = SliceLayer.Type.ICON;
+ else if (attr_content == "caption")
+ type = SliceLayer.Type.CAPTION;
else if (attr_content != "file")
warning("Invalid attribute content " + attr_content + " for attribute " + attr_name + " in <slice_layer> element!");
break;
case "colorize":
colorize = bool.parse(attr_content);
break;
+ case "font":
+ slice_caption_font = attr_content;
+ break;
+ case "width":
+ slice_caption_width = (int)(int.parse(attr_content) * Config.global.global_scale);
+ if (slice_caption_width % 2 == 1)
+ --slice_caption_width;
+ break;
+ case "height":
+ slice_caption_height = (int)(int.parse(attr_content) * Config.global.global_scale);
+ if (slice_caption_height % 2 == 1)
+ --slice_caption_height;
+ break;
+ case "x":
+ pos_x = (int)(double.parse(attr_content) * Config.global.global_scale);
+ break;
+ case "y":
+ pos_y = (int)(double.parse(attr_content) * Config.global.global_scale);
+ break;
+ case "color":
+ slice_caption_color = new Color.from_string(attr_content);
+ break;
+ case "visibility":
+ if (attr_content == "without_caption")
+ visibility = SliceLayer.Visibility.WITHOUT_CAPTION;
+ else if (attr_content == "with_caption") {
+ this.has_slice_captions = true;
+ visibility = SliceLayer.Visibility.WITH_CAPTION;
+ } else if (attr_content != "any")
+ warning("Invalid attribute content " + attr_content + " for attribute " + attr_name + " in <slice_layer> element!");
+ break;
default:
warning("Invalid attribute \"" + attr_name + "\" in <slice_layer> element!");
break;
@@ -438,9 +483,17 @@ public class Theme : GLib.Object {
int size = 2*(int)(slice_radius*scale*max_zoom);
if (slice->name.down() == "activeslice") {
- active_slice_layers.add(new SliceLayer(file, size, colorize, is_icon));
+ if (type == SliceLayer.Type.ICON) active_slice_layers.add(new SliceLayer.icon(file, size, colorize, visibility));
+ else if (type == SliceLayer.Type.CAPTION) active_slice_layers.add(new SliceLayer.caption(slice_caption_font,
+ slice_caption_width, slice_caption_height,
+ pos_y, slice_caption_color, colorize, visibility));
+ else active_slice_layers.add(new SliceLayer.file(file, size, colorize, visibility));
} else {
- inactive_slice_layers.add(new SliceLayer(file, size, colorize, is_icon));
+ if (type == SliceLayer.Type.ICON) inactive_slice_layers.add(new SliceLayer.icon(file, size, colorize, visibility));
+ else if (type == SliceLayer.Type.CAPTION) inactive_slice_layers.add(new SliceLayer.caption(slice_caption_font,
+ slice_caption_width, slice_caption_height,
+ pos_y, slice_caption_color, colorize, visibility));
+ else inactive_slice_layers.add(new SliceLayer.file(file, size, colorize, visibility));
}
} else {