summaryrefslogtreecommitdiff
path: root/src/themes
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-04-18 15:43:01 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-04-18 15:43:01 +0200
commitdd33244267d4c4be09521937de8b0e05ff216a5c (patch)
tree4d1f734c1f55a6dcceb3d0bd5373c838e4667d3f /src/themes
parentb1f493d50d3d891f35033dbf6f4a49ab5bcd00cf (diff)
parent84a27086bbd9f493128b354300f9c77ccb32a56b (diff)
Merge tag 'upstream/0.6.0'
Upstream version 0.6.0
Diffstat (limited to 'src/themes')
-rw-r--r--src/themes/centerLayer.vala74
-rw-r--r--src/themes/sliceLayer.vala64
-rw-r--r--src/themes/theme.vala139
3 files changed, 140 insertions, 137 deletions
diff --git a/src/themes/centerLayer.vala b/src/themes/centerLayer.vala
index 3469fd0..59f37ed 100644
--- a/src/themes/centerLayer.vala
+++ b/src/themes/centerLayer.vala
@@ -1,23 +1,23 @@
-/*
-Copyright (c) 2011 by Simon Schneegans
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-more details.
-
-You should have received a copy of the GNU General Public License along with
-this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2015 by Simon Schneegans
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or (at
+// your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+/////////////////////////////////////////////////////////////////////////
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// This class representing a layer of the center of a pie. Each theme
/// may have plenty of them.
/////////////////////////////////////////////////////////////////////////
@@ -32,77 +32,77 @@ public class CenterLayer : GLib.Object {
/////////////////////////////////////////////////////////////////////
public enum RotationMode {AUTO, TO_MOUSE, TO_ACTIVE}
-
+
/////////////////////////////////////////////////////////////////////
/// Information on the contained image.
/////////////////////////////////////////////////////////////////////
-
+
public Image image {get; private set;}
public string image_file;
-
+
/////////////////////////////////////////////////////////////////////
/// Properties for the active state of this layer.
/////////////////////////////////////////////////////////////////////
-
+
public double active_scale {get; private set;}
public double active_rotation_speed {get; private set;}
public double active_alpha {get; private set;}
public bool active_colorize {get; private set;}
public RotationMode active_rotation_mode {get; private set;}
-
+
/////////////////////////////////////////////////////////////////////
/// Properties for the inactive state of this layer.
/////////////////////////////////////////////////////////////////////
-
+
public double inactive_scale {get; private set;}
public double inactive_rotation_speed {get; private set;}
public double inactive_alpha {get; private set;}
public bool inactive_colorize {get; private set;}
public RotationMode inactive_rotation_mode {get; private set;}
-
+
/////////////////////////////////////////////////////////////////////
/// The current rotation of this layer. TODO: Remove this.
/////////////////////////////////////////////////////////////////////
-
+
public double rotation {get; set;}
-
+
/////////////////////////////////////////////////////////////////////
/// Helper variable for image loading.
/////////////////////////////////////////////////////////////////////
-
+
private int center_radius;
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members of the layer.
/////////////////////////////////////////////////////////////////////
-
- public CenterLayer(string image_file, int center_radius, double active_scale, double active_rotation_speed,
+
+ public CenterLayer(string image_file, int center_radius, double active_scale, double active_rotation_speed,
double active_alpha, bool active_colorize, RotationMode active_rotation_mode,
- double inactive_scale, double inactive_rotation_speed,
+ double inactive_scale, double inactive_rotation_speed,
double inactive_alpha, bool inactive_colorize, RotationMode inactive_rotation_mode) {
-
+
this.image_file = image_file;
this.center_radius = center_radius;
-
+
this.active_scale = active_scale;
this.active_rotation_speed = active_rotation_speed;
this.active_alpha = active_alpha;
this.active_colorize = active_colorize;
this.active_rotation_mode = active_rotation_mode;
-
+
this.inactive_scale = inactive_scale;
this.inactive_rotation_speed = inactive_rotation_speed;
this.inactive_alpha = inactive_alpha;
this.inactive_colorize = inactive_colorize;
this.inactive_rotation_mode = inactive_rotation_mode;
-
+
this.rotation = 0.0;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Loads the contained image.
/////////////////////////////////////////////////////////////////////
-
+
public void load_image() {
this.image = new Image.from_file_at_size(image_file, 2*center_radius, 2*center_radius);
}
diff --git a/src/themes/sliceLayer.vala b/src/themes/sliceLayer.vala
index 3c650c0..17ac3bb 100644
--- a/src/themes/sliceLayer.vala
+++ b/src/themes/sliceLayer.vala
@@ -1,23 +1,23 @@
-/*
-Copyright (c) 2011 by Simon Schneegans
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-more details.
-
-You should have received a copy of the GNU General Public License along with
-this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2015 by Simon Schneegans
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or (at
+// your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+/////////////////////////////////////////////////////////////////////////
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// This class representing a layer of a slice of a pie. Each theme may
/// have plenty of them.
/////////////////////////////////////////////////////////////////////////
@@ -26,35 +26,35 @@ 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;}
-
-
+
+
/////////////////////////////////////////////////////////////////////
/// Properties of this layer.
/////////////////////////////////////////////////////////////////////
-
+
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.file(string icon_file, int icon_size, bool colorize, Visibility visibility) {
this.layer_type = Type.FILE;
this.icon_file = icon_file;
@@ -62,7 +62,7 @@ public class SliceLayer : GLib.Object {
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;
@@ -70,7 +70,7 @@ public class SliceLayer : GLib.Object {
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;
@@ -81,15 +81,15 @@ public class SliceLayer : GLib.Object {
this.visibility = visibility;
this.colorize = colorize;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Loads the contained image.
/////////////////////////////////////////////////////////////////////
-
+
public void load_image() {
this.image = null;
-
- if (this.icon_file == "" && this.layer_type == Type.ICON)
+
+ 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 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 1956046..e068b9e 100644
--- a/src/themes/theme.vala
+++ b/src/themes/theme.vala
@@ -1,34 +1,34 @@
-/*
-Copyright (c) 2011 by Simon Schneegans
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation, either version 3 of the License, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-more details.
-
-You should have received a copy of the GNU General Public License along with
-this program. If not, see <http:www.gnu.org/licenses/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2015 by Simon Schneegans
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or (at
+// your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+/////////////////////////////////////////////////////////////////////////
using GLib.Math;
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// A theme of Gnome-Pie. Can be loaded from XML-Files.
/////////////////////////////////////////////////////////////////////////
public class Theme : GLib.Object {
-
+
/////////////////////////////////////////////////////////////////////
/// Properties of a theme.
/////////////////////////////////////////////////////////////////////
-
+
public string directory {get; private set; default="";}
public string name {get; private set; default="";}
public string description {get; private set; default="";}
@@ -49,6 +49,7 @@ public class Theme : GLib.Object {
public double center_radius {get; private set; default=90.0;}
public double active_radius {get; private set; default=45.0;}
public double slice_radius {get; private set; default=32.0;}
+ public double visible_slice_radius {get; private set; default=0.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;}
@@ -58,39 +59,39 @@ public class Theme : GLib.Object {
public double caption_position {get; private set; default=0.0;}
public Color caption_color {get; private set; default=new Color();}
public Icon preview_icon {get; private set; default=new Icon("gnome-pie", 36);}
-
+
public Gee.ArrayList<CenterLayer?> center_layers {get; private set;}
public Gee.ArrayList<SliceLayer?> active_slice_layers {get; private set;}
public Gee.ArrayList<SliceLayer?> inactive_slice_layers {get; private set;}
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, creates a theme object for a given theme directory. This
/// directory should contain a theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
public Theme(string dir) {
this.center_layers = new Gee.ArrayList<CenterLayer?>();
this.active_slice_layers = new Gee.ArrayList<SliceLayer?>();
this.inactive_slice_layers = new Gee.ArrayList<SliceLayer?>();
-
+
this.directory = dir;
}
-
+
/////////////////////////////////////////////////////////////////////
- /// Loads the theme from its directory. Images have to be loaded
+ /// Loads the theme from its directory. Images have to be loaded
/// explicitly.
/////////////////////////////////////////////////////////////////////
-
+
public bool load() {
this.center_layers.clear();
this.active_slice_layers.clear();
this.inactive_slice_layers.clear();
-
+
this.preview_icon = new Icon(this.directory + "/preview.png", 36);
-
+
Xml.Parser.init();
string path = this.directory + "/theme.xml";
-
+
Xml.Doc* themeXML = Xml.Parser.parse_file(path);
if (themeXML == null) {
warning("Failed to add theme: \"" + path + "\" not found!");
@@ -103,21 +104,21 @@ public class Theme : GLib.Object {
warning("Failed to add theme: \"theme.xml\" is empty!");
return false;
}
-
+
this.parse_root(root);
-
+
delete themeXML;
Xml.Parser.cleanup();
-
+
this.radius *= max_zoom;
-
+
return true;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Loads all images of the theme.
/////////////////////////////////////////////////////////////////////
-
+
public void load_images() {
foreach (var layer in this.center_layers)
layer.load_image();
@@ -126,17 +127,17 @@ public class Theme : GLib.Object {
foreach (var layer in this.inactive_slice_layers)
layer.load_image();
}
-
+
/////////////////////////////////////////////////////////////////////
/// The following methods parse specific parts of the theme file.
/// Nothing special here, just some boring code.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_root(Xml.Node* root) {
for (Xml.Attr* attribute = root->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "name":
name = attr_content;
@@ -161,16 +162,16 @@ public class Theme : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <pie> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_pie(Xml.Node* pie) {
for (Xml.Attr* attribute = pie->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "radius":
radius = double.parse(attr_content) * Config.global.global_scale;
@@ -234,16 +235,16 @@ public class Theme : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <center> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_center(Xml.Node* center) {
for (Xml.Attr* attribute = center->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "radius":
center_radius = double.parse(attr_content) * Config.global.global_scale;
@@ -259,7 +260,7 @@ public class Theme : GLib.Object {
for (Xml.Node* node = center->children; node != null; node = node->next) {
if (node->type == Xml.ElementType.ELEMENT_NODE) {
string element_name = node->name.down();
-
+
if (element_name == "center_layer") {
parse_center_layer(node);
} else {
@@ -268,19 +269,20 @@ public class Theme : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <slices> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_slices(Xml.Node* slices) {
for (Xml.Attr* attribute = slices->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "radius":
slice_radius = double.parse(attr_content) * Config.global.global_scale;
+ visible_slice_radius = double.parse(attr_content) * Config.global.global_scale;
break;
case "mingap":
slice_gap = double.parse(attr_content) * Config.global.global_scale;
@@ -293,7 +295,7 @@ public class Theme : GLib.Object {
for (Xml.Node* node = slices->children; node != null; node = node->next) {
if (node->type == Xml.ElementType.ELEMENT_NODE) {
string element_name = node->name.down();
-
+
if (element_name == "activeslice" || element_name == "inactiveslice") {
parse_slice_layers(node);
} else {
@@ -302,11 +304,11 @@ public class Theme : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <center_layer> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_center_layer(Xml.Node* layer) {
string file = "";
@@ -320,11 +322,11 @@ public class Theme : GLib.Object {
bool inactive_colorize = false;
CenterLayer.RotationMode active_rotation_mode = CenterLayer.RotationMode.AUTO;
CenterLayer.RotationMode inactive_rotation_mode = CenterLayer.RotationMode.AUTO;
-
+
for (Xml.Attr* attribute = layer->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "file":
file = attr_content;
@@ -342,10 +344,10 @@ public class Theme : GLib.Object {
break;
case "turn_to_active":
active_rotation_mode = CenterLayer.RotationMode.TO_ACTIVE;
- break;
+ break;
case "turn_to_mouse":
active_rotation_mode = CenterLayer.RotationMode.TO_MOUSE;
- break;
+ break;
default:
warning("Invalid value \"" + attr_content + "\" for attribute \"" + attr_name + "\" in <center_layer> element!");
break;
@@ -370,10 +372,10 @@ public class Theme : GLib.Object {
break;
case "turn_to_active":
inactive_rotation_mode = CenterLayer.RotationMode.TO_ACTIVE;
- break;
+ break;
case "turn_to_mouse":
inactive_rotation_mode = CenterLayer.RotationMode.TO_MOUSE;
- break;
+ break;
default:
warning("Invalid value \"" + attr_content + "\" for attribute \"" + attr_name + "\" in <center_layer> element!");
break;
@@ -392,19 +394,19 @@ public class Theme : GLib.Object {
}
double max_scale = GLib.Math.fmax(active_scale, inactive_scale);
- center_layers.add(new CenterLayer(directory + "/" + file, (int)(center_radius*max_scale), active_scale/max_scale, active_rotation_speed, active_alpha, active_colorize, active_rotation_mode,
+ center_layers.add(new CenterLayer(directory + "/" + file, (int)(center_radius*max_scale), active_scale/max_scale, active_rotation_speed, active_alpha, active_colorize, active_rotation_mode,
inactive_scale/max_scale, inactive_rotation_speed, inactive_alpha, inactive_colorize, inactive_rotation_mode));
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <slice_layer> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_slice_layers(Xml.Node* slice) {
for (Xml.Node* layer = slice->children; layer != null; layer = layer->next) {
if (layer->type == Xml.ElementType.ELEMENT_NODE) {
string element_name = layer->name.down();
-
+
if (element_name == "slice_layer") {
string file = "";
double scale = 1.0;
@@ -417,11 +419,11 @@ public class Theme : GLib.Object {
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();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "file":
file = attr_content;
@@ -476,11 +478,12 @@ public class Theme : GLib.Object {
break;
}
}
-
+
if (file != "")
file = directory + "/" + file;
-
+
int size = 2*(int)(slice_radius*scale*max_zoom);
+ this.visible_slice_radius = Math.fmax(slice_radius*scale, this.visible_slice_radius);
if (slice->name.down() == "activeslice") {
if (type == SliceLayer.Type.ICON) active_slice_layers.add(new SliceLayer.icon(file, size, colorize, visibility));
@@ -502,16 +505,16 @@ public class Theme : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <caption> element from the theme.xml file.
/////////////////////////////////////////////////////////////////////
-
+
private void parse_caption(Xml.Node* caption) {
for (Xml.Attr* attribute = caption->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "font":
caption_font = attr_content;