summaryrefslogtreecommitdiff
diff options
authorDidier Roche <didier.roche@canonical.com>2011-03-10 18:16:28 +0100
committerDidier Roche <didier.roche@canonical.com>2011-03-10 18:16:28 +0100
commitd8e9970e825687e16954b25b48e18f2432677957 (patch)
tree5287133ce204613c451cf5d00e0ae29cf4a6214a
parent548500899177ebab1d934c98eb3a1e0bc3758961 (diff)
parentae6f6807927c9c1db882b43477d52fa28a08b75c (diff)
Import upstream version 3.6.4upstream-3.6.4
(bzr r55.4.47)
-rw-r--r--CMakeLists.txt2
-rw-r--r--services/panel-service.c13
-rw-r--r--src/IconTexture.cpp3
-rw-r--r--src/IconTexture.h5
-rw-r--r--src/Launcher.cpp48
-rw-r--r--src/LauncherIcon.cpp16
-rw-r--r--src/PanelHomeButton.cpp42
-rw-r--r--src/PanelHomeButton.h7
-rw-r--r--src/PanelIndicatorObjectEntryView.cpp6
-rw-r--r--src/PanelMenuView.cpp7
-rw-r--r--src/PanelTray.cpp11
-rw-r--r--src/PanelView.cpp8
-rw-r--r--src/Place.h11
-rw-r--r--src/PlaceEntry.h8
-rw-r--r--src/PlaceEntryHome.cpp11
-rw-r--r--src/PlaceEntryHome.h11
-rw-r--r--src/PlaceEntryRemote.cpp27
-rw-r--r--src/PlaceEntryRemote.h8
-rw-r--r--src/PlaceFactoryFile.cpp4
-rw-r--r--src/PlaceLauncherIcon.cpp44
-rw-r--r--src/PlaceLauncherIcon.h3
-rw-r--r--src/PlaceLauncherSection.cpp16
-rw-r--r--src/PlaceRemote.cpp89
-rw-r--r--src/PlaceRemote.h11
-rw-r--r--src/PlacesController.cpp112
-rw-r--r--src/PlacesController.h14
-rw-r--r--src/PlacesGroup.cpp69
-rw-r--r--src/PlacesGroup.h4
-rw-r--r--src/PlacesGroupController.cpp94
-rw-r--r--src/PlacesGroupController.h3
-rw-r--r--src/PlacesHomeView.cpp5
-rw-r--r--src/PlacesResultsController.cpp11
-rw-r--r--src/PlacesResultsController.h2
-rw-r--r--src/PlacesResultsView.cpp19
-rw-r--r--src/PlacesResultsView.h2
-rw-r--r--src/PlacesSearchBar.cpp17
-rw-r--r--src/PlacesSearchBar.h4
-rw-r--r--src/PlacesSettings.cpp18
-rw-r--r--src/PlacesSettings.h20
-rw-r--r--src/PlacesSimpleTile.cpp21
-rw-r--r--src/PlacesSimpleTile.h4
-rw-r--r--src/PlacesTile.cpp15
-rw-r--r--src/PlacesTile.h11
-rw-r--r--src/PlacesView.cpp178
-rw-r--r--src/PlacesView.h14
-rw-r--r--src/QuicklistView.cpp7
-rw-r--r--src/StaticCairoText.cpp6
-rw-r--r--src/StaticCairoText.h1
-rw-r--r--src/TrashLauncherIcon.cpp65
-rw-r--r--src/nux-area-accessible.cpp29
-rw-r--r--src/nux-base-window-accessible.cpp65
-rw-r--r--src/nux-view-accessible.cpp69
-rw-r--r--src/unity-launcher-accessible.cpp3
-rw-r--r--src/unity-launcher-icon-accessible.cpp227
-rw-r--r--src/unityshell.cpp38
-rw-r--r--src/unityshell.h15
-rw-r--r--tests/TestPlaces.cpp2
-rw-r--r--unityshell.xml.in29
58 files changed, 1299 insertions, 305 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 443ed4ecd..b754f80d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ subdirs (services tests tools doc)
set (PROJECT_NAME "unity")
set (UNITY_MAJOR 3)
set (UNITY_MINOR 6)
-set (UNITY_MICRO 2)
+set (UNITY_MICRO 4)
set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}")
set (UNITY_API_VERSION "3.0")
diff --git a/services/panel-service.c b/services/panel-service.c
index 99ec9a2e0..adf8f54a2 100644
--- a/services/panel-service.c
+++ b/services/panel-service.c
@@ -486,6 +486,19 @@ on_entry_removed (IndicatorObject *object,
IndicatorObjectEntry *entry,
PanelService *self)
{
+ PanelServicePrivate *priv;
+ gchar *id;
+
+ g_return_if_fail (PANEL_IS_SERVICE (self));
+ g_return_if_fail (entry != NULL);
+
+ priv = self->priv;
+
+ id = g_strdup_printf ("%p", entry);
+ g_hash_table_remove (priv->entry2indicator_hash, entry);
+ g_hash_table_remove (priv->id2entry_hash, id);
+ g_free (id);
+
notify_object (object);
}
diff --git a/src/IconTexture.cpp b/src/IconTexture.cpp
index f081ccab2..acefc1c4e 100644
--- a/src/IconTexture.cpp
+++ b/src/IconTexture.cpp
@@ -46,6 +46,7 @@ IconTexture::IconTexture (const char *icon_name, unsigned int size, bool defer_i
LoadIcon ();
_can_pass_focus_to_composite_layout = false;
+ SetCanFocus (false);
}
IconTexture::~IconTexture ()
@@ -187,7 +188,7 @@ IconTexture::GetTextureSize (int *width, int *height)
}
bool
-IconTexture::CanFocus ()
+IconTexture::DoCanFocus ()
{
return false;
}
diff --git a/src/IconTexture.h b/src/IconTexture.h
index 3c4022373..01c12bfa3 100644
--- a/src/IconTexture.h
+++ b/src/IconTexture.h
@@ -42,7 +42,8 @@ public:
protected:
const gchar* GetName ();
void AddProperties (GVariantBuilder *builder);
-
+ virtual bool DoCanFocus ();
+
private:
void Draw (nux::GraphicsEngine& GfxContext, bool force_draw);
@@ -53,8 +54,6 @@ private:
char *_icon_name;
unsigned int _size;
- virtual bool CanFocus ();
-
GdkPixbuf *_pixbuf_cached;
nux::BaseTexture *_texture_cached;
int _texture_width;
diff --git a/src/Launcher.cpp b/src/Launcher.cpp
index dec84f8c5..d32d4a71a 100644
--- a/src/Launcher.cpp
+++ b/src/Launcher.cpp
@@ -1490,12 +1490,14 @@ Launcher::GetMouseY ()
gboolean
Launcher::SingleFingerHoldTimeout (gpointer data)
{
- Launcher* self = (Launcher*) data;
+ Launcher* self = NULL;
+ LauncherIcon* launcher_icon = NULL;
- LauncherIcon* launcher_icon = 0;
+ self = (Launcher*) data;
launcher_icon = self->MouseIconIntersection (self->GetMouseX (),
self->GetMouseY ());
- launcher_icon->OpenQuicklist ();
+ if (launcher_icon)
+ launcher_icon->OpenQuicklist ();
return false;
}
@@ -1533,7 +1535,7 @@ Launcher::EnsureHiddenState ()
bool
Launcher::CheckIntersectWindow (CompWindow *window)
{
- nux::Geometry geo = GetGeometry ();
+ nux::Geometry geo = GetAbsoluteGeometry ();
int intersect_types = CompWindowTypeNormalMask | CompWindowTypeDialogMask |
CompWindowTypeModalDialogMask | CompWindowTypeUtilMask;
@@ -1877,6 +1879,7 @@ void Launcher::SetIconSize(int tile_size, int icon_size)
_icon_size = tile_size;
_icon_image_size = icon_size;
_icon_image_size_delta = tile_size - icon_size;
+ _icon_glow_size = icon_size + 14;
// recreate tile textures
@@ -3539,22 +3542,42 @@ Launcher::ProcessDndMove (int x, int y, std::list<char *> mimes)
EventLogic ();
LauncherIcon* hovered_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
+
+ bool hovered_icon_is_appropriate = false;
+ if(hovered_icon)
+ {
+ if(hovered_icon->Type () == LauncherIcon::TYPE_TRASH)
+ _steal_drag = false;
+
+ if(hovered_icon->Type () == LauncherIcon::TYPE_APPLICATION || hovered_icon->Type () == LauncherIcon::TYPE_EXPO)
+ hovered_icon_is_appropriate = true;
+ }
if (_steal_drag)
{
_drag_action = nux::DNDACTION_COPY;
- if (!_dnd_hovered_icon)
+ if (!_dnd_hovered_icon && hovered_icon_is_appropriate)
{
_dnd_hovered_icon = new SpacerLauncherIcon (this);
_dnd_hovered_icon->SetSortPriority (G_MAXINT);
_model->AddIcon (_dnd_hovered_icon);
-
- if (hovered_icon)
- _model->ReorderBefore (_dnd_hovered_icon, hovered_icon, true);
+ _model->ReorderBefore (_dnd_hovered_icon, hovered_icon, true);
}
- else if (hovered_icon)
+ else if(_dnd_hovered_icon)
{
- _model->ReorderSmart (_dnd_hovered_icon, hovered_icon, true);
+ if(hovered_icon)
+ {
+ if(hovered_icon_is_appropriate)
+ {
+ _model->ReorderSmart (_dnd_hovered_icon, hovered_icon, true);
+ }
+ else
+ {
+ _dnd_hovered_icon->SetQuirk (LauncherIcon::QUIRK_VISIBLE, false);
+ _dnd_hovered_icon->remove.emit (_dnd_hovered_icon);
+ _dnd_hovered_icon = 0;
+ }
+ }
}
}
else
@@ -3650,5 +3673,8 @@ Launcher::GetSelectedMenuIcon ()
it = _model->at (_current_icon_index);
- return *it;
+ if (it != (LauncherModel::iterator)NULL)
+ return *it;
+ else
+ return NULL;
}
diff --git a/src/LauncherIcon.cpp b/src/LauncherIcon.cpp
index e90e99379..d5e2dfbbf 100644
--- a/src/LauncherIcon.cpp
+++ b/src/LauncherIcon.cpp
@@ -361,8 +361,9 @@ LauncherIcon::RecvMouseEnter ()
return;
}
- int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
- int tip_y = _center.y + _launcher->GetParent ()->GetGeometry ().y;
+ nux::Geometry geo = _launcher->GetAbsoluteGeometry ();
+ int tip_x = geo.x + geo.width + 1;
+ int tip_y = geo.y + _center.y;
_tooltip->ShowTooltipWithTipAt (tip_x, tip_y);
@@ -419,10 +420,10 @@ void LauncherIcon::OpenQuicklist (bool default_to_first_item)
if (default_to_first_item)
_quicklist->DefaultToFirstItem ();
- int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
- int tip_y = _center.y + _launcher->GetParent ()->GetGeometry ().y;
+ nux::Geometry geo = _launcher->GetAbsoluteGeometry ();
+ int tip_x = geo.x + geo.width + 1;
+ int tip_y = geo.y + _center.y;
QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
- //nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist);
}
void LauncherIcon::RecvMouseDown (int button)
@@ -465,8 +466,9 @@ LauncherIcon::SetCenter (nux::Point3 center)
{
_center = center;
- int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w;
- int tip_y = _center.y + _launcher->GetParent ()->GetGeometry ().y;
+ nux::Geometry geo = _launcher->GetAbsoluteGeometry ();
+ int tip_x = geo.x + geo.width + 1;
+ int tip_y = geo.y + _center.y;
if (_quicklist->IsVisible ())
QuicklistManager::Default ()->ShowQuicklist (_quicklist, tip_x, tip_y);
diff --git a/src/PanelHomeButton.cpp b/src/PanelHomeButton.cpp
index 2a9d27d09..2eaa3bf13 100644
--- a/src/PanelHomeButton.cpp
+++ b/src/PanelHomeButton.cpp
@@ -35,15 +35,14 @@
#include "PanelStyle.h"
#define PANEL_HEIGHT 24
-#define BUTTON_WIDTH 66
NUX_IMPLEMENT_OBJECT_TYPE (PanelHomeButton);
PanelHomeButton::PanelHomeButton ()
-: TextureArea (NUX_TRACKER_LOCATION),
- _util_cg (CAIRO_FORMAT_ARGB32, BUTTON_WIDTH, PANEL_HEIGHT)
+: TextureArea (NUX_TRACKER_LOCATION)
{
- SetMinMaxSize (BUTTON_WIDTH, PANEL_HEIGHT);
+ _button_width = 66;
+ SetMinMaxSize (_button_width, PANEL_HEIGHT);
OnMouseClick.connect (sigc::mem_fun (this, &PanelHomeButton::RecvMouseClick));
@@ -52,7 +51,9 @@ PanelHomeButton::PanelHomeButton ()
OnMouseLeave.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseLeave));
OnMouseMove.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseMove));
- PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &PanelHomeButton::Refresh));
+ g_signal_connect (gtk_icon_theme_get_default (), "changed",
+ G_CALLBACK (PanelHomeButton::OnIconThemeChanged), this);
+
Refresh ();
}
@@ -77,17 +78,19 @@ PanelHomeButton::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
void
PanelHomeButton::Refresh ()
{
- int width = BUTTON_WIDTH;
+ int width = _button_width;
int height = PANEL_HEIGHT;
GdkPixbuf *pixbuf;
+ SetMinMaxSize (_button_width, PANEL_HEIGHT);
+
nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_graphics.GetContext();
cairo_set_line_width (cr, 1);
pixbuf = PanelStyle::GetDefault ()->GetHomeButton ();
gdk_cairo_set_source_pixbuf (cr, pixbuf,
- (BUTTON_WIDTH-gdk_pixbuf_get_width (pixbuf))/2,
+ (_button_width-gdk_pixbuf_get_width (pixbuf))/2,
(PANEL_HEIGHT-gdk_pixbuf_get_height (pixbuf))/2);
g_object_unref (pixbuf);
@@ -158,7 +161,7 @@ PanelHomeButton::RecvMouseEnter (int x, int y, unsigned long button_flags, unsig
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(iiiia{sv})"));
g_variant_builder_add (&builder, "i", x);
g_variant_builder_add (&builder, "i", y);
- g_variant_builder_add (&builder, "i", BUTTON_WIDTH);
+ g_variant_builder_add (&builder, "i", _button_width);
g_variant_builder_add (&builder, "i", PANEL_HEIGHT);
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -178,7 +181,7 @@ PanelHomeButton::RecvMouseLeave (int x, int y, unsigned long button_flags, unsig
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(iiiia{sv})"));
g_variant_builder_add (&builder, "i", x);
g_variant_builder_add (&builder, "i", y);
- g_variant_builder_add (&builder, "i", BUTTON_WIDTH);
+ g_variant_builder_add (&builder, "i", _button_width);
g_variant_builder_add (&builder, "i", PANEL_HEIGHT);
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -198,7 +201,7 @@ PanelHomeButton::RecvMouseMove(int x, int y, int dx, int dy, unsigned long butto
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(iiiia{sv})"));
g_variant_builder_add (&builder, "i", x);
g_variant_builder_add (&builder, "i", y);
- g_variant_builder_add (&builder, "i", BUTTON_WIDTH);
+ g_variant_builder_add (&builder, "i", _button_width);
g_variant_builder_add (&builder, "i", PANEL_HEIGHT);
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -209,6 +212,17 @@ PanelHomeButton::RecvMouseMove(int x, int y, int dx, int dy, unsigned long butto
ubus_server_send_message (ubus, UBUS_HOME_BUTTON_TRIGGER_UPDATE, g_variant_builder_end (&builder));
}
+void
+PanelHomeButton::SetButtonWidth (int button_width)
+{
+ if (_button_width == button_width)
+ return;
+
+ _button_width = button_width;
+
+ Refresh();
+}
+
const gchar*
PanelHomeButton::GetName ()
{
@@ -225,3 +239,11 @@ PanelHomeButton::AddProperties (GVariantBuilder *builder)
g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
}
+
+void
+PanelHomeButton::OnIconThemeChanged (GtkIconTheme *icon_theme, gpointer data)
+{
+ PanelHomeButton* self = (PanelHomeButton*) data;
+
+ self->Refresh ();
+}
diff --git a/src/PanelHomeButton.h b/src/PanelHomeButton.h
index aaacc112c..17dd1d237 100644
--- a/src/PanelHomeButton.h
+++ b/src/PanelHomeButton.h
@@ -20,6 +20,8 @@
#ifndef PANEL_HOME_BUTTON_H
#define PANEL_HOME_BUTTON_H
+#include <gtk/gtk.h>
+
#include <Nux/TextureArea.h>
#include <Nux/View.h>
#include <NuxImage/CairoGraphics.h>
@@ -41,15 +43,18 @@ public:
void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
+ void SetButtonWidth (int button_width);
+
protected:
const gchar* GetName ();
void AddProperties (GVariantBuilder *builder);
private:
void Refresh ();
+ static void OnIconThemeChanged (GtkIconTheme *icon_theme, gpointer data);
private:
- nux::CairoGraphics _util_cg;
+ int _button_width;
};
#endif // PANEL_HOME_BUTTON_H
diff --git a/src/PanelIndicatorObjectEntryView.cpp b/src/PanelIndicatorObjectEntryView.cpp
index c45919227..080291ab5 100644
--- a/src/PanelIndicatorObjectEntryView.cpp
+++ b/src/PanelIndicatorObjectEntryView.cpp
@@ -72,7 +72,7 @@ PanelIndicatorObjectEntryView::OnMouseDown (int x, int y, long button_flags, lon
if ((_proxy->label_visible && _proxy->label_sensitive)
|| (_proxy->icon_visible && _proxy->icon_sensitive))
{
- _proxy->ShowMenu (GetGeometry ().x + 1, //cairo translation
+ _proxy->ShowMenu (GetAbsoluteGeometry ().x + 1, //cairo translation
PANEL_HEIGHT,
time (NULL),
nux::GetEventButton (button_flags));
@@ -88,7 +88,7 @@ PanelIndicatorObjectEntryView::OnMouseWheel (int x, int y, int delta, unsigned l
void
PanelIndicatorObjectEntryView::Activate ()
{
- _proxy->ShowMenu (GetGeometry ().x + 1, //cairo translation FIXME: Make this into one function
+ _proxy->ShowMenu (GetAbsoluteGeometry().x + 1, //cairo translation FIXME: Make this into one function
PANEL_HEIGHT,
time (NULL),
1);
@@ -239,7 +239,7 @@ PanelIndicatorObjectEntryView::Refresh ()
textcol.GetRed (),
textcol.GetGreen (),
textcol.GetBlue (),
- _proxy->label_sensitive ? 1.0f : 0.0f);
+ _proxy->label_sensitive ? 1.0f : 0.5f);
cairo_move_to (cr, x, (int)((height - text_height)/2));
pango_cairo_show_layout (cr, layout);
cairo_stroke (cr);
diff --git a/src/PanelMenuView.cpp b/src/PanelMenuView.cpp
index 85f7c469e..34f0cc22c 100644
--- a/src/PanelMenuView.cpp
+++ b/src/PanelMenuView.cpp
@@ -70,6 +70,7 @@ PanelMenuView::PanelMenuView (int padding)
G_CALLBACK (on_active_window_changed), this);
_menu_layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
+ _menu_layout->SetParentObject (this);
/* This is for our parent and for PanelView to read indicator entries, we
* shouldn't touch this again
@@ -142,7 +143,7 @@ long
PanelMenuView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
{
long ret = TraverseInfo;
- nux::Geometry geo = GetGeometry ();
+ nux::Geometry geo = GetAbsoluteGeometry ();
if (geo.IsPointInside (ievent.e_x, ievent.e_y))
{
@@ -170,7 +171,8 @@ PanelMenuView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long Proces
ret = _panel_titlebar_grab_area->OnEvent (ievent, ret, ProcessEventInfo);
}
- ret = _menu_layout->ProcessEvent (ievent, ret, ProcessEventInfo);
+ if (!_is_own_window)
+ ret = _menu_layout->ProcessEvent (ievent, ret, ProcessEventInfo);
return ret;
}
@@ -188,7 +190,6 @@ long PanelMenuView::PostLayoutManagement (long LayoutResult)
_window_buttons->ComputeLayout2 ();
new_window_buttons_w = _window_buttons->GetContentWidth ();
-
/* Explicitly set the size and position of the widgets */
geo.x += _padding + new_window_buttons_w + _padding;
geo.width -= _padding + new_window_buttons_w + _padding;
diff --git a/src/PanelTray.cpp b/src/PanelTray.cpp
index 0693cc42a..22d4f74b7 100644
--- a/src/PanelTray.cpp
+++ b/src/PanelTray.cpp
@@ -29,9 +29,10 @@ PanelTray::PanelTray ()
_settings = g_settings_new (SETTINGS_NAME);
_whitelist = g_settings_get_strv (_settings, "systray-whitelist");
- _window = gtk_window_new (GTK_WINDOW_POPUP);
+ _window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_type_hint (GTK_WINDOW (_window), GDK_WINDOW_TYPE_HINT_DOCK);
- //gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE);
+ gtk_window_set_has_resize_grip (GTK_WINDOW (_window), FALSE);
+ gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE);
gtk_window_set_skip_pager_hint (GTK_WINDOW (_window), TRUE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (_window), TRUE);
gtk_window_resize (GTK_WINDOW (_window), 1, 24);
@@ -138,7 +139,11 @@ PanelTray::FilterTrayCallback (NaTray *tray, NaTrayChild *icon, PanelTray *self)
g_idle_add ((GSourceFunc)IdleSync, self);
}
- g_debug ("TrayChild %s: %s %s", na_tray_child_get_title (icon), res_name, res_class);
+ g_debug ("TrayChild %s: %s %s %s",
+ accept ? "Accepted" : "Rejected",
+ na_tray_child_get_title (icon),
+ res_name,
+ res_class);
g_free (res_name);
g_free (res_class);
diff --git a/src/PanelView.cpp b/src/PanelView.cpp
index feac1d762..ca292c1ef 100644
--- a/src/PanelView.cpp
+++ b/src/PanelView.cpp
@@ -252,8 +252,8 @@ PanelView::OnObjectAdded (IndicatorObjectProxy *proxy)
void
PanelView::OnMenuPointerMoved (int x, int y)
{
- nux::Geometry geo = GetGeometry ();
- nux::Geometry hgeo = _home_button->GetGeometry ();
+ nux::Geometry geo = GetAbsoluteGeometry ();
+ nux::Geometry hgeo = _home_button->GetAbsoluteGeometry ();
if (x <= (hgeo.x + hgeo.width))
return;
@@ -271,7 +271,7 @@ PanelView::OnMenuPointerMoved (int x, int y)
if (view->_layout == NULL)
continue;
- geo = view->GetGeometry ();
+ geo = view->GetAbsoluteGeometry ();
if (x >= geo.x && x <= (geo.x + geo.width)
&& y >= geo.y && y <= (geo.y + geo.height))
{
@@ -282,7 +282,7 @@ PanelView::OnMenuPointerMoved (int x, int y)
{
PanelIndicatorObjectEntryView *entry = static_cast<PanelIndicatorObjectEntryView *> (*it2);
- geo = entry->GetGeometry ();
+ geo = entry->GetAbsoluteGeometry ();
if (x >= geo.x && x <= (geo.x + geo.width)
&& y >= geo.y && y <= (geo.y + geo.height))
{
diff --git a/src/Place.h b/src/Place.h
index b0df3dc74..5e5eba2db 100644
--- a/src/Place.h
+++ b/src/Place.h
@@ -23,9 +23,17 @@
#include <vector>
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
+#include <glib.h>
#include "PlaceEntry.h"
+enum ActivationResult
+{
+ FALLBACK = 0,
+ SHOW_DASH,
+ HIDE_DASH
+};
+
class Place : public sigc::trackable
{
public:
@@ -34,9 +42,12 @@ public:
virtual std::vector<PlaceEntry *>& GetEntries () = 0;
virtual guint32 GetNEntries () = 0;
+ virtual void ActivateResult (const char *uri, const char *mimetype) = 0;
+
// Signals
sigc::signal<void, PlaceEntry *> entry_added;
sigc::signal<void, PlaceEntry *> entry_removed;
+ sigc::signal<void, const char *, ActivationResult> result_activated;
protected:
std::vector<PlaceEntry *> _entries;
diff --git a/src/PlaceEntry.h b/src/PlaceEntry.h
index 886651c5f..9e9b8d9ac 100644
--- a/src/PlaceEntry.h
+++ b/src/PlaceEntry.h
@@ -15,6 +15,7 @@
*
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
*/
+
#ifndef PLACE_ENTRY_H
#define PLACE_ENTRY_H
@@ -26,6 +27,8 @@
#include <glib.h>
+class Place;
+
class PlaceEntrySection
{
public:
@@ -74,6 +77,8 @@ public:
typedef sigc::slot<void, PlaceEntry *, PlaceEntryGroup&> GroupForeachCallback;
typedef sigc::slot<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> ResultForeachCallback;
+ virtual Place * GetParent () = 0;
+
virtual const char * GetId () = 0;
virtual const char * GetName () = 0;
virtual const char * GetIcon () = 0;
@@ -119,6 +124,9 @@ public:
virtual void GetResult (const void *id, ResultForeachCallback slot) = 0;
virtual void GetGlobalResult (const void *id, ResultForeachCallback slot) = 0;
+ virtual void ActivateResult (const void *id) = 0;
+ virtual void ActivateGlobalResult (const void *id) = 0;
+
// Signals
sigc::signal<void, bool> active_changed;
diff --git a/src/PlaceEntryHome.cpp b/src/PlaceEntryHome.cpp
index e61dadb90..e84026010 100644
--- a/src/PlaceEntryHome.cpp
+++ b/src/PlaceEntryHome.cpp
@@ -281,3 +281,14 @@ PlaceEntryHome::GetResult (const void *id, ResultForeachCallback slot)
entry->GetGlobalResult (id, sigc::mem_fun (this, &PlaceEntryHome::OnForeachResult));
}
}
+
+void
+PlaceEntryHome::ActivateResult (const void *id)
+{
+ PlaceEntry *entry = _id_to_entry[id];
+
+ if (entry)
+ {
+ entry->ActivateGlobalResult (id);
+ }
+}
diff --git a/src/PlaceEntryHome.h b/src/PlaceEntryHome.h
index 0334f37a9..b7b713907 100644
--- a/src/PlaceEntryHome.h
+++ b/src/PlaceEntryHome.h
@@ -37,6 +37,8 @@ public:
~PlaceEntryHome ();
/* Overrides */
+ Place * GetParent () { return NULL; }
+
const gchar * GetId ();
const gchar * GetName ();
const gchar * GetIcon ();
@@ -58,17 +60,20 @@ public:
void SetActiveSection (guint32 section_id);
void SetGlobalSearch (const gchar *search, std::map<gchar*, gchar*>& hints);
- void ForeachSection (SectionForeachCallback slot) { };
+ void ForeachSection (SectionForeachCallback slot) {};
void ForeachGroup (GroupForeachCallback slot);
void ForeachResult (ResultForeachCallback slot);
- void ForeachGlobalGroup (GroupForeachCallback slot) { };
- void ForeachGlobalResult (ResultForeachCallback slot) { };
+ void ForeachGlobalGroup (GroupForeachCallback slot) {};
+ void ForeachGlobalResult (ResultForeachCallback slot) {};
void GetResult (const void *id, ResultForeachCallback slot);
void GetGlobalResult (const void *id, ResultForeachCallback slot) {};
+ void ActivateResult (const void *id);
+ void ActivateGlobalResult (const void *id) {};
+
private:
void LoadExistingEntries ();
void OnPlaceAdded (Place *place);
diff --git a/src/PlaceEntryRemote.cpp b/src/PlaceEntryRemote.cpp
index e986f0729..0d7b3e063 100644
--- a/src/PlaceEntryRemote.cpp
+++ b/src/PlaceEntryRemote.cpp
@@ -180,8 +180,9 @@ private:
};
-PlaceEntryRemote::PlaceEntryRemote (const gchar *dbus_name)
+PlaceEntryRemote::PlaceEntryRemote (Place *parent, const gchar *dbus_name)
: dirty (false),
+ _parent (parent),
_dbus_path (NULL),
_name (NULL),
_icon (NULL),
@@ -303,6 +304,12 @@ PlaceEntryRemote::InitFromKeyFile (GKeyFile *key_file,
}
/* Overrides */
+Place *
+PlaceEntryRemote::GetParent ()
+{
+ return _parent;
+}
+
const gchar *
PlaceEntryRemote::GetId ()
{
@@ -627,6 +634,24 @@ PlaceEntryRemote::GetGlobalResult (const void *id, ResultForeachCallback slot)
slot (this, group, result);
}
+void
+PlaceEntryRemote::ActivateResult (const void *id)
+{
+ DeeModelIter *iter = (DeeModelIter *)id;
+
+ _parent->ActivateResult (dee_model_get_string (_results_model, iter, RESULT_URI),
+ dee_model_get_string (_results_model, iter, RESULT_MIMETYPE));
+}
+
+void
+PlaceEntryRemote::ActivateGlobalResult (const void *id)
+{
+ DeeModelIter *iter = (DeeModelIter *)id;
+
+ _parent->ActivateResult (dee_model_get_string (_global_results_model, iter, RESULT_URI),
+ dee_model_get_string (_global_results_model, iter, RESULT_MIMETYPE));
+}
+
/* Other methods */
bool
PlaceEntryRemote::IsValid ()
diff --git a/src/PlaceEntryRemote.h b/src/PlaceEntryRemote.h
index 397c2b86b..c20414f6e 100644
--- a/src/PlaceEntryRemote.h
+++ b/src/PlaceEntryRemote.h
@@ -35,12 +35,14 @@
class PlaceEntryRemote : public PlaceEntry
{
public:
- PlaceEntryRemote (const gchar *dbus_name);
+ PlaceEntryRemote (Place *parent, const gchar *dbus_name);
~PlaceEntryRemote ();
void InitFromKeyFile (GKeyFile *key_file, const gchar *group);
/* Overrides */
+ Place * GetParent ();
+
const gchar * GetId ();
const gchar * GetName ();
const gchar * GetIcon ();
@@ -73,6 +75,9 @@ public:
void GetResult (const void *id, ResultForeachCallback slot);
void GetGlobalResult (const void *id, ResultForeachCallback slot);
+ void ActivateResult (const void *id);
+ void ActivateGlobalResult (const void *id);
+
/* Other methods */
bool IsValid ();
const gchar * GetPath ();
@@ -110,6 +115,7 @@ public:
bool dirty;
private:
+ Place *_parent;
gchar *_dbus_name;
gchar *_dbus_path;
gchar *_name;
diff --git a/src/PlaceFactoryFile.cpp b/src/PlaceFactoryFile.cpp
index a00a11c85..9c37c584b 100644
--- a/src/PlaceFactoryFile.cpp
+++ b/src/PlaceFactoryFile.cpp
@@ -27,10 +27,6 @@ static void on_directory_enumeration_ready (GObject *source,
PlaceFactoryFile::PlaceFactoryFile (const char *directory)
{
- //FIXME: This is a temporary Alpha 2 fix
- g_spawn_command_line_sync ("killall unity-files-daemon", NULL, NULL, NULL, NULL);
- g_spawn_command_line_sync ("killall unity-applications-daemon", NULL, NULL, NULL, NULL);
-
/* Use the default lookup location */
if (directory == NULL)
_directory = g_build_filename (DATADIR, "unity", "places", NULL);
diff --git a/src/PlaceLauncherIcon.cpp b/src/PlaceLauncherIcon.cpp
index c7851a69b..b6a5a763c 100644
--- a/src/PlaceLauncherIcon.cpp
+++ b/src/PlaceLauncherIcon.cpp
@@ -26,6 +26,8 @@
#include <glib/gi18n-lib.h>
+#define SECTION_NUMBER "ted-loves-strings"
+
PlaceLauncherIcon::PlaceLauncherIcon (Launcher *launcher, PlaceEntry *entry)
: SimpleLauncherIcon(launcher),
_entry (entry)
@@ -87,24 +89,52 @@ PlaceLauncherIcon::UpdatePlaceIcon ()
}
+void
+PlaceLauncherIcon::ForeachSectionCallback (PlaceEntry *entry, PlaceEntrySection& section)
+{
+ DbusmenuMenuitem *menu_item;
+ char *temp;
+
+ temp = g_markup_escape_text (section.GetName (), -1);
+ menu_item = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, section.GetName ());
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ dbusmenu_menuitem_property_set_int (menu_item, SECTION_NUMBER, _current_menu.size ());
+ _current_menu.push_back (menu_item);
+ g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (&PlaceLauncherIcon::OnOpen), this);
+ g_free (temp);
+}
+
std::list<DbusmenuMenuitem *>
PlaceLauncherIcon::GetMenus ()
{
- std::list<DbusmenuMenuitem *> result;
DbusmenuMenuitem *menu_item;
+ char * temp;
+
+ _current_menu.erase (_current_menu.begin (), _current_menu.end ());
+ _entry->ForeachSection (sigc::mem_fun (this, &PlaceLauncherIcon::ForeachSectionCallback));
+
menu_item = dbusmenu_menuitem_new ();
-
- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Open"));
+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ _current_menu.push_back (menu_item);
+ temp = g_markup_escape_text (_entry->GetName (), -1);
+ menu_item = dbusmenu_menuitem_new ();
+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, temp);
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ dbusmenu_menuitem_property_set_int (menu_item, SECTION_NUMBER, 0);
+ _current_menu.push_back (menu_item);
g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK (&PlaceLauncherIcon::OnOpen), this);
+ g_free (temp);
- result.push_back (menu_item);
-
- return result;
+ return _current_menu;
}
void
@@ -121,7 +151,7 @@ PlaceLauncherIcon::ActivatePlace (guint section_id, const char *search_string)
void
PlaceLauncherIcon::OnOpen (DbusmenuMenuitem *item, int time, PlaceLauncherIcon *self)
{
- self->ActivateLauncherIcon ();
+ self->ActivatePlace (dbusmenu_menuitem_property_get_int (item, SECTION_NUMBER), "");
}
void
diff --git a/src/PlaceLauncherIcon.h b/src/PlaceLauncherIcon.h
index 7833b1a6d..4ad3861db 100644
--- a/src/PlaceLauncherIcon.h
+++ b/src/PlaceLauncherIcon.h
@@ -44,10 +44,13 @@ private:
void ActivateLauncherIcon ();
void ActivatePlace (guint section_id, const char *search_string);
void OnActiveChanged (bool is_active);
+ void ForeachSectionCallback (PlaceEntry *entry, PlaceEntrySection& section);
+
static void OnOpen (DbusmenuMenuitem *item, int time, PlaceLauncherIcon *self);
private:
PlaceEntry *_entry;
+ std::list<DbusmenuMenuitem *> _current_menu;
};
#endif // _PLACE_LAUNCHER_ICON_H__H
diff --git a/src/PlaceLauncherSection.cpp b/src/PlaceLauncherSection.cpp
index f4d6aefc2..a0b9f54d5 100644
--- a/src/PlaceLauncherSection.cpp
+++ b/src/PlaceLauncherSection.cpp
@@ -43,9 +43,12 @@ PlaceLauncherSection::OnPlaceAdded (Place *place)
for (i = entries.begin (); i != entries.end (); ++i)
{
PlaceEntry *entry = static_cast<PlaceEntry *> (*i);
- PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry);
-
- IconAdded.emit (icon);
+
+ if (entry->ShowInLauncher ())
+ {
+ PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry);
+ IconAdded.emit (icon);
+ }
}
}
@@ -64,9 +67,12 @@ PlaceLauncherSection::PopulateEntries ()
for (i = entries.begin (); i != entries.end (); ++i)
{
PlaceEntry *entry = static_cast<PlaceEntry *> (*i);
- PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry);
- IconAdded.emit (icon);
+ if (entry->ShowInLauncher ())
+ {
+ PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry);
+ IconAdded.emit (icon);
+ }
}
}
}
diff --git a/src/PlaceRemote.cpp b/src/PlaceRemote.cpp
index 4ac76e713..0902b8a46 100644
--- a/src/PlaceRemote.cpp
+++ b/src/PlaceRemote.cpp
@@ -32,6 +32,7 @@
#define MIME_PATTERN "MimetypePattern"
#define PLACE_IFACE "com.canonical.Unity.Place"
+#define ACTIVE_IFACE "com.canonical.Unity.Activation"
static void on_service_proxy_ready (GObject *source,
GAsyncResult *result,
@@ -60,7 +61,6 @@ PlaceRemote::PlaceRemote (const char *path)
GKeyFile *key_file;
GError *error = NULL;
- g_debug ("Loading Place: %s", path);
_path = g_strdup (path);
// A .place file is a keyfile, so we create on representing the .place file to
@@ -216,6 +216,17 @@ PlaceRemote::Connect ()
NULL,
on_service_proxy_ready,
this);
+
+ if (_uri_regex || _mime_regex)
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL,
+ _dbus_name,
+ _dbus_path,
+ ACTIVE_IFACE,
+ NULL,
+ (GAsyncReadyCallback)PlaceRemote::OnActivationProxyReady,
+ this);
}
std::vector<PlaceEntry *>&
@@ -244,7 +255,7 @@ PlaceRemote::LoadKeyFileEntries (GKeyFile *key_file)
if (g_str_has_prefix (group, ENTRY_PREFIX))
{
- PlaceEntryRemote *entry = new PlaceEntryRemote (_dbus_name);
+ PlaceEntryRemote *entry = new PlaceEntryRemote (this, _dbus_name);
entry->InitFromKeyFile (key_file, group);
if (entry->IsValid ())
@@ -369,7 +380,7 @@ PlaceRemote::OnEntriesReceived (GVariant *args)
if (!existing)
{
- existing = new PlaceEntryRemote (_dbus_name);
+ existing = new PlaceEntryRemote (this, _dbus_name);
_entries.push_back (existing);
entry_added.emit (existing);
@@ -456,7 +467,7 @@ PlaceRemote::OnEntryAdded (GVariant *args)
&global_results_model,
&global_hints);
- entry = new PlaceEntryRemote (_dbus_name);
+ entry = new PlaceEntryRemote (this, _dbus_name);
entry->Update (dbus_path,
name,
icon,
@@ -512,6 +523,76 @@ PlaceRemote::OnEntryRemoved (const gchar *dbus_path)
}
}
+void
+PlaceRemote::OnActivationResultReceived (GObject *source,
+ GAsyncResult *result,
+ PlaceRemote *self)
+{
+ GVariant *args;
+ GError *error = NULL;
+ guint ret = 0;
+
+ args = g_dbus_proxy_call_finish ((GDBusProxy *)source, result, &error);
+ if (error)
+ {
+ g_warning ("Unable to call Activate() on: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ self->result_activated.emit (self->_active_uri.c_str (), (ActivationResult)ret);
+
+ g_variant_unref (args);
+}
+
+void
+PlaceRemote::ActivateResult (const char *uri, const char *mimetype)
+{
+ if (G_IS_DBUS_PROXY (_activation_proxy)
+ && ((_uri_regex && g_regex_match (_uri_regex, uri, (GRegexMatchFlags)0, NULL))
+ || (_mime_regex && g_regex_match (_mime_regex, mimetype, (GRegexMatchFlags)0, NULL))))
+ {
+ _active_uri = uri;
+ g_dbus_proxy_call (_activation_proxy,
+ "Activate",
+ g_variant_new ("(s)", uri),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)OnActivationResultReceived,
+ this);
+ }
+ else
+ {
+ result_activated.emit (uri, FALLBACK);
+ }
+}
+
+void
+PlaceRemote::OnActivationProxyReady (GObject *source,
+ GAsyncResult *result,
+ PlaceRemote *self)
+{
+ GError *error = NULL;
+ gchar *name_owner = NULL;
+
+ self->_activation_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
+ name_owner = g_dbus_proxy_get_name_owner (self->_activation_proxy);
+
+ if (error || !name_owner)
+ {
+ g_warning ("Unable to connect to PlaceRemote Activation %s: %s",
+ self->_dbus_name,
+ error ? error->message : "No name owner");
+ if (error)
+ g_error_free (error);
+ }
+
+ g_free (name_owner);
+}
+
+
/*
* C callbacks
*/
diff --git a/src/PlaceRemote.h b/src/PlaceRemote.h
index 039cc012b..871a91630 100644
--- a/src/PlaceRemote.h
+++ b/src/PlaceRemote.h
@@ -49,10 +49,19 @@ public:
const gchar * GetDBusName ();
+ void ActivateResult (const char *uri, const char *mimetype);
+
private:
void LoadKeyFileEntries (GKeyFile *key_file);
void Connect ();
+ static void OnActivationProxyReady (GObject *source,
+ GAsyncResult *result,
+ PlaceRemote *self);
+ static void OnActivationResultReceived (GObject *source,
+ GAsyncResult *result,
+ PlaceRemote *self);
+
private:
char *_path;
char *_dbus_name;
@@ -63,6 +72,8 @@ private:
GDBusProxy *_service_proxy;
GDBusProxy *_activation_proxy;
+
+ std::string _active_uri;
};
#endif // PLACE_REMOTE_H
diff --git a/src/PlacesController.cpp b/src/PlacesController.cpp
index 23cfdff2c..7dddb3b28 100644
--- a/src/PlacesController.cpp
+++ b/src/PlacesController.cpp
@@ -32,9 +32,12 @@
#include "PlacesController.h"
+int PlacesController::_launcher_size = 66;
+
PlacesController::PlacesController ()
: _visible (false),
- _fullscren_request (false)
+ _fullscren_request (false),
+ _timeline_id (0)
{
// register interest with ubus so that we get activation messages
UBusServer *ubus = ubus_server_get_default ();
@@ -45,7 +48,7 @@ PlacesController::PlacesController ()
(UBusCallback)&PlacesController::CloseRequest,
this);
- _factory = new PlaceFactoryFile ();
+ _factory = PlaceFactory::GetDefault ();
_window_layout = new nux::HLayout ();
@@ -55,6 +58,7 @@ PlacesController::PlacesController ()
_window->SetConfigureNotifyCallback(&PlacesController::WindowConfigureCallback, this);
_window->ShowWindow(false);
_window->InputWindowEnableStruts(false);
+ _window->SetOpacity (0.0f);
_window->OnMouseDownOutsideArea.connect (sigc::mem_fun (this, &PlacesController::RecvMouseDownOutsideOfView));
@@ -74,6 +78,12 @@ PlacesController::PlacesController ()
PlacesSettings::GetDefault ()->changed.connect (sigc::mem_fun (this, &PlacesController::OnSettingsChanged));
_view->SetFocused (true);
+
+ Relayout (gdk_screen_get_default (), this);
+ g_signal_connect (gdk_screen_get_default (), "monitors-changed",
+ G_CALLBACK (PlacesController::Relayout), this);
+ g_signal_connect (gdk_screen_get_default (), "size-changed",
+ G_CALLBACK (PlacesController::Relayout), this);
}
PlacesController::~PlacesController ()
@@ -81,11 +91,28 @@ PlacesController::~PlacesController ()
_window->UnReference ();
}
+void
+PlacesController::Relayout (GdkScreen *screen, PlacesController *self)
+{
+ int width = 0, height = 0;
+
+ gdk_screen_get_monitor_geometry (screen,
+ gdk_screen_get_primary_monitor (screen),
+ &self->_monitor_rect);
+
+ self->GetWindowSize (&width, &height);
+ self->_window->SetGeometry (nux::Geometry (self->_monitor_rect.x + _launcher_size,
+ self->_monitor_rect.y + 24,
+ width,
+ height));
+}
+
void PlacesController::Show ()
{
if (_visible)
return;
+ _view->AboutToShow ();
_window->ShowWindow (true, false);
// Raise this window on top of all other BaseWindows
_window->PushToFront ();
@@ -94,12 +121,13 @@ void PlacesController::Show ()
//_window->GrabKeyboard ();
_window->QueueDraw ();
_window->CaptureMouseDownAnyWhereElse (true);
+
+ StartShowHideTimeline ();
_visible = true;
ubus_server_send_message (ubus_server_get_default (), UBUS_PLACE_VIEW_SHOWN, NULL);
}
-
void PlacesController::Hide ()
{
if (!_visible)
@@ -110,13 +138,13 @@ void PlacesController::Hide ()
_window->UnGrabPointer ();
//_window->UnGrabKeyboard ();
_window->EnableInputWindow (false);
- _window->ShowWindow (false, false);
-
_visible = false;
_fullscren_request = false;
_view->SetActiveEntry (NULL, 0, "");
+ StartShowHideTimeline ();
+
ubus_server_send_message (ubus_server_get_default (), UBUS_PLACE_VIEW_HIDDEN, NULL);
}
@@ -126,6 +154,55 @@ void PlacesController::ToggleShowHide ()
}
void
+PlacesController::StartShowHideTimeline ()
+{
+ if (_timeline_id)
+ g_source_remove (_timeline_id);
+
+ _timeline_id = g_timeout_add (15, (GSourceFunc)PlacesController::OnViewShowHideFrame, this);
+ _last_opacity = _window->GetOpacity ();
+ _start_time = g_get_monotonic_time ();
+}
+
+gboolean
+PlacesController::OnViewShowHideFrame (PlacesController *self)
+{
+#define _LENGTH_ 90000
+ gint64 diff;
+ float progress;
+ float last_opacity;
+
+ diff = g_get_monotonic_time () - self->_start_time;
+
+ progress = diff/(float)_LENGTH_;
+
+ last_opacity = self->_last_opacity;
+
+ if (self->_visible)
+ {
+ self->_window->SetOpacity (last_opacity + ((1.0f - last_opacity) * progress));
+ }
+ else
+ {
+ self->_window->SetOpacity (last_opacity - (last_opacity * progress));
+ }
+
+ if (diff > _LENGTH_)
+ {
+ self->_timeline_id = 0;
+
+ // Make sure the state is right
+ self->_window->SetOpacity (self->_visible ? 1.0f : 0.0f);
+ if (!self->_visible)
+ self->_window->ShowWindow (false, false);
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+void
PlacesController::GetWindowSize (int *out_width, int *out_height)
{
PlacesSettings *settings = PlacesSettings::GetDefault ();
@@ -156,7 +233,7 @@ PlacesController::GetWindowSize (int *out_width, int *out_height)
}
else
{
- width = rect.width - 66;
+ width = rect.width - _launcher_size;
height = rect.height - 24;
_view->SetSizeMode (PlacesView::SIZE_MODE_FULLSCREEN);
@@ -171,9 +248,14 @@ PlacesController::GetWindowSize (int *out_width, int *out_height)
void
PlacesController::WindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data)
{
+ PlacesController *self = static_cast<PlacesController *> (user_data);
int width = 0, height = 0;
- static_cast<PlacesController *> (user_data)->GetWindowSize (&width, &height);
- geo = nux::Geometry (66, 24, width, height);
+
+ self->GetWindowSize (&width, &height);
+ geo = nux::Geometry (self->_monitor_rect.x + self->_launcher_size,
+ self->_monitor_rect.y + 24,
+ width,
+ height);
}
void
@@ -182,7 +264,10 @@ PlacesController::OnDashFullscreenRequest ()
int width = 0, height = 0;
_fullscren_request = true;
GetWindowSize (&width, &height);
- _window->SetGeometry (nux::Geometry (66, 24, width, height));
+ _window->SetGeometry (nux::Geometry (_monitor_rect.x + _launcher_size,
+ _monitor_rect.y + 24,
+ width,
+ height));
}
void
@@ -202,8 +287,7 @@ PlacesController::CloseRequest (GVariant *data, void *val)
void
PlacesController::RecvMouseDownOutsideOfView (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- //FIXME: We need a way to get the real position/size of the homebutton
- nux::Geometry geo (0, 0, 66, 24);
+ nux::Geometry geo (_monitor_rect.x, _monitor_rect.y, _launcher_size, 24);
if (!geo.IsPointInside (x, y))
Hide ();
}
@@ -214,6 +298,12 @@ PlacesController::OnActivePlaceEntryChanged (PlaceEntry *entry)
entry ? Show () : Hide ();
}
+void
+PlacesController::SetLauncherSize (int launcher_size)
+{
+ _launcher_size = launcher_size;
+}
+
/* Introspection */
const gchar *
diff --git a/src/PlacesController.h b/src/PlacesController.h
index 7337581fb..6ebe9ead7 100644
--- a/src/PlacesController.h
+++ b/src/PlacesController.h
@@ -31,6 +31,7 @@
#include "Introspectable.h"
#include <Nux/BaseWindow.h>
+#include <Nux/TimelineEasings.h>
class PlacesController : public Introspectable
{
@@ -41,6 +42,9 @@ public:
void Show ();
void Hide ();
void ToggleShowHide ();
+ static void SetLauncherSize (int launcher_size);
+
+ nux::BaseWindow* GetWindow () {return _window;}
protected:
const gchar* GetName ();
@@ -57,14 +61,22 @@ private:
void OnSettingsChanged (PlacesSettings *settings);
void OnDashFullscreenRequest ();
void GetWindowSize (int *width, int *height);
+ void StartShowHideTimeline ();
+ static gboolean OnViewShowHideFrame (PlacesController *self);
+ static void Relayout (GdkScreen *screen, PlacesController *self);
private:
nux::BaseWindow *_window;
nux::HLayout *_window_layout;
PlacesView *_view;
- PlaceFactoryFile *_factory;
+ PlaceFactory *_factory;
bool _visible;
bool _fullscren_request;
+ static int _launcher_size;
+ guint _timeline_id;
+ float _last_opacity;
+ gint64 _start_time;
+ GdkRectangle _monitor_rect;
};
#endif // PLACES_CONTROLLER_H
diff --git a/src/PlacesGroup.cpp b/src/PlacesGroup.cpp
index f90123297..a02825e66 100644
--- a/src/PlacesGroup.cpp
+++ b/src/PlacesGroup.cpp
@@ -58,7 +58,8 @@ PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL)
{
PlacesStyle *style = PlacesStyle::GetDefault ();
nux::BaseTexture *arrow = style->GetGroupUnexpandIcon ();
-
+
+ _cached_name = NULL;
_group_layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
_header_layout = new nux::HLayout (NUX_TRACKER_LOCATION);
@@ -77,11 +78,17 @@ PlacesGroup::PlacesGroup (NUX_FILE_LINE_DECL)
_expand_label->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
_expand_label->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);
_expand_label->SetTextColor (kExpandDefaultTextColor);
+ _expand_label->SetCanFocus (true);
+ _expand_label->FocusActivated.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelActivated));
+ _expand_label->FocusChanged.connect (sigc::mem_fun (this, &PlacesGroup::OnLabelFocusChanged));
+
+
_header_layout->AddView (_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
_expand_icon = new nux::TextureArea ();
_expand_icon->SetTexture (arrow);
_expand_icon->SetMinimumSize (arrow->GetWidth (), arrow->GetHeight ());
+ _expand_icon->SetCanFocus (false);
_header_layout->AddView (_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
SetLayout (_group_layout);
@@ -107,17 +114,39 @@ PlacesGroup::~PlacesGroup ()
}
void
+PlacesGroup::OnLabelActivated (nux::Area *label)
+{
+ SetExpanded (!_is_expanded);
+}
+
+void
+PlacesGroup::OnLabelFocusChanged (nux::Area *label)
+{
+ RefreshLabel ();
+}
+void
PlacesGroup::SetName (const char *name)
{
// Spaces are on purpose, want padding to be proportional to the size of the text
// Bear with me, I'm trying something different :)
const gchar *temp = " <big>%s</big> ";
- gchar *tmp, *final;
+ const gchar *temp_focused = " <big><b>%s</b></big> ";
+ gchar *tmp = NULL;
+ gchar *final = NULL;
+ if (_cached_name != NULL)
+ {
+ g_free (_cached_name);
+ }
+
+ _cached_name = g_strdup (name);
tmp = g_markup_escape_text (name, -1);
- final = g_strdup_printf (temp, tmp);
-
+ if (_expand_label->GetFocused ())
+ final = g_strdup_printf (temp_focused, tmp);
+ else
+ final = g_strdup_printf (temp, tmp);
+
_name->SetText (final);
g_free (tmp);
@@ -149,7 +178,7 @@ PlacesGroup::GetChildLayout ()
}
void
-PlacesGroup::Refresh ()
+PlacesGroup::RefreshLabel ()
{
const char *temp = "<small>%s</small>";
char *result_string;
@@ -166,20 +195,23 @@ PlacesGroup::Refresh ()
else
{
result_string = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
- "See one more result",
- "See %d more results",
- _n_total_items - _n_visible_items_in_unexpand_mode),
+ "See one more result",
+ "See %d more results",
+ _n_total_items - _n_visible_items_in_unexpand_mode),
_n_total_items - _n_visible_items_in_unexpand_mode);
}
-
+
_expand_icon->SetVisible (!(_n_visible_items_in_unexpand_mode >= _n_total_items && _n_total_items != 0));
- final = g_strdup_printf (temp, result_string);
+ char *tmpname = g_strdup (_cached_name);
+ SetName (tmpname);
+ g_free (tmpname);
+ final = g_strdup_printf (temp, result_string);
+
_expand_label->SetText (final);
_expand_label->SetVisible (_n_visible_items_in_unexpand_mode < _n_total_items);
- ComputeChildLayout ();
QueueDraw ();
g_free ((result_string));
@@ -187,6 +219,15 @@ PlacesGroup::Refresh ()
}
void
+PlacesGroup::Refresh ()
+{
+ RefreshLabel ();
+ ComputeChildLayout ();
+ QueueDraw ();
+}
+
+
+void
PlacesGroup::Relayout ()
{
if (_idle_id == 0)
@@ -203,6 +244,12 @@ PlacesGroup::OnIdleRelayout (PlacesGroup *self)
self->ComputeChildLayout ();
self->_idle_id = 0;
+ if (self->GetFocused ())
+ {
+ self->SetFocused (false); // unset focus on all children
+ self->SetFocused (true); // set focus on first child
+ }
+
return FALSE;
}
diff --git a/src/PlacesGroup.h b/src/PlacesGroup.h
index b6782fa58..543624eb0 100644
--- a/src/PlacesGroup.h
+++ b/src/PlacesGroup.h
@@ -65,6 +65,9 @@ private:
void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
+ void OnLabelActivated (nux::Area *label);
+ void OnLabelFocusChanged (nux::Area *label);
+ void RefreshLabel ();
private:
nux::VLayout *_group_layout;
@@ -81,6 +84,7 @@ private:
bool _is_expanded;
guint _n_visible_items_in_unexpand_mode;
guint _n_total_items;
+ char *_cached_name;
};
#endif
diff --git a/src/PlacesGroupController.cpp b/src/PlacesGroupController.cpp
index f1375beba..b8c76f776 100644
--- a/src/PlacesGroupController.cpp
+++ b/src/PlacesGroupController.cpp
@@ -91,9 +91,12 @@ PlacesGroupController::AddTile (PlaceEntry *ignore,
tile = new PlacesSimpleTile (result_icon,
result_name,
- style->GetTileIconSize ());
+ style->GetTileIconSize (),
+ false,
+ result.GetId ());
tile->SetURI (result.GetURI ());
tile->QueueRelayout ();
+ tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::TileClicked));
_id_to_tile[result.GetId ()] = tile;
@@ -105,21 +108,28 @@ PlacesGroupController::AddTile (PlaceEntry *ignore,
}
void
+PlacesGroupController::TileClicked (PlacesTile *tile)
+{
+ if (_entry)
+ {
+ _entry->ActivateResult (tile->GetId ());
+ }
+}
+
+void
PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)
{
PlacesStyle *style = PlacesStyle::GetDefault ();
- if (!_group->GetExpanded ()
- && _id_to_tile.size () >= (guint)style->GetDefaultNColumns ())
- {
- _queue.push_back (result.GetId ());
- }
- else
+ _queue.push_back (result.GetId ());
+
+ if (_group->GetExpanded ()
+ || _id_to_tile.size () != (guint)style->GetDefaultNColumns ())
{
AddTile (_entry, group, result);
}
- _group->SetCounts (style->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ());
+ _group->SetCounts (style->GetDefaultNColumns (), _queue.size ());
}
void
@@ -134,19 +144,21 @@ PlacesGroupController::RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& r
{
_queue.erase (it);
}
- else if ((tile = _id_to_tile[result.GetId ()]))
- {
- _id_to_tile.erase (result.GetId ());
+ if ((tile = _id_to_tile[result.GetId ()]))
+ {
_group->GetChildLayout ()->RemoveChildObject (tile);
_group->Relayout ();
- _group->SetVisible (_id_to_tile.size ());
}
+
+ _id_to_tile.erase (result.GetId ());
if (!_check_tiles_id)
_check_tiles_id = g_timeout_add (0, (GSourceFunc)CheckTilesTimeout, this);
-
- _group->SetCounts (PlacesStyle::GetDefault ()->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ());
+
+ _group->SetVisible (_queue.size ());
+ _group->SetCounts (PlacesStyle::GetDefault ()->GetDefaultNColumns (),
+ _queue.size ());
}
void
@@ -162,7 +174,7 @@ PlacesGroupController::CheckTiles ()
guint n_to_show;
if (_group->GetExpanded ())
- n_to_show = _id_to_tile.size () + _queue.size ();
+ n_to_show = _queue.size ();
else
n_to_show = style->GetDefaultNColumns ();
@@ -172,30 +184,34 @@ PlacesGroupController::CheckTiles ()
}
else if (_id_to_tile.size () < n_to_show)
{
- while (_id_to_tile.size () < n_to_show && _queue.size ())
+ std::vector<const void *>::iterator it = _queue.begin ();
+
+ if (_queue.size () >= n_to_show)
{
- _entry->GetResult ((*_queue.begin ()), sigc::mem_fun (this, &PlacesGroupController::AddTile));
- _queue.erase (_queue.begin ());
+ it += _id_to_tile.size ();
+
+ while (_id_to_tile.size () < n_to_show && it != _queue.end ())
+ {
+ _entry->GetResult ((*it), sigc::mem_fun (this, &PlacesGroupController::AddTile));
+ it++;
+ }
}
}
else // Remove some
{
- while (_id_to_tile.size () != n_to_show)
- {
- std::map<const void *, PlacesTile *>::reverse_iterator it;
+ std::vector<const void *>::iterator it, eit = _queue.end ();
- it = _id_to_tile.rbegin ();
+ for (it = _queue.begin () + n_to_show; it != eit; ++it)
+ {
+ PlacesTile *tile = _id_to_tile[*it];
- if (it != _id_to_tile.rend ())
- {
- _group->GetChildLayout ()->RemoveChildObject ((*it).second);
- }
+ if (tile)
+ _group->GetChildLayout ()->RemoveChildObject (tile);
- _queue.insert (_queue.begin (), (*it).first);
- _id_to_tile.erase ((*it).first);
+ _id_to_tile.erase (*it);
}
- }
+ }
_group->Relayout ();
}
@@ -208,6 +224,26 @@ PlacesGroupController::CheckTilesTimeout (PlacesGroupController *self)
return FALSE;
}
+bool
+PlacesGroupController::ActivateFirst ()
+{
+ std::vector<const void *>::iterator it = _queue.begin ();
+
+ if (it != _queue.end ())
+ {
+ PlacesTile *tile = _id_to_tile[*it];
+
+ if (tile)
+ {
+ nux::Geometry geo = tile->GetGeometry ();
+ tile->OnMouseClick.emit (geo.x, geo.y, 0, 0);
+ return true;
+ }
+ }
+
+ return false;
+}
+
//
// Introspectable
//
diff --git a/src/PlacesGroupController.h b/src/PlacesGroupController.h
index 94e94b2a6..7f87b8bb1 100644
--- a/src/PlacesGroupController.h
+++ b/src/PlacesGroupController.h
@@ -41,6 +41,8 @@ public:
void Clear ();
+ bool ActivateFirst ();
+
protected:
const gchar* GetName ();
void AddProperties (GVariantBuilder *builder);
@@ -49,6 +51,7 @@ private:
void AddTile (PlaceEntry *ignore, PlaceEntryGroup& group, PlaceEntryResult& result);
void CheckTiles ();
static gboolean CheckTilesTimeout (PlacesGroupController *self);
+ void TileClicked (PlacesTile *tile);
private:
PlaceEntry *_entry;
diff --git a/src/PlacesHomeView.cpp b/src/PlacesHomeView.cpp
index 77fa6e3be..5e17c365f 100644
--- a/src/PlacesHomeView.cpp
+++ b/src/PlacesHomeView.cpp
@@ -126,6 +126,8 @@ PlacesHomeView::PlacesHomeView ()
NULL, NULL);
Refresh ();
+
+ expanded.connect (sigc::mem_fun (this, &PlacesHomeView::Refresh));
}
PlacesHomeView::~PlacesHomeView ()
@@ -156,6 +158,9 @@ PlacesHomeView::Refresh ()
_layout->Clear ();
+ if (!GetExpanded ())
+ return;
+
// Find Media Apps
markup = g_strdup_printf (temp, _("Find Media Apps"));
shortcut = new Shortcut (PKGDATADIR"/find_media_apps.png",
diff --git a/src/PlacesResultsController.cpp b/src/PlacesResultsController.cpp
index 1a2c3670e..943efc103 100644
--- a/src/PlacesResultsController.cpp
+++ b/src/PlacesResultsController.cpp
@@ -103,6 +103,17 @@ PlacesResultsController::Clear ()
_results_view->Clear ();
}
+bool
+PlacesResultsController::ActivateFirst ()
+{
+ std::map <const void *, PlacesGroupController *>::iterator it, eit = _id_to_group.end ();
+
+ for (it = _id_to_group.begin (); it != eit; ++it)
+ if ((it->second)->ActivateFirst ())
+ return true;
+
+ return false;
+}
//
// Introspection
diff --git a/src/PlacesResultsController.h b/src/PlacesResultsController.h
index d8bec6ef7..0cb9444af 100644
--- a/src/PlacesResultsController.h
+++ b/src/PlacesResultsController.h
@@ -44,6 +44,8 @@ public:
// Clears all the current groups and results
void Clear ();
+ bool ActivateFirst ();
+
protected:
const gchar* GetName ();
void AddProperties (GVariantBuilder *builder);
diff --git a/src/PlacesResultsView.cpp b/src/PlacesResultsView.cpp
index 8212e205c..474596efe 100644
--- a/src/PlacesResultsView.cpp
+++ b/src/PlacesResultsView.cpp
@@ -41,6 +41,7 @@ PlacesResultsView::PlacesResultsView (NUX_FILE_LINE_DECL)
EnableVerticalScrollBar (true);
EnableHorizontalScrollBar (false);
+ _idle_id = 0;
}
PlacesResultsView::~PlacesResultsView ()
@@ -55,8 +56,24 @@ PlacesResultsView::AddGroup (PlacesGroup *group)
ResetScrollToUp ();
_groups.push_back (group);
_layout->AddView (group, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+
+ if (_idle_id == 0)
+ _idle_id = g_idle_add ((GSourceFunc)OnIdleFocus, this);
}
+gboolean
+PlacesResultsView::OnIdleFocus (PlacesResultsView *self)
+{
+ self->_idle_id = 0;
+
+ if (self->GetFocused ())
+ {
+ self->SetFocused (false); // unset focus on all children
+ self->SetFocused (true); // set focus on first child
+ }
+
+ return FALSE;
+}
void
PlacesResultsView::RemoveGroup (PlacesGroup *group)
{
@@ -64,6 +81,8 @@ PlacesResultsView::RemoveGroup (PlacesGroup *group)
ResetScrollToUp ();
_groups.remove (group);
_layout->RemoveChildObject (group);
+ if (_idle_id == 0)
+ _idle_id = g_idle_add ((GSourceFunc)OnIdleFocus, this);
}
void
diff --git a/src/PlacesResultsView.h b/src/PlacesResultsView.h
index c55ff83f9..22623ce64 100644
--- a/src/PlacesResultsView.h
+++ b/src/PlacesResultsView.h
@@ -54,6 +54,8 @@ public:
private:
nux::Layout *_layout;
std::list<PlacesGroup *> _groups;
+ uint _idle_id;
+ static gboolean OnIdleFocus (PlacesResultsView *self);
};
#endif // PLACE_RESULTS_VIEW_H
diff --git a/src/PlacesSearchBar.cpp b/src/PlacesSearchBar.cpp
index 84ad5191a..f12d4af84 100644
--- a/src/PlacesSearchBar.cpp
+++ b/src/PlacesSearchBar.cpp
@@ -65,15 +65,19 @@ PlacesSearchBar::PlacesSearchBar (NUX_FILE_LINE_DECL)
_search_icon->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());
_layout->AddView (_search_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
_search_icon->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));
+ _search_icon->SetCanFocus (false);
_layered_layout = new nux::LayeredLayout ();
_hint = new nux::StaticCairoText (" ");
_hint->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.5f));
+ _hint->SetCanFocus (false);
_layered_layout->AddLayer (_hint);
_pango_entry = new nux::TextEntry ("", NUX_TRACKER_LOCATION);
_pango_entry->sigTextChanged.connect (sigc::mem_fun (this, &PlacesSearchBar::OnSearchChanged));
+ _pango_entry->SetCanFocus (true);
+ _pango_entry->activated.connect (sigc::mem_fun (this, &PlacesSearchBar::OnEntryActivated));
_layered_layout->AddLayer (_pango_entry);
_layered_layout->SetPaintAll (true);
@@ -86,6 +90,7 @@ PlacesSearchBar::PlacesSearchBar (NUX_FILE_LINE_DECL)
_combo->SetVisible (false);
_combo->sigTriggered.connect (sigc::mem_fun (this, &PlacesSearchBar::OnComboChanged));
_combo->GetMenuPage ()->sigMouseDownOutsideMenuCascade.connect (sigc::mem_fun (this, &PlacesSearchBar::OnMenuClosing));
+ _combo->SetCanFocus (false); // NOT SUPPORTING THIS QUITE YET
_layout->AddView (_combo, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
_layout->SetVerticalExternalMargin (18);
@@ -118,12 +123,6 @@ PlacesSearchBar::GetChildsName ()
return "";
}
-bool
-PlacesSearchBar::CanFocus ()
-{
- return false;
-}
-
void PlacesSearchBar::AddProperties (GVariantBuilder *builder)
{
nux::Geometry geo = GetGeometry ();
@@ -300,6 +299,12 @@ PlacesSearchBar::OnClearClicked (int x, int y, unsigned long button_flags, unsig
}
void
+PlacesSearchBar::OnEntryActivated ()
+{
+ activated.emit ();
+}
+
+void
PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self)
{
#define HOW_LARGE 8
diff --git a/src/PlacesSearchBar.h b/src/PlacesSearchBar.h
index 6ca4e9ea1..6db7be734 100644
--- a/src/PlacesSearchBar.h
+++ b/src/PlacesSearchBar.h
@@ -55,8 +55,7 @@ public:
const char *search_string);
sigc::signal<void, const char *> search_changed;
-
- bool CanFocus ();
+ sigc::signal<void> activated;
protected:
// Introspectable methods
@@ -72,6 +71,7 @@ private:
void OnSectionAdded (PlaceEntry *entry, PlaceEntrySection& section);
void OnComboChanged (nux::ComboBoxSimple *simple);
void OnMenuClosing (nux::MenuPage *menu, int x, int y);
+ void OnEntryActivated ();
static bool OnLiveSearchTimeout (PlacesSearchBar *self);
static void OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self);
diff --git a/src/PlacesSettings.cpp b/src/PlacesSettings.cpp
index 005268eff..41e3a0746 100644
--- a/src/PlacesSettings.cpp
+++ b/src/PlacesSettings.cpp
@@ -26,7 +26,8 @@ static PlacesSettings *_places_settings = NULL;
PlacesSettings::PlacesSettings ()
: _settings (NULL),
_raw_from_factor (0),
- _form_factor (DESKTOP)
+ _form_factor (DESKTOP),
+ _dash_blur_type (NO_BLUR)
{
_settings = g_settings_new ("com.canonical.Unity");
g_signal_connect (_settings, "changed",
@@ -54,7 +55,7 @@ PlacesSettings::Refresh ()
primary_monitor = gdk_screen_get_primary_monitor (screen);
gdk_screen_get_monitor_geometry (screen, primary_monitor, &geo);
- _form_factor = geo.height > 800 ? DESKTOP : NETBOOK;
+ _form_factor = geo.height > 799 ? DESKTOP : NETBOOK;
}
else
{
@@ -91,3 +92,16 @@ PlacesSettings::GetDefaultTileWidth ()
//FIXME: We want to calculate this from DPI
return 140;
}
+
+PlacesSettings::DashBlurType
+PlacesSettings::GetDashBlurType ()
+{
+ return _dash_blur_type;
+}
+
+void
+PlacesSettings::SetDashBlurType (PlacesSettings::DashBlurType type)
+{
+ _dash_blur_type = type;
+}
+
diff --git a/src/PlacesSettings.h b/src/PlacesSettings.h
index 991bb4073..497ee2d82 100644
--- a/src/PlacesSettings.h
+++ b/src/PlacesSettings.h
@@ -28,12 +28,18 @@
class PlacesSettings : public nux::Object
{
public:
- typedef enum
+ enum FormFactor
{
DESKTOP=1,
NETBOOK
- } FormFactor;
+ };
+
+ enum DashBlurType
+ {
+ NO_BLUR=0,
+ STATIC_BLUR
+ };
PlacesSettings ();
~PlacesSettings ();
@@ -43,6 +49,9 @@ public:
FormFactor GetFormFactor ();
int GetDefaultTileWidth ();
+ DashBlurType GetDashBlurType ();
+ void SetDashBlurType (DashBlurType type);
+
sigc::signal<void, PlacesSettings *> changed;
private:
@@ -50,9 +59,10 @@ private:
static void Changed (GSettings *settings, gchar *key, PlacesSettings *self);
private:
- GSettings *_settings;
- int _raw_from_factor;
- FormFactor _form_factor;
+ GSettings *_settings;
+ int _raw_from_factor;
+ FormFactor _form_factor;
+ DashBlurType _dash_blur_type;
};
#endif // PLACES_SETTINGS_H
diff --git a/src/PlacesSimpleTile.cpp b/src/PlacesSimpleTile.cpp
index 14be72b52..22ca1b555 100644
--- a/src/PlacesSimpleTile.cpp
+++ b/src/PlacesSimpleTile.cpp
@@ -26,8 +26,12 @@
#include "PlacesSimpleTile.h"
-PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, int icon_size, bool defer_icon_loading)
-: PlacesTile (NUX_TRACKER_LOCATION),
+PlacesSimpleTile::PlacesSimpleTile (const char *icon_name,
+ const char *label,
+ int icon_size,
+ bool defer_icon_loading,
+ const void *id)
+: PlacesTile (NUX_TRACKER_LOCATION, id),
_label (NULL),
_icon (NULL),
_uri (NULL)
@@ -58,8 +62,6 @@ PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, in
SetLayout (layout);
- OnMouseClick.connect (sigc::mem_fun (this, &PlacesSimpleTile::Clicked));
-
SetDndEnabled (true, false);
}
@@ -190,17 +192,6 @@ PlacesSimpleTile::AddProperties (GVariantBuilder *builder)
}
void
-PlacesSimpleTile::Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags)
-{
- if (_uri)
- {
- ubus_server_send_message (ubus_server_get_default (),
- UBUS_PLACE_TILE_ACTIVATE_REQUEST,
- g_variant_new_string (_uri));
- }
-}
-
-void
PlacesSimpleTile::LoadIcon ()
{
_icontex->LoadIcon ();
diff --git a/src/PlacesSimpleTile.h b/src/PlacesSimpleTile.h
index 58b4a0c45..070ad98ee 100644
--- a/src/PlacesSimpleTile.h
+++ b/src/PlacesSimpleTile.h
@@ -31,7 +31,7 @@ class PlacesSimpleTile : public Introspectable, public PlacesTile
{
public:
- PlacesSimpleTile (const char *icon, const char *label, int icon_size=64, bool defer_icon_loading=false);
+ PlacesSimpleTile (const char *icon, const char *label, int icon_size=64, bool defer_icon_loading=false, const void *id=NULL);
~PlacesSimpleTile ();
const char * GetLabel ();
@@ -53,8 +53,6 @@ protected:
virtual std::list<const char *> DndSourceGetDragTypes ();
virtual const char * DndSourceGetDataForType (const char *type, int *size, int *format);
virtual void DndSourceDragFinished (nux::DndAction result);
-private:
- void Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags);
private:
nux::Geometry _highlight_geometry;
diff --git a/src/PlacesTile.cpp b/src/PlacesTile.cpp
index 917317e89..48a05efc8 100644
--- a/src/PlacesTile.cpp
+++ b/src/PlacesTile.cpp
@@ -27,8 +27,9 @@
#define PADDING 8
-PlacesTile::PlacesTile (NUX_FILE_LINE_DECL) :
+PlacesTile::PlacesTile (NUX_FILE_LINE_DECL, const void *id) :
View (NUX_FILE_LINE_PARAM),
+ _id (id),
_hilight_background (NULL),
_hilight_layer (NULL),
_last_width (0),
@@ -40,6 +41,7 @@ PlacesTile::PlacesTile (NUX_FILE_LINE_DECL) :
OnMouseEnter.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseEnter));
OnMouseLeave.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseLeave));
FocusChanged.connect (sigc::mem_fun (this, &PlacesTile::OnFocusChanged));
+ FocusActivated.connect (sigc::mem_fun (this, &PlacesTile::OnFocusActivated));
_can_pass_focus_to_composite_layout = false;
}
@@ -55,7 +57,14 @@ PlacesTile::~PlacesTile ()
delete _hilight_layer;
}
-void PlacesTile::OnFocusChanged (nux::Area *area)
+const void *
+PlacesTile::GetId ()
+{
+ return _id;
+}
+
+void
+PlacesTile::OnFocusChanged (nux::Area *area)
{
QueueDraw ();
}
@@ -343,7 +352,7 @@ PlacesTile::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned l
}
void
-PlacesTile::ActivateFocus ()
+PlacesTile::OnFocusActivated (nux::Area *area)
{
sigClick.emit (this);
}
diff --git a/src/PlacesTile.h b/src/PlacesTile.h
index 8938c89f3..bf1e8b127 100644
--- a/src/PlacesTile.h
+++ b/src/PlacesTile.h
@@ -31,16 +31,16 @@
class PlacesTile : public nux::View
{
public:
- PlacesTile (NUX_FILE_LINE_PROTO);
+ PlacesTile (NUX_FILE_LINE_PROTO, const void *id=NULL);
~PlacesTile ();
- sigc::signal<void, PlacesTile*> sigClick;
+ const void * GetId ();
- virtual void ActivateFocus ();
+ sigc::signal<void, PlacesTile*> sigClick;
protected:
virtual nux::Geometry GetHighlightGeometry ();
-
+
private:
void Draw (nux::GraphicsEngine &GfxContext, bool force_draw);
void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
@@ -64,11 +64,12 @@ private:
void DrawHighlight (const char *texid, int width, int height, nux::BaseTexture **texture);
private:
+ const void *_id;
nux::BaseTexture *_hilight_background;
nux::TextureLayer *_hilight_layer;
void OnFocusChanged (nux::Area *area);
-
+ void OnFocusActivated (nux::Area *area);
int _last_width;
int _last_height;
diff --git a/src/PlacesView.cpp b/src/PlacesView.cpp
index 82b96dcf7..2c8de49a7 100644
--- a/src/PlacesView.cpp
+++ b/src/PlacesView.cpp
@@ -30,7 +30,7 @@
#include "PlaceFactory.h"
#include "PlacesStyle.h"
-
+#include "PlacesSettings.h"
#include "PlacesView.h"
static void place_entry_activate_request (GVariant *payload, PlacesView *self);
@@ -43,6 +43,9 @@ PlacesView::PlacesView (PlaceFactory *factory)
_entry (NULL),
_size_mode (SIZE_MODE_FULLSCREEN)
{
+ LoadPlaces ();
+ _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded));
+
_home_entry = new PlaceEntryHome (_factory);
_layout = new nux::HLayout (NUX_TRACKER_LOCATION);
@@ -58,6 +61,7 @@ PlacesView::PlacesView (PlaceFactory *factory)
AddChild (_search_bar);
_search_bar->search_changed.connect (sigc::mem_fun (this, &PlacesView::OnSearchChanged));
+ _search_bar->activated.connect (sigc::mem_fun (this, &PlacesView::OnEntryActivated));
_layered_layout = new nux::LayeredLayout (NUX_TRACKER_LOCATION);
vlayout->AddLayout (_layered_layout, 1, nux::eCenter, nux::eFull);
@@ -96,7 +100,7 @@ PlacesView::PlacesView (PlaceFactory *factory)
(UBusCallback)&PlacesView::CloseRequest,
this);
ubus_server_register_interest (ubus, UBUS_PLACE_TILE_ACTIVATE_REQUEST,
- (UBusCallback)&PlacesView::OnResultClicked,
+ (UBusCallback)&PlacesView::OnResultActivated,
this);
ubus_server_register_interest (ubus, UBUS_PLACE_VIEW_QUEUE_DRAW,
(UBusCallback)&PlacesView::OnPlaceViewQueueDrawNeeded,
@@ -132,13 +136,15 @@ PlacesView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEve
{
PlacesStyle *style = PlacesStyle::GetDefault ();
nux::BaseTexture *corner = style->GetDashCorner ();
- nux::Geometry geo = GetGeometry ();
- nux::Geometry fullscreen (geo.x + geo.width - corner->GetWidth () + 66,
- geo.y + geo.height - corner->GetHeight () + 24,
+ nux::Geometry geo = GetAbsoluteGeometry ();
+ nux::Geometry fullscreen (geo.x + geo.width - corner->GetWidth (),
+ geo.y + geo.height - corner->GetHeight (),
corner->GetWidth (),
corner->GetHeight ());
+
if (fullscreen.IsPointInside (ievent.e_x, ievent.e_y))
{
+ _bg_blur_texture.Release ();
fullscreen_request.emit ();
return TraverseInfo |= nux::eMouseEventSolved;
@@ -154,6 +160,9 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
{
PlacesStyle *style = PlacesStyle::GetDefault ();
nux::Geometry geo = GetGeometry ();
+ nux::Geometry geo_absolute = GetAbsoluteGeometry ();
+ PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType ();
+ bool paint_blur = type != PlacesSettings::NO_BLUR;
GfxContext.PushClippingRectangle (geo);
@@ -162,6 +171,60 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
GfxContext.GetRenderStates ().SetBlend (true);
GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
+ nux::Geometry _bg_blur_geo = GetGeometry ();
+
+ if ((_size_mode == SIZE_MODE_HOVER))
+ {
+ nux::BaseTexture *bottom = style->GetDashBottomTile ();
+ nux::BaseTexture *right = style->GetDashRightTile ();
+
+ _bg_blur_geo.OffsetSize (-right->GetWidth (), -bottom->GetHeight ());
+ }
+
+ if (!_bg_blur_texture.IsValid () && paint_blur)
+ {
+ nux::ObjectPtr<nux::IOpenGLFrameBufferObject> current_fbo = nux::GetGpuDevice ()->GetCurrentFrameBufferObject ();
+ nux::GetGpuDevice ()->DeactivateFrameBuffer ();
+
+ GfxContext.SetViewport (0, 0, GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());
+ GfxContext.SetScissor (0, 0, GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());
+ GfxContext.GetRenderStates ().EnableScissor (false);
+
+ nux::ObjectPtr <nux::IOpenGLBaseTexture> _bg_texture = GfxContext.CreateTextureFromBackBuffer (
+ geo_absolute.x, geo_absolute.y, _bg_blur_geo.width, _bg_blur_geo.height);
+
+ nux::TexCoordXForm texxform__bg;
+ _bg_blur_texture = GfxContext.QRP_GetBlurTexture (0, 0, _bg_blur_geo.width, _bg_blur_geo.height, _bg_texture, texxform__bg, nux::Color::White, 1.0f, 2);
+
+ if (current_fbo.IsValid ())
+ {
+ current_fbo->Activate (true);
+ GfxContext.Push2DWindow (current_fbo->GetWidth (), current_fbo->GetHeight ());
+ }
+ else
+ {
+ GfxContext.SetViewport (0, 0, GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());
+ GfxContext.Push2DWindow (GfxContext.GetWindowWidth (), GfxContext.GetWindowHeight ());
+ GfxContext.ApplyClippingRectangle ();
+ }
+ }
+
+ if (_bg_blur_texture.IsValid () && paint_blur)
+ {
+ nux::TexCoordXForm texxform_blur__bg;
+ nux::ROPConfig rop;
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+
+ gPainter.PushDrawTextureLayer (GfxContext, _bg_blur_geo,
+ _bg_blur_texture,
+ texxform_blur__bg,
+ nux::Color::White,
+ true,
+ rop);
+ }
+
if (_size_mode == SIZE_MODE_HOVER)
{
nux::BaseTexture *corner = style->GetDashCorner ();
@@ -240,6 +303,9 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
nux::GetPainter ().RenderSinglePaintLayer (GfxContext, geo, _bg_layer);
}
+ if (_bg_blur_texture.IsValid () && paint_blur)
+ gPainter.PopBackground ();
+
GfxContext.GetRenderStates ().SetBlend (false);
GfxContext.PopClippingRectangle ();
@@ -249,16 +315,38 @@ PlacesView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
void
PlacesView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
{
+ PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType ();
+ bool paint_blur = type != PlacesSettings::NO_BLUR;
+ int bgs = 1;
+
GfxContext.PushClippingRectangle (GetGeometry() );
GfxContext.GetRenderStates ().SetBlend (true);
GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
+ if (_bg_blur_texture.IsValid () && paint_blur)
+ {
+
+ nux::TexCoordXForm texxform_blur__bg;
+ nux::ROPConfig rop;
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+
+ gPainter.PushTextureLayer (GfxContext, _bg_blur_geo,
+ _bg_blur_texture,
+ texxform_blur__bg,
+ nux::Color::White,
+ true,
+ rop);
+ bgs++;
+ }
+
nux::GetPainter ().PushLayer (GfxContext, _bg_layer->GetGeometry (), _bg_layer);
if (_layout)
_layout->ProcessDraw (GfxContext, force_draw);
- nux::GetPainter ().PopBackground ();
+ nux::GetPainter ().PopBackground (bgs);
GfxContext.GetRenderStates ().SetBlend (false);
@@ -269,6 +357,12 @@ PlacesView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
// PlacesView Methods
//
void
+PlacesView::AboutToShow ()
+{
+ _bg_blur_texture.Release ();
+}
+
+void
PlacesView::SetActiveEntry (PlaceEntry *entry, guint section_id, const char *search_string, bool signal)
{
if (signal)
@@ -299,11 +393,13 @@ PlacesView::SetActiveEntry (PlaceEntry *entry, guint section_id, const char *sea
_group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded));
_result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded));
_result_removed_conn = _entry->result_removed.connect (sigc::mem_fun (this, &PlacesView::OnResultRemoved));
-
+
if (_entry == _home_entry && (g_strcmp0 (search_string, "") == 0))
_layered_layout->SetActiveLayer (_home_view);
else
_layered_layout->SetActiveLayer (_results_view);
+
+
}
PlaceEntry *
@@ -378,25 +474,17 @@ PlacesView::OnGroupAdded (PlaceEntry *entry, PlaceEntryGroup& group)
void
PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
{
- //FIXME: We can't do anything with these do just ignore
- if (g_str_has_prefix (result.GetURI (), "unity-install"))
- return;
-
_results_controller->AddResult (entry, group, result);
}
void
PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
{
- //FIXME: We can't do anything with these do just ignore
- if (g_str_has_prefix (result.GetURI (), "unity-install"))
- return;
-
_results_controller->RemoveResult (entry, group, result);
}
void
-PlacesView::OnResultClicked (GVariant *data, PlacesView *self)
+PlacesView::OnResultActivated (GVariant *data, PlacesView *self)
{
const char *uri;
@@ -527,6 +615,52 @@ PlacesView::OnPlaceViewQueueDrawNeeded (GVariant *data, PlacesView *self)
self->QueueDraw ();
}
+void
+PlacesView::OnEntryActivated ()
+{
+ if (!_results_controller->ActivateFirst ())
+ g_debug ("Cannot activate anything");
+}
+
+void
+PlacesView::LoadPlaces ()
+{
+ std::vector<Place *>::iterator it, eit = _factory->GetPlaces ().end ();
+
+ for (it = _factory->GetPlaces ().begin (); it != eit; ++it)
+ {
+ OnPlaceAdded (*it);
+ }
+}
+
+void
+PlacesView::OnPlaceAdded (Place *place)
+{
+ place->result_activated.connect (sigc::mem_fun (this, &PlacesView::OnPlaceResultActivated));
+}
+
+void
+PlacesView::OnPlaceResultActivated (const char *uri, ActivationResult res)
+{
+ switch (res)
+ {
+ case FALLBACK:
+ OnResultActivated (g_variant_new_string (uri), this);
+ break;
+ case SHOW_DASH:
+ break;
+ case HIDE_DASH:
+ ubus_server_send_message (ubus_server_get_default (),
+ UBUS_PLACE_VIEW_CLOSE_REQUEST,
+ NULL);
+ break;
+ default:
+ g_warning ("Activation result %d not supported", res);
+ break;
+ };
+}
+
+
//
// Introspection
//
@@ -563,6 +697,18 @@ place_entry_activate_request (GVariant *payload, PlacesView *self)
self->PlaceEntryActivateRequest (id, section, search_string);
+ if (self->GetFocused ())
+ {
+ // reset the focus
+ self->SetFocused (false);
+ self->SetFocused (true);
+ }
+ else
+ {
+ // Not focused but we really should be
+ self->SetFocused (true);
+ }
+
g_free (id);
g_free (search_string);
}
diff --git a/src/PlacesView.h b/src/PlacesView.h
index 001f47fa0..faaefb6b7 100644
--- a/src/PlacesView.h
+++ b/src/PlacesView.h
@@ -79,6 +79,8 @@ public:
SizeMode GetSizeMode ();
void SetSizeMode (SizeMode size_mode);
+ void AboutToShow ();
+
// Signals
sigc::signal<void, PlaceEntry *> entry_changed;
sigc::signal<void> fullscreen_request;
@@ -95,12 +97,19 @@ private:
void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
- static void OnResultClicked (GVariant *data, PlacesView *self);
+ bool TryPlaceActivation (const char *uri);
+ static void OnResultActivated (GVariant *data, PlacesView *self);
void OnSearchChanged (const char *search_string);
void OnResultsViewGeometryChanged (nux::Area *view, nux::Geometry& view_geo);
static void OnPlaceViewQueueDrawNeeded (GVariant *data, PlacesView *self);
+ void OnEntryActivated ();
+
+ void LoadPlaces ();
+ void OnPlaceAdded (Place *place);
+ void OnPlaceResultActivated (const char *uri, ActivationResult res);
+
private:
PlaceFactory *_factory;
nux::HLayout *_layout;
@@ -122,6 +131,9 @@ private:
nux::SpaceLayout *_v_spacer;
SizeMode _size_mode;
+
+ nux::ObjectPtr <nux::IOpenGLBaseTexture> _bg_blur_texture;
+ nux::Geometry _bg_blur_geo;
};
#endif // PANEL_HOME_BUTTON_H
diff --git a/src/QuicklistView.cpp b/src/QuicklistView.cpp
index 703cf3c35..c0d99b3b8 100644
--- a/src/QuicklistView.cpp
+++ b/src/QuicklistView.cpp
@@ -170,7 +170,8 @@ QuicklistView::RecvKeyPressed (unsigned int key_sym,
// <SPACE>, <RETURN> (activate selected menu-item)
case NUX_VK_SPACE:
case NUX_VK_ENTER:
- if (_current_item_index >= 0 && _current_item_index < GetNumItems ())
+ if (_current_item_index >= 0 && _current_item_index < GetNumItems () &&
+ GetNthItems (_current_item_index)->GetEnabled ())
{
dbusmenu_menuitem_handle_event (GetNthItems (_current_item_index)->_menuItem,
@@ -606,7 +607,7 @@ void QuicklistView::RecvCairoTextColorChanged (QuicklistMenuItem* cairo_text)
void QuicklistView::RecvItemMouseClick (QuicklistMenuItem* item, int x, int y)
{
_mouse_down = false;
- if (IsVisible ())
+ if (IsVisible () && item->GetEnabled ())
{
// Check if the mouse was released over an item and emit the signal
CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ());
@@ -661,7 +662,7 @@ void QuicklistView::RecvItemMouseRelease (QuicklistMenuItem* item, int x, int y)
_mouse_down = false;
- if (IsVisible ())
+ if (IsVisible () && item->GetEnabled ())
{
// Check if the mouse was released over an item and emit the signal
CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ());
diff --git a/src/StaticCairoText.cpp b/src/StaticCairoText.cpp
index 5dbc9dce8..b02111e4b 100644
--- a/src/StaticCairoText.cpp
+++ b/src/StaticCairoText.cpp
@@ -50,6 +50,7 @@ namespace nux
_ellipsize = NUX_ELLIPSIZE_END;
_align = NUX_ALIGN_LEFT;
_fontstring = NULL;
+ SetCanFocus (false);
}
StaticCairoText::~StaticCairoText ()
@@ -477,9 +478,4 @@ void StaticCairoText::OnFontChanged (GObject *gobject, GParamSpec *pspec,
self->sigFontChanged.emit (self);
}
-bool StaticCairoText::CanFocus ()
-{
- return false;
-}
-
}
diff --git a/src/StaticCairoText.h b/src/StaticCairoText.h
index 22f49d743..554aeb905 100644
--- a/src/StaticCairoText.h
+++ b/src/StaticCairoText.h
@@ -89,7 +89,6 @@ namespace nux
sigc::signal<void, StaticCairoText*> sigTextChanged;
sigc::signal<void, StaticCairoText*> sigTextColorChanged;
sigc::signal<void, StaticCairoText*> sigFontChanged;
- virtual bool CanFocus ();
private:
int _cached_extent_width;
diff --git a/src/TrashLauncherIcon.cpp b/src/TrashLauncherIcon.cpp
index 8d1c52952..f8e5d2f33 100644
--- a/src/TrashLauncherIcon.cpp
+++ b/src/TrashLauncherIcon.cpp
@@ -26,6 +26,9 @@
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
+#include <gconf/gconf-client.h>
+
+#define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash"
TrashLauncherIcon::TrashLauncherIcon (Launcher* IconManager)
: SimpleLauncherIcon(IconManager)
@@ -73,21 +76,18 @@ TrashLauncherIcon::EnsureMenuItemsReady ()
DbusmenuMenuitem *menu_item;
/* Empty Trash */
- if (_menu_items.find ("Empty") == _menu_items.end ())
- {
- menu_item = dbusmenu_menuitem_new ();
- g_object_ref (menu_item);
+ menu_item = dbusmenu_menuitem_new ();
+ g_object_ref (menu_item);
- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash"));
- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash..."));
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !_empty);
+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
- g_signal_connect (menu_item,
- DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);
+ g_signal_connect (menu_item,
+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ (GCallback)&TrashLauncherIcon::OnEmptyTrash, this);
- _menu_items["Empty"] = menu_item;
- }
+ _menu_items["Empty"] = menu_item;
}
void
@@ -98,7 +98,7 @@ TrashLauncherIcon::OnMouseClick (int button)
if (button == 1)
ActivateLauncherIcon ();
- else if (button == 3 && _empty == FALSE)
+ else if (button == 3)
{
EnsureMenuItemsReady ();
@@ -128,24 +128,37 @@ TrashLauncherIcon::ActivateLauncherIcon ()
void
TrashLauncherIcon::OnEmptyTrash(DbusmenuMenuitem *item, int time, TrashLauncherIcon *self)
{
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- NULL);
-
- g_object_set (GTK_DIALOG (dialog),
- "text", _("Empty all items from Trash?"),
- "secondary-text", _("All items in the Trash will be permanently deleted."),
- NULL);
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("Empty Trash"), GTK_RESPONSE_OK );
+ GConfClient *client;
+ GtkWidget *dialog;
+ bool ask_confirmation;
+
+ client = gconf_client_get_default ();
+ ask_confirmation = gconf_client_get_bool (client, ASK_CONFIRMATION_KEY, NULL);
+ g_object_unref (client);
+
+ if (ask_confirmation)
+ {
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ NULL);
+
+ g_object_set (GTK_DIALOG (dialog),
+ "text", _("Empty all items from Trash?"),
+ "secondary-text", _("All items in the Trash will be permanently deleted."),
+ NULL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Empty Trash"), GTK_RESPONSE_OK );
+ }
QuicklistManager::Default ()->HideQuicklist (self->_quicklist);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ if (!ask_confirmation || gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ {
g_thread_create ((GThreadFunc)&TrashLauncherIcon::EmptyTrashAction, NULL, FALSE, NULL);
+ }
- gtk_widget_destroy (dialog);
+ if (ask_confirmation)
+ gtk_widget_destroy (dialog);
}
diff --git a/src/nux-area-accessible.cpp b/src/nux-area-accessible.cpp
index e201704af..0a73c564b 100644
--- a/src/nux-area-accessible.cpp
+++ b/src/nux-area-accessible.cpp
@@ -30,6 +30,8 @@
#include "nux-area-accessible.h"
+#include "unitya11y.h"
+
/* GObject */
static void nux_area_accessible_class_init (NuxAreaAccessibleClass *klass);
static void nux_area_accessible_init (NuxAreaAccessible *area_accessible);
@@ -37,6 +39,7 @@ static void nux_area_accessible_init (NuxAreaAccessible *area_accessible);
/* AtkObject.h */
static void nux_area_accessible_initialize (AtkObject *accessible,
gpointer data);
+static AtkObject *nux_area_accessible_get_parent (AtkObject *obj);
/* AtkComponent.h */
static void atk_component_interface_init (AtkComponentIface *iface);
@@ -59,6 +62,7 @@ nux_area_accessible_class_init (NuxAreaAccessibleClass *klass)
/* AtkObject */
atk_class->initialize = nux_area_accessible_initialize;
+ atk_class->get_parent = nux_area_accessible_get_parent;
}
static void
@@ -90,6 +94,31 @@ nux_area_accessible_initialize (AtkObject *accessible,
accessible->role = ATK_ROLE_UNKNOWN;
}
+static AtkObject *
+nux_area_accessible_get_parent (AtkObject *obj)
+{
+ nux::Object *nux_object = NULL;
+ nux::Area *area = NULL;
+ nux::Area *parent = NULL;
+
+ g_return_val_if_fail (NUX_IS_AREA_ACCESSIBLE (obj), NULL);
+
+ if (obj->accessible_parent)
+ return obj->accessible_parent;
+
+ nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
+
+ if (nux_object == NULL) /* actor is defunct */
+ return NULL;
+
+ area = dynamic_cast<nux::Area *>(nux_object);
+
+ parent = area->GetParentObject ();
+
+ return unity_a11y_get_accessible (parent);
+}
+
+
/* AtkComponent implementation */
static void
atk_component_interface_init (AtkComponentIface *iface)
diff --git a/src/nux-base-window-accessible.cpp b/src/nux-base-window-accessible.cpp
index a8aa6d49e..3476c0615 100644
--- a/src/nux-base-window-accessible.cpp
+++ b/src/nux-base-window-accessible.cpp
@@ -30,7 +30,6 @@
*/
#include "nux-base-window-accessible.h"
-#include "unitya11y.h"
#include "Nux/Area.h"
#include "Nux/Layout.h"
@@ -42,9 +41,6 @@ static void nux_base_window_accessible_init (NuxBaseWindowAccessible *base
/* AtkObject.h */
static void nux_base_window_accessible_initialize (AtkObject *accessible,
gpointer data);
-static gint nux_base_window_accessible_get_n_children (AtkObject *obj);
-static AtkObject *nux_base_window_accessible_ref_child (AtkObject *obj,
- gint i);
static AtkObject *nux_base_window_accessible_get_parent (AtkObject *obj);
@@ -57,8 +53,6 @@ nux_base_window_accessible_class_init (NuxBaseWindowAccessibleClass *klass)
/* AtkObject */
atk_class->initialize = nux_base_window_accessible_initialize;
- atk_class->get_n_children = nux_base_window_accessible_get_n_children;
- atk_class->ref_child = nux_base_window_accessible_ref_child;
atk_class->get_parent = nux_base_window_accessible_get_parent;
}
@@ -78,6 +72,8 @@ nux_base_window_accessible_new (nux::Object *object)
atk_object_initialize (accessible, object);
+ atk_object_set_name (accessible, "BaseWindow");
+
return accessible;
}
@@ -91,59 +87,8 @@ nux_base_window_accessible_initialize (AtkObject *accessible,
accessible->role = ATK_ROLE_WINDOW;
}
-static gint
-nux_base_window_accessible_get_n_children (AtkObject *obj)
-{
- nux::Object *nux_object = NULL;
- nux::BaseWindow *base_window = NULL;
- nux::Layout *layout = NULL;
-
- g_return_val_if_fail (NUX_IS_BASE_WINDOW_ACCESSIBLE (obj), 0);
-
- nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
- if (nux_object == NULL) /* state is defunct */
- return 0;
- base_window = dynamic_cast<nux::BaseWindow *>(nux_object);
-
- layout = base_window->GetLayout ();
-
- if (layout == NULL)
- return 0;
- else
- return 1;
-}
-
-static AtkObject *
-nux_base_window_accessible_ref_child (AtkObject *obj,
- gint i)
-{
- nux::Object *nux_object = NULL;
- nux::BaseWindow *base_window = NULL;
- nux::Layout *layout = NULL;
- AtkObject *layout_accessible = NULL;
- gint num = 0;
-
- g_return_val_if_fail (NUX_IS_BASE_WINDOW_ACCESSIBLE (obj), 0);
- num = atk_object_get_n_accessible_children (obj);
- g_return_val_if_fail ((i < num)&&(i >= 0), NULL);
-
- nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
- if (nux_object == NULL) /* state is defunct */
- return 0;
-
- base_window = dynamic_cast<nux::BaseWindow *>(nux_object);
-
- layout = base_window->GetLayout ();
-
- layout_accessible = unity_a11y_get_accessible (layout);
-
- g_object_ref (layout_accessible);
-
- return layout_accessible;
-}
-
-static AtkObject
-*nux_base_window_accessible_get_parent (AtkObject *obj)
+static AtkObject*
+nux_base_window_accessible_get_parent (AtkObject *obj)
{
- return NULL;
+ return atk_get_root ();
}
diff --git a/src/nux-view-accessible.cpp b/src/nux-view-accessible.cpp
index ce671452c..b816b7f9a 100644
--- a/src/nux-view-accessible.cpp
+++ b/src/nux-view-accessible.cpp
@@ -28,6 +28,9 @@
*/
#include "nux-view-accessible.h"
+#include "unitya11y.h"
+
+#include "Nux/Layout.h"
/* GObject */
static void nux_view_accessible_class_init (NuxViewAccessibleClass *klass);
@@ -38,6 +41,9 @@ static void nux_view_accessible_initialize (AtkObject *accessible,
gpointer data);
static AtkStateSet* nux_view_accessible_ref_state_set (AtkObject *obj);
+static gint nux_view_accessible_get_n_children (AtkObject *obj);
+static AtkObject* nux_view_accessible_ref_child (AtkObject *obj,
+ gint i);
/* AtkComponent.h */
static void atk_component_interface_init (AtkComponentIface *iface);
@@ -67,6 +73,8 @@ nux_view_accessible_class_init (NuxViewAccessibleClass *klass)
/* AtkObject */
atk_class->initialize = nux_view_accessible_initialize;
atk_class->ref_state_set = nux_view_accessible_ref_state_set;
+ atk_class->ref_child = nux_view_accessible_ref_child;
+ atk_class->get_n_children = nux_view_accessible_get_n_children;
}
static void
@@ -138,9 +146,65 @@ nux_view_accessible_ref_state_set (AtkObject *obj)
return state_set;
}
+static gint
+nux_view_accessible_get_n_children (AtkObject *obj)
+{
+ nux::Object *nux_object = NULL;
+ nux::View *view = NULL;
+ nux::Layout *layout = NULL;
+
+ g_return_val_if_fail (NUX_IS_VIEW_ACCESSIBLE (obj), 0);
+
+ nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
+ if (nux_object == NULL) /* state is defunct */
+ return 0;
+
+ view = dynamic_cast<nux::View *>(nux_object);
+
+ layout = view->GetLayout ();
+
+ if (layout == NULL)
+ return 0;
+ else
+ return 1;
+}
+
+static AtkObject *
+nux_view_accessible_ref_child (AtkObject *obj,
+ gint i)
+{
+ nux::Object *nux_object = NULL;
+ nux::View *view = NULL;
+ nux::Layout *layout = NULL;
+ AtkObject *layout_accessible = NULL;
+ gint num = 0;
+
+ g_return_val_if_fail (NUX_IS_VIEW_ACCESSIBLE (obj), 0);
+
+ num = atk_object_get_n_accessible_children (obj);
+ g_return_val_if_fail ((i < num)&&(i >= 0), NULL);
+
+ nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
+ if (nux_object == NULL) /* state is defunct */
+ return 0;
+
+ view = dynamic_cast<nux::View *>(nux_object);
+
+ layout = view->GetLayout ();
+
+ layout_accessible = unity_a11y_get_accessible (layout);
+
+ if (layout_accessible != NULL)
+ g_object_ref (layout_accessible);
+
+ return layout_accessible;
+}
+
static void
on_start_focus_cb (AtkObject *accessible)
{
+ g_debug ("[a11y] on start_focus_cb: (%p:%s)", accessible, atk_object_get_name (accessible));
+
g_signal_emit_by_name (accessible, "focus_event", TRUE);
atk_focus_tracker_notify (accessible);
}
@@ -148,6 +212,8 @@ on_start_focus_cb (AtkObject *accessible)
static void
on_end_focus_cb (AtkObject *accessible)
{
+ g_debug ("[a11y] on end_focus_cb: (%p:%s)", accessible, atk_object_get_name (accessible));
+
g_signal_emit_by_name (accessible, "focus_event", FALSE);
atk_focus_tracker_notify (accessible);
}
@@ -235,5 +301,8 @@ nux_view_accessible_focus_handler (AtkObject *accessible,
{
g_return_if_fail (NUX_IS_VIEW_ACCESSIBLE (accessible));
+ g_debug ("[a11y] view_focus_handler (%p:%s:%i)",
+ accessible, atk_object_get_name (accessible), focus_in);
+
atk_object_notify_state_change (accessible, ATK_STATE_FOCUSED, focus_in);
}
diff --git a/src/unity-launcher-accessible.cpp b/src/unity-launcher-accessible.cpp
index e4698a6b4..ec33f0049 100644
--- a/src/unity-launcher-accessible.cpp
+++ b/src/unity-launcher-accessible.cpp
@@ -28,6 +28,8 @@
*
*/
+#include <glib/gi18n.h>
+
#include "unity-launcher-accessible.h"
#include "unitya11y.h"
@@ -116,6 +118,7 @@ unity_launcher_accessible_new (nux::Object *object)
accessible = ATK_OBJECT (g_object_new (UNITY_TYPE_LAUNCHER_ACCESSIBLE, NULL));
atk_object_initialize (accessible, object);
+ atk_object_set_name (accessible, _("Launcher"));
return accessible;
}
diff --git a/src/unity-launcher-icon-accessible.cpp b/src/unity-launcher-icon-accessible.cpp
index 306762ae6..78204ce03 100644
--- a/src/unity-launcher-icon-accessible.cpp
+++ b/src/unity-launcher-icon-accessible.cpp
@@ -29,26 +29,46 @@
*/
#include "unity-launcher-icon-accessible.h"
+#include "unity-launcher-accessible.h"
#include "LauncherIcon.h"
+#include "unitya11y.h"
+
/* GObject */
static void unity_launcher_icon_accessible_class_init (UnityLauncherIconAccessibleClass *klass);
static void unity_launcher_icon_accessible_init (UnityLauncherIconAccessible *launcher_icon_accessible);
-static void unity_launcher_icon_accessible_finalize (GObject *object);
+static void unity_launcher_icon_accessible_dispose (GObject *object);
/* AtkObject.h */
-static void unity_launcher_icon_accessible_initialize (AtkObject *accessible,
- gpointer data);
+static void unity_launcher_icon_accessible_initialize (AtkObject *accessible,
+ gpointer data);
static AtkStateSet* unity_launcher_icon_accessible_ref_state_set (AtkObject *obj);
-static const gchar * unity_launcher_icon_accessible_get_name (AtkObject *obj);
+static const gchar * unity_launcher_icon_accessible_get_name (AtkObject *obj);
+static AtkObject * unity_launcher_icon_accessible_get_parent (AtkObject *obj);
+
+/* AtkComponent.h */
+static void atk_component_interface_init (AtkComponentIface *iface);
+static guint unity_launcher_icon_accessible_add_focus_handler (AtkComponent *component,
+ AtkFocusHandler handler);
+static void unity_launcher_icon_accessible_remove_focus_handler (AtkComponent *component,
+ guint handler_id);
+static void unity_launcher_icon_accessible_focus_handler (AtkObject *accessible,
+ gboolean focus_in);
/* private/utility methods*/
-static void check_selected (UnityLauncherIconAccessible *self);
-static void on_selection_change_cb (UnityLauncherIconAccessible *icon_accessible);
-
-
-G_DEFINE_TYPE (UnityLauncherIconAccessible, unity_launcher_icon_accessible, NUX_TYPE_OBJECT_ACCESSIBLE)
+static void check_selected (UnityLauncherIconAccessible *self);
+static void on_parent_selection_change_cb (AtkSelection *selection,
+ gpointer data);
+static void on_parent_focus_event_cb (AtkObject *object,
+ gboolean in,
+ gpointer data);
+
+G_DEFINE_TYPE_WITH_CODE (UnityLauncherIconAccessible,
+ unity_launcher_icon_accessible,
+ NUX_TYPE_OBJECT_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT,
+ atk_component_interface_init))
#define UNITY_LAUNCHER_ICON_ACCESSIBLE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_LAUNCHER_ICON_ACCESSIBLE, \
@@ -58,8 +78,10 @@ struct _UnityLauncherIconAccessiblePrivate
{
/* Cached values (used to avoid extra notifications) */
gboolean selected;
+ gboolean parent_focused;
- sigc::connection on_selection_change_connection;
+ guint on_parent_selection_change_id;
+ guint on_parent_focus_event_id;
};
static void
@@ -68,12 +90,13 @@ unity_launcher_icon_accessible_class_init (UnityLauncherIconAccessibleClass *kla
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
- gobject_class->finalize = unity_launcher_icon_accessible_finalize;
+ gobject_class->dispose = unity_launcher_icon_accessible_dispose;
/* AtkObject */
atk_class->initialize = unity_launcher_icon_accessible_initialize;
atk_class->get_name = unity_launcher_icon_accessible_get_name;
atk_class->ref_state_set = unity_launcher_icon_accessible_ref_state_set;
+ atk_class->get_parent = unity_launcher_icon_accessible_get_parent;
g_type_class_add_private (gobject_class, sizeof (UnityLauncherIconAccessiblePrivate));
}
@@ -88,13 +111,23 @@ unity_launcher_icon_accessible_init (UnityLauncherIconAccessible *launcher_icon_
}
static void
-unity_launcher_icon_accessible_finalize (GObject *object)
+unity_launcher_icon_accessible_dispose (GObject *object)
{
UnityLauncherIconAccessible *self = UNITY_LAUNCHER_ICON_ACCESSIBLE (object);
+ AtkObject *parent = NULL;
- self->priv->on_selection_change_connection.disconnect ();
+ parent = atk_object_get_parent (ATK_OBJECT (object));
- G_OBJECT_CLASS (unity_launcher_icon_accessible_parent_class)->finalize (object);
+ if (UNITY_IS_LAUNCHER_ACCESSIBLE (parent))
+ {
+ if (self->priv->on_parent_selection_change_id != 0)
+ g_signal_handler_disconnect (parent, self->priv->on_parent_selection_change_id);
+
+ if (self->priv->on_parent_focus_event_id != 0)
+ g_signal_handler_disconnect (parent, self->priv->on_parent_focus_event_id);
+ }
+
+ G_OBJECT_CLASS (unity_launcher_icon_accessible_parent_class)->dispose (object);
}
@@ -119,6 +152,7 @@ unity_launcher_icon_accessible_initialize (AtkObject *accessible,
{
LauncherIcon *icon = NULL;
Launcher *launcher = NULL;
+ UnityLauncherAccessible *launcher_accessible = NULL;
UnityLauncherIconAccessible *self = NULL;
nux::Object *nux_object = NULL;
@@ -131,11 +165,23 @@ unity_launcher_icon_accessible_initialize (AtkObject *accessible,
icon = dynamic_cast<LauncherIcon *>(nux_object);
launcher = icon->GetLauncher ();
- if (launcher != NULL)
- {
- self->priv->on_selection_change_connection =
- launcher->selection_change.connect (sigc::bind (sigc::ptr_fun (on_selection_change_cb), self));
- }
+ if (launcher == NULL)
+ return;
+
+ /* NOTE: we could also get the launcher_accessible by just calling
+ atk_object_get_parent */
+ launcher_accessible = UNITY_LAUNCHER_ACCESSIBLE (unity_a11y_get_accessible (launcher));
+
+ self->priv->on_parent_selection_change_id =
+ g_signal_connect (launcher_accessible, "selection-changed",
+ G_CALLBACK (on_parent_selection_change_cb), self);
+
+ self->priv->on_parent_focus_event_id =
+ g_signal_connect (launcher_accessible, "focus-event",
+ G_CALLBACK (on_parent_focus_event_cb), self);
+
+ atk_component_add_focus_handler (ATK_COMPONENT (accessible),
+ unity_launcher_icon_accessible_focus_handler);
/* Check the cached selected state and notify the first selection.
* Ie: it is required to ensure a first notification
@@ -185,11 +231,40 @@ unity_launcher_icon_accessible_ref_state_set (AtkObject *obj)
return state_set;
if (self->priv->selected)
- atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
+ {
+ atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
+ atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
+ atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
+ }
return state_set;
}
+static AtkObject *
+unity_launcher_icon_accessible_get_parent (AtkObject *obj)
+{
+ nux::Object *nux_object = NULL;
+ LauncherIcon *icon = NULL;
+ Launcher *launcher = NULL;
+
+ g_return_val_if_fail (UNITY_IS_LAUNCHER_ICON_ACCESSIBLE (obj), NULL);
+
+ if (obj->accessible_parent)
+ return obj->accessible_parent;
+
+ nux_object = nux_object_accessible_get_object (NUX_OBJECT_ACCESSIBLE (obj));
+
+ if (nux_object == NULL) /* actor is defunct */
+ return NULL;
+
+ icon = dynamic_cast<LauncherIcon *>(nux_object);
+ launcher = icon->GetLauncher ();
+
+ g_return_val_if_fail (dynamic_cast<Launcher *>(launcher), NULL);
+
+ return unity_a11y_get_accessible (launcher);
+}
+
/* private methods */
/*
@@ -209,7 +284,7 @@ check_selected (UnityLauncherIconAccessible *self)
icon = dynamic_cast<LauncherIcon *>(nux_object);
launcher = icon->GetLauncher ();
- if (launcher == NULL)
+ if ((launcher == NULL) || (self->priv->parent_focused == FALSE))
return;
selected_icon = launcher->GetSelectedMenuIcon ();
@@ -219,17 +294,121 @@ check_selected (UnityLauncherIconAccessible *self)
if (found != self->priv->selected)
{
+ gboolean return_val = FALSE;
+
self->priv->selected = found;
atk_object_notify_state_change (ATK_OBJECT (self),
ATK_STATE_SELECTED,
found);
- g_debug ("[LAUNCHER-ICON]: selected state changed (%p:%i)", self, found);
+ atk_object_notify_state_change (ATK_OBJECT (self),
+ ATK_STATE_ACTIVE,
+ found);
+
+ g_signal_emit_by_name (self, "focus_event", found, &return_val);
+ atk_focus_tracker_notify (ATK_OBJECT (self));
+
+ g_debug ("[LAUNCHER-ICON]: selected state changed (%p:%i:%s)",
+ self, found, atk_object_get_name (ATK_OBJECT (self)));
}
}
static void
-on_selection_change_cb (UnityLauncherIconAccessible *icon_accessible)
+on_parent_selection_change_cb (AtkSelection *selection,
+ gpointer data)
{
- check_selected (icon_accessible);
+ g_return_if_fail (UNITY_IS_LAUNCHER_ACCESSIBLE (selection));
+ g_return_if_fail (UNITY_IS_LAUNCHER_ICON_ACCESSIBLE (data));
+
+ check_selected (UNITY_LAUNCHER_ICON_ACCESSIBLE (data));
+}
+
+
+static void
+on_parent_focus_event_cb (AtkObject *object,
+ gboolean in,
+ gpointer data)
+{
+ UnityLauncherIconAccessible *self = NULL;
+
+ g_return_if_fail (UNITY_IS_LAUNCHER_ICON_ACCESSIBLE (data));
+
+ self = UNITY_LAUNCHER_ICON_ACCESSIBLE (data);
+ self->priv->parent_focused = in;
+
+ /* we check the selection stuff again, to report the focus change
+ now */
+ check_selected (self);
+}
+
+/* AtkComponent.h */
+
+static void
+atk_component_interface_init (AtkComponentIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ /* focus management */
+ iface->add_focus_handler = unity_launcher_icon_accessible_add_focus_handler;
+ iface->remove_focus_handler = unity_launcher_icon_accessible_remove_focus_handler;
+
+ /* FIXME: still missing the size and position methods. Remember that
+ * this is not a nux::Area, and probably we would require to poke
+ * the Launcher to get those positions
+ */
+}
+
+/*
+ * comment C&P from cally-actor:
+ *
+ * "These methods are basically taken from gail, as I don't see any
+ * reason to modify it. It makes me wonder why it is really required
+ * to be implemented in the toolkit"
+ */
+
+static guint
+unity_launcher_icon_accessible_add_focus_handler (AtkComponent *component,
+ AtkFocusHandler handler)
+{
+ GSignalMatchType match_type;
+ gulong ret;
+ guint signal_id;
+
+ g_return_val_if_fail (UNITY_IS_LAUNCHER_ICON_ACCESSIBLE (component), 0);
+
+ match_type = (GSignalMatchType) (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC);
+ signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT);
+
+ ret = g_signal_handler_find (component, match_type, signal_id, 0, NULL,
+ (gpointer) handler, NULL);
+ if (!ret)
+ {
+ return g_signal_connect_closure_by_id (component,
+ signal_id, 0,
+ g_cclosure_new (G_CALLBACK (handler), NULL,
+ (GClosureNotify) NULL),
+ FALSE);
+ }
+ else
+ return 0;
}
+static void
+unity_launcher_icon_accessible_remove_focus_handler (AtkComponent *component,
+ guint handler_id)
+{
+ g_return_if_fail (NUX_IS_VIEW_ACCESSIBLE (component));
+
+ g_signal_handler_disconnect (component, handler_id);
+}
+
+static void
+unity_launcher_icon_accessible_focus_handler (AtkObject *accessible,
+ gboolean focus_in)
+{
+ g_return_if_fail (UNITY_IS_LAUNCHER_ICON_ACCESSIBLE (accessible));
+
+ g_debug ("[a11y] launcher_icon_focus_handler (%p:%s:%i)",
+ accessible, atk_object_get_name (accessible), focus_in);
+
+ atk_object_notify_state_change (accessible, ATK_STATE_FOCUSED, focus_in);
+}
diff --git a/src/unityshell.cpp b/src/unityshell.cpp
index 799fa3222..fd3452d23 100644
--- a/src/unityshell.cpp
+++ b/src/unityshell.cpp
@@ -30,6 +30,7 @@
#include "Launcher.h"
#include "LauncherIcon.h"
#include "LauncherController.h"
+#include "PlacesSettings.h"
#include "PluginAdapter.h"
#include "StartupNotifyService.h"
#include "unityshell.h"
@@ -253,6 +254,20 @@ UnityScreen::showPanelFirstMenuKeyTerminate (CompAction *action,
return false;
}
+bool
+UnityScreen::executeCommand (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ ubus_server_send_message (ubus_server_get_default (),
+ UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
+ g_variant_new ("(sus)",
+ "/com/canonical/unity/applicationsplace/runner",
+ 0,
+ ""));
+ return false;
+}
+
void
UnityScreen::restartLauncherKeyNav ()
{
@@ -555,9 +570,20 @@ UnityScreen::optionChanged (CompOption *opt,
break;
case UnityshellOptions::PanelOpacity:
panelView->SetOpacity (optionGetPanelOpacity ());
+ break;
+ case UnityshellOptions::IconSize:
+ panelHomeButton->SetButtonWidth (optionGetIconSize()+18);
+ launcher->SetIconSize (optionGetIconSize()+6, optionGetIconSize());
+ PlacesController::SetLauncherSize (optionGetIconSize()+18);
+
+ break;
case UnityshellOptions::AutohideAnimation:
launcher->SetAutoHideAnimation ((Launcher::AutoHideAnimation) optionGetAutohideAnimation ());
break;
+
+ case UnityshellOptions::DashBlurExperimental:
+ PlacesSettings::GetDefault ()->SetDashBlurType ((PlacesSettings::DashBlurType)optionGetDashBlurExperimental ());
+ break;
default:
break;
}
@@ -591,6 +617,8 @@ UnityScreen::Relayout ()
gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect);
_primary_monitor = rect;
+ wt->SetWindowSize (rect.width, rect.height);
+
pCurGeom = panelWindow->GetGeometry();
lCurGeom = launcherWindow->GetGeometry();
@@ -743,11 +771,14 @@ UnityScreen::UnityScreen (CompScreen *screen) :
optionSetLaunchAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
optionSetUrgentAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
optionSetPanelOpacityNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
+ optionSetIconSizeNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
optionSetAutohideAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
+ optionSetDashBlurExperimentalNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
optionSetShowLauncherInitiate (boost::bind (&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3));
optionSetShowLauncherTerminate (boost::bind (&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3));
optionSetKeyboardFocusInitiate (boost::bind (&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3));
//optionSetKeyboardFocusTerminate (boost::bind (&UnityScreen::setKeyboardFocusKeyTerminate, this, _1, _2, _3));
+ optionSetExecuteCommandInitiate (boost::bind (&UnityScreen::executeCommand, this, _1, _2, _3));
optionSetPanelFirstMenuInitiate (boost::bind (&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
optionSetPanelFirstMenuTerminate(boost::bind (&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
@@ -847,6 +878,8 @@ void UnityScreen::initLauncher (nux::NThread* thread, void* InitData)
self->panelView = new PanelView ();
self->AddChild (self->panelView);
+ self->panelHomeButton = self->panelView->HomeButton ();
+
layout = new nux::HLayout();
self->panelView->SetMaximumHeight(24);
@@ -874,6 +907,11 @@ void UnityScreen::initLauncher (nux::NThread* thread, void* InitData)
/* Setup Places */
self->placesController = new PlacesController ();
+ /* FIXME: this should not be manual, should be managed with a
+ show/hide callback like in GAIL*/
+ if (unity_a11y_initialized () == TRUE)
+ unity_util_accessible_add_window (self->placesController->GetWindow ());
+
self->launcher->SetHideMode (Launcher::LAUNCHER_HIDE_DODGE_WINDOWS);
self->launcher->SetLaunchAnimation (Launcher::LAUNCH_ANIMATION_PULSE);
self->launcher->SetUrgentAnimation (Launcher::URGENT_ANIMATION_WIGGLE);
diff --git a/src/unityshell.h b/src/unityshell.h
index 9dade73c4..7188c4750 100644
--- a/src/unityshell.h
+++ b/src/unityshell.h
@@ -34,6 +34,7 @@
#include "Launcher.h"
#include "LauncherController.h"
#include "PanelView.h"
+#include "PanelHomeButton.h"
#include "PlacesController.h"
#include "DebugDBusInterface.h"
#include <Nux/WindowThread.h>
@@ -103,14 +104,19 @@ class UnityScreen :
showLauncherKeyTerminate (CompAction *action, CompAction::State state,
CompOption::Vector &options);
- bool
- showPanelFirstMenuKeyInitiate (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
+ bool
+ showPanelFirstMenuKeyInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
bool
showPanelFirstMenuKeyTerminate (CompAction *action,
CompAction::State state,
CompOption::Vector &options);
+
+ bool
+ executeCommand (CompAction* action,
+ CompAction::State state,
+ CompOption::Vector& options);
bool
setKeyboardFocusKeyInitiate (CompAction* action,
CompAction::State state,
@@ -193,6 +199,7 @@ class UnityScreen :
Launcher *launcher;
LauncherController *controller;
PanelView *panelView;
+ PanelHomeButton *panelHomeButton;
PlacesController *placesController;
nux::WindowThread *wt;
nux::BaseWindow *launcherWindow;
diff --git a/tests/TestPlaces.cpp b/tests/TestPlaces.cpp
index e021e544e..bc6eae076 100644
--- a/tests/TestPlaces.cpp
+++ b/tests/TestPlaces.cpp
@@ -46,6 +46,8 @@ public:
_combo = new nux::ComboBoxSimple (NUX_TRACKER_LOCATION);
_combo->SetMinimumWidth (150);
_combo->sigTriggered.connect (sigc::mem_fun (this, &TestApp::OnComboChangedFoRealz));
+ _combo->SetCanFocus (false);
+ g_debug ("can we focus? %s", _combo->CanFocus () ? "yes :(" : "no! :D");
layout->AddView (_combo, 0, nux::eCenter, nux::eFix);
_factory = PlaceFactory::GetDefault ();
diff --git a/unityshell.xml.in b/unityshell.xml.in
index a7927346c..f382f42f0 100644
--- a/unityshell.xml.in
+++ b/unityshell.xml.in
@@ -72,6 +72,11 @@
<_long>Set the keyboard-focus on the launcher so it can be navigated with the cursor-keys</_long>
<default>&lt;Alt&gt;F1</default>
</option>
+ <option name="execute_command" type="key">
+ <_short>Key to execute a command</_short>
+ <_long>Key to open a folder or execute a command</_long>
+ <default>&lt;Alt&gt;F2</default>
+ </option>
<option name="panel_first_menu" type="key">
<_short>Key to open the first panel menu</_short>
<_long>Open the first menu on the panel, allowing keyboard navigation thereafter.</_long>
@@ -144,6 +149,14 @@
<max>1.0</max>
<precision>0.01</precision>
</option>
+ <option name="icon_size" type="int">
+ <_short>Launcher icon size</_short>
+ <_long>The size of the launcher icons</_long>
+ <default>48</default>
+ <min>32</min>
+ <max>64</max>
+ <precision>1</precision>
+ </option>
<option name="autohide_animation" type="int">
<_short>Hide Animation</_short>
<_long>Animation played when the launcher is showing or hiding</_long>
@@ -163,6 +176,22 @@
<_name>Fade only</_name>
</desc>
</option>
+
+ <option name="dash_blur_experimental" type="int">
+ <_short>Dash Blur</_short>
+ <_long>Type of blur in the Dash</_long>
+ <min>0</min>
+ <max>1</max>
+ <default>0</default>
+ <desc>
+ <value>0</value>
+ <_name>No Blur</_name>
+ </desc>
+ <desc>
+ <value>1</value>
+ <_name>Static Blur</_name>
+ </desc>
+ </option>
</group>
</options>
</plugin>