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 Ubuntu.Application 0.1
21 id: applicationManager
23 property var mainStageApplications: ApplicationManager.mainStageApplications
24 property var sideStageApplications: ApplicationManager.sideStageApplications
25 property var mainStageFocusedApplication: ApplicationManager.mainStageFocusedApplication
26 property var sideStageFocusedApplication: ApplicationManager.sideStageFocusedApplication
27 property bool sideStageEnabled: true
28 signal focusRequested(string desktopFile)
29 property bool keyboardVisible: ApplicationManager.keyboardVisible
30 property int keyboardHeight: ApplicationManager.keyboardHeight
32 Component.onCompleted: {
33 // Start the watcher so that the ApplicationManager applications model can be populated.
34 ApplicationManager.startWatcher();
37 function activateApplication(desktopFile, argument) {
39 application = getApplicationFromDesktopFile(desktopFile, ApplicationInfo.MainStage);
40 if (application == null) {
41 application = getApplicationFromDesktopFile(desktopFile, ApplicationInfo.SideStage);
43 if (application != null) {
47 var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
50 return ApplicationManager.startProcess(desktopFile, execFlags, [argument]);
52 return ApplicationManager.startProcess(desktopFile, execFlags);
56 function stopProcess(application) {
57 ApplicationManager.stopProcess(application)
60 function focusApplication(application) {
61 if (application == null || application == undefined) {
65 ApplicationManager.focusApplication(application.handle);
68 function unfocusCurrentApplication() {
69 ApplicationManager.unfocusCurrentApplication(ApplicationInfo.MainStage);
72 function moveRunningApplicationStackPosition(from, to, stage) {
74 if (stage == ApplicationInfo.SideStage) {
75 applications = ApplicationManager.sideStageApplications;
77 applications = ApplicationManager.mainStageApplications;
79 // FIXME: applications.move(0, 0) crashes
80 if (from !== to && from >= 0 && to >= 0) applications.move(from, to);
83 function getApplicationFromDesktopFile(desktopFile, stage) {
84 var foundSideStageApp, foundMainStageApp;
86 foundMainStageApp = __find(desktopFile, ApplicationManager.mainStageApplications)
87 if (stage == ApplicationInfo.MainStage) {
88 return foundMainStageApp;
90 foundSideStageApp = __find(desktopFile, ApplicationManager.sideStageApplications)
91 if (stage == ApplicationInfo.SideStage) {
92 return foundSideStageApp;
95 // if stage not specified, return whichever app running on either stage
96 return (foundMainStageApp) ? foundMainStageApp : foundSideStageApp;
99 function __find(desktopFile, applications) {
100 for (var i = 0; i < applications.count; i++ ) {
101 var application = applications.get(i);
102 if (application.desktopFile == desktopFile) {
111 target: ApplicationManager
113 // FIXME: hardcoded mapping from ApplicationManager.FavoriteApplications
114 // enum to desktop files
116 if (favoriteApplication == ApplicationManager.CameraApplication) {
117 desktopFile = "/usr/share/applications/camera-app.desktop"
118 } else if (favoriteApplication == ApplicationManager.GalleryApplication) {
119 desktopFile = "/usr/share/applications/gallery-app.desktop"
120 } else if (favoriteApplication == ApplicationManager.ShareApplication) {
121 desktopFile = "/usr/share/applications/share-app.desktop"
122 } else if (favoriteApplication == ApplicationManager.BrowserApplication) {
123 desktopFile = "/usr/share/applications/webbrowser-app.desktop"
124 } else if (favoriteApplication == 4) { // ApplicationManager.PhoneApplication
125 desktopFile = "/usr/share/applications/phone-app.desktop"
127 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