mirror of
https://github.com/elementary/gala.git
synced 2024-08-16 18:40:27 +03:00
Finish background menu
This commit is contained in:
parent
c499ef00df
commit
5742055d4b
68
src/Widgets/BackgroundMenu.vala
Normal file
68
src/Widgets/BackgroundMenu.vala
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2023 elementary, Inc. <https://elementary.io>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
public class Gala.BackgroundMenu : Menu {
|
||||
public BackgroundMenu (Gala.WindowManager wm) {
|
||||
Object (wm: wm);
|
||||
}
|
||||
|
||||
construct {
|
||||
var change_wallpaper = new MenuItem (_("Change Wallpaper…"));
|
||||
change_wallpaper.activated.connect (() => {
|
||||
try {
|
||||
AppInfo.launch_default_for_uri ("settings://desktop/appearance/wallpaper", null);
|
||||
} catch (Error e) {
|
||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
||||
"Failed to Open Wallpaper Settings",
|
||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
||||
"dialog-error",
|
||||
Gtk.ButtonsType.CLOSE
|
||||
);
|
||||
message_dialog.show_error_details (e.message);
|
||||
message_dialog.run ();
|
||||
message_dialog.destroy ();
|
||||
}
|
||||
});
|
||||
|
||||
var display_settings = new MenuItem (_("Display Settings…"));
|
||||
display_settings.activated.connect (() => {
|
||||
try {
|
||||
AppInfo.launch_default_for_uri ("settings://display", null);
|
||||
} catch (Error e) {
|
||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
||||
"Failed to Open Display Settings",
|
||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
||||
"dialog-warning",
|
||||
Gtk.ButtonsType.CLOSE
|
||||
);
|
||||
message_dialog.show_error_details (e.message);
|
||||
message_dialog.run ();
|
||||
message_dialog.destroy ();
|
||||
}
|
||||
});
|
||||
|
||||
var system_settings = new MenuItem (_("System Settings…"));
|
||||
system_settings.activated.connect (() => {
|
||||
try {
|
||||
AppInfo.launch_default_for_uri ("settings://", null);
|
||||
} catch (Error e) {
|
||||
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
|
||||
"Failed to Open System Settings",
|
||||
"Unable to open System Settings. A handler for the `settings://` URI scheme must be installed.",
|
||||
"dialog-warning",
|
||||
Gtk.ButtonsType.CLOSE
|
||||
);
|
||||
message_dialog.show_error_details (e.message);
|
||||
message_dialog.run ();
|
||||
message_dialog.destroy ();
|
||||
}
|
||||
});
|
||||
|
||||
add_menuitem (change_wallpaper);
|
||||
add_menuitem (display_settings);
|
||||
add_separator ();
|
||||
add_menuitem (system_settings);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
public class Gala.WindowMenu : Clutter.Actor {
|
||||
public class Gala.Menu : Clutter.Actor {
|
||||
private const int ANIMATION_DURATION = 200;
|
||||
|
||||
public bool opened { get; private set; default = false; }
|
||||
@ -23,9 +23,7 @@ public class Gala.WindowMenu : Clutter.Actor {
|
||||
private Gtk.StyleContext style_context;
|
||||
private unowned Gtk.CssProvider? dark_style_provider = null;
|
||||
|
||||
private bool first_release = true;
|
||||
|
||||
public WindowMenu (Gala.WindowManager wm) {
|
||||
public Menu (Gala.WindowManager wm) {
|
||||
Object (wm: wm);
|
||||
}
|
||||
|
||||
@ -74,16 +72,12 @@ public class Gala.WindowMenu : Clutter.Actor {
|
||||
notify["allocation"].connect (() => canvas.set_size ((int) width, (int) height));
|
||||
|
||||
canvas.draw.connect (draw);
|
||||
|
||||
add_menuitem (new MenuItem ("Change Wallpaper..."));
|
||||
add_menuitem (new MenuItem ("Display Settings..."));
|
||||
add_separator ();
|
||||
add_menuitem (new MenuItem ("System Settings..."));
|
||||
}
|
||||
|
||||
public void add_menuitem (MenuItem menuitem) {
|
||||
container.add_child (menuitem);
|
||||
menuitem.scale (wm.get_display ().get_monitor_scale (wm.get_display ().get_current_monitor ()));
|
||||
menuitem.activated.connect (() => toggle_display (false));
|
||||
}
|
||||
|
||||
public void add_separator () {
|
||||
@ -185,13 +179,7 @@ public class Gala.WindowMenu : Clutter.Actor {
|
||||
}
|
||||
|
||||
public override bool button_release_event (Clutter.ButtonEvent event) {
|
||||
if (first_release) {
|
||||
first_release = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
toggle_display (false);
|
||||
first_release = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,8 @@ namespace Gala {
|
||||
|
||||
private WindowSwitcher? winswitcher = null;
|
||||
private ActivatableComponent? window_overview = null;
|
||||
private WindowMenu window_menu;
|
||||
|
||||
private BackgroundMenu background_menu;
|
||||
|
||||
public ScreenSaverManager? screensaver { get; private set; }
|
||||
|
||||
@ -231,6 +232,7 @@ namespace Gala {
|
||||
Clutter.BindCoordinate.ALL, 0));
|
||||
stage.insert_child_below (system_background.background_actor, null);
|
||||
|
||||
|
||||
ui_group = new Clutter.Actor ();
|
||||
ui_group.reactive = true;
|
||||
stage.add_child (ui_group);
|
||||
@ -248,6 +250,9 @@ namespace Gala {
|
||||
stage.remove_child (top_window_group);
|
||||
ui_group.add_child (top_window_group);
|
||||
|
||||
background_menu = new BackgroundMenu (this);
|
||||
ui_group.add_child (background_menu);
|
||||
|
||||
FilterManager.init (this);
|
||||
|
||||
/*keybindings*/
|
||||
@ -346,8 +351,6 @@ namespace Gala {
|
||||
ui_group.add_child ((Clutter.Actor) window_overview);
|
||||
}
|
||||
|
||||
window_menu = new WindowMenu (this);
|
||||
|
||||
notification_group = new Clutter.Actor ();
|
||||
ui_group.add_child (notification_group);
|
||||
|
||||
@ -408,17 +411,8 @@ namespace Gala {
|
||||
}
|
||||
|
||||
private void on_show_background_menu (int x, int y) {
|
||||
if (daemon_proxy == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
daemon_proxy.show_desktop_menu.begin (x, y, (obj, res) => {
|
||||
try {
|
||||
((Daemon) obj).show_desktop_menu.end (res);
|
||||
} catch (Error e) {
|
||||
message ("Error invoking MenuManager: %s", e.message);
|
||||
}
|
||||
});
|
||||
background_menu.set_position (x, y);
|
||||
background_menu.open_menu ();
|
||||
}
|
||||
|
||||
private void on_monitors_changed () {
|
||||
@ -989,7 +983,7 @@ namespace Gala {
|
||||
switch (menu) {
|
||||
case Meta.WindowMenuType.WM:
|
||||
warning ("CREATE MENU");
|
||||
var window_menu = new WindowMenu (this);
|
||||
var window_menu = new BackgroundMenu (this);
|
||||
ui_group.add_child (window_menu);
|
||||
window_menu.set_position (x, y);
|
||||
window_menu.open_menu ();
|
||||
|
@ -38,6 +38,7 @@ gala_bin_sources = files(
|
||||
'Gestures/ToucheggBackend.vala',
|
||||
'HotCorners/HotCorner.vala',
|
||||
'HotCorners/HotCornerManager.vala',
|
||||
'Widgets/BackgroundMenu.vala',
|
||||
'Widgets/DwellClickTimer.vala',
|
||||
'Widgets/IconGroup.vala',
|
||||
'Widgets/IconGroupContainer.vala',
|
||||
|
Loading…
Reference in New Issue
Block a user