From 21c8b0c749be00fff27e41e4c2d677dd7d320fa0 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Tue, 24 Jan 2012 09:42:25 +0100 Subject: Imported Upstream version 0.4.1 --- src/CMakeLists.txt | 7 ++++-- src/deamon.vala | 1 - src/gui/aboutWindow.vala | 2 +- src/gui/iconSelectWindow.vala | 45 ++++++++++++++++++++---------------- src/gui/newSliceWindow.vala | 9 ++++---- src/gui/preferencesWindow.vala | 10 +++++--- src/images/renderedText.vala | 52 +++--------------------------------------- src/pies/pieManager.vala | 4 ++++ 8 files changed, 50 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b809c48..91ed3ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,11 +6,14 @@ file(GLOB VALA_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.vala */*.vala) if (${INDICATOR_FOUND}) - SET(DEFINES --define HAVE_APPINDICATOR) + LIST(APPEND DEFINES --define HAVE_APPINDICATOR) endif(${INDICATOR_FOUND}) +if (${INDICATOR3_FOUND}) + LIST(APPEND DEFINES --define HAVE_APPINDICATOR) +endif(${INDICATOR3_FOUND}) if (${GTK3_FOUND}) - SET(DEFINES --define HAVE_GTK_3) + LIST(APPEND DEFINES --define HAVE_GTK_3) endif(${GTK3_FOUND}) if (${GMENU3_FOUND}) diff --git a/src/deamon.vala b/src/deamon.vala index cec9539..ceecf1b 100644 --- a/src/deamon.vala +++ b/src/deamon.vala @@ -140,7 +140,6 @@ public class Deamon : GLib.Object { PieManager.init(); Icon.init(); ThemedIcon.init(); - RenderedText.init(); // launch the indicator this.indicator = new Indicator(); diff --git a/src/gui/aboutWindow.vala b/src/gui/aboutWindow.vala index ccd956a..e7faca3 100644 --- a/src/gui/aboutWindow.vala +++ b/src/gui/aboutWindow.vala @@ -68,7 +68,7 @@ public class AboutWindow: Gtk.AboutDialog { logo_icon_name: "gnome-pie", website: "http://www.simonschneegans.de/?page_id=12", website_label: "www.gnome-pie.simonschneegans.de", - version: "0.4.0" + version: "0.4.1" ); } } diff --git a/src/gui/iconSelectWindow.vala b/src/gui/iconSelectWindow.vala index d66c654..174c23d 100644 --- a/src/gui/iconSelectWindow.vala +++ b/src/gui/iconSelectWindow.vala @@ -234,7 +234,7 @@ public class IconSelectWindow : GLib.Object { // displays the filtered icons this.icon_view = new Gtk.IconView.with_model(this.icon_list_filtered); this.icon_view.item_width = 32; - this.icon_view.item_padding = 3; + this.icon_view.item_padding = 2; this.icon_view.pixbuf_column = 2; this.icon_view.tooltip_column = 0; @@ -309,13 +309,20 @@ public class IconSelectWindow : GLib.Object { } } + public static void clear_icons() { + if (icon_list != null) { + need_reload = true; + icon_list.clear(); + } + } + ///////////////////////////////////////////////////////////////////// /// Makes the window select the icon of the given Pie. ///////////////////////////////////////////////////////////////////// - public void set_pie(string id) { - string icon = PieManager.all_pies[id].icon; - + public void set_icon(string icon) { + this.active_icon = icon; + if (icon.contains("/")) { this.file_chooser.set_filename(icon); this.tabs.set_current_page(1); @@ -369,28 +376,24 @@ public class IconSelectWindow : GLib.Object { // disable sorting of the icon_view - else it's horribly slow this.icon_list.set_sort_column_id(-1, Gtk.SortType.ASCENDING); - - try { - // start loading in another thread - unowned Thread loader = Thread.create(load_thread, false); - loader.set_priority(ThreadPriority.LOW); - } catch (GLib.ThreadError e) { - error("Failed to create icon loader thread!"); - } - + + this.load_all.begin(); + // insert loaded icons every 200 ms Timeout.add(200, () => { while (this.load_queue.length() > 0) { var new_entry = this.load_queue.pop(); Gtk.TreeIter current; - this.icon_list.append(out current); - this.icon_list.set(current, 0, new_entry.name, + icon_list.append(out current); + 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) this.icon_list.set_sort_column_id(0, Gtk.SortType.ASCENDING); + if (!this.loading) { + icon_list.set_sort_column_id(0, Gtk.SortType.ASCENDING); + } return loading; }); @@ -402,12 +405,13 @@ public class IconSelectWindow : GLib.Object { /// load_queue. ///////////////////////////////////////////////////////////////////// - private void* load_thread() { + private async void load_all() { var icon_theme = Gtk.IconTheme.get_default(); - + foreach (var context in icon_theme.list_contexts()) { if (!disabled_contexts.contains(context)) { foreach (var icon in icon_theme.list_icons(context)) { + IconContext icon_context = IconContext.OTHER; switch(context) { case "Apps": case "Applications": @@ -423,6 +427,9 @@ public class IconSelectWindow : GLib.Object { default: break; } + Idle.add(load_all.callback); + yield; + try { // create a new entry for the queue var new_entry = new ListEntry(); @@ -447,8 +454,6 @@ public class IconSelectWindow : GLib.Object { // hide the spinner if (spinner != null) spinner.visible = false; - - return null; } } diff --git a/src/gui/newSliceWindow.vala b/src/gui/newSliceWindow.vala index 4e38376..7bd6340 100644 --- a/src/gui/newSliceWindow.vala +++ b/src/gui/newSliceWindow.vala @@ -359,15 +359,16 @@ public class NewSliceWindow : GLib.Object { ///////////////////////////////////////////////////////////////////// private void on_icon_button_clicked(Gtk.Button button) { - if (icon_window == null) { - icon_window = new IconSelectWindow(this.window); - icon_window.on_ok.connect((icon) => { + if (this.icon_window == null) { + this.icon_window = new IconSelectWindow(this.window); + this.icon_window.on_ok.connect((icon) => { this.current_custom_icon = icon; this.set_icon(icon); }); } - icon_window.show(); + this.icon_window.show(); + this.icon_window.set_icon(this.current_icon); } ///////////////////////////////////////////////////////////////////// diff --git a/src/gui/preferencesWindow.vala b/src/gui/preferencesWindow.vala index 022e44b..933919b 100644 --- a/src/gui/preferencesWindow.vala +++ b/src/gui/preferencesWindow.vala @@ -129,6 +129,11 @@ public class PreferencesWindow : GLib.Object { // save settings on close Config.global.save(); Pies.save(); + + Timeout.add(100, () => { + IconSelectWindow.clear_icons(); + return false; + }); }); this.window.delete_event.connect(this.window.hide_on_delete); @@ -181,9 +186,7 @@ public class PreferencesWindow : GLib.Object { if (pie.icon.contains("/")) try { this.icon.pixbuf = new Gdk.Pixbuf.from_file_at_scale(pie.icon, - this.icon.get_pixel_size(), - this.icon.get_pixel_size(), - true); + this.icon.get_pixel_size(), this.icon.get_pixel_size(), true); } catch (GLib.Error error) { warning(error.message); } @@ -305,6 +308,7 @@ public class PreferencesWindow : GLib.Object { } this.icon_window.show(); + this.icon_window.set_icon(PieManager.all_pies[selected_id].icon); } } diff --git a/src/images/renderedText.vala b/src/images/renderedText.vala index e4bb4cb..41146d6 100644 --- a/src/images/renderedText.vala +++ b/src/images/renderedText.vala @@ -22,34 +22,6 @@ namespace GnomePie { ///////////////////////////////////////////////////////////////////////// public class RenderedText : Image { - - ///////////////////////////////////////////////////////////////////// - /// A cache which stores images. It is cleared when the theme of - /// Gnome-Pie changes. - /// The key is in form @x:. - ///////////////////////////////////////////////////////////////////// - - private static Gee.HashMap cache { private get; private set; } - - ///////////////////////////////////////////////////////////////////// - /// Initializes the cache. - ///////////////////////////////////////////////////////////////////// - - public static void init() { - clear_cache(); - - Config.global.notify["theme"].connect(() => { - clear_cache(); - }); - } - - ///////////////////////////////////////////////////////////////////// - /// Clears the cache. - ///////////////////////////////////////////////////////////////////// - - static void clear_cache() { - cache = new Gee.HashMap(); - } ///////////////////////////////////////////////////////////////////// /// C'tor, creates a new image representation of a string. @@ -58,16 +30,7 @@ public class RenderedText : Image { public RenderedText(string text, int width, int height, string font, Color color, double scale) { - var cached = this.cache.get("%s@%ux%u@%f:%s:%f:%f:%f:%f".printf(text, width, height, scale, font, - color.r, color.g, color.b, color.a)); - - if (cached == null) { - this.render_text(text, width, height, font, color, scale); - this.cache.set("%s@%ux%u@%f:%s:%f:%f:%f:%f".printf(text, width, height, scale, font, - color.r, color.g, color.b, color.a), this.surface); - } else { - this.surface = cached; - } + this.render_text(text, width, height, font, color, scale); } ///////////////////////////////////////////////////////////////////// @@ -77,17 +40,8 @@ public class RenderedText : Image { public RenderedText.with_markup(string text, int width, int height, string font, Color color, double scale) { - - var cached = this.cache.get("%s@%ux%u@%f:%s:%f:%f:%f:%f".printf(text, width, height, scale, font, - color.r, color.g, color.b, color.a)); - - if (cached == null) { - this.render_markup(text, width, height, font, color, scale); - this.cache.set("%s@%ux%u@%f:%s:%f:%f:%f:%f".printf(text, width, height, scale, font, - color.r, color.g, color.b, color.a), this.surface); - } else { - this.surface = cached; - } + + this.render_markup(text, width, height, font, color, scale); } ///////////////////////////////////////////////////////////////////// diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala index 0263d23..162a61f 100644 --- a/src/pies/pieManager.vala +++ b/src/pies/pieManager.vala @@ -88,6 +88,10 @@ public class PieManager : GLib.Object { window.on_closed.connect(() => { opened_windows.remove(window); + if (opened_windows.size == 0) { + ThemedIcon.clear_cache(); + Icon.clear_cache(); + } }); window.on_closing.connect(() => { -- cgit v1.2.3