Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve Panel Menu to match designs. #146

Merged
merged 2 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
padding-right: 2px;
padding-top: 6px;
padding-bottom: 6px;
}

.pop-shell-gaps-entry {
width: 50px;
}
4 changes: 4 additions & 0 deletions light.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
padding-right: 2px;
padding-top: 6px;
padding-bottom: 6px;
}

.pop-shell-gaps-entry {
width: 50px;
}
65 changes: 43 additions & 22 deletions src/panel_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Entity } from './ecs';
import type { Ext } from './extension';

const { Clutter, Gio, St } = imports.gi;
const { PopupBaseMenuItem, PopupMenuItem, PopupSwitchMenuItem, PopupSubMenuMenuItem } = imports.ui.popupMenu;
const { PopupBaseMenuItem, PopupMenuItem, PopupSwitchMenuItem, PopupSeparatorMenuItem } = imports.ui.popupMenu;
const { Button } = imports.ui.panelMenu;
const { Forest } = Me.imports.forest;
const GLib: GLib = imports.gi.GLib;
Expand All @@ -28,14 +28,13 @@ export class Indicator {
this.button.add_actor(this.button.icon);

this.button.menu.addMenuItem(tiled(ext));
this.button.menu.addMenuItem(menu_separator(''));

this.button.menu.addMenuItem(shortcuts(this.button.menu));
this.button.menu.addMenuItem(settings_button(this.button.menu));
this.button.menu.addMenuItem(menu_separator(''));

this.appearances = new PopupSubMenuMenuItem('Appearance', true);
this.appearances.icon.icon_name = 'preferences-desktop-display-symbolic';
this.button.menu.addMenuItem(this.appearances);

this.appearances.menu.addMenuItem(
this.button.menu.addMenuItem(
toggle(
_("Show Active Hint"),
ext.settings.active_hint(),
Expand All @@ -45,7 +44,7 @@ export class Indicator {
)
);

this.appearances.menu.addMenuItem(
this.button.menu.addMenuItem(
number_entry(
_("Gaps"),
ext.settings.gap_inner(),
Expand All @@ -60,15 +59,14 @@ export class Indicator {
}
}

function menu_separator(text: any): any {
return new PopupSeparatorMenuItem(text);
}

function settings_button(menu: any): any {
let button = new St.Button({
label: "View All",
x_align: St.Align.START,
style_class: 'shell-link',
margin_left: 12,
});

button.connect('clicked', () => {
let item = new PopupMenuItem(_('View All'));
item.connect('activate', () => {
let path: string | null = GLib.find_program_in_path('pop-shell-shortcuts');
if (path) {
imports.misc.util.spawn([path]);
Expand All @@ -77,35 +75,56 @@ function settings_button(menu: any): any {
}

menu.close();
});
})

return button;
item.label.get_clutter_text().set_margin_left(12);

return item;
}

function shortcuts(menu: any): any {
let layout_manager = new Clutter.GridLayout({ orientation: Clutter.Orientation.HORIZONTAL });
let widget = new St.Widget({ layout_manager, x_expand: true });

let item = new PopupBaseMenuItem();
item.connect('activate', () => {
let path: string | null = GLib.find_program_in_path('pop-shell-shortcuts');
if (path) {
imports.misc.util.spawn([path]);
} else {
Log.error(`You must install \`pop-shell-shortcuts\``)
}

menu.close();
})
item.add_child(widget);

function create_label(text: string): any {
return new St.Label({ text });
}

function create_shortcut_label(text: string): any {
let label = create_label(text);
label.set_x_align(Clutter.ActorAlign.END);
return label;
}

let launcher = create_label(_('Launcher'));
launcher.get_clutter_text().set_margin_left(12);
let navigate_windows = create_label(_('Navigate Windows'));
navigate_windows.get_clutter_text().set_margin_left(12);

// Shortcut items
let launcher_shortcut = create_shortcut_label(_('Super + /'));
let navigate_windows_shortcut = create_shortcut_label(_('Super + Arrow Keys'));

layout_manager.set_row_spacing(12);
layout_manager.set_column_spacing(8);
layout_manager.set_column_spacing(30);
layout_manager.attach(create_label(_('Shortcuts')), 0, 0, 2, 1);
layout_manager.attach(launcher, 0, 1, 1, 1);
layout_manager.attach(create_label(_('Super + /')), 1, 1, 1, 1);
layout_manager.attach(launcher_shortcut, 1, 1, 1, 1);
layout_manager.attach(navigate_windows, 0, 2, 1, 1);
layout_manager.attach(create_label(_('Super + Arrow keys')), 1, 2, 1, 1);
layout_manager.attach(settings_button(menu), 0, 3, 1, 1);
layout_manager.attach(navigate_windows_shortcut, 1, 2, 1, 1);

return item;
}
Expand All @@ -121,8 +140,9 @@ function number_entry(
): any {
let entry = new St.Entry({ text: String(value) });
entry.set_input_purpose(Clutter.InputContentPurpose.NUMBER);
entry.set_x_align(Clutter.ActorAlign.FILL);
entry.set_x_expand(true);
entry.set_x_align(Clutter.ActorAlign.END);
entry.set_x_expand(false);
entry.set_style_class_name('pop-shell-gaps-entry');
entry.connect('button-release-event', () => {
return true;
});
Expand Down Expand Up @@ -164,6 +184,7 @@ function number_entry(
});

let item = new PopupMenuItem(label);
item.label.get_clutter_text().set_x_expand(true);
item.label.set_y_align(Clutter.ActorAlign.CENTER);
item.add_child(entry);

Expand Down