Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jonas Dreßler
gnome-shell
Commits
e191636f
Commit
e191636f
authored
Jun 30, 2009
by
Colin Walters
Browse files
Update for review of
e57b7ec3
parent
39e31a3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
js/misc/appInfo.js
View file @
e191636f
...
...
@@ -71,39 +71,43 @@ function getAppInfo(appId) {
return
info
;
}
// get
MostUsed
Apps:
// get
Top
Apps:
// @count: maximum number of apps to retrieve
//
// Gets a list of #AppInfos for the @count most-frequently-used
// applications
// applications
, with explicitly-chosen favorites first.
//
// Return value: the list of #AppInfo
function
get
MostUsed
Apps
(
count
)
{
function
get
Top
Apps
(
count
)
{
let
appMonitor
=
Shell
.
AppMonitor
.
get_default
();
let
matches
=
[],
alreadyAdded
=
{};
let
favs
=
getFavorites
();
for
(
let
i
=
0
;
i
<
favs
.
length
&&
favs
.
length
<=
count
;
i
++
)
{
let
appId
=
favs
[
i
].
appId
;
if
(
alreadyAdded
[
appId
])
continue
;
alreadyAdded
[
appId
]
=
true
;
matches
.
push
(
favs
[
i
]);
}
// Ask for more apps than we need, since the list of recently used
// apps might contain an app we don't have a desktop file for
let
apps
=
appMonitor
.
get_most_used_apps
(
0
,
Math
.
round
(
count
*
1.5
));
let
matches
=
[],
alreadyAdded
=
{};
for
(
let
i
=
0
;
i
<
apps
.
length
&&
matches
.
length
<=
count
;
i
++
)
{
let
appId
=
apps
[
i
]
+
"
.desktop
"
;
if
(
alreadyAdded
[
appId
])
continue
;
alreadyAdded
[
appId
]
=
true
;
let
appInfo
=
getAppInfo
(
appId
);
if
(
appInfo
)
{
matches
.
push
(
appInfo
);
alreadyAdded
[
appId
]
=
true
;
}
}
let
favs
=
getFavorites
();
// Fill the list with default applications it's not full yet
for
(
let
i
=
0
;
i
<
favs
.
length
&&
favs
.
length
<=
count
;
i
++
)
{
let
appId
=
favs
[
i
].
appId
;
if
(
alreadyAdded
[
appId
])
continue
;
matches
.
push
(
favs
[
i
]);
}
return
matches
;
}
...
...
@@ -126,11 +130,5 @@ function getFavorites() {
function
getRunning
()
{
let
monitor
=
Shell
.
AppMonitor
.
get_default
();
let
basename
=
function
(
n
)
{
let
i
=
n
.
lastIndexOf
(
'
/
'
);
if
(
i
<
0
)
return
n
;
return
n
.
substring
(
i
+
1
);
}
return
_idListToInfos
(
monitor
.
get_running_app_ids
().
map
(
basename
));
return
_idListToInfos
(
monitor
.
get_running_app_ids
());
}
js/ui/appDisplay.js
View file @
e191636f
...
...
@@ -351,7 +351,7 @@ AppDisplay.prototype = {
// Sets the list of the displayed items based on the most used apps.
_setDefaultList
:
function
()
{
let
matchedInfos
=
AppInfo
.
get
MostUsed
Apps
(
MAX_ITEMS
);
let
matchedInfos
=
AppInfo
.
get
Top
Apps
(
MAX_ITEMS
);
this
.
_matchedItems
=
matchedInfos
.
map
(
function
(
info
)
{
return
info
.
appId
;
});
},
...
...
@@ -519,7 +519,6 @@ WellArea.prototype = {
children
=
this
.
actor
.
get_children
();
children
.
forEach
(
Lang
.
bind
(
this
,
function
(
v
)
{
this
.
actor
.
remove_actor
(
v
);
v
.
destroy
();
}));
...
...
@@ -550,6 +549,8 @@ WellArea.prototype = {
Mainloop
.
idle_add
(
function
()
{
appSystem
.
add_favorite
(
id
);
});
}
else
{
return
false
;
}
return
true
;
...
...
js/ui/widget.js
View file @
e191636f
...
...
@@ -284,7 +284,7 @@ AppsWidget.prototype = {
this
.
actor
=
new
Big
.
Box
({
spacing
:
2
});
this
.
collapsedActor
=
new
Big
.
Box
({
spacing
:
2
});
let
apps
=
AppInfo
.
get
MostUsed
Apps
(
5
);
let
apps
=
AppInfo
.
get
Top
Apps
(
5
);
for
(
let
i
=
0
;
i
<
apps
.
length
;
i
++
)
this
.
addItem
(
apps
[
i
]);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment