Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions lib/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public abstract class Wingpanel.Indicator : GLib.Object {
*/
public string code_name { get; construct; }

/**
* Set the indicator positioning on the panel
*/
public IndicatorPosition position { get; set; default = IndicatorPosition.RIGHT;}

/**
* Defines if the indicator display widget should be shown or not.
*/
Expand Down
24 changes: 24 additions & 0 deletions lib/IndicatorPosition.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/

public enum Wingpanel.IndicatorPosition {
Copy link
Member

Choose a reason for hiding this comment

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

i am not sure where to put the enum definition where it doesnt get lost in code. Having its own file for three lines feels overkills.

Maybe putting this into Indicator.vala is fine? I agree with having its own file feels overkill.

LEFT,
CENTER,
RIGHT;
}
1 change: 1 addition & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libwingpanel_deps = [
libwingpanel_lib = library('wingpanel',
'Indicator.vala',
'IndicatorManager.vala',
'IndicatorPosition.vala',
'Widgets/Container.vala',
'Widgets/OverlayIcon.vala',
'Widgets/Separator.vala',
Expand Down
1 change: 1 addition & 0 deletions src/Services/IndicatorSorter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Wingpanel.Services.IndicatorSorter : Object {
private static Gee.HashMap<string, int> indicator_order = new Gee.HashMap<string,int> ();
static construct {
indicator_order[AYATANA_INDICATOR] = 0;
indicator_order[Indicator.APP_LAUNCHER] = 0;
indicator_order[UNKNOWN_INDICATOR] = 1;
indicator_order[Indicator.ACCESSIBILITY] = 2;
indicator_order[Indicator.NIGHT_LIGHT] = 3;
Expand Down
17 changes: 13 additions & 4 deletions src/Widgets/Panel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,21 @@ public class Wingpanel.Widgets.Panel : Gtk.EventBox {
private void add_indicator (Indicator indicator) {
var indicator_entry = new IndicatorEntry (indicator, popover_manager);

switch (indicator.code_name) {
Copy link
Member

Choose a reason for hiding this comment

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

We have specific code for Applications menu and DateTime indicator elsewhere, did you revisit them and check that we don't need fix them?

user@elementary:~/work/tmp/wingpanel (master =)$ git grep -n APP_LAUNCHER
lib/Indicator.vala:21:    public const string APP_LAUNCHER = "app-launcher";
src/Services/IndicatorSorter.vala:35:        indicator_order[Indicator.APP_LAUNCHER] = 0;
src/Widgets/Panel.vala:143:            case Indicator.APP_LAUNCHER:
src/Widgets/Panel.vala:197:            case Indicator.APP_LAUNCHER:
src/Widgets/Panel.vala:251:        if (indicator.code_name == Indicator.APP_LAUNCHER) {
user@elementary:~/work/tmp/wingpanel (master =)$ git grep -n DATETIME
lib/Indicator.vala:23:    public const string DATETIME = "datetime";
src/Widgets/Panel.vala:158:            case Indicator.DATETIME:
src/Widgets/Panel.vala:212:            case Indicator.DATETIME:
src/Widgets/Panel.vala:255:        if (indicator.code_name == Indicator.DATETIME) {
vapi/mutter-clutter.vapi:8363:          DATETIME,
user@elementary:~/work/tmp/wingpanel (master =)$

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check

case Indicator.APP_LAUNCHER:
// Workaround until both indicators get their own position prop
if (indicator.code_name == Indicator.APP_LAUNCHER) {
indicator.position = IndicatorPosition.LEFT;
};

if (indicator.code_name == Indicator.DATETIME) {
indicator.position = IndicatorPosition.CENTER;
};

switch (indicator.position) {
case IndicatorPosition.LEFT:
indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_RIGHT);
left_menubar.add (indicator_entry);
left_menubar.insert_sorted (indicator_entry);
break;
case Indicator.DATETIME:
case IndicatorPosition.CENTER:
indicator_entry.set_transition_type (Gtk.RevealerTransitionType.SLIDE_DOWN);
center_menubar.add (indicator_entry);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we may leave this add() or should update to insert_sorted(). The previous code was add() because it's only DateTime indicator that is placed in the center. However, now we're allowing showing multiple indicators in the center, so I guess we need to revisit this.

I'm concerning that possibly the indicator order of CENTER could be different every time when the panel starts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Properly centering opens a lot of uneasy questions:
-Would it mean we do a IndicatorPosition.CENTER_LEFT and CENTER_RIGHT, and leave a pure center for the date?
-Would it mean we rewrite a whole lot of code for basically a fourth and fifth position ?
-Is it worth it?

Im aware i am doing a PR for a new functionality, but also it is directed at a niche hacky extension that relies on using an unsupported (for user software) packaging system

So when doing the code i was unsure whether to address this properly, or wait until there is actual demand for actually putting in the center in a more proper way. Or also only allow LEFT or RIGHT.
Tbh im fine with all. The easiest path out would be to remove CENTER position, id be fine with adding a CENTER_LEFT + CENTER_RIGHT but that would take time out of other eOS related project to implement.

break;
Expand Down
Loading