2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Unity.Application 0.1
22 id: applicationManager
24 property var mainStageApplications: mainStageModel
25 property var sideStageApplications: sideStageModel
26 property var mainStageFocusedApplication: null
27 property var sideStageFocusedApplication: null
28 property bool sideStageEnabled: true
29 signal focusRequested(string desktopFile)
30 property bool keyboardVisible: ApplicationManager.keyboardVisible
31 property int keyboardHeight: ApplicationManager.keyboardHeight
33 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
35 SortFilterProxyModel {
37 model: ApplicationManager
38 dynamicSortFilter: true
39 filterRole: ApplicationManager.RoleStage
40 filterRegExp: RegExp(ApplicationInfo.MainStage)
42 onCountChanged: { print("MODEL Main:", count, ApplicationManager.RoleStage, ApplicationManager.RoleFocused)
43 mainStageFocusedApplication = ApplicationManager.get(mainStageModel.findFirst(ApplicationManager.RoleFocused, true));
44 print("MS", mainStageFocusedApplication)
46 onLayoutChanged: print("LAYOUT")
47 onDataChanged: print("DATA")
50 SortFilterProxyModel {
52 model: ApplicationManager
53 dynamicSortFilter: true
54 filterRole: ApplicationManager.RoleStage
55 filterRegExp: RegExp(ApplicationInfo.SideStage)
57 onDataChanged: { print("MODEL Side", count)
58 sideStageFocusedApplication = ApplicationManager.get(sideStageModel.findFirst(ApplicationManager.RoleFocused, true));
59 print("SS", sideStageFocusedApplication)
63 function activateApplication(desktopFile, argument) {
66 // HACK: might be called with appId, but mostly with desktopFile
67 if (desktopFile.indexOf(".desktop") = -1) {
68 appId = desktopFileToAppId(desktopFile);
73 var application = ApplicationManager.findApplication(appId);
74 if (application !== null) {
78 var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
81 return ApplicationManager.startApplication(appId, execFlags, [argument]);
83 return ApplicationManager.startApplication(appId, execFlags);
87 function stopProcess(application) {
90 // HACK: might be called with appId, or else with Application object
91 if (typeof application == "string") {
92 appId = desktopFileToAppId(application.desktopFile);
97 ApplicationManager.stopProcess(appId);
100 function focusApplication(application) {
101 if (application == null || application == undefined) {
105 ApplicationManager.focusApplication(application.appId);
108 function unfocusCurrentApplication() {
109 ApplicationManager.unfocusCurrentApplication();
112 function moveRunningApplicationStackPosition(from, to, stage) { //FIXME: stage unused!
113 if (from !== to && from >= 0 && to >= 0) ApplicationManager.move(from, to);
116 function getApplicationFromDesktopFile(desktopFile, stage) {
117 var foundSideStageApp, foundMainStageApp;
118 var appId = desktopFileToAppId(desktopFile);
120 for (var i = 0, len = ApplicationManager.count; i < len; i++ ) {
121 var app = ApplicationManager.get(i);
123 // if stage not specified, return whichever app running on either stage
124 if (app.appId == appId && (stage == undefined || app.stage == stage)) {
130 function desktopFileToAppId(desktopFile) {
131 var right = desktopFile.lastIndexOf(".desktop");
132 var left = desktopFile.lastIndexOf("/");
133 if (left == -1 || right == -1 || left == right) {
134 console.log("ApplicationManagerWrapper: unable to extract appId from '" + desktopFile + "'");
137 return desktopFile.substring(left+1, right);
140 function appIdToDesktopFile(desktopFile) {
141 return "/usr/share/applications/" + desktopFile + ".desktop"
145 target: ApplicationManager
147 // FIXME: hardcoded mapping from ApplicationManager.FavoriteApplications
148 // enum to desktop files
150 if (favoriteApplication == ApplicationManager.CameraApplication) {
151 desktopFile = "/usr/share/applications/camera-app.desktop"
152 } else if (favoriteApplication == ApplicationManager.GalleryApplication) {
153 desktopFile = "/usr/share/applications/gallery-app.desktop"
154 } else if (favoriteApplication == ApplicationManager.ShareApplication) {
155 desktopFile = "/usr/share/applications/share-app.desktop"
156 } else if (favoriteApplication == ApplicationManager.BrowserApplication) {
157 desktopFile = "/usr/share/applications/webbrowser-app.desktop"
158 } else if (favoriteApplication == ApplicationManager.PhoneApplication) {
159 desktopFile = "/usr/share/applications/phone-app.desktop"
160 } else if (favoriteApplication == ApplicationManager.DialerApplication) {
161 desktopFile = "/usr/share/applications/dialer-app.desktop"
162 } else if (favoriteApplication == ApplicationManager.MessagingApplication) {
163 desktopFile = "/usr/share/applications/messaging-app.desktop"
164 } else if (favoriteApplication == ApplicationManager.AddressbookApplication) {
165 desktopFile = "/usr/share/applications/address-book-app.desktop"
168 applicationManager.focusRequested(desktopFile);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list