diff --git a/src/Widgets/IndicatorMenuBar.vala b/src/Widgets/IndicatorBar.vala similarity index 78% rename from src/Widgets/IndicatorMenuBar.vala rename to src/Widgets/IndicatorBar.vala index e0f73505..1e56c9e2 100644 --- a/src/Widgets/IndicatorMenuBar.vala +++ b/src/Widgets/IndicatorBar.vala @@ -17,16 +17,18 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.IndicatorMenuBar : Gtk.MenuBar { +public class Wingpanel.Widgets.IndicatorBar : Gtk.Box { private Gee.List sorted_items; private Services.IndicatorSorter sorter = new Services.IndicatorSorter (); construct { sorted_items = new Gee.ArrayList (); + + spacing = 6; } public void insert_sorted (IndicatorEntry item) { - item.menu_bar = this; + item.indicator_bar = this; if (!(item in sorted_items)) { sorted_items.add (item); @@ -46,18 +48,18 @@ public class Wingpanel.Widgets.IndicatorMenuBar : Gtk.MenuBar { } if (item.get_parent () != this) { - this.insert (item, index); + add (item); + reorder_child (item, index); } } } - public override void remove (Gtk.Widget widget) { - var indicator_widget = widget as IndicatorEntry; - - if (indicator_widget != null) { - sorted_items.remove (indicator_widget); + public void remove_indicator (Indicator indicator) { + foreach (var entry in sorted_items) { + if (entry.base_indicator.code_name == indicator.code_name) { + sorted_items.remove (entry); + remove (entry); + } } - - base.remove (widget); } } diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index 9c020a4f..61efefbb 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -17,11 +17,11 @@ * Boston, MA 02110-1301 USA. */ -public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem { +public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { public Indicator base_indicator { get; construct; } public Services.PopoverManager popover_manager { get; construct; } - public IndicatorMenuBar? menu_bar; + public IndicatorBar? indicator_bar; public Gtk.Widget display_widget { get; private set; } private Gtk.Widget _indicator_widget = null; @@ -69,13 +69,13 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem { }); base_indicator.notify["visible"].connect (() => { - if (menu_bar != null) { + 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); - menu_bar.insert_sorted (this); + indicator_bar.insert_sorted (this); set_reveal (base_indicator.visible); } else { set_reveal (base_indicator.visible); @@ -124,7 +124,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem { private void indicator_unmapped () { base_indicator.get_display_widget ().unmap.disconnect (indicator_unmapped); - menu_bar.remove (this); + indicator_bar.remove (this); } public void set_transition_type (Gtk.RevealerTransitionType transition_type) { diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index 9c03adab..1f27e783 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -20,9 +20,9 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { public Services.PopoverManager popover_manager { get; construct; } - private IndicatorMenuBar right_menubar; - private Gtk.MenuBar left_menubar; - private Gtk.MenuBar center_menubar; + private IndicatorBar right_menubar; + private IndicatorBar left_menubar; + private IndicatorBar center_menubar; private unowned Gtk.StyleContext style_context; private Gtk.CssProvider? style_provider = null; @@ -39,20 +39,16 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { height_request = 30; hexpand = true; vexpand = true; - valign = Gtk.Align.START; + valign = START; - left_menubar = new Gtk.MenuBar () { - can_focus = true, - halign = Gtk.Align.START + left_menubar = new IndicatorBar () { + halign = START }; - center_menubar = new Gtk.MenuBar () { - can_focus = true - }; + center_menubar = new IndicatorBar (); - right_menubar = new IndicatorMenuBar () { - can_focus = true, - halign = Gtk.Align.END + right_menubar = new IndicatorBar () { + halign = END }; var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); @@ -78,6 +74,10 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } public override bool button_press_event (Gdk.EventButton event) { + if (Utils.is_wayland ()) { + return Gdk.EVENT_PROPAGATE; + } + if (event.button != Gdk.BUTTON_PRIMARY) { return Gdk.EVENT_PROPAGATE; } @@ -257,21 +257,9 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox { } private void remove_indicator (Indicator indicator) { - remove_indicator_from_container (left_menubar, indicator); - remove_indicator_from_container (center_menubar, indicator); - remove_indicator_from_container (right_menubar, indicator); - } - - private void remove_indicator_from_container (Gtk.Container container, Indicator indicator) { - foreach (unowned Gtk.Widget child in container.get_children ()) { - unowned IndicatorEntry? entry = (child as IndicatorEntry); - - if (entry != null && entry.base_indicator == indicator) { - container.remove (child); - - return; - } - } + left_menubar.remove_indicator (indicator); + center_menubar.remove_indicator (indicator); + right_menubar.remove_indicator (indicator); } private void update_background (Services.BackgroundState state, uint animation_duration) { diff --git a/src/meson.build b/src/meson.build index d9ca1250..5454be03 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,7 +7,7 @@ wingpanel_files = files( 'Services/IndicatorSorter.vala', 'Services/PopoverManager.vala', 'Widgets/IndicatorEntry.vala', - 'Widgets/IndicatorMenuBar.vala', + 'Widgets/IndicatorBar.vala', 'Widgets/IndicatorPopover.vala', 'Widgets/Panel.vala' )