summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Frings-Fürst <jff@merkur>2014-07-23 11:40:08 +0200
committerJörg Frings-Fürst <jff@merkur>2014-07-23 11:40:08 +0200
commit6edfb34cb3eee958e392a433ae9ac4f240279d09 (patch)
treed33f9e9032809dba2ccb1b8c9ccc928507c38cf6
parent1f6f24308e96040962794c5a9ffd81597b5e072a (diff)
Imported Upstream version 0.5.5upstream/0.5.5
-rw-r--r--src/actionGroups/clipboardGroup.vala4
-rw-r--r--src/actions/pieAction.vala2
-rw-r--r--src/deamon.vala4
-rw-r--r--src/gui/iconSelectWindow.vala38
-rw-r--r--src/gui/piePreviewDeleteSign.vala14
-rw-r--r--src/gui/piePreviewSliceRenderer.vala36
-rw-r--r--src/images/icon.vala25
-rw-r--r--src/images/image.vala10
-rw-r--r--src/pies/pieManager.vala8
-rw-r--r--src/renderers/pieWindow.vala9
-rw-r--r--src/utilities/key.vala12
11 files changed, 79 insertions, 83 deletions
diff --git a/src/actionGroups/clipboardGroup.vala b/src/actionGroups/clipboardGroup.vala
index 836c927..c104d62 100644
--- a/src/actionGroups/clipboardGroup.vala
+++ b/src/actionGroups/clipboardGroup.vala
@@ -79,7 +79,7 @@ public class ClipboardGroup : ActionGroup {
/// The maximum remembered items of the clipboard.
/////////////////////////////////////////////////////////////////////
- private const int max_items = 6;
+ private static const int max_items = 6;
private Gee.ArrayList<ClipboardItem?> items;
@@ -98,7 +98,7 @@ public class ClipboardGroup : ActionGroup {
private void add_item(Gtk.Clipboard c, Gtk.SelectionData contents) {
var new_item = new ClipboardItem(contents);
- if (this.items.size == this.max_items)
+ if (this.items.size == ClipboardGroup.max_items)
this.items.remove_at(0);
this.items.add(new_item);
diff --git a/src/actions/pieAction.vala b/src/actions/pieAction.vala
index faf7aca..c65c1d6 100644
--- a/src/actions/pieAction.vala
+++ b/src/actions/pieAction.vala
@@ -96,7 +96,7 @@ public class PieAction : Action {
/////////////////////////////////////////////////////////////////////
public override void activate() {
- PieManager.open_pie(real_command, true);
+ PieManager.open_pie(real_command);
}
}
diff --git a/src/deamon.vala b/src/deamon.vala
index a987de3..8cf95f8 100644
--- a/src/deamon.vala
+++ b/src/deamon.vala
@@ -36,7 +36,7 @@ public class Deamon : GLib.Object {
/////////////////////////////////////////////////////////////////////
public static int main(string[] args) {
- version = "0.5.4";
+ version = "0.5.5";
Logger.init();
Gdk.threads_init();
@@ -95,7 +95,7 @@ public class Deamon : GLib.Object {
warning(error.message);
}
- if (this.reset) {
+ if (Deamon.reset) {
if (GLib.FileUtils.remove(Paths.pie_config) == 0)
message("Removed file \"%s\"", Paths.pie_config);
if (GLib.FileUtils.remove(Paths.settings) == 0)
diff --git a/src/gui/iconSelectWindow.vala b/src/gui/iconSelectWindow.vala
index 174c23d..9159f15 100644
--- a/src/gui/iconSelectWindow.vala
+++ b/src/gui/iconSelectWindow.vala
@@ -140,24 +140,24 @@ public class IconSelectWindow : GLib.Object {
try {
this.load_queue = new GLib.AsyncQueue<ListEntry?>();
- if (this.icon_list == null) {
- this.icon_list = new Gtk.ListStore(3, typeof(string), // icon name
+ if (IconSelectWindow.icon_list == null) {
+ IconSelectWindow.icon_list = new Gtk.ListStore(3, typeof(string), // icon name
typeof(IconContext), // icon type
typeof(Gdk.Pixbuf)); // the icon itself
// disable sorting until all icons are loaded
// else loading becomes horribly slow
- this.icon_list.set_default_sort_func(() => {return 0;});
+ IconSelectWindow.icon_list.set_default_sort_func(() => {return 0;});
// reload if icon theme changes
Gtk.IconTheme.get_default().changed.connect(() => {
if (this.window.visible) load_icons();
- else need_reload = true;
+ else IconSelectWindow.need_reload = true;
});
}
// make the icon_view filterable
- this.icon_list_filtered = new Gtk.TreeModelFilter(this.icon_list, null);
+ this.icon_list_filtered = new Gtk.TreeModelFilter(IconSelectWindow.icon_list, null);
Gtk.Builder builder = new Gtk.Builder();
@@ -303,16 +303,16 @@ public class IconSelectWindow : GLib.Object {
this.window.show_all();
this.spinner.hide();
- if (this.need_reload) {
- this.need_reload = false;
+ if (IconSelectWindow.need_reload) {
+ IconSelectWindow.need_reload = false;
this.load_icons();
}
}
public static void clear_icons() {
- if (icon_list != null) {
- need_reload = true;
- icon_list.clear();
+ if (IconSelectWindow.icon_list != null) {
+ IconSelectWindow.need_reload = true;
+ IconSelectWindow.icon_list.clear();
}
}
@@ -366,16 +366,16 @@ public class IconSelectWindow : GLib.Object {
private void load_icons() {
// only if it's not loading currently
- if (!this.loading) {
- this.loading = true;
- this.icon_list.clear();
+ if (!IconSelectWindow.loading) {
+ IconSelectWindow.loading = true;
+ IconSelectWindow.icon_list.clear();
// display the spinner
if (spinner != null)
this.spinner.visible = true;
// disable sorting of the icon_view - else it's horribly slow
- this.icon_list.set_sort_column_id(-1, Gtk.SortType.ASCENDING);
+ IconSelectWindow.icon_list.set_sort_column_id(-1, Gtk.SortType.ASCENDING);
this.load_all.begin();
@@ -384,15 +384,15 @@ public class IconSelectWindow : GLib.Object {
while (this.load_queue.length() > 0) {
var new_entry = this.load_queue.pop();
Gtk.TreeIter current;
- icon_list.append(out current);
- icon_list.set(current, 0, new_entry.name,
+ IconSelectWindow.icon_list.append(out current);
+ IconSelectWindow.icon_list.set(current, 0, new_entry.name,
1, new_entry.context,
2, new_entry.pixbuf);
}
// enable sorting of the icon_view if loading finished
- if (!this.loading) {
- icon_list.set_sort_column_id(0, Gtk.SortType.ASCENDING);
+ if (!IconSelectWindow.loading) {
+ IconSelectWindow.icon_list.set_sort_column_id(0, Gtk.SortType.ASCENDING);
}
return loading;
@@ -449,7 +449,7 @@ public class IconSelectWindow : GLib.Object {
}
// finished loading
- this.loading = false;
+ IconSelectWindow.loading = false;
// hide the spinner
if (spinner != null)
diff --git a/src/gui/piePreviewDeleteSign.vala b/src/gui/piePreviewDeleteSign.vala
index 2ff3321..500d876 100644
--- a/src/gui/piePreviewDeleteSign.vala
+++ b/src/gui/piePreviewDeleteSign.vala
@@ -42,9 +42,9 @@ public class PiePreviewDeleteSign : GLib.Object {
/// Some constants determining the look and behaviour of this Slice.
/////////////////////////////////////////////////////////////////////
- private const int radius = 18;
- private const double globale_scale = 0.8;
- private const double click_cancel_treshold = 5;
+ private static const int radius = 18;
+ private static const double globale_scale = 0.8;
+ private static const double click_cancel_treshold = 5;
/////////////////////////////////////////////////////////////////////
/// True, when the add sign is currently visible.
@@ -85,7 +85,7 @@ public class PiePreviewDeleteSign : GLib.Object {
/////////////////////////////////////////////////////////////////////
public void load() {
- this.icon = new Icon("stock_delete", radius*2);
+ this.icon = new Icon("stock_delete", PiePreviewDeleteSign.radius*2);
}
/////////////////////////////////////////////////////////////////////
@@ -133,7 +133,7 @@ public class PiePreviewDeleteSign : GLib.Object {
// transform the context
double scale = (this.size.val*this.clicked.val
- + this.activity.val*0.2 - 0.2)*globale_scale;
+ + this.activity.val*0.2 - 0.2)*PiePreviewDeleteSign.globale_scale;
ctx.scale(scale, scale);
// paint the image
@@ -150,11 +150,11 @@ public class PiePreviewDeleteSign : GLib.Object {
public bool on_mouse_move(double x, double y) {
if (this.clicked.end == 0.9) {
double dist = GLib.Math.pow(x-this.clicked_x, 2) + GLib.Math.pow(y-this.clicked_y, 2);
- if (dist > this.click_cancel_treshold*this.click_cancel_treshold)
+ if (dist > PiePreviewDeleteSign.click_cancel_treshold*PiePreviewDeleteSign.click_cancel_treshold)
this.clicked.reset_target(1.0, 0.1);
}
- if (GLib.Math.fabs(x) <= radius*globale_scale && GLib.Math.fabs(y) <= radius*globale_scale) {
+ if (GLib.Math.fabs(x) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale && GLib.Math.fabs(y) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale) {
this.activity.reset_target(1.0, 0.2);
return true;
}
diff --git a/src/gui/piePreviewSliceRenderer.vala b/src/gui/piePreviewSliceRenderer.vala
index af39c1f..6a12a47 100644
--- a/src/gui/piePreviewSliceRenderer.vala
+++ b/src/gui/piePreviewSliceRenderer.vala
@@ -72,11 +72,11 @@ public class PiePreviewSliceRenderer : GLib.Object {
/// Some constants determining the look and behaviour of this Slice.
/////////////////////////////////////////////////////////////////////
- private const double pie_radius = 126;
- private const double radius = 24;
- private const double delete_x = 13;
- private const double delete_y = -13;
- private const double click_cancel_treshold = 5;
+ private static const double pie_radius = 126;
+ private static const double radius = 24;
+ private static const double delete_x = 13;
+ private static const double delete_y = -13;
+ private static const double click_cancel_treshold = 5;
/////////////////////////////////////////////////////////////////////
/// Storing the position where a mouse click was executed. Useful for
@@ -120,10 +120,10 @@ public class PiePreviewSliceRenderer : GLib.Object {
// if it's a custom ActionGroup
if (group.get_type().depth() == 2 && group.actions.size > 0) {
- this.icon = new Icon(group.actions[0].icon, (int)(radius*2));
+ this.icon = new Icon(group.actions[0].icon, (int)(PiePreviewSliceRenderer.radius*2));
this.name = group.actions[0].name;
} else {
- this.icon = new Icon(GroupRegistry.descriptions[group.get_type().name()].icon, (int)(radius*2));
+ this.icon = new Icon(GroupRegistry.descriptions[group.get_type().name()].icon, (int)(PiePreviewSliceRenderer.radius*2));
this.name = GroupRegistry.descriptions[group.get_type().name()].name;
}
}
@@ -174,7 +174,7 @@ public class PiePreviewSliceRenderer : GLib.Object {
ctx.save();
// transform the context
- ctx.translate(cos(this.angle.val)*pie_radius, sin(this.angle.val)*pie_radius);
+ ctx.translate(cos(this.angle.val)*PiePreviewSliceRenderer.pie_radius, sin(this.angle.val)*PiePreviewSliceRenderer.pie_radius);
double scale = this.size.val*this.clicked.val
+ this.activity.val*0.1 - 0.1;
@@ -187,7 +187,7 @@ public class PiePreviewSliceRenderer : GLib.Object {
ctx.restore();
- ctx.translate(delete_x*this.size.val, delete_y*this.size.val);
+ ctx.translate(PiePreviewSliceRenderer.delete_x*this.size.val, PiePreviewSliceRenderer.delete_y*this.size.val);
this.delete_sign.draw(frame_time, ctx);
ctx.restore();
@@ -216,14 +216,14 @@ public class PiePreviewSliceRenderer : GLib.Object {
if (this.clicked.end == 0.9) {
double dist = GLib.Math.pow(x-this.clicked_x, 2) + GLib.Math.pow(y-this.clicked_y, 2);
- if (dist > this.click_cancel_treshold*this.click_cancel_treshold)
+ if (dist > PiePreviewSliceRenderer.click_cancel_treshold*PiePreviewSliceRenderer.click_cancel_treshold)
this.clicked.reset_target(1.0, 0.1);
}
- double own_x = cos(this.angle.val)*pie_radius;
- double own_y = sin(this.angle.val)*pie_radius;
- this.delete_hovered = this.delete_sign.on_mouse_move(x - own_x - delete_x*this.size.val,
- y - own_y - delete_y*this.size.val);
+ double own_x = cos(this.angle.val)*PiePreviewSliceRenderer.pie_radius;
+ double own_y = sin(this.angle.val)*PiePreviewSliceRenderer.pie_radius;
+ this.delete_hovered = this.delete_sign.on_mouse_move(x - own_x - PiePreviewSliceRenderer.delete_x*this.size.val,
+ y - own_y - PiePreviewSliceRenderer.delete_y*this.size.val);
return active;
}
@@ -244,10 +244,10 @@ public class PiePreviewSliceRenderer : GLib.Object {
public void on_button_press(double x, double y) {
bool delete_pressed = false;
if (this.activity.end == 1.0) {
- double own_x = cos(this.angle.val)*pie_radius;
- double own_y = sin(this.angle.val)*pie_radius;
- delete_pressed = this.delete_sign.on_button_press(x - own_x - delete_x*this.size.val,
- y - own_y - delete_y*this.size.val);
+ double own_x = cos(this.angle.val)*PiePreviewSliceRenderer.pie_radius;
+ double own_y = sin(this.angle.val)*PiePreviewSliceRenderer.pie_radius;
+ delete_pressed = this.delete_sign.on_button_press(x - own_x - PiePreviewSliceRenderer.delete_x*this.size.val,
+ y - own_y - PiePreviewSliceRenderer.delete_y*this.size.val);
}
if (!delete_pressed && this.activity.end == 1.0) {
diff --git a/src/images/icon.vala b/src/images/icon.vala
index 42be41f..6dfb53b 100644
--- a/src/images/icon.vala
+++ b/src/images/icon.vala
@@ -56,11 +56,11 @@ public class Icon : Image {
/////////////////////////////////////////////////////////////////////
public Icon(string icon_name, int size) {
- var cached = this.cache.get("%s@%u".printf(icon_name, size));
+ var cached = Icon.cache.get("%s@%u".printf(icon_name, size));
if (cached == null) {
- this.load_file_at_size(this.get_icon_file(icon_name, size), size, size);
- this.cache.set("%s@%u".printf(icon_name, size), this.surface);
+ this.load_file_at_size(Icon.get_icon_file(icon_name, size), size, size);
+ Icon.cache.set("%s@%u".printf(icon_name, size), this.surface);
} else {
this.surface = cached;
}
@@ -105,7 +105,6 @@ public class Icon : Image {
return icon_name;
warning("Icon \"" + icon_name + "\" not found! Using default icon...");
- icon_name = "stock_unknown";
}
@@ -115,14 +114,20 @@ public class Icon : Image {
if (result == "") {
warning("Icon \"" + icon_name + "\" not found! Using default icon...");
- icon_name = "stock_unknown";
- file = icon_theme.lookup_icon(icon_name, size, 0);
- if (file != null) result = file.get_filename();
- }
- if (result == "")
- warning("Icon \"" + icon_name + "\" not found! Will be ugly...");
+ string[] default_icons = {"application-default-icon", "stock_unknown"};
+ foreach (var icon in default_icons) {
+ file = icon_theme.lookup_icon(icon, size, 0);
+ if (file != null) {
+ result = file.get_filename();
+ break;
+ }
+ }
+ if (result == "")
+ warning("No default icon found! Will be ugly...");
+ }
+
return result;
}
}
diff --git a/src/images/image.vala b/src/images/image.vala
index 1d9674b..197523b 100644
--- a/src/images/image.vala
+++ b/src/images/image.vala
@@ -134,6 +134,7 @@ public class Image : GLib.Object {
warning("Failed to load " + filename + "!");
this.surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width, height);
}
+
} catch (GLib.Error e) {
message("Error loading image file: %s", e.message);
this.surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width, height);
@@ -167,8 +168,11 @@ public class Image : GLib.Object {
/////////////////////////////////////////////////////////////////////
public Gdk.Pixbuf to_pixbuf() {
- var pixbuf = new Gdk.Pixbuf.from_data(surface.get_data(), Gdk.Colorspace.RGB, true, 8,
- width(), height(), surface.get_stride(), null);
+ if (this.surface == null || this.surface.get_data().length <= 0)
+ return new Gdk.Pixbuf(Gdk.Colorspace.RGB, true, 8, 1, 1);
+
+ var pixbuf = new Gdk.Pixbuf.from_data(this.surface.get_data(), Gdk.Colorspace.RGB, true, 8,
+ width(), height(), this.surface.get_stride(), null);
pixbuf = pixbuf.copy();
@@ -180,7 +184,7 @@ public class Image : GLib.Object {
*(p + i) = *(p + i + 2);
*(p + i + 2) = tmp;
}
-
+
return pixbuf;
}
diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala
index f574085..83a8309 100644
--- a/src/pies/pieManager.vala
+++ b/src/pies/pieManager.vala
@@ -81,7 +81,7 @@ public class PieManager : GLib.Object {
/// Opens the Pie with the given ID, if it exists.
/////////////////////////////////////////////////////////////////////
- public static void open_pie(string id, bool at_last_position = false) {
+ public static void open_pie(string id) {
if (!a_pie_is_active) {
Pie? pie = all_pies[id];
@@ -92,11 +92,7 @@ public class PieManager : GLib.Object {
var window = new PieWindow();
window.load_pie(pie);
- if (at_last_position) {
- window.open_at(last_x, last_y);
- } else {
- window.open();
- }
+ window.open();
opened_windows.add(window);
diff --git a/src/renderers/pieWindow.vala b/src/renderers/pieWindow.vala
index 5238dfe..66ed863 100644
--- a/src/renderers/pieWindow.vala
+++ b/src/renderers/pieWindow.vala
@@ -197,15 +197,6 @@ public class PieWindow : Gtk.Window {
}
/////////////////////////////////////////////////////////////////////
- /// Opens the window at a given location.
- /////////////////////////////////////////////////////////////////////
-
- public void open_at(int at_x, int at_y) {
- this.open();
- this.move(at_x-this.width_request/2, at_y-this.height_request/2);
- }
-
- /////////////////////////////////////////////////////////////////////
/// Gets the center position of the window.
/////////////////////////////////////////////////////////////////////
diff --git a/src/utilities/key.vala b/src/utilities/key.vala
index 5f27a1e..af6e86a 100644
--- a/src/utilities/key.vala
+++ b/src/utilities/key.vala
@@ -118,8 +118,8 @@ public class Key : GLib.Object {
display.flush();
// press and release the actual key
- X.Test.fake_key_event(this.display, this.key_code, true, 0);
- X.Test.fake_key_event(this.display, this.key_code, false, 0);
+ X.Test.fake_key_event(display, this.key_code, true, 0);
+ X.Test.fake_key_event(display, this.key_code, false, 0);
// release the pressed modifiers and re-press the keys hold down by the user
press_modifiers(this.modifiers, false);
@@ -145,16 +145,16 @@ public class Key : GLib.Object {
private void press_modifiers(Gdk.ModifierType modifiers, bool down) {
if ((modifiers & Gdk.ModifierType.CONTROL_MASK) > 0)
- X.Test.fake_key_event(this.display, this.ctrl_code, down, 0);
+ X.Test.fake_key_event(display, ctrl_code, down, 0);
if ((modifiers & Gdk.ModifierType.SHIFT_MASK) > 0)
- X.Test.fake_key_event(this.display, this.shift_code, down, 0);
+ X.Test.fake_key_event(display, shift_code, down, 0);
if ((modifiers & Gdk.ModifierType.MOD1_MASK) > 0)
- X.Test.fake_key_event(this.display, this.alt_code, down, 0);
+ X.Test.fake_key_event(display, alt_code, down, 0);
if ((modifiers & Gdk.ModifierType.SUPER_MASK) > 0)
- X.Test.fake_key_event(this.display, this.super_code, down, 0);
+ X.Test.fake_key_event(display, super_code, down, 0);
}
}