Merge pull request #29 from robrobinbin/master

Option to add/remove AppMenu
This commit is contained in:
Jason DeRose
2017-01-17 14:13:07 -05:00
committed by GitHub
4 changed files with 69 additions and 1 deletions

View File

@@ -784,6 +784,50 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="show_appmenu_row">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="show_appmenu_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSwitch" id="show_appmenu_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="show_appmenu_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Show AppMenu</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="show_window_previews">
<property name="width_request">100</property>

View File

@@ -103,6 +103,7 @@ const dtpPanel = new Lang.Class({
this._oldCenterBoxStyle = this.panel._centerBox.get_style();
this._oldRightBoxStyle = this.panel._rightBox.get_style();
this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button'));
this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu'));
this._setClockLocation(this._dtpSettings.get_string('location-clock'));
this.panel.actor.add_style_class_name('dashtopanelMainPanel');
@@ -165,6 +166,7 @@ const dtpPanel = new Lang.Class({
this._signalsHandler.destroy();
this.container.remove_child(this.taskbar.actor);
this._setAppmenuVisible(false);
this.container.add_child(this.appMenu.container);
this.taskbar.destroy();
this.panel.actor.disconnect(this._panelConnectId);
@@ -210,6 +212,10 @@ const dtpPanel = new Lang.Class({
this._dtpSettings.connect('changed::show-activities-button', Lang.bind(this, function() {
this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button'));
}));
this._dtpSettings.connect('changed::show-appmenu', Lang.bind(this, function() {
this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu'));
}));
this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() {
this._setClockLocation(this._dtpSettings.get_string('location-clock'));
@@ -319,6 +325,15 @@ const dtpPanel = new Lang.Class({
isVisible ? this.panel.statusArea.activities.actor.show() :
this.panel.statusArea.activities.actor.hide();
},
_setAppmenuVisible: function(isVisible) {
let centerBox = this.panel._centerBox;
if (isVisible && centerBox.get_children().indexOf(this.appMenu.container) == -1) {
centerBox.insert_child_at_index(this.appMenu.container, 0)
} else if (!isVisible && centerBox.get_children().indexOf(this.appMenu.container) != -1) {
centerBox.remove_child(this.appMenu.container);
}
},
_setClockLocation: function(loc) {
let centerBox = this.panel._centerBox;
@@ -355,4 +370,4 @@ const dtpPanel = new Lang.Class({
}
}
});
});

View File

@@ -147,6 +147,10 @@ const Settings = new Lang.Class({
this._builder.get_object('show_activities_button_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-appmenu',
this._builder.get_object('show_appmenu_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-window-previews',
this._builder.get_object('show_window_previews_switch'),
'active',

View File

@@ -59,6 +59,11 @@
<summary>Show activities button</summary>
<description>Show activities button on the left hand side of the taskbar</description>
</key>
<key type="b" name="show-appmenu">
<default>false</default>
<summary>Show appMenu</summary>
<description>Show appMenu on the right hand side of the panel</description>
</key>
<key type="b" name="show-window-previews">
<default>true</default>
<summary>Show window preview</summary>