Skip to content

Commit

Permalink
Merge branch 'menu-categories' of git://github.com/JosephMcc/Cinnamon
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Jan 28, 2016
2 parents 76cd086 + 27f6dfd commit 964931e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
59 changes: 37 additions & 22 deletions files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,25 +740,29 @@ RecentClearButton.prototype = {
}
};

function CategoryButton(app) {
this._init(app);
function CategoryButton(app, showIcon) {
this._init(app, showIcon);
}

CategoryButton.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,

_init: function(category) {
_init: function(category, showIcon) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, {hover: false});

this.actor.set_style_class_name('menu-category-button');
var label;
let icon = null;
if (category) {
icon = category.get_icon();
if (icon && icon.get_names)
this.icon_name = icon.get_names().toString();
else
if (showIcon) {
icon = category.get_icon();
if (icon && icon.get_names)
this.icon_name = icon.get_names().toString();
else
this.icon_name = "";
} else {
this.icon_name = "";
}
label = category.get_name();
} else
label = _("All Applications");
Expand All @@ -778,41 +782,51 @@ CategoryButton.prototype = {
}
};

function PlaceCategoryButton(app) {
this._init(app);
function PlaceCategoryButton(app, showIcon) {
this._init(app, showIcon);
}

PlaceCategoryButton.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,

_init: function(category) {
_init: function(category, showIcon) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, {hover: false});
this.actor.set_style_class_name('menu-category-button');
this.actor._delegate = this;
this.label = new St.Label({ text: _("Places"), style_class: 'menu-category-button-label' });
this.icon = new St.Icon({icon_name: "folder", icon_size: CATEGORY_ICON_SIZE, icon_type: St.IconType.FULLCOLOR});
this.addActor(this.icon);
this.icon.realize();
if (showIcon) {
this.icon = new St.Icon({icon_name: "folder", icon_size: CATEGORY_ICON_SIZE, icon_type: St.IconType.FULLCOLOR});
this.addActor(this.icon);
this.icon.realize();
} else {
this.icon = null;
}
// this.addActor(this.icon);
// this.icon.realize();
this.addActor(this.label);
this.label.realize();
}
};

function RecentCategoryButton(app) {
this._init(app);
function RecentCategoryButton(app, showIcon) {
this._init(app, showIcon);
}

RecentCategoryButton.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,

_init: function(category) {
_init: function(category, showIcon) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, {hover: false});
this.actor.set_style_class_name('menu-category-button');
this.actor._delegate = this;
this.label = new St.Label({ text: _("Recent Files"), style_class: 'menu-category-button-label' });
this.icon = new St.Icon({icon_name: "folder-recent", icon_size: CATEGORY_ICON_SIZE, icon_type: St.IconType.FULLCOLOR});
this.addActor(this.icon);
this.icon.realize()
if (showIcon) {
this.icon = new St.Icon({icon_name: "folder-recent", icon_size: CATEGORY_ICON_SIZE, icon_type: St.IconType.FULLCOLOR});
this.addActor(this.icon);
this.icon.realize()
} else {
this.icon = null;
}
this.addActor(this.label);
this.label.realize();
}
Expand Down Expand Up @@ -1082,6 +1096,7 @@ MyApplet.prototype = {
this.settings.bindProperty(Settings.BindingDirection.IN, "menu-icon", "menuIcon", this._updateIconAndLabel, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "menu-label", "menuLabel", this._updateIconAndLabel, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "overlay-key", "overlayKey", this._updateKeybinding, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "show-category-icons", "showCategoryIcons", this._refreshAll, null);

this._updateKeybinding();

Expand Down Expand Up @@ -1629,7 +1644,7 @@ MyApplet.prototype = {

// Now generate Places category and places buttons and add to the list
if (this.showPlaces) {
this.placesButton = new PlaceCategoryButton();
this.placesButton = new PlaceCategoryButton(null, this.showCategoryIcons);
this._addEnterEvent(this.placesButton, Lang.bind(this, function() {
if (!this.searchActive) {
this.placesButton.isHovered = true;
Expand Down Expand Up @@ -1714,7 +1729,7 @@ MyApplet.prototype = {

// Now generate recent category and recent files buttons and add to the list
if (this.privacy_settings.get_boolean(REMEMBER_RECENT_KEY)) {
this.recentButton = new RecentCategoryButton();
this.recentButton = new RecentCategoryButton(null, this.showCategoryIcons);
this._addEnterEvent(this.recentButton, Lang.bind(this, function() {
if (!this.searchActive) {
this.recentButton.isHovered = true;
Expand Down Expand Up @@ -1892,7 +1907,7 @@ MyApplet.prototype = {
if (dir.get_is_nodisplay())
continue;
if (this._loadCategory(dir)) {
let categoryButton = new CategoryButton(dir);
let categoryButton = new CategoryButton(dir, this.showCategoryIcons);
this._addEnterEvent(categoryButton, Lang.bind(this, function() {
if (!this.searchActive) {
categoryButton.isHovered = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"description" : "Text",
"tooltip" : "Enter custom text to show in the panel."
},
"show-category-icons" : {
"type" : "checkbox",
"default" : true,
"description" : "Show category icons",
"tooltip" : "Choose whether or not to show icons on categories."
},
"show-places" : {
"type" : "checkbox",
"default" : true,
Expand Down

0 comments on commit 964931e

Please sign in to comment.