summaryrefslogtreecommitdiff
diff options
-rw-r--r--.bzrignore1
-rw-r--r--targets/mutter/plugin.vala6
-rw-r--r--tests/unit/test-place.vala50
-rw-r--r--tests/unit/test-places-place.vala8
-rw-r--r--unity-private/Makefile.am1
-rw-r--r--unity-private/panel/panel-home-button.vala15
-rw-r--r--unity-private/places/places-default-renderer-group.vala142
-rw-r--r--unity-private/places/places-place-bar.vala41
-rw-r--r--unity-private/places/places-place-entry.vala84
-rw-r--r--unity-private/places/places-place-home.vala178
-rw-r--r--unity-private/places/places-place-search-bar.vala16
-rw-r--r--unity-private/places/places-place.vala22
-rw-r--r--unity-private/places/places-view.vala30
-rw-r--r--unity-private/testing/test-window.vala27
-rw-r--r--unity/unity-expanding-bin.vala10
15 files changed, 537 insertions, 94 deletions
diff --git a/.bzrignore b/.bzrignore
index 7e0bf92c5..04650a798 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -322,3 +322,4 @@ tests/unit/test-io.c
unity/unity-appinfo-manager.c
unity/unity-io.c
unity/unity-expanding-bin.c
+unity-private/places/places-place-home.c
diff --git a/targets/mutter/plugin.vala b/targets/mutter/plugin.vala
index ea6b38935..3a5261278 100644
--- a/targets/mutter/plugin.vala
+++ b/targets/mutter/plugin.vala
@@ -331,7 +331,7 @@ namespace Unity
fullscreen_obstruction = false;
}
}
-
+
public uint32 get_current_time ()
{
return Mutter.MetaDisplay.get_current_time (Mutter.MetaScreen.get_display (plugin.get_screen ()));
@@ -615,6 +615,8 @@ namespace Unity
while (Gtk.events_pending ())
Gtk.main_iteration ();
+
+ places.hidden ();
}
public void show_unity ()
@@ -651,6 +653,8 @@ namespace Unity
plugin.get_normal_window_group ().animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, "opacity", 0);
places.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100,
"opacity", 255);
+
+ places.shown ();
}
}
diff --git a/tests/unit/test-place.vala b/tests/unit/test-place.vala
index 3e628ec46..1cfb62747 100644
--- a/tests/unit/test-place.vala
+++ b/tests/unit/test-place.vala
@@ -46,92 +46,92 @@ namespace Unity.Tests.Unit
assert (ctl.num_entries() == 0);
assert (ctl.get_entry ("no such entry") == null);
}
-
+
internal static void test_one_entry()
{
var entry_path = "/org/ayatana/unity/testplace/testentry1";
var entry = new EntryInfo(entry_path);
assert (entry is EntryInfo);
assert (entry.dbus_path == entry_path);
-
+
var ctl = new Controller("/org/ayatana/unity/testplace");
assert (ctl.num_entries() == 0);
-
+
/* Assert that we can add one entry */
ctl.add_entry (entry);
assert (ctl.num_entries() == 1);
assert (ctl.get_entry (entry_path) == entry);
-
- var entry_paths = ctl.get_entry_paths();
+
+ var entry_paths = ctl.get_entry_paths();
assert (entry_paths.length == 1);
assert (entry_paths[0] == entry_path);
-
+
var entries = ctl.get_entries ();
assert (entries.length == 1);
assert (entries[0] == entry);
-
+
/* Assert that we can remove it again */
ctl.remove_entry (entry_path);
assert (ctl.num_entries() == 0);
assert (ctl.get_entry (entry_path) == null);
}
-
+
internal static void test_two_entries()
{
var entry_path1 = "/org/ayatana/unity/testplace/testentry1";
var entry_path2 = "/org/ayatana/unity/testplace/testentry2";
var entry1 = new EntryInfo(entry_path1);
var entry2 = new EntryInfo(entry_path2);
-
+
var ctl = new Controller("/org/ayatana/unity/testplace");
assert (ctl.num_entries() == 0);
-
+
ctl.add_entry (entry1);
assert (ctl.num_entries() == 1);
-
+
ctl.add_entry (entry2);
assert (ctl.num_entries() == 2);
-
+
assert (ctl.get_entry (entry_path1) == entry1);
assert (ctl.get_entry (entry_path2) == entry2);
-
+
var entry_paths = ctl.get_entry_paths();
assert (entry_paths.length == 2);
assert (entry_paths[0] == entry_path1);
assert (entry_paths[1] == entry_path2);
-
+
var entries = ctl.get_entries ();
assert (entries.length == 2);
assert (entries[0] == entry1);
assert (entries[1] == entry2);
-
+
/* Assert we can't add them twice */
-
+
ctl.add_entry (entry1);
assert (ctl.num_entries() == 2);
-
+
ctl.add_entry (entry2);
assert (ctl.num_entries() == 2);
-
+
/* Assert we can remove them */
-
+
ctl.remove_entry (entry_path1);
assert (ctl.num_entries() == 1);
assert (ctl.get_entry (entry_path1) == null);
assert (ctl.get_entry (entry_path2) == entry2);
-
+
ctl.remove_entry (entry_path2);
assert (ctl.num_entries() == 0);
assert (ctl.get_entry (entry_path1) == null);
assert (ctl.get_entry (entry_path2) == null);
-
+
entry_paths = ctl.get_entry_paths();
assert (entry_paths.length == 0);
-
+
entries = ctl.get_entries ();
assert (entries.length == 0);
}
-
+
internal static void test_local_models ()
{
var entry = new EntryInfo("/foo/bar");
@@ -141,7 +141,7 @@ namespace Unity.Tests.Unit
entry.sections_model = sections_model;
assert (entry.sections_model == sections_model);
assert (sections_model.get_n_rows() == 0);
-
+
var renderer = entry.entry_renderer_info;
assert (renderer is RendererInfo);
Dee.Model groups_model = new Dee.SequenceModel(3,
@@ -163,6 +163,6 @@ namespace Unity.Tests.Unit
assert (renderer.results_model == results_model);
assert (results_model.get_n_rows() == 0);
}
-
+
}
}
diff --git a/tests/unit/test-places-place.vala b/tests/unit/test-places-place.vala
index 6c9ce63cc..6ac23935e 100644
--- a/tests/unit/test-places-place.vala
+++ b/tests/unit/test-places-place.vala
@@ -88,9 +88,9 @@ namespace Unity.Tests.Unit
assert (place.n_entries == 3);
/* Test individual entry's properties were loaded correctly */
- PlaceEntry? e;
+ PlaceEntryDbus? e;
- e = place.get_nth_entry (0);
+ e = place.get_nth_entry (0) as PlaceEntryDbus;;
assert (e is PlaceEntry);
assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry1");
assert (e.name == "One");
@@ -99,7 +99,7 @@ namespace Unity.Tests.Unit
assert (e.show_global == true);
assert (e.show_entry == false);
- e = place.get_nth_entry (1);
+ e = place.get_nth_entry (1) as PlaceEntryDbus;
assert (e is PlaceEntry);
assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry2");
assert (e.name == "Two");
@@ -108,7 +108,7 @@ namespace Unity.Tests.Unit
assert (e.show_global == false);
assert (e.show_entry == true);
- e = place.get_nth_entry (2);
+ e = place.get_nth_entry (2) as PlaceEntryDbus;
assert (e is PlaceEntry);
assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry3");
assert (e.name == "Three");
diff --git a/unity-private/Makefile.am b/unity-private/Makefile.am
index 71755f772..c8505099d 100644
--- a/unity-private/Makefile.am
+++ b/unity-private/Makefile.am
@@ -93,6 +93,7 @@ places_sources = \
places/places-place-bar.vala \
places/places-place-entry-view.vala \
places/places-place-entry.vala \
+ places/places-place-home.vala \
places/places-place-model.vala \
places/places-place-view.vala \
places/places-place.vala \
diff --git a/unity-private/panel/panel-home-button.vala b/unity-private/panel/panel-home-button.vala
index 01cff2da2..fe38730f1 100644
--- a/unity-private/panel/panel-home-button.vala
+++ b/unity-private/panel/panel-home-button.vala
@@ -86,9 +86,10 @@ namespace Unity.Panel
add_actor (theme_image);
theme_image.show ();
- button_press_event.connect (on_button_press);
- button_release_event.connect (on_button_release);
+ //button_press_event.connect (on_button_press);
+ //button_release_event.connect (on_button_release);
motion_event.connect (on_motion_event);
+ clicked.connect (on_clicked);
}
/* We always want to be the width of the launcher */
@@ -99,7 +100,7 @@ namespace Unity.Panel
min_width = shell.get_launcher_width_foobar ();
nat_width = shell.get_launcher_width_foobar ();
}
-
+/*
private bool on_button_press (Clutter.Event event)
{
return true;
@@ -107,11 +108,19 @@ namespace Unity.Panel
private bool on_button_release (Clutter.Event event)
{
+ print (@"BUTTON_RELEASE: $(event.button.button)\n");
shell.show_unity ();
MenuManager manager = MenuManager.get_default ();
manager.popdown_current_menu ();
return true;
}
+*/
+ private void on_clicked ()
+ {
+ shell.show_unity ();
+ MenuManager manager = MenuManager.get_default ();
+ manager.popdown_current_menu ();
+ }
private bool on_motion_event (Clutter.Event event)
{
diff --git a/unity-private/places/places-default-renderer-group.vala b/unity-private/places/places-default-renderer-group.vala
index 47a0e6390..7b808d502 100644
--- a/unity-private/places/places-default-renderer-group.vala
+++ b/unity-private/places/places-default-renderer-group.vala
@@ -37,10 +37,14 @@ namespace Unity.Places
private Ctk.Image expander;
private Ctk.IconView renderer;
+ private MoreResultsButton? more_results_button;
+
/* Some caching to speed up lookups */
private uint n_results = 0;
private bool dirty = false;
+ private bool allow_expand = true;
+
public DefaultRendererGroup (uint group_id,
string group_renderer,
string display_name,
@@ -56,9 +60,12 @@ namespace Unity.Places
construct
{
- padding = { 0.0f, 0.0f, PADDING , 0.0f};
+ padding = { 0.0f, 0.0f, PADDING, 0.0f};
hide ();
+ if (group_renderer == "UnityLinkGroupRenderer")
+ allow_expand = false;
+
vbox = new Ctk.VBox (SPACING);
vbox.spacing = SPACING;
vbox.homogeneous = false;
@@ -91,7 +98,7 @@ namespace Unity.Places
rect.show ();
title_box.button_release_event.connect (() => {
- if (n_results <= renderer.get_n_cols ())
+ if (n_results <= renderer.get_n_cols () || allow_expand == false)
return true;
if (bin_state == ExpandingBinState.UNEXPANDED)
@@ -107,7 +114,7 @@ namespace Unity.Places
return true;
});
title_box.motion_event.connect (() => {
- if (dirty)
+ if (dirty && allow_expand)
{
var children = renderer.get_children ();
foreach (Clutter.Actor child in children)
@@ -138,6 +145,37 @@ namespace Unity.Places
results.row_added.connect (on_result_added);
results.row_removed.connect (on_result_removed);
+
+ if (group_renderer == "UnityLinkGroupRenderer")
+ {
+ allow_expand = false;
+
+ more_results_button = new MoreResultsButton ();
+ more_results_button.padding = { PADDING/4,
+ PADDING/2,
+ PADDING/4,
+ PADDING/2 };
+ vbox.pack (more_results_button, false, false);
+ more_results_button.show ();
+
+ more_results_button.clicked.connect (() =>
+ {
+ /* FIXME:!!!
+ * This is not the way we'll end up doing this. This is a stop-gap
+ * until we have better support for signalling things through
+ * a place
+ */
+ PlaceBar place_bar = (Testing.ObjectRegistry.get_default ().lookup ("UnityPlacesPlaceBar"))[0] as PlaceBar;
+ PlaceSearchBar search_bar = (Testing.ObjectRegistry.get_default ().lookup ("UnityPlacesSearchBar"))[0] as PlaceSearchBar;
+
+ if (place_bar is PlaceBar && search_bar is PlaceSearchBar)
+ {
+ string text = search_bar.get_search_text ();
+ place_bar.active_entry_name (display_name);
+ search_bar.search (text);
+ }
+ });
+ }
}
private override void allocate (Clutter.ActorBox box,
@@ -155,7 +193,8 @@ namespace Unity.Places
if (child is Clutter.Actor &&
child.height != unexpanded_height)
{
- unexpanded_height = title_box.height + 1.0f + child.height;
+ var h = more_results_button != null ? more_results_button.height : 0;
+ unexpanded_height = title_box.height + 1.0f + child.height + h;
}
}
@@ -222,13 +261,25 @@ namespace Unity.Places
if (n_results > renderer.get_n_cols ())
{
- expander.animate (Clutter.AnimationMode.EASE_IN_SINE, 200,
- "opacity", 255);
+ if (allow_expand)
+ {
+ expander.animate (Clutter.AnimationMode.EASE_IN_SINE, 200,
+ "opacity", 255);
+ }
+ else if (more_results_button != null)
+ {
+ more_results_button.count = n_results - renderer.get_n_cols ();
+ }
}
else
{
- expander.animate (Clutter.AnimationMode.EASE_IN_SINE, 200,
- "opacity", 0);
+ expander.animate (Clutter.AnimationMode.EASE_OUT_SINE, 200,
+ "opacity", 0);
+
+ if (more_results_button != null)
+ {
+ more_results_button.count = 0;
+ }
}
}
@@ -258,6 +309,74 @@ namespace Unity.Places
}
}
+ public class MoreResultsButton : Ctk.Button
+ {
+ public uint count {
+ get { return _count; }
+ set {
+ _count = value;
+ text.text = _("See %u more results").printf (_count);
+
+ animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
+ "opacity", count == 0 ? 0:255);
+ }
+ }
+
+ private uint _count = 0;
+ private Ctk.Text text;
+
+ public MoreResultsButton ()
+ {
+ Object (orientation:Ctk.Orientation.HORIZONTAL);
+ }
+
+ construct
+ {
+ var bg = new CairoCanvas (paint_bg);
+ set_background (bg);
+
+ text = new Ctk.Text ("");
+ add_actor (text);
+ text.show ();
+ }
+
+ private override void get_preferred_height (float for_width,
+ out float mheight,
+ out float nheight)
+ {
+ if (count == 0)
+ {
+ mheight = 0.0f;
+ nheight = 0.0f;
+ }
+ else
+ {
+ mheight = 28 + padding.top + padding.bottom;
+ nheight = mheight;
+ }
+ }
+
+ private void paint_bg (Cairo.Context cr, int width, int height)
+ {
+ var vpad = padding.top;
+ var hpad = padding.left;
+ float nwidth;
+ text.get_preferred_width (height, null, out nwidth);
+
+ cr.translate (0.5, 0.5);
+ cr.rectangle (0.0,
+ vpad,
+ hpad + nwidth + hpad,
+ height - vpad - vpad);
+ cr.set_source_rgba (1.0, 1.0, 1.0, 0.2);
+ cr.fill_preserve ();
+
+ cr.set_line_width (1.5);
+ cr.set_source_rgba (1.0, 1.0, 1.0, 0.5);
+ cr.stroke ();
+ }
+ }
+
public class Tile : Ctk.Button
{
static const int ICON_SIZE = 48;
@@ -301,8 +420,11 @@ namespace Unity.Places
return;
shown = true;
- set_label (display_name);
- set_icon ();
+ Timeout.add (0, () => {
+ set_label (display_name);
+ set_icon ();
+ return false;
+ });
}
private override void get_preferred_width (float for_height,
diff --git a/unity-private/places/places-place-bar.vala b/unity-private/places/places-place-bar.vala
index 83d5729e7..66c9d1c44 100644
--- a/unity-private/places/places-place-bar.vala
+++ b/unity-private/places/places-place-bar.vala
@@ -29,7 +29,7 @@ namespace Unity.Places
private Ctk.EffectGlow glow;
private PlaceEntryView active_view = null;
- public signal void entry_view_activated (PlaceEntryView view, int x);
+ public signal void entry_view_activated (PlaceEntry view, int x);
public PlaceBar (Shell shell, PlaceModel model)
{
@@ -38,6 +38,9 @@ namespace Unity.Places
orientation:Ctk.Orientation.HORIZONTAL,
homogeneous:false,
spacing:0);
+
+ Testing.ObjectRegistry.get_default ().register ("UnityPlacesPlaceBar",
+ this);
}
construct
@@ -69,6 +72,40 @@ namespace Unity.Places
});
}
+ public void reset ()
+ {
+ if (active_view is PlaceEntryView)
+ {
+ active_view.entry.active = false;
+ active_view = null;
+ }
+ }
+
+ public void active_entry_name (string name)
+ {
+ var children = get_children ();
+ foreach (Clutter.Actor p in children)
+ {
+ PlaceView view = p as PlaceView;
+ var c = view.get_children ();
+
+ bool found = false;
+ foreach (Clutter.Actor e in c)
+ {
+ PlaceEntryView v = e as PlaceEntryView;
+
+ if (v.entry.name == name)
+ {
+ on_entry_activated (view, v);
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+
private override void allocate (Clutter.ActorBox box,
Clutter.AllocationFlags flags)
{
@@ -105,7 +142,7 @@ namespace Unity.Places
glow.set_invalidate_effect_cache (true);
- entry_view_activated (entry_view,
+ entry_view_activated (entry_view.entry,
bg.entry_position + (PlaceEntryView.WIDTH/2));
}
}
diff --git a/unity-private/places/places-place-entry.vala b/unity-private/places/places-place-entry.vala
index 25ff32cbc..1b52676fc 100644
--- a/unity-private/places/places-place-entry.vala
+++ b/unity-private/places/places-place-entry.vala
@@ -19,11 +19,59 @@
namespace Unity.Places
{
+ public interface PlaceEntry : Object
+ {
+ public abstract string name { get; construct set; }
+ public abstract string icon { get; construct set; }
+ public abstract string description { get; construct set; }
+
+ public abstract uint position { get; set; }
+ public abstract string[] mimetypes { get; set; }
+ public abstract bool sensitive { get; set; }
+
+
+ public abstract Gee.HashMap<string, string> hints { get; set; }
+
+ public abstract bool online { get; construct set; }
+ public abstract bool active { get; set; }
+
+ public abstract Dee.Model? sections_model { get; set; }
+
+ /* Entry rendering info */
+ public abstract string entry_renderer_name { get; set; }
+ public abstract Dee.Model? entry_groups_model { get; set; }
+ public abstract Dee.Model? entry_results_model { get; set; }
+ public abstract Gee.HashMap<string, string>? entry_renderer_hints { get; set; }
+
+ /* Global rendering info */
+ public abstract string global_renderer_name { get; set; }
+
+ public abstract Dee.Model? global_groups_model { set; get; }
+ public abstract Dee.Model? global_results_model { set; get; }
+ public abstract Gee.HashMap<string, string>? global_renderer_hints { get; set; }
+
+ /* Signals */
+ public signal void updated ();
+ public signal void renderer_info_changed ();
+
+ /* Methods */
+
+ public abstract new void connect ();
+
+ public abstract void set_search (string search, HashTable<string, string> hints);
+
+ public abstract void set_active_section (uint section_id);
+
+ public abstract void set_global_search (string search,
+ HashTable<string, string> hints);
+ }
+
+
/**
* Represents a PlaceEntry through a .place file ("offline") and then through
* DBus ("online").
**/
- public class PlaceEntry : Object
+ public class PlaceEntryDbus : Object, PlaceEntry
{
/* FIXME: Use what's in libunity. We only need this so vala allows us to
* connect to the signal
@@ -103,7 +151,7 @@ namespace Unity.Places
}
/* Entry rendering info */
- public string entry_renderer_name;
+ public string entry_renderer_name { get; set; }
public string entry_groups_model_name;
private Dee.Model? _entry_groups_model;
@@ -143,10 +191,10 @@ namespace Unity.Places
}
}
- public Gee.HashMap<string, string>? entry_renderer_hints;
+ public Gee.HashMap<string, string>? entry_renderer_hints { get; set; }
/* Global rendering info */
- public string global_renderer_name;
+ public string global_renderer_name { get; set; }
public string global_groups_model_name;
private Dee.Model? _global_groups_model;
@@ -167,7 +215,7 @@ namespace Unity.Places
}
}
- public string global_results_model_name;
+ public string global_results_model_name { get; set; }
private Dee.Model? _global_results_model;
public Dee.Model? global_results_model {
get {
@@ -186,7 +234,7 @@ namespace Unity.Places
}
}
- public Gee.HashMap<string, string>? global_renderer_hints;
+ public Gee.HashMap<string, string>? global_renderer_hints { get; set; }
/* Our connection to the place-entry over dbus */
private DBus.Connection? connection;
@@ -195,24 +243,21 @@ namespace Unity.Places
/*
* Signals
*/
- public signal void updated ();
- public signal void renderer_info_changed ();
-
/*
* Constructors
*/
- public PlaceEntry (string dbus_name, string dbus_path)
+ public PlaceEntryDbus (string dbus_name, string dbus_path)
{
Object (dbus_name:dbus_name, dbus_path:dbus_path);
}
- public PlaceEntry.with_info (string dbus_name,
- string dbus_path,
- string name,
- string icon,
- string description,
- bool show_global,
- bool show_entry)
+ public PlaceEntryDbus.with_info (string dbus_name,
+ string dbus_path,
+ string name,
+ string icon,
+ string description,
+ bool show_global,
+ bool show_entry)
{
Object (dbus_name:dbus_name,
dbus_path:dbus_path,
@@ -235,7 +280,10 @@ namespace Unity.Places
requires (value_array.n_values == 10)
{
/* Un-marshal the array and update our information */
- name = value_array.get_nth (1).get_string ();
+ var n = value_array.get_nth (1).get_string ();
+ if (n != "")
+ name = n;
+
icon = value_array.get_nth (2).get_string ();
position = value_array.get_nth (3).get_uint ();
diff --git a/unity-private/places/places-place-home.vala b/unity-private/places/places-place-home.vala
new file mode 100644
index 000000000..1c612689d
--- /dev/null
+++ b/unity-private/places/places-place-home.vala
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2010 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
+ *
+ */
+using Unity;
+
+namespace Unity.Places
+{
+ public class PlaceHomeEntry : Object, PlaceEntry
+ {
+ /* Properties */
+ public Shell shell { get; construct; }
+
+ public string name { get; construct set; }
+ public string icon { get; construct set; }
+ public string description { get; construct set; }
+
+ public uint position { get; set; }
+ public string[] mimetypes { get; set; }
+ public bool sensitive { get; set; }
+
+
+ public Gee.HashMap<string, string> hints { get; set; }
+
+ public bool online { get; construct set; }
+ public bool active { get; set; }
+
+ private Dee.Model _sections_model;
+ public Dee.Model? sections_model {
+ get { return _sections_model; }
+ set { _sections_model = value; }
+ }
+
+ /* Entry rendering info */
+ public string entry_renderer_name { get; set; }
+ public Dee.Model? entry_groups_model { get; set; }
+ public Dee.Model? entry_results_model { get; set; }
+ public Gee.HashMap<string, string>? entry_renderer_hints { get; set; }
+
+ /* Global rendering info */
+ public string global_renderer_name { get; set; }
+
+ public Dee.Model? global_groups_model { set; get; }
+ public Dee.Model? global_results_model { set; get; }
+ public Gee.HashMap<string, string>? global_renderer_hints { get; set; }
+
+ public PlaceModel place_model { get; set construct; }
+
+ private Gee.HashMap<PlaceEntry?, uint> entry_group_map;
+
+ public PlaceHomeEntry (Shell shell, PlaceModel model)
+ {
+ Object (shell:shell, place_model:model);
+ }
+
+ construct
+ {
+ entry_group_map = new Gee.HashMap<PlaceEntry?, uint> ();
+
+ _sections_model = new Dee.SequenceModel (2, typeof (string), typeof (string));
+ entry_renderer_name = "UnityHomeScreen";
+
+ entry_groups_model = new Dee.SequenceModel (3,
+ typeof (string),
+ typeof (string),
+ typeof (string));
+
+ place_model.place_added.connect (on_place_added);
+
+
+ entry_results_model = new Dee.SequenceModel (6,
+ typeof (string),
+ typeof (string),
+ typeof (uint),
+ typeof (string),
+ typeof (string),
+ typeof (string));
+ entry_renderer_hints = new Gee.HashMap<string, string> ();
+
+ foreach (Place place in place_model)
+ on_place_added (place);
+ }
+
+ /*
+ * Private
+ */
+ private void on_place_added (Place place)
+ {
+ foreach (PlaceEntry entry in place.get_entries ())
+ {
+ unowned Dee.ModelIter iter;
+ iter = entry_groups_model.append (0, "UnityLinkGroupRenderer",
+ 1, entry.name,
+ 2, entry.icon,
+ -1);
+
+ entry_group_map[entry] = entry_groups_model.get_position (iter);
+
+ entry.global_results_model.row_added.connect ((it) => {
+ var _model = entry.global_results_model;
+
+ entry_results_model.append (0, _model.get_string (it, 0),
+ 1, _model.get_string (it, 1),
+ 2, entry_group_map[entry],
+ 3, _model.get_string (it, 3),
+ 4, _model.get_string (it, 4),
+ 5, _model.get_string (it, 5),
+ -1);
+ });
+
+ entry.global_results_model.row_removed.connect ((it) => {
+ var _model = entry.global_results_model;
+
+ string uri = _model.get_string (it, 0);
+
+ unowned Dee.ModelIter i = entry_results_model.get_first_iter ();
+ while (i != null && !entry_results_model.is_last (i))
+ {
+ if (entry_results_model.get_string (i, 0) == uri)
+ {
+ entry_results_model.remove (i);
+ break;
+ }
+
+ i = _model.next (i);
+ }
+ });
+ }
+ }
+
+ /*
+ * Public Methods
+ */
+ public new void connect ()
+ {
+ online = true;
+ }
+
+ public void set_search (string search, HashTable<string, string> hints)
+ {
+ debug ("Global search %s", search);
+
+ foreach (Gee.Map.Entry<PlaceEntry, uint> e in entry_group_map.entries)
+ {
+ PlaceEntry? entry = e.key;
+
+ if (entry != null)
+ entry.set_global_search (search, hints);
+ }
+ }
+
+ public void set_active_section (uint section_id)
+ {
+
+ }
+
+ public void set_global_search (string search,
+ HashTable<string, string> hints)
+ {
+
+ }
+ }
+}
+
diff --git a/unity-private/places/places-place-search-bar.vala b/unity-private/places/places-place-search-bar.vala
index d84634505..51fc9b78d 100644
--- a/unity-private/places/places-place-search-bar.vala
+++ b/unity-private/places/places-place-search-bar.vala
@@ -37,6 +37,9 @@ namespace Unity.Places
Object (orientation:Ctk.Orientation.HORIZONTAL,
homogeneous:false,
spacing:8);
+
+ Testing.ObjectRegistry.get_default ().register ("UnityPlacesSearchBar",
+ this);
}
construct
@@ -67,6 +70,17 @@ namespace Unity.Places
entry.reset ();
}
+ public void search (string text)
+ {
+ entry.text.text = text;
+ on_search_text_changed (text);
+ }
+
+ public string get_search_text ()
+ {
+ return entry.text.text;
+ }
+
private override void allocate (Clutter.ActorBox box,
Clutter.AllocationFlags flags)
{
@@ -116,6 +130,8 @@ namespace Unity.Places
active_entry = entry;
bg.entry_position = x;
sections.set_active_entry (entry);
+
+ this.entry.text.grab_key_focus ();
}
}
diff --git a/unity-private/places/places-place.vala b/unity-private/places/places-place.vala
index 75efa3fa9..e074bce75 100644
--- a/unity-private/places/places-place.vala
+++ b/unity-private/places/places-place.vala
@@ -135,8 +135,9 @@ namespace Unity.Places
var path = array.get_nth (0).get_string ();
bool existing = false;
- foreach (PlaceEntry entry in entries_array)
+ foreach (PlaceEntry e in entries_array)
{
+ var entry = e as PlaceEntryDbus;
if (entry.dbus_path == path)
{
entry.update_info (array);
@@ -176,7 +177,7 @@ namespace Unity.Places
{
debug ("EntryAdded %s", info.get_nth (0).get_string ());
/* This is a new entry */
- var entry = new PlaceEntry (dbus_name,
+ var entry = new PlaceEntryDbus (dbus_name,
info.get_nth (0).get_string ());
entry.update_info (info);
entries_array.add (entry);
@@ -190,8 +191,9 @@ namespace Unity.Places
debug (@"EntryRemoved: $entry_path");
PlaceEntry? entry = null;
- foreach (PlaceEntry e in entries_array)
+ foreach (PlaceEntry ent in entries_array)
{
+ var e = ent as PlaceEntryDbus;
if (e.dbus_path == entry_path)
{
entry = e;
@@ -262,13 +264,13 @@ namespace Unity.Places
show_entry = true;
}
- return new PlaceEntry.with_info (dbus_name,
- path,
- name,
- icon,
- desc,
- show_global,
- show_entry);
+ return new PlaceEntryDbus.with_info (dbus_name,
+ path,
+ name,
+ icon,
+ desc,
+ show_global,
+ show_entry);
}
}
}
diff --git a/unity-private/places/places-view.vala b/unity-private/places/places-view.vala
index 261472447..3232b859b 100644
--- a/unity-private/places/places-view.vala
+++ b/unity-private/places/places-view.vala
@@ -33,13 +33,15 @@ namespace Unity.Places
set { _model = value; }
}
- private PlaceBar place_bar;
-
- private Ctk.VBox content_box;
+ private PlaceBar place_bar;
+ private Ctk.VBox content_box;
+ private PlaceHomeEntry home_entry;
private PlaceSearchBar search_bar;
private Unity.Place.Renderer renderer;
+ private bool is_showing = false;
+
public View (Shell shell)
{
Object (shell:shell, orientation:Ctk.Orientation.VERTICAL);
@@ -53,12 +55,13 @@ namespace Unity.Places
{
if (_model is PlaceFileModel)
{
- search_bar.reset ();
return;
}
_model = new PlaceFileModel () as PlaceModel;
+ home_entry = new PlaceHomeEntry (shell, _model);
+
place_bar = new PlaceBar (shell, _model);
pack (place_bar, false, true);
place_bar.show ();
@@ -80,10 +83,23 @@ namespace Unity.Places
search_bar.show ();
}
- private void on_entry_view_activated (PlaceEntryView entry_view, int x)
+ public void shown ()
+ {
+ is_showing = true;
+
+ place_bar.reset ();
+ search_bar.reset ();
+
+ on_entry_view_activated (home_entry, 0);
+ }
+
+ public void hidden ()
{
- PlaceEntry entry = entry_view.entry;
+ is_showing = false;
+ }
+ private void on_entry_view_activated (PlaceEntry entry, int x)
+ {
/* Create the correct results view */
if (renderer is Clutter.Actor)
{
@@ -98,7 +114,7 @@ namespace Unity.Places
/* Update the search bar */
search_bar.set_active_entry_view (entry,
- x
+ x == 0 ? 0 : x
- shell.get_launcher_width_foobar ()
- 8);
}
diff --git a/unity-private/testing/test-window.vala b/unity-private/testing/test-window.vala
index 23b1eca84..560a80897 100644
--- a/unity-private/testing/test-window.vala
+++ b/unity-private/testing/test-window.vala
@@ -156,7 +156,7 @@ namespace Unity.Testing
END_FUNCTION ();
}
-
+
public uint32 get_current_time ()
{
return Clutter.get_current_event_time ();
@@ -303,17 +303,22 @@ namespace Unity.Testing
{
if (this.showing_places)
{
+ /* We're already showing, so we hide */
this.showing_places = false;
- this.panel.set_indicator_mode (true);
- this.background.opacity = 160;
- this.places.opacity = 255;
+ this.panel.set_indicator_mode (false);
+ this.background.opacity = 255;
+ this.places.opacity = 0;
+
+ places.hidden ();
}
else
{
this.showing_places = true;
- this.panel.set_indicator_mode (false);
- this.background.opacity = 255;
- this.places.opacity = 0;
+ this.panel.set_indicator_mode (true);
+ this.background.opacity = 160;
+ this.places.opacity = 255;
+
+ places.shown ();
}
this.places.do_queue_redraw ();
@@ -321,12 +326,16 @@ namespace Unity.Testing
public void hide_unity ()
{
- if (showing_places == false)
+ if (showing_places == true)
{
- showing_places = true;
+ showing_places = false;
panel.set_indicator_mode (false);
background.opacity = 255;
places.opacity = 0;
+
+ places.hidden ();
+
+ debug ("Hide unity");
}
}
diff --git a/unity/unity-expanding-bin.vala b/unity/unity-expanding-bin.vala
index 652ad58fd..c02a66990 100644
--- a/unity/unity-expanding-bin.vala
+++ b/unity/unity-expanding-bin.vala
@@ -30,7 +30,7 @@ namespace Unity
public class ExpandingBin : Ctk.Bin
{
- public static const int ANIMATION_TIME = 200;
+ public static const int ANIMATION_TIME = 500;
/*
* Properties
*/
@@ -140,7 +140,7 @@ namespace Unity
switch (_state)
{
case ExpandingBinState.CLOSED:
- var anim = animate (Clutter.AnimationMode.EASE_OUT_SINE, ANIMATION_TIME,
+ var anim = animate (Clutter.AnimationMode.EASE_OUT_QUAD, ANIMATION_TIME,
"size_factor", 1.0f,
"opacity", 0);
_target_height = 0.0f;
@@ -152,8 +152,8 @@ namespace Unity
break;
case ExpandingBinState.UNEXPANDED:
- animate (_old_state == ExpandingBinState.CLOSED ? Clutter.AnimationMode.EASE_IN_SINE
- : Clutter.AnimationMode.EASE_OUT_SINE,
+ animate (_old_state == ExpandingBinState.CLOSED ? Clutter.AnimationMode.EASE_IN_QUAD
+ : Clutter.AnimationMode.EASE_OUT_QUAD,
ANIMATION_TIME,
"size_factor", 1.0f,
"opacity", 255);
@@ -162,7 +162,7 @@ namespace Unity
break;
case ExpandingBinState.EXPANDED:
- animate (Clutter.AnimationMode.EASE_IN_SINE, ANIMATION_TIME,
+ animate (Clutter.AnimationMode.EASE_IN_QUAD, ANIMATION_TIME,
"size_factor", 1.0f,
"opacity", 255);
get_child ().get_preferred_height (width, null, out _expanded_height);