Skip to content
Closed
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
15 changes: 12 additions & 3 deletions src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}
}
}
Expand Down Expand Up @@ -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;
}
});
Comment on lines +132 to +140

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks more complicated than before. Why is this necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember what I was doing here. Gonna draft these and break up individual changes

}
}
75 changes: 30 additions & 45 deletions src/Widgets/IndicatorEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string, int> indicator_order = new Gee.HashMap<string,int> ();

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,
Expand Down Expand Up @@ -77,87 +72,77 @@ 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)) {
popover_manager.current_indicator = this;
}
});

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 () {
base_indicator.get_display_widget ().unmap.disconnect (indicator_unmapped);
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;
Expand Down
3 changes: 0 additions & 3 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down