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
17 changes: 6 additions & 11 deletions src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ public class Wingpanel.Services.PopoverManager : Object {
}

if (_current_indicator == null && value != null) { // First open
indicator_open = true;
_current_indicator = value;
indicator_open = true;
} else if (value == null && _current_indicator != null) { // Close requested
indicator_open = false;
_current_indicator.base_indicator.closed ();
_current_indicator.set_state_flags (NORMAL, true);
_current_indicator = null;
} else if (_current_indicator.base_indicator.code_name == value.base_indicator.code_name) { // Close due to toggle
_current_indicator.set_state_flags (NORMAL, true);
_current_indicator.display_widget.has_tooltip = true;
_current_indicator.base_indicator.closed ();
_current_indicator = null;
popover.popdown ();
indicator_open = false;
} else { // Switch
_current_indicator.set_state_flags (NORMAL, true);
_current_indicator.display_widget.has_tooltip = true;
Expand All @@ -55,14 +53,12 @@ public class Wingpanel.Services.PopoverManager : Object {

if (_current_indicator != null) {
popover.child = _current_indicator.indicator_widget;
_current_indicator.display_widget.has_tooltip = false;
popover.set_parent (_current_indicator);
popover.popup ();

_current_indicator.set_state_flags (CHECKED, true);
_current_indicator.display_widget.has_tooltip = false;
_current_indicator.base_indicator.opened ();
} else {
((Widgets.IndicatorEntry)popover.parent).display_widget.has_tooltip = true;
popover.popdown ();
}
}
}
Expand All @@ -75,7 +71,6 @@ public class Wingpanel.Services.PopoverManager : Object {
popover.add_css_class ("indicator");

popover.closed.connect (() => {
_current_indicator.set_state_flags (NORMAL, true);
current_indicator = null;
popover.unparent ();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/IndicatorEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {
add_controller (gesture_controller);

gesture_controller.pressed.connect ((_gesture_controller, n_press, x, y) => {
popover_manager.current_indicator = this;
popover_manager.current_indicator = popover_manager.current_indicator == this ? null : this;
_gesture_controller.set_state (CLAIMED);
});

Expand Down
9 changes: 8 additions & 1 deletion src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,19 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
}

public void toggle_indicator (string name) {
IndicatorEntry? indicator_entry_to_toggle = null;
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;
indicator_entry_to_toggle = indicator_entry;
break;
}
}

popover_manager.current_indicator = (
popover_manager.current_indicator == indicator_entry_to_toggle ?
null :
indicator_entry_to_toggle
);
}
}
Loading