summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authorNeil Jagdish Patel <neil.patel@canonical.com>2010-09-02 19:52:53 -0400
committerNeil Jagdish Patel <neil.patel@canonical.com>2010-09-02 19:52:53 -0400
commit1de1efd8838e4de9c161e871bfc4d78c351d431f (patch)
tree893e472276fa4cfaaee112e08c85f1aecf545d4c /unity-private
parente25db81d5096d7848bc117e7d44e3c6872ba3bcc (diff)
Make seaching in places a little nicer
(bzr r479.1.5)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/places/places-button.vala1
-rw-r--r--unity-private/places/places-default-renderer-group.vala56
-rw-r--r--unity-private/places/places-default-renderer-tiles.vala133
3 files changed, 146 insertions, 44 deletions
diff --git a/unity-private/places/places-button.vala b/unity-private/places/places-button.vala
index 631f096eb..e58050b5f 100644
--- a/unity-private/places/places-button.vala
+++ b/unity-private/places/places-button.vala
@@ -128,6 +128,7 @@ namespace Unity.Places
cr.close_path (); }
private void paint_bg (Cairo.Context cr, int width, int height)
+ requires (this is Button)
{
var x = 1;
diff --git a/unity-private/places/places-default-renderer-group.vala b/unity-private/places/places-default-renderer-group.vala
index 9c84cc9db..a98fd213d 100644
--- a/unity-private/places/places-default-renderer-group.vala
+++ b/unity-private/places/places-default-renderer-group.vala
@@ -73,6 +73,9 @@ namespace Unity.Places
public signal void activated (string uri, string mimetype);
+ private GLib.List<Tile?> cleanup_tiles = new GLib.List<Tile?> ();
+ private uint cleanup_operation = 0;
+
public DefaultRendererGroup (uint group_id,
string group_renderer,
string display_name,
@@ -266,8 +269,18 @@ namespace Unity.Places
Tile button;
-
- if (group_renderer == "UnityFileInfoRenderer")
+ if (cleanup_tiles.length () > 0)
+ {
+ button = cleanup_tiles.nth_data (0);
+ button.update_details (results.get_string (iter, 0),
+ results.get_string (iter, 1),
+ results.get_string (iter, 3),
+ results.get_string (iter, 4),
+ results.get_string (iter, 5));
+ button.iter = iter;
+ cleanup_tiles.remove (button);
+ }
+ else if (group_renderer == "UnityFileInfoRenderer")
{
button = new FileInfoTile (iter,
results.get_string (iter, 0),
@@ -275,6 +288,11 @@ namespace Unity.Places
results.get_string (iter, 3),
results.get_string (iter, 4),
results.get_string (iter, 5));
+
+ renderer.add_actor (button);
+ button.show ();
+ button.unref (); /* Because Vala sucks and holds references when it shouldn't*/;
+ button.activated.connect ((u, m) => { activated (u, m); });
}
else if (group_renderer == "UnityShowcaseRenderer")
{
@@ -284,6 +302,11 @@ namespace Unity.Places
results.get_string (iter, 3),
results.get_string (iter, 4),
results.get_string (iter, 5));
+ renderer.add_actor (button);
+ button.show ();
+ button.unref (); /* Because Vala sucks and holds references when it shouldn't*/;
+
+ button.activated.connect ((u, m) => { activated (u, m); });
}
else
{
@@ -293,18 +316,18 @@ namespace Unity.Places
results.get_string (iter, 3),
results.get_string (iter, 4),
results.get_string (iter, 5));
+ renderer.add_actor (button);
+ button.show ();
+ button.unref (); /* Because Vala sucks and holds references when it shouldn't*/;
+
+ button.activated.connect ((u, m) => { activated (u, m); });
}
- renderer.add_actor (button);
- button.show ();
- button.unref (); /* Because Vala sucks and holds references when it shouldn't*/;
if (bin_state == ExpandingBinState.EXPANDED || _always_expanded)
{
button.about_to_show ();
}
- button.activated.connect ((u, m) => { activated (u, m); });
-
add_to_n_results (1);
if (bin_state == ExpandingBinState.CLOSED)
@@ -319,6 +342,20 @@ namespace Unity.Places
dirty = true;
}
+ private bool cleanup_operation_callback ()
+ {
+ foreach (Tile? tile in cleanup_tiles)
+ {
+ renderer.remove_actor (tile);
+ }
+
+ cleanup_tiles = null;
+ cleanup_tiles = new GLib.List<Tile?> ();
+
+ cleanup_operation = 0;
+ return false;
+ }
+
private void on_result_removed (Dee.ModelIter iter)
{
if (!interesting (iter))
@@ -331,7 +368,10 @@ namespace Unity.Places
if (tile.iter == iter)
{
- renderer.remove_actor (tile);
+ cleanup_tiles.append (tile);
+ if (cleanup_operation == 0)
+ cleanup_operation = Timeout.add (200, cleanup_operation_callback);
+
add_to_n_results (-1);
break;
}
diff --git a/unity-private/places/places-default-renderer-tiles.vala b/unity-private/places/places-default-renderer-tiles.vala
index df0824a8c..ad5c3ca77 100644
--- a/unity-private/places/places-default-renderer-tiles.vala
+++ b/unity-private/places/places-default-renderer-tiles.vala
@@ -27,17 +27,22 @@ namespace Unity.Places
static const string DEFAULT_ICON = "text-x-preview";
- public unowned Dee.ModelIter iter { get; construct; }
+ public unowned Dee.ModelIter iter { get; construct set; }
- public string display_name { get; construct; }
- public string? icon_hint { get; construct; }
- public string uri { get; construct; }
- public string? mimetype { get; construct; }
- public string? comment { get; construct; }
+ public string display_name { get; construct set; }
+ public string? icon_hint { get; construct set; }
+ public string uri { get; construct set; }
+ public string? mimetype { get; construct set; }
+ public string? comment { get; construct set; }
public signal void activated (string uri, string mimetype);
public abstract void about_to_show ();
+ public abstract void update_details (string uri,
+ string? icon_hint,
+ string? mimetype,
+ string display_name,
+ string? comment);
}
public class FileInfoTile : Tile
@@ -92,6 +97,24 @@ namespace Unity.Places
nwidth = 210.0f;
}
+ public override void update_details (string uri,
+ string? icon_hint,
+ string? mimetype,
+ string display_name,
+ string? comment)
+ {
+ this.display_name = display_name;
+ this.icon_hint = icon_hint;
+ this.uri = uri;
+ this.mimetype = mimetype;
+ this.comment = comment;
+
+ if (shown == false)
+ return;
+
+ update_details_real ();
+ }
+
public override void about_to_show ()
{
if (shown)
@@ -141,38 +164,40 @@ namespace Unity.Places
}
});
- Timeout.add (0, () => {
-
- leaf.text = display_name;
+ Timeout.add (0, update_details_real);
+ queue_relayout ();
+ }
- /* Set the parent directory */
- var file = File.new_for_uri (uri);
- if (file is File)
- {
- var parent = file.get_parent ();
- if (parent is File)
- {
- folder.text = parent.get_basename ();
- folder_button.clicked.connect (() => {
- try {
- activated (parent.get_uri (), "inode/directory");
-
- } catch (Error e) {
- warning (@"Unable to launch parent folder: $(e.message)");
- }
- });
- }
- else
- folder.text = "";
- }
- else
- folder.text = "";
+ private bool update_details_real ()
+ {
+ leaf.text = display_name;
- set_icon ();
- return false;
- });
+ /* Set the parent directory */
+ var file = File.new_for_uri (uri);
+ if (file is File)
+ {
+ var parent = file.get_parent ();
+ if (parent is File)
+ {
+ folder.text = parent.get_basename ();
+ folder_button.clicked.connect (() => {
+ try {
+ activated (parent.get_uri (), "inode/directory");
+
+ } catch (Error e) {
+ warning (@"Unable to launch parent folder: $(e.message)");
+ }
+ });
+ }
+ else
+ folder.text = "";
+ }
+ else
+ folder.text = "";
- queue_relayout ();
+ set_icon ();
+
+ return false;
}
private override void clicked ()
@@ -371,6 +396,25 @@ namespace Unity.Places
});
}
+ public override void update_details (string uri,
+ string? icon_hint,
+ string? mimetype,
+ string display_name,
+ string? comment)
+ {
+ this.display_name = display_name;
+ this.icon_hint = icon_hint;
+ this.uri = uri;
+ this.mimetype = mimetype;
+ this.comment = comment;
+
+ if (shown == false)
+ return;
+
+ set_label (display_name);
+ set_icon ();
+ }
+
private override void get_preferred_width (float for_height,
out float mwidth,
out float nwidth)
@@ -456,7 +500,24 @@ namespace Unity.Places
});
}
- private override void get_preferred_width (float for_height,
+ public override void update_details (string uri,
+ string? icon_hint,
+ string? mimetype,
+ string display_name,
+ string? comment)
+ {
+ this.display_name = display_name;
+ this.icon_hint = icon_hint;
+ this.uri = uri;
+ this.mimetype = mimetype;
+ this.comment = comment;
+
+ if (shown == false)
+ return;
+
+ set_label (display_name);
+ set_icon ();
+ } private override void get_preferred_width (float for_height,
out float mwidth,
out float nwidth)
{