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
23 property alias mainStageApplications: mainStageModel
24 property alias sideStageApplications: sideStageModel
25 property variant mainStageFocusedApplication: null
26 property variant sideStageFocusedApplication: null
27 property bool sideStageEnabled: true
28 property bool keyboardVisible: ApplicationManager.keyboardVisible
29 property int keyboardHeight: ApplicationManager.keyboardHeight
31 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
33 signal focusRequested(string appId)
35 ApplicationsModelStageFiltered {
37 stage: ApplicationInfo.MainStage
40 ApplicationsModelStageFiltered {
42 stage: ApplicationInfo.SideStage
46 target: ApplicationManager
47 onFocusedApplicationIdChanged: {
48 var app = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
49 if (!app) { //nothing at all focused, so clear all
50 mainStageFocusedApplication = null;
51 sideStageFocusedApplication = null;
53 if (app.stage == ApplicationInfo.MainStage) {
54 mainStageFocusedApplication = app;
55 // possible the side stage app being unfocused fired this signal, so check for it
56 if (sideStageFocusedApplication && !sideStageFocusedApplication.focused)
57 sideStageFocusedApplication = null;
59 sideStageFocusedApplication = app;
60 // possible the main stage app being unfocused fired this signal, so check for it
61 if (mainStageFocusedApplication && !mainStageFocusedApplication.focused)
62 mainStageFocusedApplication = null;
68 // if no side stage enabled, override application's stage parameter
69 var app = ApplicationManager.findApplication(appId);
70 if (app && app.stage === ApplicationInfo.SideStage && !sideStageEnabled) {
71 app.stage = ApplicationInfo.MainStage;
74 root.focusRequested(appId);
78 function activateApplication(desktopFile, argument) {
81 // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
82 // TODO: convert entire shell to use appId only.
83 if (desktopFile.indexOf(".desktop") >= 0) {
84 appId = desktopFileToAppId(desktopFile);
89 var application = ApplicationManager.findApplication(appId);
90 if (application !== null) {
94 var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
97 return ApplicationManager.startApplication(appId, execFlags, [argument]);
99 return ApplicationManager.startApplication(appId, execFlags);
103 function stopApplication(application) {
106 // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
107 // TODO: convert entire shell to use appId only.
108 if (typeof application == "string") {
111 appId = desktopFileToAppId(application.desktopFile);
114 ApplicationManager.stopApplication(appId);
117 function focusApplication(application) {
118 if (application == null || application == undefined) {
122 ApplicationManager.focusApplication(application.appId);
125 function unfocusCurrentApplication() {
126 ApplicationManager.unfocusCurrentApplication();
129 function moveRunningApplicationStackPosition(from, to, stage) {
130 if (from == to || from < 0 || to < 0) return;
132 if (stage == ApplicationInfo.SideStage) {
133 sideStageModel.move(from, to);
135 mainStageModel.move(from, to);
139 function getApplicationFromDesktopFile(desktopFile, stage) {
142 // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
143 // TODO: convert entire shell to use appId only.
144 if (desktopFile.indexOf(".desktop") >= 0) {
145 appId = desktopFileToAppId(desktopFile);
150 for (var i = 0, len = ApplicationManager.count; i < len; i++ ) {
151 var app = ApplicationManager.get(i);
153 // if stage not specified, return whichever app running on either stage
154 if (app.appId == appId && (stage == undefined || app.stage == stage)) {
160 function desktopFileToAppId(desktopFile) {
161 var right = desktopFile.lastIndexOf(".desktop");
162 var left = desktopFile.lastIndexOf("/");
163 if (left == -1 || right == -1 || left == right) {
164 console.log("ApplicationManagerWrapper: unable to extract appId from '" + desktopFile + "'");
167 return desktopFile.substring(left+1, right);
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