diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index c7533f44..0d22c85c 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -60,9 +60,6 @@ public class Wingpanel.Services.PopoverManager : Object { popover.popup (); _current_indicator.set_state_flags (CHECKED, true); _current_indicator.base_indicator.opened (); - } else { - update_has_tooltip (((Wingpanel.Widgets.IndicatorEntry)popover.parent).display_widget); - popover.popdown (); } } } @@ -129,5 +126,17 @@ public class Wingpanel.Services.PopoverManager : Object { } registered_indicators.set (widg.base_indicator.code_name, widg); + + widg.base_indicator.close.connect (close); + + widg.base_indicator.notify["visible"].connect (() => { + /* order will be changed so close all open popovers */ + popover.popdown (); + + if (!widg.base_indicator.visible && get_visible (widg)) { + current_indicator = null; + widg.display_widget.has_tooltip = true; + } + }); } } diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index c5a81404..2a5dc8ec 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -24,7 +24,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin { public Indicator base_indicator { get; construct; } public Services.PopoverManager popover_manager { get; construct; } - public IndicatorBar? indicator_bar; + public IndicatorBar? indicator_bar { get; set; } public Gtk.Widget display_widget { get; private set; } private Gtk.Widget _indicator_widget = null; @@ -41,11 +41,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin { /* The order in which the indicators are shown from left to right. */ private static Gee.HashMap indicator_order = new Gee.HashMap (); - private Gtk.Revealer revealer; - - private Gtk.GestureClick gesture_controller; - private Gtk.EventControllerMotion motion_controller; - public IndicatorEntry (Indicator base_indicator, Services.PopoverManager popover_manager) { Object ( base_indicator: base_indicator, @@ -77,60 +72,59 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin { construct { display_widget = base_indicator.get_display_widget (); - halign = Gtk.Align.START; name = base_indicator.code_name + "/entry"; if (display_widget == null) { return; } - revealer = new Gtk.Revealer () { + var revealer = new Gtk.Revealer () { child = display_widget }; revealer.add_css_class ("composited-indicator"); + switch (base_indicator.code_name) { + case Indicator.APP_LAUNCHER: + revealer.transition_type = SLIDE_RIGHT; + break; + case Indicator.DATETIME: + revealer.transition_type = SLIDE_DOWN; + break; + default: + revealer.transition_type = SLIDE_LEFT; + break; + } + child = revealer; if (base_indicator.visible) { popover_manager.register_indicator (this); } - base_indicator.close.connect (() => { - popover_manager.close (); - }); - base_indicator.notify["visible"].connect (() => { - if (indicator_bar != null) { - /* order will be changed so close all open popovers */ - popover_manager.close (); - - if (base_indicator.visible) { - popover_manager.register_indicator (this); - indicator_bar.insert_sorted (this); - set_reveal (base_indicator.visible); - } else { - set_reveal (base_indicator.visible); - popover_manager.unregister_indicator (this); - // reorder indicators when indicator is invisible - display_widget.unmap.connect (indicator_unmapped); - } + if (indicator_bar == null) { + return; + } + + if (base_indicator.visible) { + popover_manager.register_indicator (this); + indicator_bar.insert_sorted (this); } else { - set_reveal (base_indicator.visible); + popover_manager.unregister_indicator (this); + // reorder indicators when indicator is invisible + display_widget.unmap.connect (indicator_unmapped); } }); - gesture_controller = new Gtk.GestureClick (); - add_controller (gesture_controller); + var gesture_controller = new Gtk.GestureClick (); gesture_controller.pressed.connect (() => { popover_manager.current_indicator = this; gesture_controller.set_state (CLAIMED); }); - motion_controller = new Gtk.EventControllerMotion () { + var motion_controller = new Gtk.EventControllerMotion () { propagation_phase = CAPTURE }; - add_controller (motion_controller); - motion_controller.enter.connect (() => { // If something is open and it's not us, open us. This implements the scrubbing behavior if (popover_manager.current_indicator != null && !popover_manager.get_visible (this)) { @@ -138,7 +132,10 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin { } }); - set_reveal (base_indicator.visible); + add_controller (gesture_controller); + add_controller (motion_controller); + + base_indicator.bind_property ("visible", revealer, "reveal-child", SYNC_CREATE); } private void indicator_unmapped () { @@ -146,18 +143,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin { indicator_bar.remove (this); } - public void set_transition_type (Gtk.RevealerTransitionType transition_type) { - revealer.set_transition_type (transition_type); - } - - private void set_reveal (bool reveal) { - if (!reveal && popover_manager.get_visible (this)) { - popover_manager.current_indicator = null; - } - - revealer.set_reveal_child (reveal); - } - public static int compare_func (Wingpanel.Widgets.IndicatorEntry? a, Wingpanel.Widgets.IndicatorEntry? b) { if (a == null) { return (b == null) ? 0 : -1; diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index 999f3cdf..b5f8b6d3 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -163,15 +163,12 @@ public class Wingpanel.Widgets.Panel : Granite.Bin { switch (indicator.code_name) { case Indicator.APP_LAUNCHER: - indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_RIGHT); left_menubar.insert_sorted (indicator_entry); break; case Indicator.DATETIME: - indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_DOWN); center_menubar.insert_sorted (indicator_entry); break; default: - indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_LEFT); right_menubar.insert_sorted (indicator_entry); break; }