summaryrefslogtreecommitdiff
path: root/src/themes
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-03-05 12:20:00 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-03-05 12:20:00 +0100
commit9efffcc071e59e6c0fe5d0b406e558cc7319e8ee (patch)
tree1f4d8d555dc439403da78c52e413be3c29833c21 /src/themes
parent75655ffca55cb5e5ca51d8f6a4d3d600f1f54cdc (diff)
parent98f3ef2689de06e8ab8b46a91acfa7dd2056a3a6 (diff)
Merge tag 'upstream/0.5.1'
Upstream version 0.5.1
Diffstat (limited to 'src/themes')
-rw-r--r--src/themes/sliceLayer.vala50
-rw-r--r--src/themes/theme.vala61
2 files changed, 99 insertions, 12 deletions
diff --git a/src/themes/sliceLayer.vala b/src/themes/sliceLayer.vala
index 2620912..3c650c0 100644
--- a/src/themes/sliceLayer.vala
+++ b/src/themes/sliceLayer.vala
@@ -23,31 +23,63 @@ namespace GnomePie {
/////////////////////////////////////////////////////////////////////////
public class SliceLayer : GLib.Object {
+
+ public enum Type { FILE, ICON, CAPTION }
+ public enum Visibility { ANY, WITH_CAPTION, WITHOUT_CAPTION }
+
+ public Type layer_type { get; private set; }
+ public Visibility visibility { get; private set; }
/////////////////////////////////////////////////////////////////////
/// Information on the contained image.
/////////////////////////////////////////////////////////////////////
public Image image {get; set;}
- public string icon_file {get; private set;}
+
/////////////////////////////////////////////////////////////////////
/// Properties of this layer.
/////////////////////////////////////////////////////////////////////
- public bool colorize {get; private set; }
- public bool is_icon {get; private set;}
- public int icon_size {get; private set;}
+ public string icon_file {get; private set; default="";}
+ public bool colorize {get; private set; default=false;}
+ public int icon_size {get; private set; default=1;}
+
+ public string font {get; private set; default="";}
+ public int width {get; private set; default=0;}
+ public int height {get; private set; default=0;}
+ public int position {get; private set; default=0;}
+ public Color color {get; private set; default=new Color();}
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members of the layer.
/////////////////////////////////////////////////////////////////////
- public SliceLayer(string icon_file, int icon_size, bool colorize, bool is_icon) {
+ public SliceLayer.file(string icon_file, int icon_size, bool colorize, Visibility visibility) {
+ this.layer_type = Type.FILE;
this.icon_file = icon_file;
this.colorize = colorize;
- this.is_icon = is_icon;
this.icon_size = icon_size;
+ this.visibility = visibility;
+ }
+
+ public SliceLayer.icon(string icon_file, int icon_size, bool colorize, Visibility visibility) {
+ this.layer_type = Type.ICON;
+ this.icon_file = icon_file;
+ this.colorize = colorize;
+ this.icon_size = icon_size;
+ this.visibility = visibility;
+ }
+
+ public SliceLayer.caption(string font, int width, int height, int position, Color color, bool colorize, Visibility visibility) {
+ this.layer_type = Type.CAPTION;
+ this.font = font;
+ this.width = width;
+ this.height = height;
+ this.position = position;
+ this.color = color;
+ this.visibility = visibility;
+ this.colorize = colorize;
}
/////////////////////////////////////////////////////////////////////
@@ -55,9 +87,11 @@ public class SliceLayer : GLib.Object {
/////////////////////////////////////////////////////////////////////
public void load_image() {
- if (this.icon_file == "" && this.is_icon == true)
+ this.image = null;
+
+ if (this.icon_file == "" && this.layer_type == Type.ICON)
this.image = new Image.empty(this.icon_size, this.icon_size, new Color.from_rgb(1, 1, 1));
- else
+ else if (this.icon_file != "")
this.image = new Image.from_file_at_size(this.icon_file, this.icon_size, this.icon_size);
}
}
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 {