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/gui/iconSelectWindow.vala | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'src/gui/iconSelectWindow.vala') 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; } } -- cgit v1.2.3