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
8 changes: 5 additions & 3 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public class Wingpanel.Application : Gtk.Application {
panel_window = new PanelWindow (this);
panel_window.present ();

var popover_manager = Services.PopoverManager.get_default ();

var list_indicators_action = new SimpleAction.stateful (LIST_INDICATORS_ACTION_NAME, null, new Variant.strv (list_indicators ()));

var indicator_manager = IndicatorManager.get_default ();
Expand All @@ -122,17 +124,17 @@ public class Wingpanel.Application : Gtk.Application {

var open_indicator_action = new SimpleAction (OPEN_INDICATOR_ACTION_NAME, VariantType.STRING);
open_indicator_action.activate.connect ((parameter) => {
panel_window.popover_manager.set_popover_visible (parameter.get_string (), true);
popover_manager.set_popover_visible (parameter.get_string (), true);
});

var close_indicator_action = new SimpleAction (CLOSE_INDICATOR_ACTION_NAME, VariantType.STRING);
close_indicator_action.activate.connect ((parameter) => {
panel_window.popover_manager.set_popover_visible (parameter.get_string (), false);
popover_manager.set_popover_visible (parameter.get_string (), false);
});

var toggle_indicator_action = new SimpleAction (TOGGLE_INDICATOR_ACTION_NAME, VariantType.STRING);
toggle_indicator_action.activate.connect ((parameter) => {
panel_window.toggle_indicator (parameter.get_string ());
popover_manager.toggle_popover_visible (parameter.get_string ());
});

add_action (list_indicators_action);
Expand Down
10 changes: 2 additions & 8 deletions src/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

public class Wingpanel.PanelWindow : Gtk.Window {
public Services.PopoverManager popover_manager;

private Widgets.Panel panel;
private int panel_height;
Expand All @@ -36,9 +35,7 @@ public class Wingpanel.PanelWindow : Gtk.Window {
vexpand: false
);

popover_manager = new Services.PopoverManager ();

panel = new Widgets.Panel (popover_manager);
panel = new Widgets.Panel ();
panel.realize.connect (on_realize);

var cycle_action = new SimpleAction ("cycle", null);
Expand All @@ -55,6 +52,7 @@ public class Wingpanel.PanelWindow : Gtk.Window {
child = panel;
remove_css_class (Granite.STYLE_CLASS_BACKGROUND);

var popover_manager = Services.PopoverManager.get_default ();
popover_manager.notify["indicator-open"].connect (() => {
if (!popover_manager.indicator_open) {
Services.BackgroundManager.get_default ().restore_window ();
Expand Down Expand Up @@ -94,10 +92,6 @@ public class Wingpanel.PanelWindow : Gtk.Window {
this.set_size_request (monitor_dimensions.width, -1);
}

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

private void on_scale_changed () {
if (desktop_panel != null) {
desktop_panel.set_size (-1, get_actual_height ());
Expand Down
9 changes: 8 additions & 1 deletion src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ public class Wingpanel.Services.PopoverManager : Object {
}
}

public PopoverManager () {
private static GLib.Once<PopoverManager> instance;
public static unowned PopoverManager get_default () {
return instance.once (() => { return new PopoverManager (); });
}

private PopoverManager () {}

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

popover = new Gtk.Popover () {
Expand Down
11 changes: 5 additions & 6 deletions src/Widgets/IndicatorEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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 Gtk.Widget display_widget { get; private set; }
Expand All @@ -40,11 +39,8 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {
private Gtk.GestureClick gesture_controller;
private Gtk.EventControllerMotion motion_controller;

public IndicatorEntry (Indicator base_indicator, Services.PopoverManager popover_manager) {
Object (
base_indicator: base_indicator,
popover_manager: popover_manager
);
public IndicatorEntry (Indicator base_indicator) {
Object (base_indicator: base_indicator);
}

construct {
Expand All @@ -63,6 +59,8 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {

child = revealer;

var popover_manager = Services.PopoverManager.get_default ();

if (base_indicator.visible) {
popover_manager.register_indicator (this);
}
Expand Down Expand Up @@ -123,6 +121,7 @@ public class Wingpanel.Widgets.IndicatorEntry : Granite.Bin {
}

private void set_reveal (bool reveal) {
var popover_manager = Services.PopoverManager.get_default ();
if (!reveal && popover_manager.get_visible (this)) {
popover_manager.current_indicator = null;
}
Expand Down
11 changes: 3 additions & 8 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
public class Wingpanel.Widgets.Panel : Granite.Bin {
private static Settings panel_settings = new Settings ("io.elementary.desktop.wingpanel");

public Services.PopoverManager popover_manager { get; construct; }

private IndicatorBar right_menubar;
private IndicatorBar left_menubar;
private IndicatorBar center_menubar;
Expand All @@ -32,10 +30,6 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
private Gtk.EventControllerScroll scroll_controller;
private double current_scroll_delta = 0;

public Panel (Services.PopoverManager popover_manager) {
Object (popover_manager : popover_manager);
}

class construct {
set_css_name ("panel");
}
Expand Down Expand Up @@ -102,13 +96,14 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
}

private void begin_drag (double x, double y) {
popover_manager.close ();
Services.PopoverManager.get_default ().close ();

var background_manager = Services.BackgroundManager.get_default ();
background_manager.begin_grab_focused_window ((int) x, (int) y);
}

public void cycle (bool forward) {
var popover_manager = Services.PopoverManager.get_default ();
var current = popover_manager.current_indicator;
if (current == null) {
return;
Expand Down Expand Up @@ -161,7 +156,7 @@ public class Wingpanel.Widgets.Panel : Granite.Bin {
}

private void add_indicator (Indicator indicator) {
var indicator_entry = new IndicatorEntry (indicator, popover_manager);
var indicator_entry = new IndicatorEntry (indicator);

switch (indicator.code_name) {
case Indicator.APP_LAUNCHER:
Expand Down
Loading