Merge pull request #2970 from RichNeese/cinnamon-skel

fixing desktop menu icon.
This commit is contained in:
Richard Neese
2021-07-04 14:09:14 -04:00
committed by GitHub
4 changed files with 3507 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
const Cinnamon = imports.gi.Cinnamon;
const CMenu = imports.gi.CMenu;
const Util = imports.misc.util;
let appsys = Cinnamon.AppSystem.get_default();
// sort apps by their latinised name
function appSort(a, b) {
a = Util.latinise(a[0].get_name().toLowerCase());
b = Util.latinise(b[0].get_name().toLowerCase());
return a > b;
}
// sort cmenu directories with admin and prefs categories last
function dirSort(a, b) {
let menuIdA = a.get_menu_id().toLowerCase();
let menuIdB = b.get_menu_id().toLowerCase();
let prefCats = ["administration", "preferences"];
let prefIdA = prefCats.indexOf(menuIdA);
let prefIdB = prefCats.indexOf(menuIdB);
if (prefIdA < 0 && prefIdB >= 0) {
return -1;
}
if (prefIdA >= 0 && prefIdB < 0) {
return 1;
}
let nameA = a.get_name().toLowerCase();
let nameB = b.get_name().toLowerCase();
if (nameA > nameB) {
return 1;
}
if (nameA < nameB) {
return -1;
}
return 0;
}
/* returns all apps and the categories they belong to, and all top level categories
*
* [
* [
* app 1,
* [
* top level category 1,
* random category,
* random category
* ]
* ],
* ...
* ],
* [
* top level category 1,
* top level category 2,
* top level category 3,
* top level category 4,
* ...
* ] */
function getApps() {
let apps = new Map();
let dirs = [];
let tree = appsys.get_tree();
let root = tree.get_root_directory();
let iter = root.iter();
let nextType;
while ((nextType = iter.next()) != CMenu.TreeItemType.INVALID) {
if (nextType == CMenu.TreeItemType.DIRECTORY) {
let dir = iter.get_directory();
if (dir.get_is_nodisplay())
continue;
if (loadDirectory(dir, dir, apps))
dirs.push(dir);
}
}
dirs.sort(dirSort);
let sortedApps = Array.from(apps.entries()).sort(appSort);
return [sortedApps, dirs];
}
// load all apps and their categories from a cmenu directory
// into 'apps' Map
function loadDirectory(dir, top_dir, apps) {
let iter = dir.iter();
let has_entries = false;
let nextType;
while ((nextType = iter.next()) != CMenu.TreeItemType.INVALID) {
if (nextType == CMenu.TreeItemType.ENTRY) {
let desktopId = iter.get_entry().get_desktop_file_id();
let app = appsys.lookup_app(desktopId);
if (!app || app.get_nodisplay())
continue;
has_entries = true;
if (apps.has(app))
apps.get(app).push(dir.get_menu_id());
else
apps.set(app, [top_dir.get_menu_id()]);
} else if (nextType == CMenu.TreeItemType.DIRECTORY) {
has_entries = loadDirectory(iter.get_directory(), top_dir, apps);
}
}
return has_entries;
}

View File

@@ -0,0 +1,7 @@
{
"uuid": "menu@cinnamon.org",
"name": "Menu",
"description": "Main Cinnamon menu",
"icon": "applications-other",
"max-instances": -1
}

View File

@@ -0,0 +1,258 @@
{
"layout": {
"type": "layout",
"pages": [
"panel",
"menu"
],
"panel": {
"type": "page",
"title": "Panel",
"sections": [
"panel-appear",
"panel-behave"
]
},
"menu": {
"type": "page",
"title": "Menu",
"sections": [
"menu-layout",
"menu-behave"
]
},
"panel-appear": {
"type": "section",
"title": "Appearance",
"keys": [
"menu-custom",
"menu-icon",
"menu-icon-size",
"menu-label"
]
},
"panel-behave": {
"type": "section",
"title": "Behavior",
"keys": [
"overlay-key",
"activate-on-hover",
"hover-delay",
"force-show-panel",
"enable-animation"
]
},
"menu-layout": {
"type": "section",
"title": "Layout and content",
"keys": [
"show-category-icons",
"category-icon-size",
"show-application-icons",
"application-icon-size",
"favbox-show",
"fav-icon-size",
"favbox-min-height",
"show-places",
"show-recents",
"menu-editor-button"
]
},
"menu-behave": {
"type": "section",
"title": "Behavior",
"keys": [
"enable-autoscroll",
"search-filesystem"
]
}
},
"overlay-key": {
"type": "keybinding",
"description": "Keyboard shortcut to open and close the menu",
"default": "Super_L::Super_R",
"value": "Super_L::Super_R"
},
"menu-custom": {
"type": "switch",
"default": false,
"description": "Use a custom icon and label",
"tooltip": "Check this to specify a custom icon and label",
"value": true
},
"menu-icon": {
"type": "iconfilechooser",
"default": "cinnamon-symbolic",
"description": "Icon",
"tooltip": "Select an icon to show in the panel.",
"default_icon": "cinnamon-symbolic",
"dependency": "menu-custom",
"indent": true,
"value": "/usr/share/pixmaps/armbian/armbian.png"
},
"menu-icon-size": {
"type": "spinbutton",
"default": 32,
"min": 16,
"max": 96,
"step": 1,
"units": "px",
"description": "Icon size",
"dependency": "menu-custom",
"indent": true,
"value": 32
},
"menu-label": {
"type": "entry",
"default": "Menu",
"description": "Text",
"tooltip": "Enter custom text to show in the panel.",
"dependency": "menu-custom",
"indent": true,
"value": "Menu"
},
"favbox-min-height": {
"type": "spinbutton",
"default": 300,
"min": 50,
"max": 1000,
"step": 10,
"units": "px",
"dependency": "favbox-show",
"description": "Minimum height of the favorites section",
"tooltip": "The minimum size allocated for the favorites section (this has an impact on the overall height of the menu).",
"value": 300
},
"show-category-icons": {
"type": "switch",
"default": true,
"description": "Show category icons",
"tooltip": "Choose whether or not to show icons on categories.",
"value": true
},
"category-icon-size": {
"type": "spinbutton",
"default": 22,
"min": 16,
"max": 48,
"step": 1,
"units": "px",
"description": "Categories icon size",
"dependency": "show-category-icons",
"indent": true,
"value": 22
},
"show-application-icons": {
"type": "switch",
"default": true,
"description": "Show application icons",
"tooltip": "Choose whether or not to show icons on applications.",
"value": true
},
"application-icon-size": {
"type": "spinbutton",
"default": 22,
"min": 16,
"max": 48,
"step": 1,
"units": "px",
"description": "Applications icon size",
"dependency": "show-application-icons",
"indent": true,
"value": 22
},
"favbox-show": {
"type": "switch",
"default": true,
"description": "Show favorites and session buttons",
"tooltip": "Choose whether or not to show the left pane of the menu.",
"value": true
},
"fav-icon-size": {
"type": "spinbutton",
"default": 32,
"min": 16,
"max": 64,
"step": 1,
"units": "px",
"description": "Favorites icon size",
"dependency": "favbox-show",
"indent": true,
"value": 32
},
"show-favorites": {
"type": "switch",
"default": true,
"description": "Show favorites",
"tooltip": "Choose whether or not to show favorite files in the menu.",
"value": true
},
"show-places": {
"type": "switch",
"default": true,
"description": "Show bookmarks and places",
"tooltip": "Choose whether or not to show bookmarks and places in the menu.",
"value": true
},
"show-recents": {
"type": "switch",
"default": true,
"description": "Show recents",
"tooltip": "Choose whether or not to show recents in the menu.",
"value": true
},
"enable-autoscroll": {
"type": "switch",
"default": true,
"description": "Enable autoscrolling in application list",
"tooltip": "Choose whether or not to enable smooth autoscrolling in the application list.",
"value": true
},
"search-filesystem": {
"type": "switch",
"default": false,
"description": "Enable filesystem path entry in search box",
"tooltip": "Allows path entry in the menu search box.",
"value": false
},
"force-show-panel": {
"type": "switch",
"default": true,
"description": "Force the panel to be visible when opening the menu",
"tooltip": "Opening the menu will also show the main panel (which may be auto-hidden).",
"value": true
},
"activate-on-hover": {
"type": "switch",
"default": false,
"description": "Open the menu when I move my mouse over it",
"tooltip": "Enable opening the menu when the mouse enters the applet",
"value": false
},
"hover-delay": {
"type": "spinbutton",
"default": 0,
"min": 0,
"max": 1000,
"step": 50,
"units": "milliseconds",
"dependency": "activate-on-hover",
"description": "Menu hover delay",
"tooltip": "Delay before the menu opens when hovered",
"value": 0
},
"enable-animation": {
"type": "switch",
"default": false,
"description": "Use menu animations",
"tooltip": "Allow the menu to animate on open and close",
"value": false
},
"menu-editor-button": {
"type": "button",
"description": "Open the menu editor",
"callback": "_launch_editor",
"tooltip": "Press this button to customize your menu entries."
},
"__md5__": "c4b27da93411965126569249b61793d7"
}