Skip to content

Commit

Permalink
Close application's context menu when switching category
Browse files Browse the repository at this point in the history
  • Loading branch information
glebihan committed Dec 31, 2011
1 parent 79722e5 commit 6b47b6f
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions js/ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ApplicationContextMenuItem.prototype = {
let desktopFiles = settings.get_strv('panel-launchers');
desktopFiles.push(this._appButton.app.get_id());
settings.set_strv('panel-launchers', desktopFiles);
this._appButton.menu.close();
this._appButton.closeMenu();
break;
}
return false;
Expand Down Expand Up @@ -113,15 +113,24 @@ ApplicationButton.prototype = {
this.activate(event);
}
if (event.get_button()==3){
this.appsMenuButton.closeApplicationsContextMenus(this.app);
this.menu.toggle();
this.appsMenuButton.closeApplicationsContextMenus(this.app, true);
this.toggleMenu();
}
return true;
},

activate: function(event) {
this.app.open_new_window(-1);
this.appsMenuButton.menu.close();
},

closeMenu: function() {
global.log(this.menu.actor.has_key_focus());
this.menu.close();
},

toggleMenu: function() {
this.menu.toggle();
}
};
Signals.addSignalMethods(ApplicationButton.prototype);
Expand Down Expand Up @@ -486,7 +495,7 @@ ApplicationsButton.prototype = {
if (scrollBoxHeight<300) scrollBoxHeight = 300;
this.applicationsScrollBox.style = "height: "+scrollBoxHeight+"px;";
} else {
this.closeApplicationsContextMenus();
this.closeApplicationsContextMenus(null, false);
//this.resetSearch();
//this._clearSelections(this.categoriesBox);
//this._clearSelections(this.applicationsBox);
Expand Down Expand Up @@ -754,12 +763,18 @@ ApplicationsButton.prototype = {
this._clearApplicationsBox(categoryButton.actor);
if (dir) this._displayButtons(this._listApplications(dir.get_menu_id()));
else this._displayButtons(this._listApplications(null));
this.closeApplicationsContextMenus(null, false);
},

closeApplicationsContextMenus: function(excludeApp) {
for (var app in this._applicationsButtons)
if (app!=excludeApp && this._applicationsButtons[app].menu.isOpen)
this._applicationsButtons[app].menu.toggle();
closeApplicationsContextMenus: function(excludeApp, animate) {
for (var app in this._applicationsButtons){
if (app!=excludeApp && this._applicationsButtons[app].menu.isOpen){
if (animate)
this._applicationsButtons[app].toggleMenu();
else
this._applicationsButtons[app].closeMenu();
}
}
},

_displayButtons: function(apps, places){
Expand Down

0 comments on commit 6b47b6f

Please sign in to comment.