From 10af7615316fd91eef61cc66a8ede38a2bff3fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 19 Aug 2015 16:25:31 +0200 Subject: Imported Upstream version 0.6.5 --- src/deamon.vala | 2 +- src/gui/preferencesWindow.vala | 14 +++++++++ src/images/themedIcon.vala | 8 ++++-- src/renderers/pieRenderer.vala | 62 +++++++++++++++++++++++++++++++--------- src/renderers/pieWindow.vala | 45 +++++++++++++++++++---------- src/renderers/sliceRenderer.vala | 17 +++++------ src/themes/sliceLayer.vala | 16 +++++++---- src/themes/theme.vala | 12 ++++---- src/utilities/config.vala | 5 ++++ 9 files changed, 130 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/deamon.vala b/src/deamon.vala index 24bc451..8c84f3a 100644 --- a/src/deamon.vala +++ b/src/deamon.vala @@ -43,7 +43,7 @@ public class Deamon : GLib.Application { ///////////////////////////////////////////////////////////////////// public static int main(string[] args) { - version = "0.6.4"; + version = "0.6.5"; // disable overlay scrollbar --- hacky workaround for black / // transparent background diff --git a/src/gui/preferencesWindow.vala b/src/gui/preferencesWindow.vala index fe3eeb0..5d22d6b 100644 --- a/src/gui/preferencesWindow.vala +++ b/src/gui/preferencesWindow.vala @@ -46,6 +46,7 @@ public class PreferencesWindow : GLib.Object { private ThemeList? theme_list = null; private Gtk.ToggleButton? indicator = null; + private Gtk.ToggleButton? search_by_string = null; private Gtk.ToggleButton? autostart = null; private Gtk.ToggleButton? captions = null; @@ -159,6 +160,9 @@ public class PreferencesWindow : GLib.Object { this.indicator = (builder.get_object("indicator-checkbox") as Gtk.ToggleButton); this.indicator.toggled.connect(on_indicator_toggled); + this.search_by_string = (builder.get_object("select-by-string-checkbox") as Gtk.ToggleButton); + this.search_by_string.toggled.connect(on_search_by_string_toggled); + this.captions = (builder.get_object("captions-checkbox") as Gtk.ToggleButton); this.captions.toggled.connect(on_captions_toggled); @@ -234,6 +238,7 @@ public class PreferencesWindow : GLib.Object { this.indicator.active = Config.global.show_indicator; this.autostart.active = Config.global.auto_start; this.captions.active = Config.global.show_captions; + this.search_by_string.active = Config.global.search_by_string; if (Config.global.theme.has_slice_captions) { this.captions.sensitive = true; @@ -311,6 +316,15 @@ public class PreferencesWindow : GLib.Object { Config.global.show_captions = check.active; } + ///////////////////////////////////////////////////////////////////// + /// Enables or disables Slice selection by typing. + ///////////////////////////////////////////////////////////////////// + + private void on_search_by_string_toggled(Gtk.ToggleButton check_box) { + var check = check_box as Gtk.CheckButton; + Config.global.search_by_string = check.active; + } + ///////////////////////////////////////////////////////////////////// /// Called when a new Pie is selected in the PieList. ///////////////////////////////////////////////////////////////////// diff --git a/src/images/themedIcon.vala b/src/images/themedIcon.vala index b7b6f74..9f4ca8a 100644 --- a/src/images/themedIcon.vala +++ b/src/images/themedIcon.vala @@ -74,6 +74,7 @@ public class ThemedIcon : Image { if (layer.layer_type == SliceLayer.Type.ICON) { ctx.push_group(); + ctx.translate(layer.x, layer.y); layer.image.paint_on(ctx); ctx.set_operator(Cairo.Operator.IN); @@ -86,6 +87,7 @@ public class ThemedIcon : Image { } icon.paint_on(ctx); + ctx.translate(-layer.x, -layer.y); ctx.pop_group_to_source(); ctx.paint(); @@ -93,11 +95,13 @@ public class ThemedIcon : Image { } else if (layer.layer_type == SliceLayer.Type.CAPTION) { Image text = new RenderedText(caption, layer.width, layer.height, layer.font, layer.color, Config.global.global_scale); - ctx.translate(0, layer.position); + ctx.translate(layer.x, layer.y); text.paint_on(ctx); - ctx.translate(0, -layer.position); + ctx.translate(-layer.x, -layer.y); } else if (layer.layer_type == SliceLayer.Type.FILE) { + ctx.translate(layer.x, layer.y); layer.image.paint_on(ctx); + ctx.translate(-layer.x, -layer.y); } // colorize the whole layer if neccasary diff --git a/src/renderers/pieRenderer.vala b/src/renderers/pieRenderer.vala index cd50644..1ff2b3e 100644 --- a/src/renderers/pieRenderer.vala +++ b/src/renderers/pieRenderer.vala @@ -221,7 +221,7 @@ public class PieRenderer : GLib.Object { } } - this.set_highlighted_slice(this.quickaction); + this.select_by_index(this.quickaction); ShowPieMode showpie= ShowPieMode.FULL_PIE; @@ -500,19 +500,19 @@ public class PieRenderer : GLib.Object { if (this.first_slice_idx+this.visible_slice_count >= slices.size) { this.visible_slice_count= slices.size - this.first_slice_idx; } - this.reset_sclice_anim(); - this.set_highlighted_slice(-1); + this.reset_slice_anim(); + this.select_by_index(-1); calc_key_navigation_pos(); this.key_board_control = true; } else if (this.first_slice_idx > 0) { //go to first page this.first_slice_idx= 0; - this.reset_sclice_anim(); + this.reset_slice_anim(); //recover the original value this.visible_slice_count= this.original_visible_slice_count; - this.reset_sclice_anim(); - this.set_highlighted_slice(-1); + this.reset_slice_anim(); + this.select_by_index(-1); calc_key_navigation_pos(); this.key_board_control = true; } @@ -532,8 +532,8 @@ public class PieRenderer : GLib.Object { if (this.first_slice_idx < 0) { this.first_slice_idx= 0; } - this.reset_sclice_anim(); - this.set_highlighted_slice(-1); + this.reset_slice_anim(); + this.select_by_index(-1); calc_key_navigation_pos(); this.key_board_control = true; @@ -547,19 +547,53 @@ public class PieRenderer : GLib.Object { //last page has less slices than previous this.visible_slice_count= n; this.first_slice_idx= slices.size - this.visible_slice_count; - this.reset_sclice_anim(); - this.set_highlighted_slice(-1); + this.reset_slice_anim(); + this.select_by_index(-1); calc_key_navigation_pos(); this.key_board_control = true; } } - private void reset_sclice_anim() { + private void reset_slice_anim() { //reset animation values in all the new visible slices for (int i= 0; i < this.visible_slice_count; ++i) this.slices[ i+this.first_slice_idx ].reset_anim(); } + ///////////////////////////////////////////////////////////////////// + /// Selects a slice based on a search string. + ///////////////////////////////////////////////////////////////////// + + public void select_by_string(string search) { + float max_similarity = 0; + int index = -1; + + for (int i=0; i max_similarity) { + index = this.first_slice_idx+i; + max_similarity = similarity; + } + } + + if (index >= 0 && index < slice_count()) { + key_board_control = true; + select_by_index(index); + } + } + ///////////////////////////////////////////////////////////////////// /// Returns the amount of slices in this pie. ///////////////////////////////////////////////////////////////////// @@ -616,7 +650,7 @@ public class PieRenderer : GLib.Object { next_active_slice = -1; } - this.set_highlighted_slice(next_active_slice); + this.select_by_index(next_active_slice); } center.draw(frame_time, ctx, angle, slice_track); @@ -639,7 +673,7 @@ public class PieRenderer : GLib.Object { /// Called when the currently active slice changes. ///////////////////////////////////////////////////////////////////// - public void set_highlighted_slice(int index) { + public void select_by_index(int index) { if (index != this.active_slice) { if (index >= this.first_slice_idx && index < this.first_slice_idx+this.visible_slice_count) this.active_slice = index; @@ -847,7 +881,7 @@ public class PieRenderer : GLib.Object { pos= this.first_slice_idx; } - this.set_highlighted_slice(pos); + this.select_by_index(pos); this.key_board_control = true; } diff --git a/src/renderers/pieWindow.vala b/src/renderers/pieWindow.vala index 95432c5..a49813a 100755 --- a/src/renderers/pieWindow.vala +++ b/src/renderers/pieWindow.vala @@ -94,6 +94,13 @@ public class PieWindow : Gtk.Window { private bool has_compositing = false; + ///////////////////////////////////////////////////////////////////// + /// When a Pie is opened, pressed buttons are accumulated and + /// matches are searched in all slices. + ///////////////////////////////////////////////////////////////////// + + private string search_string = ""; + ///////////////////////////////////////////////////////////////////// /// C'tor, sets up the window. ///////////////////////////////////////////////////////////////////// @@ -145,7 +152,7 @@ public class PieWindow : Gtk.Window { this.key_press_event.connect((e) => { if (e.keyval != last_key) { last_key = e.keyval; - this.handle_key_press(e.keyval, e.time); + this.handle_key_press(e.keyval, e.time, e.str); } return true; }); @@ -429,7 +436,7 @@ public class PieWindow : Gtk.Window { /// Do some useful stuff when keys are pressed. ///////////////////////////////////////////////////////////////////// - private void handle_key_press(uint key, uint32 time_stamp) { + private void handle_key_press(uint key, uint32 time_stamp, string text) { if (Gdk.keyval_name(key) == "Escape") this.cancel(); else if (Gdk.keyval_name(key) == "Return") this.activate_slice(time_stamp); else if (!PieManager.get_is_turbo(this.renderer.id)) { @@ -441,23 +448,31 @@ public class PieWindow : Gtk.Window { else if (Gdk.keyval_name(key) == "Page_Up") this.renderer.select_prevpage(); else if (Gdk.keyval_name(key) == "Tab") this.renderer.select_nextpage(); else if (Gdk.keyval_name(key) == "ISO_Left_Tab") this.renderer.select_prevpage(); - else if (Gdk.keyval_name(key) == "Alt_L") this.renderer.show_hotkeys = true; + else if (Gdk.keyval_name(key) == "Alt_L" && !Config.global.search_by_string) this.renderer.show_hotkeys = true; else { - int index = -1; - if (key >= 48 && key <= 57) index = ((int)key - 39)%10; - else if (key >= 97 && key <= 122) index = (int)key - 87; - else if (key >= 65 && key <= 90) index = (int)key - 55; + if (Config.global.search_by_string) { + this.search_string += text; + this.renderer.select_by_string(search_string.down()); + + } else { + + int index = -1; + + if (key >= 48 && key <= 57) index = ((int)key - 39)%10; + else if (key >= 97 && key <= 122) index = (int)key - 87; + else if (key >= 65 && key <= 90) index = (int)key - 55; - if (index >= 0 && index < this.renderer.slice_count()) { - this.renderer.key_board_control = true; - this.renderer.set_highlighted_slice(index); + if (index >= 0 && index < this.renderer.slice_count()) { + this.renderer.key_board_control = true; + this.renderer.select_by_index(index); - if (this.renderer.active_slice == index) { - GLib.Timeout.add((uint)(Config.global.theme.transition_time*1000.0), ()=> { - this.activate_slice(time_stamp); - return false; - }); + if (this.renderer.active_slice == index) { + GLib.Timeout.add((uint)(Config.global.theme.transition_time*1000.0), ()=> { + this.activate_slice(time_stamp); + return false; + }); + } } } } diff --git a/src/renderers/sliceRenderer.vala b/src/renderers/sliceRenderer.vala index dfcf512..591fbdd 100644 --- a/src/renderers/sliceRenderer.vala +++ b/src/renderers/sliceRenderer.vala @@ -45,6 +45,12 @@ public class SliceRenderer : GLib.Object { public Color color {get; private set;} + ///////////////////////////////////////////////////////////////////// + /// The Action which is rendered by this SliceRenderer. + ///////////////////////////////////////////////////////////////////// + + public Action action; + ///////////////////////////////////////////////////////////////////// /// The two Images used, when this slice is active or not. ///////////////////////////////////////////////////////////////////// @@ -58,12 +64,6 @@ public class SliceRenderer : GLib.Object { private Image hotkey; - ///////////////////////////////////////////////////////////////////// - /// The Action which is rendered by this SliceRenderer. - ///////////////////////////////////////////////////////////////////// - - private Action action; - ///////////////////////////////////////////////////////////////////// /// The PieRenderer which owns this SliceRenderer. ///////////////////////////////////////////////////////////////////// @@ -150,7 +150,7 @@ public class SliceRenderer : GLib.Object { this.hotkey = new RenderedText(hotkey_label, (int)Config.global.theme.slice_radius*2, (int)Config.global.theme.slice_radius*2, "sans 20", - Config.global.theme.caption_color, Config.global.global_scale); + new Color(), Config.global.global_scale); } ///////////////////////////////////////////////////////////////////// @@ -284,8 +284,9 @@ public class SliceRenderer : GLib.Object { ctx.paint(); // draw hotkeys if necassary - if (this.parent.show_hotkeys) + if (this.parent.show_hotkeys) { this.hotkey.paint_on(ctx, 1.0); + } ctx.restore(); } diff --git a/src/themes/sliceLayer.vala b/src/themes/sliceLayer.vala index 17ac3bb..bd9e98b 100644 --- a/src/themes/sliceLayer.vala +++ b/src/themes/sliceLayer.vala @@ -48,35 +48,41 @@ public class SliceLayer : GLib.Object { 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 int x {get; private set; default=0;} + public int y {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) { + public SliceLayer.file(string icon_file, int icon_size, int x, int y, bool colorize, Visibility visibility) { this.layer_type = Type.FILE; this.icon_file = icon_file; this.colorize = colorize; this.icon_size = icon_size; + this.x = x; + this.y = y; this.visibility = visibility; } - public SliceLayer.icon(string icon_file, int icon_size, bool colorize, Visibility visibility) { + public SliceLayer.icon(string icon_file, int icon_size, int x, int y, bool colorize, Visibility visibility) { this.layer_type = Type.ICON; this.icon_file = icon_file; this.colorize = colorize; this.icon_size = icon_size; + this.x = x; + this.y = y; this.visibility = visibility; } - public SliceLayer.caption(string font, int width, int height, int position, Color color, bool colorize, Visibility visibility) { + public SliceLayer.caption(string font, int width, int height, int x, int y, Color color, bool colorize, Visibility visibility) { this.layer_type = Type.CAPTION; this.font = font; this.width = width; this.height = height; - this.position = position; + this.x = x; + this.y = y; this.color = color; this.visibility = visibility; this.colorize = colorize; diff --git a/src/themes/theme.vala b/src/themes/theme.vala index e068b9e..a7dd4f8 100644 --- a/src/themes/theme.vala +++ b/src/themes/theme.vala @@ -486,17 +486,17 @@ public class Theme : GLib.Object { 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)); + if (type == SliceLayer.Type.ICON) active_slice_layers.add(new SliceLayer.icon(file, size, pos_x, pos_y, 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)); + pos_x, pos_y, slice_caption_color, colorize, visibility)); + else active_slice_layers.add(new SliceLayer.file(file, size, pos_x, pos_y, colorize, visibility)); } else { - if (type == SliceLayer.Type.ICON) inactive_slice_layers.add(new SliceLayer.icon(file, size, colorize, visibility)); + if (type == SliceLayer.Type.ICON) inactive_slice_layers.add(new SliceLayer.icon(file, size, pos_x, pos_y, 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)); + pos_x, pos_y, slice_caption_color, colorize, visibility)); + else inactive_slice_layers.add(new SliceLayer.file(file, size, pos_x, pos_y, colorize, visibility)); } } else { diff --git a/src/utilities/config.vala b/src/utilities/config.vala index dd31885..538602d 100644 --- a/src/utilities/config.vala +++ b/src/utilities/config.vala @@ -58,6 +58,7 @@ public class Config : GLib.Object { public int max_visible_slices { get; set; default = 24; } public bool show_indicator { get; set; default = true; } public bool show_captions { get; set; default = true; } + public bool search_by_string { get; set; default = true; } public bool auto_start { get; set; default = false; } public int showed_news { get; set; default = 0; } public Gee.ArrayList themes { get; private set; } @@ -77,6 +78,7 @@ public class Config : GLib.Object { writer.write_attribute("max_visible_slices", max_visible_slices.to_string()); writer.write_attribute("show_indicator", show_indicator ? "true" : "false"); writer.write_attribute("show_captions", show_captions ? "true" : "false"); + writer.write_attribute("search_by_string", search_by_string ? "true" : "false"); writer.write_attribute("showed_news", showed_news.to_string()); writer.end_element(); writer.end_document(); @@ -131,6 +133,9 @@ public class Config : GLib.Object { case "show_captions": show_captions = bool.parse(attr_content); break; + case "search_by_string": + search_by_string = bool.parse(attr_content); + break; case "showed_news": showed_news = int.parse(attr_content); break; -- cgit v1.2.3