on xenial help sign in
[Indicators] Add support for ayatana indicators
9cc6008Marius Gripsgard
plugins/Unity/Indicators/indicatorsmanager.cpp+19−15
@@ -55,20 +55,22 @@ void IndicatorsManager::load()
55{
55{
56 unload();
56 unload();
57
57
58− const QStringList xdgLocations = shellDataDirs();
59−
60 m_fsWatcher.reset(new QFileSystemWatcher(this));
58 m_fsWatcher.reset(new QFileSystemWatcher(this));
61
59
62− Q_FOREACH(const QString& xdgLocation, xdgLocations)
60+ for (const auto xdgPath : shellDataDirs()) {
63− {
61+ // For legacy reasons we keep the old unity indicator path
64− const QString indicator_path = QDir::cleanPath(xdgLocation + "/unity/indicators");
62+ const auto unityPath = QDir::cleanPath(xdgPath + "/unity/indicators");
65− QDir indicator_dir(indicator_path);
63+ if (QFile::exists(unityPath)) {
66− if (indicator_dir.exists())
67− {
68 // watch folder for changes.
64 // watch folder for changes.
69− m_fsWatcher->addPath(indicator_path);
65+ m_fsWatcher->addPath(unityPath);
66+ loadDir(unityPath);
67+ }
70
68
71− loadDir(indicator_dir);
69+ const auto ayatanaPath = QDir::cleanPath(xdgPath + "/ayatana/indicators");
70+ if (QFile::exists(ayatanaPath)) {
71+ // watch folder for changes.
72+ m_fsWatcher->addPath(ayatanaPath);
73+ loadDir(ayatanaPath);
72 }
74 }
73 }
75 }
74
76
@@ -131,13 +133,13 @@ void IndicatorsManager::loadFile(const QFileInfo& file_info)
131 QStringList xdgLocations = shellDataDirs();
133 QStringList xdgLocations = shellDataDirs();
132 for (int i = 0; i < xdgLocations.size(); i++)
134 for (int i = 0; i < xdgLocations.size(); i++)
133 {
135 {
134− const QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
136+ const QString xdgLocation = QDir::cleanPath(xdgLocations[i]);
135
137
136− if (newFileInfoDir == indicatorDir)
138+ if (newFileInfoDir.startsWith(xdgLocation))
137 {
139 {
138 file_info_location = i;
140 file_info_location = i;
139 }
141 }
140− if (currentDataDir == indicatorDir)
142+ if (currentDataDir.startsWith(xdgLocation))
141 {
143 {
142 current_data_location = i;
144 current_data_location = i;
143 }
145 }
@@ -284,8 +286,10 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
284 // 2) enable keyboard indicator
286 // 2) enable keyboard indicator
285 //
287 //
286 // The rest of the indicators respect their default profile (which is "phone", even on desktop PCs)
288 // The rest of the indicators respect their default profile (which is "phone", even on desktop PCs)
287− if ((new_indicator->identifier() == QStringLiteral("indicator-session"))
289+ if (new_indicator->identifier() == QStringLiteral("indicator-session") ||
290+ new_indicator->identifier() == QStringLiteral("indicator-keyboard") ||
291+ new_indicator->identifier() == QStringLiteral("ayatana-indicator-session") ||
288− || new_indicator->identifier() == QStringLiteral("indicator-keyboard")) {
292+ new_indicator->identifier() == QStringLiteral("ayatana-indicator-keyboard")) {
289 new_indicator->setProfile(QString(m_profile).replace(QStringLiteral("phone"), QStringLiteral("desktop")));
293 new_indicator->setProfile(QString(m_profile).replace(QStringLiteral("phone"), QStringLiteral("desktop")));
290 } else {
294 } else {
291 new_indicator->setProfile(m_profile);
295 new_indicator->setProfile(m_profile);
qml/Panel/Indicators/IndicatorMenuItemFactory.qml+44
@@ -65,6 +65,32 @@ Object {
65
65
66 "com.canonical.indicator.calendar": calendarMenu,
66 "com.canonical.indicator.calendar": calendarMenu,
67 "com.canonical.indicator.location": timezoneMenu,
67 "com.canonical.indicator.location": timezoneMenu,
68+
69+ "org.ayatana.indicator.button" : buttonMenu,
70+ "org.ayatana.indicator.div" : separatorMenu,
71+ "org.ayatana.indicator.section" : sectionMenu,
72+ "org.ayatana.indicator.progress" : progressMenu,
73+ "org.ayatana.indicator.slider" : sliderMenu,
74+ "org.ayatana.indicator.switch" : switchMenu,
75+ "org.ayatana.indicator.alarm" : alarmMenu,
76+ "org.ayatana.indicator.appointment" : appointmentMenu,
77+ "org.ayatana.indicator.transfer" : transferMenu,
78+ "org.ayatana.indicator.button-section" : buttonSectionMenu,
79+ "org.ayatana.indicator.link" : linkMenu,
80+
81+ "org.ayatana.indicator.messages.messageitem" : messageItem,
82+ "org.ayatana.indicator.messages.sourceitem" : groupedMessage,
83+
84+ "org.ayatana.unity.slider" : sliderMenu,
85+ "org.ayatana.unity.switch" : switchMenu,
86+
87+ "org.ayatana.unity.media-player" : mediaPayerMenu,
88+ "org.ayatana.unity.playback-item" : playbackItemMenu,
89+
90+ "org.ayatana.indicator.network.modeminfoitem" : modeminfoitem,
91+
92+ "org.ayatana.indicator.calendar": calendarMenu,
93+ "org.ayatana.indicator.location": timezoneMenu,
68 },
94 },
69 "indicator-session": {
95 "indicator-session": {
70 "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
96 "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
@@ -73,6 +99,14 @@ Object {
73 },
99 },
74 "indicator-messages": {
100 "indicator-messages": {
75 "com.canonical.indicator.button": messagesButtonMenu
101 "com.canonical.indicator.button": messagesButtonMenu
102+ },
103+ "ayatana-indicator-session": {
104+ "indicator.user-menu-item": Platform.isPC ? userMenuItem : null,
105+ "indicator.guest-menu-item": Platform.isPC ? userMenuItem : null,
106+ "org.ayatana.indicator.switch": Math.min(Screen.width, Screen.height) > units.gu(60) ? switchMenu : null // Desktop mode switch
107+ },
108+ "ayatana-indicator-messages": {
109+ "org.ayatana.indicator.button": messagesButtonMenu
76 }
110 }
77 }
111 }
78
112
@@ -86,6 +120,16 @@ Object {
86 "indicator-keyboard": {
120 "indicator-keyboard": {
87 "indicator.map": null,
121 "indicator.map": null,
88 "indicator.chart": null
122 "indicator.chart": null
123+ },
124+ "ayatana-indicator-session": {
125+ "indicator.logout": Platform.isPC ? undefined : null,
126+ "indicator.suspend": Platform.isPC ? undefined : null,
127+ "indicator.hibernate": Platform.isPC ? undefined : null,
128+ "indicator.reboot": Platform.isPC ? undefined : null
129+ },
130+ "ayatana-indicator-keyboard": {
131+ "indicator.map": null,
132+ "indicator.chart": null
89 }
133 }
90 }
134 }
91
135