diff options
| -rw-r--r-- | .bzrignore | 1 | ||||
| -rw-r--r-- | targets/mutter/plugin.vala | 15 | ||||
| -rw-r--r-- | targets/mutter/window-management.vala | 15 | ||||
| -rw-r--r-- | unity-private/Makefile.am | 1 | ||||
| -rw-r--r-- | unity-private/gesture/gesture-dispatcher-xcb-glue.c | 1 | ||||
| -rw-r--r-- | unity-private/launcher/quicklist-controller.vala | 10 | ||||
| -rw-r--r-- | unity-private/panel/panel-indicator-object-entry-view.vala | 174 | ||||
| -rw-r--r-- | unity-private/panel/panel-indicator-object-view.vala | 33 | ||||
| -rw-r--r-- | unity-private/places/places-default-renderer-group.vala | 7 | ||||
| -rw-r--r-- | unity-private/places/places-place-search-bar.vala | 49 | ||||
| -rw-r--r-- | unity-private/places/places-place-search-extra-action.vala | 220 | ||||
| -rw-r--r-- | unity-private/places/places-place.vala | 4 | ||||
| -rw-r--r-- | vapi/indicator.vapi | 1 |
13 files changed, 502 insertions, 29 deletions
diff --git a/.bzrignore b/.bzrignore index e79fe0171..b833f9d29 100644 --- a/.bzrignore +++ b/.bzrignore @@ -355,3 +355,4 @@ unity/unity-stripe-texture.c unity/unity-layered-bin.c unity-private/places/places-default-renderer-tiles.c unity-private/places/places-button.c +unity-private/panel/panel-divider.c diff --git a/targets/mutter/plugin.vala b/targets/mutter/plugin.vala index 9150968dc..f7cf13ba0 100644 --- a/targets/mutter/plugin.vala +++ b/targets/mutter/plugin.vala @@ -1407,16 +1407,19 @@ namespace Unity Idle.add (() => { if (win is Object) { - if (Utils.window_is_decorated (Mutter.MetaWindow.get_xwindow (win)) == false && Mutter.MetaWindow.is_maximized (win) == false) + bool decorated = Utils.window_is_decorated (Mutter.MetaWindow.get_xwindow (win)); + bool maximized = Mutter.MetaWindow.is_maximized (win); + + bool fullscreen; + win.get ("fullscreen", out fullscreen); + + if (!decorated && !maximized) { window.set_data (UNDECORATED_HINT, "%s".printf ("true")); } - else + else if (decorated && maximized && !fullscreen) { - if (Mutter.MetaWindow.is_maximized (win)) - { - Utils.window_set_decorations (Mutter.MetaWindow.get_xwindow (win), 0); - } + Utils.window_set_decorations (Mutter.MetaWindow.get_xwindow (win), 0); } } diff --git a/targets/mutter/window-management.vala b/targets/mutter/window-management.vala index 7e643a10d..c9ddd5e2a 100644 --- a/targets/mutter/window-management.vala +++ b/targets/mutter/window-management.vala @@ -134,20 +134,6 @@ namespace Unity this.plugin.plugin.minimize_completed (window); } - private bool force_activate () - { - if (this.last_mapped is Mutter.Window) - { - unowned Mutter.MetaWindow w = this.last_mapped.get_meta_window (); - unowned Mutter.MetaDisplay d = Mutter.MetaWindow.get_display (w); - - Mutter.MetaWindow.activate (this.last_mapped.get_meta_window (), - Mutter.MetaDisplay.get_current_time (d)); - } - - return false; - } - private void window_mapped (Plugin plugin, Mutter.Window window) { int type = window.get_window_type (); @@ -169,7 +155,6 @@ namespace Unity Mutter.MetaWindow.get_user_time ( window.get_meta_window ())); this.last_mapped = window; - Idle.add (this.force_activate); } Clutter.Animation anim = null; diff --git a/unity-private/Makefile.am b/unity-private/Makefile.am index d116a855d..87b63935d 100644 --- a/unity-private/Makefile.am +++ b/unity-private/Makefile.am @@ -107,6 +107,7 @@ places_sources = \ places/places-place.vala \ places/places-place-search-bar.vala \ places/places-place-search-entry.vala \ + places/places-place-search-extra-action.vala \ places/places-place-search-navigation.vala \ places/places-place-search-sections-bar.vala \ places/places-trash-controller.vala \ diff --git a/unity-private/gesture/gesture-dispatcher-xcb-glue.c b/unity-private/gesture/gesture-dispatcher-xcb-glue.c index 6ff336cfc..b39b3d8cf 100644 --- a/unity-private/gesture/gesture-dispatcher-xcb-glue.c +++ b/unity-private/gesture/gesture-dispatcher-xcb-glue.c @@ -96,7 +96,6 @@ unity_gesture_xcb_dispatcher_glue_init (GObject *object) /* Pots and */ grail_mask_set (mask, GRAIL_TYPE_EDRAG); - grail_mask_set (mask, GRAIL_TYPE_MDRAG); if (set_mask (connection, 0, 0, mask_len, (uint32_t*)mask)) { diff --git a/unity-private/launcher/quicklist-controller.vala b/unity-private/launcher/quicklist-controller.vala index 4dc6268b1..15ef188a7 100644 --- a/unity-private/launcher/quicklist-controller.vala +++ b/unity-private/launcher/quicklist-controller.vala @@ -199,6 +199,16 @@ namespace Unity.Launcher if (Unity.global_shell is Unity.Shell) Unity.global_shell.add_fullscreen_request (this); + if(menu.get_num_items() == 0) + { + // It can happen that the quicklist menu is requested and the menu was not previously filled with a label. + // In this case we fill the menu with the label first. + string label = attached_controller.name; + var menuitem = new QuicklistMenuItem.with_label (label); + menuitem.reactive = false; + menu.append (menuitem, false); + } + menu.close_on_leave = false; menu.set_detect_clicks (true); // grab the top menu diff --git a/unity-private/panel/panel-indicator-object-entry-view.vala b/unity-private/panel/panel-indicator-object-entry-view.vala index 89525eb3f..c8cf03c08 100644 --- a/unity-private/panel/panel-indicator-object-entry-view.vala +++ b/unity-private/panel/panel-indicator-object-entry-view.vala @@ -34,6 +34,8 @@ namespace Unity.Panel.Indicators private float last_width = 0; private float last_height = 0; + public bool skip; + public IndicatorObjectEntryView (Indicator.ObjectEntry _entry) { Object (entry:_entry, @@ -66,6 +68,8 @@ namespace Unity.Panel.Indicators bg.opacity = 0; bg.show (); + skip = false; + if (entry.image is Gtk.Image) { image = new Ctk.Image (22); @@ -91,12 +95,71 @@ namespace Unity.Panel.Indicators if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) { image.show (); + if (entry.label != null) + { + if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) + { + text.show (); + this.show (); + } + } + else + { + this.show (); + } } else { image.hide (); + if (entry.label != null) + { + if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) == 0) + { + text.hide (); + this.hide (); + } + } + else + { + this.hide (); + } + } + + if ((entry.image.get_flags () & Gtk.WidgetFlags.SENSITIVE) != 0) + { + this.reactive = true; + this.skip = false; + image.opacity = 255; + } + else + { + this.reactive = false; + this.skip = true; + image.opacity = 64; } + entry.image.notify["sensitive"].connect (() => + { + if ((entry.image.get_flags () & Gtk.WidgetFlags.SENSITIVE) != 0) + { + this.reactive = true; + this.skip = false; + image.animate (Clutter.AnimationMode.EASE_OUT_QUAD, + 200, + "opacity", + 255); + } + else + { + this.reactive = false; + this.skip = true; + image.animate (Clutter.AnimationMode.EASE_OUT_QUAD, + 200, + "opacity", + 64); + } + }); + entry.image.notify["visible"].connect (() => { if (entry.image != null) @@ -104,10 +167,34 @@ namespace Unity.Panel.Indicators if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) { image.show (); + if (entry.label != null) + { + if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) + { + text.show (); + this.show (); + } + } + else + { + this.show (); + } } else { image.hide (); + if (entry.label != null) + { + if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) == 0) + { + text.hide (); + this.hide (); + } + } + else + { + this.hide (); + } } } }); @@ -135,8 +222,8 @@ namespace Unity.Panel.Indicators { if (image.gicon is GLib.Icon) { - image.gicon = entry.image.gicon; - image.size = 22; + image.gicon = entry.image.gicon; + image.size = 22; } }); @@ -164,12 +251,71 @@ namespace Unity.Panel.Indicators if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) { text.show (); + if (entry.image != null) + { + if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) + { + image.show (); + this.show (); + } + } + else + { + this.show (); + } } else { text.hide (); + if (entry.image != null) + { + if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) == 0) + { + image.hide (); + this.hide (); + } + } + else + { + this.hide (); + } + } + + if ((entry.label.get_flags () & Gtk.WidgetFlags.SENSITIVE) != 0) + { + this.reactive = true; + this.skip = false; + text.opacity = 255; + } + else + { + this.reactive = false; + this.skip = true; + text.opacity = 64; } + entry.label.notify["sensitive"].connect (() => + { + if ((entry.label.get_flags () & Gtk.WidgetFlags.SENSITIVE) != 0) + { + this.reactive = true; + this.skip = false; + text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, + 200, + "opacity", + 255); + } + else + { + this.reactive = false; + this.skip = true; + text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, + 200, + "opacity", + 64); + } + }); + entry.label.notify["visible"].connect (() => { if (entry.label != null) @@ -177,10 +323,34 @@ namespace Unity.Panel.Indicators if ((entry.label.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) { text.show (); + if (entry.image != null) + { + if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0) + { + image.show (); + this.show (); + } + } + else + { + this.show (); + } } else { text.hide (); + if (entry.image != null) + { + if ((entry.image.get_flags () & Gtk.WidgetFlags.VISIBLE) == 0) + { + image.hide (); + this.hide (); + } + } + else + { + this.hide (); + } } } }); diff --git a/unity-private/panel/panel-indicator-object-view.vala b/unity-private/panel/panel-indicator-object-view.vala index 75b7ebe7d..0816efc89 100644 --- a/unity-private/panel/panel-indicator-object-view.vala +++ b/unity-private/panel/panel-indicator-object-view.vala @@ -57,6 +57,7 @@ namespace Unity.Panel.Indicators indicator_object.entry_added.connect (this.on_entry_added); indicator_object.entry_removed.connect (this.remove_entry); + indicator_object.menu_show.connect (on_menu_show); unowned GLib.List<Indicator.ObjectEntry> list = indicator_object.get_entries (); @@ -84,6 +85,19 @@ namespace Unity.Panel.Indicators */ } + public void on_menu_show (Indicator.ObjectEntry entry, uint timestamp) + { + foreach (IndicatorObjectEntryView view in indicator_entry_array) + { + var s = (view.entry.label is Gtk.Label) ? entry.label.label : ""; + if (view.entry == entry) + { + view.show_menu (); + break; + } + } + } + private void on_menu_moved (IndicatorObjectEntryView object_entry_view, Gtk.MenuDirectionType type) { if (type != Gtk.MenuDirectionType.PARENT && @@ -114,6 +128,25 @@ namespace Unity.Panel.Indicators } IndicatorObjectEntryView next_object_entry_view = this.indicator_entry_array.get (pos); + if (next_object_entry_view.skip) + { + if (type == Gtk.MenuDirectionType.PARENT) + { + if (pos == 0) + next_object_entry_view = this.indicator_entry_array.get (this.indicator_entry_array.size - 1); + else + next_object_entry_view = this.indicator_entry_array.get (pos-1); + + } + else if (type == Gtk.MenuDirectionType.CHILD) + { + if (pos == this.indicator_entry_array.size - 1) + next_object_entry_view = this.indicator_entry_array.get (0); + else + next_object_entry_view = this.indicator_entry_array.get (pos+1); + } + } + next_object_entry_view.show_menu (); /* Signal to be picked up by IndicatorBar */ //this.menu_moved (type); diff --git a/unity-private/places/places-default-renderer-group.vala b/unity-private/places/places-default-renderer-group.vala index 1e896bfb5..8c900854c 100644 --- a/unity-private/places/places-default-renderer-group.vala +++ b/unity-private/places/places-default-renderer-group.vala @@ -284,6 +284,7 @@ namespace Unity.Places results.get_string (iter, 5)); button.iter = iter; cleanup_tiles.remove (button); + button.unref (); /* Because Vala holds references when it shouldn't*/; } else if (group_renderer == "UnityFileInfoRenderer") { @@ -296,7 +297,7 @@ namespace Unity.Places renderer.add_actor (button); button.show (); - button.unref (); /* Because Vala sucks and holds references when it shouldn't*/; + button.unref (); /* Because Vala holds references when it shouldn't*/; button.activated.connect ((u, m) => { activated (u, m); }); } else if (group_renderer == "UnityShowcaseRenderer") @@ -309,7 +310,7 @@ namespace Unity.Places results.get_string (iter, 5)); renderer.add_actor (button); button.show (); - button.unref (); /* Because Vala sucks and holds references when it shouldn't*/; + button.unref (); /* Because Vala holds references when it shouldn't*/; button.activated.connect ((u, m) => { activated (u, m); }); } @@ -323,7 +324,7 @@ namespace Unity.Places results.get_string (iter, 5)); renderer.add_actor (button); button.show (); - button.unref (); /* Because Vala sucks and holds references when it shouldn't*/; + button.unref (); /* Because Vala holds references when it shouldn't*/; button.activated.connect ((u, m) => { activated (u, m); }); } diff --git a/unity-private/places/places-place-search-bar.vala b/unity-private/places/places-place-search-bar.vala index b07434ae6..a467bc064 100644 --- a/unity-private/places/places-place-search-bar.vala +++ b/unity-private/places/places-place-search-bar.vala @@ -32,6 +32,7 @@ namespace Unity.Places private PlaceSearchNavigation navigation; public PlaceSearchEntry entry; public PlaceSearchSectionsBar sections; + public PlaceSearchExtraAction extra_action; public PlaceSearchBar () { @@ -63,7 +64,17 @@ namespace Unity.Places sections = new PlaceSearchSectionsBar (); pack (sections, false, true); - entry.show (); + sections.show (); + + /* We need a dummy to be able to space the action label */ + var space = new Clutter.Rectangle.with_color ({255, 255, 255, 0}); + pack (space, true, true); + space.show (); + + extra_action = new PlaceSearchExtraAction (); + pack (extra_action, false, true); + extra_action.hide (); /* hidden by default */ + extra_action.activated.connect (on_extra_action_activated); bg = new PlaceSearchBarBackground (navigation, entry); set_background (bg); @@ -126,6 +137,30 @@ namespace Unity.Places active_entry.set_search (text, hints); } } + + private void on_extra_action_activated () + { + if (active_entry is PlaceEntry) + { + /* The UnityExtraAction spec mandates that we send the special URI + * "." when the extra action is triggered */ + ActivationStatus result = active_entry.parent.activate (".", ""); + + switch (result) + { + case ActivationStatus.ACTIVATED_SHOW_DASH: + break; + case ActivationStatus.NOT_ACTIVATED: + case ActivationStatus.ACTIVATED_HIDE_DASH: + case ActivationStatus.ACTIVATED_FALLBACK: + global_shell.hide_unity (); + break; + default: + warning ("Unexpected activation status: %u", result); + break; + } + } + } /* * Public Methods @@ -146,6 +181,18 @@ namespace Unity.Places navigation.set_active_entry (entry); this.entry.set_active_entry (entry); this.entry.text.grab_key_focus (); + + if (entry.hints != null) + { + if (entry.hints["UnityExtraAction"] != null) + { + extra_action.set_icon_from_gicon_string ( + entry.hints["UnityExtraAction"]); + extra_action.show (); + } + else + extra_action.hide (); + } } } diff --git a/unity-private/places/places-place-search-extra-action.vala b/unity-private/places/places-place-search-extra-action.vala new file mode 100644 index 000000000..5f284b793 --- /dev/null +++ b/unity-private/places/places-place-search-extra-action.vala @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2010 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by + * Neil Jagdish Patel <neil.patel@canonical.com> + * Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> + * + */ + +using Unity; + +namespace Unity.Places +{ + public class PlaceSearchExtraAction : Ctk.Bin + { + static const float PADDING = 4.0f; + + private CairoCanvas bg; + public Ctk.Image image; + private Clutter.Color color; + private Ctk.EffectGlow glow; + + public float destroy_factor { + get { return _destroy_factor; } + set { _destroy_factor = value; queue_relayout (); } + } + + public float resize_factor { + get { return _resize_factor; } + set { _resize_factor = value; queue_relayout (); } + } + + public signal void activated (); + + private float _destroy_factor = 1.0f; + private float _resize_factor = 1.0f; + private float _last_width = 0.0f; + private float _resize_width = 0.0f; + + public PlaceSearchExtraAction () + { + Object (reactive:true); + } + + construct + { + color.alpha = 255; + + padding = { PADDING, PADDING, PADDING, PADDING }; + + bg = new CairoCanvas (paint_bg); + set_background (bg); + bg.show (); + + glow = new Ctk.EffectGlow (); + glow.set_color ({ 255, 255, 255, 255 }); + glow.set_factor (1.0f); + glow.set_margin (5); + //add_effect (glow); + + image = new Ctk.Image (22); + add_actor (image); + image.show (); + } + + public void set_icon_from_gicon_string (string icon_string) + { + PixbufCache.get_default ().set_image_from_gicon_string (image, + icon_string, + 22); + glow.set_invalidate_effect_cache (true); + } + + private override void get_preferred_width (float for_height, + out float min_width, + out float nat_width) + { + float mw, nw; + + base.get_preferred_width (for_height, out mw, out nw); + + min_width = (mw + padding.right + padding.left) * _destroy_factor; + nat_width = (nw + padding.right + padding.left) * _destroy_factor; + + if (_last_width ==0.0f) + _last_width = nat_width; + + if (_last_width != nat_width && _resize_factor == 1.0) + { + _resize_factor = 0.0f; + animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, + "resize_factor", 1.0f); + + _resize_width = _last_width; + _last_width = nat_width; + } + + if (_resize_factor != 1.0f) + { + min_width = _resize_width + ((min_width - _resize_width) * _resize_factor); + nat_width = _resize_width + ((nat_width - _resize_width) * _resize_factor); + } + } + + private override bool enter_event (Clutter.Event e) + { + state = Ctk.ActorState.STATE_PRELIGHT; + bg.update (); + return true; + } + + private override bool leave_event (Clutter.Event e) + { + state = Ctk.ActorState.STATE_NORMAL; + bg.update (); + return true; + } + + private override bool button_press_event (Clutter.Event e) + { + state = Ctk.ActorState.STATE_SELECTED; + bg.update (); + return false; + } + + private override bool button_release_event (Clutter.Event e) + { + state = Ctk.ActorState.STATE_PRELIGHT; + bg.update (); + activated (); + return false; + } + + private void paint_bg (Cairo.Context cr, int width, int height) + { + cr.set_operator (Cairo.Operator.CLEAR); + cr.paint (); + + cr.set_operator (Cairo.Operator.OVER); + cr.set_line_width (1.5); + cr.set_source_rgba (1.0, 1.0, 1.0, 0.0); + + cr.translate (0.5, 0.5); + + var x = 0; + var y = 0; + width -= 1; + height -= 1; + var radius = 10; + + cr.move_to (x, y + radius); + cr.curve_to (x, y, + x, y, + x + radius, y); + cr.line_to (width - radius, y); + cr.curve_to (width, y, + width, y, + width, y + radius); + cr.line_to (width, height - radius); + cr.curve_to (width, height, + width, height, + width - radius, height); + cr.line_to (x + radius, height); + cr.curve_to (x, height, + x, height, + x, height - radius); + cr.close_path (); + + if (state == Ctk.ActorState.STATE_SELECTED) + { + cr.set_source_rgba (1.0, 1.0, 1.0, 1.0); + } + else if (state == Ctk.ActorState.STATE_PRELIGHT) + { + var pattern = new Cairo.Surface.similar (cr.get_target (), + Cairo.Content.COLOR_ALPHA, + 4, 4); + var context = new Cairo.Context (pattern); + + context.set_operator (Cairo.Operator.CLEAR); + context.paint (); + + context.set_line_width (0.2); + context.set_operator (Cairo.Operator.OVER); + context.set_source_rgba (1.0, 1.0, 1.0, 0.85); + + context.move_to (0, 0); + context.line_to (4, 4); + + context.stroke (); + + var pat = new Cairo.Pattern.for_surface (pattern); + pat.set_extend (Cairo.Extend.REPEAT); + cr.set_source (pat); + } + else + { + cr.set_source_rgba (1.0, 1.0, 1.0, 0.0); + } + + cr.fill_preserve (); + + cr.set_source_rgba (1.0, 1.0, 1.0, + state == Ctk.ActorState.STATE_NORMAL ? 0.0 : 0.5); + cr.stroke (); + } + } +} diff --git a/unity-private/places/places-place.vala b/unity-private/places/places-place.vala index 105450dbf..75cdb65c8 100644 --- a/unity-private/places/places-place.vala +++ b/unity-private/places/places-place.vala @@ -217,7 +217,9 @@ namespace Unity.Places { bool remote_activation = false; - if (uri_regex != null && uri_regex.match (uri)) + if (uri == ".") + remote_activation = true; + else if (uri_regex != null && uri_regex.match (uri)) remote_activation = true; else if (mime_regex != null && mime_regex.match (mimetype)) remote_activation = true; diff --git a/vapi/indicator.vapi b/vapi/indicator.vapi index 548c0ae72..448d85133 100644 --- a/vapi/indicator.vapi +++ b/vapi/indicator.vapi @@ -32,6 +32,7 @@ namespace Indicator { public virtual signal void entry_moved (Indicator.ObjectEntry entry, uint old_pos, uint new_pos); public virtual signal void entry_removed (Indicator.ObjectEntry entry); public virtual signal void scroll (uint delta, Indicator.ScrollDirection direction); + public virtual signal void menu_show (Indicator.ObjectEntry entry, uint timestamp); } [Compact] [CCode (cheader_filename = "gtk/gtk.h,libindicator/indicator.h,libindicator/indicator-object.h,libindicator/indicator-service.h,libindicator/indicator-service-manager.h")] |
