Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class Wingpanel.PanelWindow : Gtk.Window {
}

public void toggle_indicator (string name) {
popover_manager.toggle_popover_visible (name);
panel.toggle_indicator (name);
}

public void registry_handle_global (Wl.Registry wl_registry, uint32 name, string @interface, uint32 version) {
Expand Down
25 changes: 1 addition & 24 deletions src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
public class Wingpanel.Services.PopoverManager : Object {
public bool indicator_open { get; private set; default = false; }

private Gee.HashMap<string, Wingpanel.Widgets.IndicatorEntry> registered_indicators;
private Gtk.Popover popover;
private Wingpanel.Widgets.IndicatorEntry? _current_indicator = null;
public Wingpanel.Widgets.IndicatorEntry? current_indicator {
Expand Down Expand Up @@ -67,9 +66,7 @@ public class Wingpanel.Services.PopoverManager : Object {
}
}

public PopoverManager () {
registered_indicators = new Gee.HashMap<string, Wingpanel.Widgets.IndicatorEntry> ();

construct {
popover = new Gtk.Popover () {
has_arrow = false,
position = BOTTOM
Expand All @@ -83,12 +80,6 @@ public class Wingpanel.Services.PopoverManager : Object {
});
}

public void toggle_popover_visible (string code_name) {
if (registered_indicators.has_key (code_name)) {
current_indicator = registered_indicators.get (code_name);
}
}

public bool get_visible (Wingpanel.Widgets.IndicatorEntry entry) {
return current_indicator != null && current_indicator.base_indicator.code_name == entry.base_indicator.code_name;
}
Expand All @@ -104,18 +95,4 @@ public class Wingpanel.Services.PopoverManager : Object {
current_indicator = null;
}
}

public void unregister_indicator (Wingpanel.Widgets.IndicatorEntry? widg) {
if (registered_indicators.has_key (widg.base_indicator.code_name)) {
registered_indicators.unset (widg.base_indicator.code_name);
}
}

public void register_indicator (Wingpanel.Widgets.IndicatorEntry? widg) {
if (registered_indicators.has_key (widg.base_indicator.code_name)) {
return;
}

registered_indicators.set (widg.base_indicator.code_name, widg);
}
}
12 changes: 1 addition & 11 deletions src/Widgets/IndicatorEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {

child = revealer;

if (base_indicator.visible) {
popover_manager.register_indicator (this);
}

base_indicator.close.connect (() => {
popover_manager.close ();
});
Expand All @@ -120,13 +116,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {
/* order will be changed so close all open popovers */
popover_manager.close ();

if (base_indicator.visible) {
popover_manager.register_indicator (this);
set_reveal (base_indicator.visible);
} else {
popover_manager.unregister_indicator (this);
set_reveal (base_indicator.visible);
}
set_reveal (base_indicator.visible);
});

var gesture_controller = new Gtk.GestureClick ();
Expand Down
10 changes: 10 additions & 0 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,14 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
private static bool right_indicators_filter_func (Object item) requires (item is IndicatorEntry) {
return !left_indicators_filter_func (item) && !center_indicators_filter_func (item);
}

public void toggle_indicator (string name) {
for (var i = 0; i < visible_indicator_entries.get_n_items (); i++) {
var indicator_entry = (IndicatorEntry) visible_indicator_entries.get_item (i);
if (indicator_entry.base_indicator.code_name == name) {
popover_manager.current_indicator = indicator_entry;
break;
}
}
}
}