diff --git a/lib/Indicator.vala b/lib/Indicator.vala index 52858ab9..d22094b6 100644 --- a/lib/Indicator.vala +++ b/lib/Indicator.vala @@ -40,6 +40,11 @@ public abstract class Wingpanel.Indicator : GLib.Object { */ public string code_name { get; construct; } + /** + * Sets 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. */ diff --git a/lib/IndicatorPosition.vala b/lib/IndicatorPosition.vala new file mode 100644 index 00000000..b5a04baa --- /dev/null +++ b/lib/IndicatorPosition.vala @@ -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 { + LEFT, + CENTER, + RIGHT; +} diff --git a/lib/meson.build b/lib/meson.build index 93e2f384..6ff832bf 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -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', diff --git a/src/Services/IndicatorSorter.vala b/src/Services/IndicatorSorter.vala index 675e5daa..33d41e54 100644 --- a/src/Services/IndicatorSorter.vala +++ b/src/Services/IndicatorSorter.vala @@ -32,6 +32,7 @@ public class Wingpanel.Services.IndicatorSorter : Object { private static Gee.HashMap indicator_order = new Gee.HashMap (); 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; diff --git a/src/Widgets/Panel.vala b/src/Widgets/Panel.vala index e10aa8a2..c82eac47 100644 --- a/src/Widgets/Panel.vala +++ b/src/Widgets/Panel.vala @@ -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) { - case Indicator.APP_LAUNCHER: + // TODO 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); break;