Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IndicatorMenuBar #451

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ src/Services/BackgroundManager.vala
src/Services/IndicatorSorter.vala
src/Services/PopoverManager.vala
src/Widgets/IndicatorEntry.vala
src/Widgets/IndicatorMenuBar.vala
src/Widgets/IndicatorPopover.vala
src/Widgets/Panel.vala
4 changes: 1 addition & 3 deletions src/Widgets/IndicatorEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem {
public Indicator base_indicator { get; construct; }
public Services.PopoverManager popover_manager { get; construct; }

public IndicatorMenuBar? menu_bar;
public Gtk.MenuBar? menu_bar;
public Gtk.Widget display_widget { get; private set; }

private Gtk.Widget _indicator_widget = null;
Expand Down Expand Up @@ -78,7 +78,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem {

if (base_indicator.visible) {
popover_manager.register_indicator (this);
menu_bar.apply_new_order ();
set_reveal (base_indicator.visible);
} else {
set_reveal (base_indicator.visible);
Expand Down Expand Up @@ -126,7 +125,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.MenuItem {

private void indicator_unmapped () {
base_indicator.get_display_widget ().unmap.disconnect (indicator_unmapped);
menu_bar.apply_new_order ();
}

public void set_transition_type (Gtk.RevealerTransitionType transition_type) {
Expand Down
82 changes: 0 additions & 82 deletions src/Widgets/IndicatorMenuBar.vala

This file was deleted.

58 changes: 55 additions & 3 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
public class Wingpanel.Widgets.Panel : Gtk.EventBox {
public Services.PopoverManager popover_manager { get; construct; }

private IndicatorMenuBar right_menubar;
private Gtk.MenuBar right_menubar;
private Gtk.MenuBar left_menubar;
private Gtk.MenuBar center_menubar;

private Gee.List<IndicatorEntry> sorted_items;
private Services.IndicatorSorter sorter = new Services.IndicatorSorter ();
private uint apply_new_order_idle_id = 0;

private unowned Gtk.StyleContext style_context;
private Gtk.CssProvider? style_provider = null;

Expand All @@ -44,6 +48,8 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox {
vexpand = true;
valign = Gtk.Align.START;

sorted_items = new Gee.ArrayList<IndicatorEntry> ();

left_menubar = new Gtk.MenuBar () {
can_focus = true,
halign = Gtk.Align.START
Expand All @@ -55,7 +61,7 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox {
};
center_menubar.get_style_context ().add_provider (resource_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

right_menubar = new IndicatorMenuBar () {
right_menubar = new Gtk.MenuBar () {
can_focus = true,
halign = Gtk.Align.END
};
Expand Down Expand Up @@ -83,6 +89,14 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox {
style_context.add_provider (resource_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

Services.BackgroundManager.get_default ().background_state_changed.connect (update_background);

right_menubar.remove.connect ((widget) => {
var indicator_widget = widget as IndicatorEntry;

if (indicator_widget != null) {
sorted_items.remove (indicator_widget);
}
});
}

public override bool button_press_event (Gdk.EventButton event) {
Expand Down Expand Up @@ -257,17 +271,55 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox {
break;
default:
indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_LEFT);
right_menubar.insert_sorted (indicator_entry);
insert_sorted (indicator_entry);
break;
}

indicator_entry.show_all ();
}

private void insert_sorted (IndicatorEntry item) {
foreach (var indicator in sorted_items) {
if (item.base_indicator.code_name == indicator.base_indicator.code_name) {
return; /* item already added */
}
}

item.menu_bar = right_menubar;

sorted_items.add (item);
sorted_items.sort (sorter.compare_func);

apply_new_order ();
}

private void apply_new_order () {
if (apply_new_order_idle_id > 0) {
GLib.Source.remove (apply_new_order_idle_id);
apply_new_order_idle_id = 0;
}

apply_new_order_idle_id = GLib.Idle.add_full (GLib.Priority.LOW, () => {
foreach (unowned var child in right_menubar.get_children ()) {
right_menubar.remove (child);
}

foreach (var widget in sorted_items) {
if (widget.base_indicator.visible) {
right_menubar.append (widget);
}
}

apply_new_order_idle_id = 0;
return false;
});
}

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);
apply_new_order ();
}

private void remove_indicator_from_container (Gtk.Container container, Indicator indicator) {
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ wingpanel_files = files(
'Services/IndicatorSorter.vala',
'Services/PopoverManager.vala',
'Widgets/IndicatorEntry.vala',
'Widgets/IndicatorMenuBar.vala',
'Widgets/IndicatorPopover.vala',
'Widgets/Panel.vala',
'Widgets/StyleClass.vala',
Expand Down