summaryrefslogtreecommitdiff
path: root/src/gui/iconSelectWindow.vala
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-01-24 09:42:26 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-01-24 09:42:26 +0100
commitd1d354100822d77ff25ef9606d91a93062ecf234 (patch)
tree9e4bb8783e452b35c9e4586f1b0c9ab009cf1009 /src/gui/iconSelectWindow.vala
parentb1677fafabacc4fa70296731552e9eb52ebe6f0b (diff)
parent21c8b0c749be00fff27e41e4c2d677dd7d320fa0 (diff)
Merge commit 'upstream/0.4.1'
Diffstat (limited to 'src/gui/iconSelectWindow.vala')
-rw-r--r--src/gui/iconSelectWindow.vala45
1 files changed, 25 insertions, 20 deletions
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<void*>(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;
}
}