33 * SPDX-License-Identifier: GPL-3.0-or-later
44 */
55
6- [DBus (name = " org.pantheon.gala" )]
7- public interface Gala.WMDBus : GLib .Object {
8- public abstract void perform_action (Gala .ActionType type ) throws DBusError , IOError ;
9- }
10-
116public struct Gala.Daemon.MonitorLabelInfo {
127 public int monitor;
138 public string label;
@@ -19,59 +14,32 @@ public struct Gala.Daemon.MonitorLabelInfo {
1914
2015[DBus (name = " org.pantheon.gala.daemon" )]
2116public class Gala.Daemon.DBus : GLib .Object {
22- private const string DBUS_NAME = " org.pantheon.gala" ;
23- private const string DBUS_OBJECT_PATH = " /org/pantheon/gala" ;
24-
25- private const string DAEMON_DBUS_NAME = " org.pantheon.gala.daemon" ;
26- private const string DAEMON_DBUS_OBJECT_PATH = " /org/pantheon/gala/daemon" ;
27-
28- private WMDBus ? wm_proxy = null ;
29-
30- private WindowMenu ? window_menu;
17+ private Gtk . Menu ? window_menu;
3118 private BackgroundMenu ? background_menu;
3219
3320 private List<MonitorLabel > monitor_labels = new List<MonitorLabel > ();
3421
3522 construct {
36- Bus . watch_name ( BusType . SESSION , DBUS_NAME , BusNameWatcherFlags . NONE , gala_appeared, lost_gala );
23+ load_window_menu . begin ( );
3724 }
3825
39- private void on_gala_get (GLib .Object ? obj , GLib .AsyncResult ? res ) {
26+ private async void load_window_menu () {
27+ DBusConnection connection;
4028 try {
41- wm_proxy = Bus . get_proxy . end (res );
29+ connection = yield Bus . get ( SESSION , null );
4230 } catch (Error e) {
43- warning (" Failed to get Gala proxy: %s " , e. message);
31+ warning (" Failed to get DBus connection: %s " , e. message);
32+ return ;
4433 }
45- }
46-
47- private void lost_gala () {
48- wm_proxy = null ;
49- }
5034
51- private void gala_appeared () {
52- if (wm_proxy == null ) {
53- Bus . get_proxy. begin< WMDBus > (BusType . SESSION , DBUS_NAME , DBUS_OBJECT_PATH , 0 , null , on_gala_get);
54- }
55- }
35+ var menu_model = DBusMenuModel . get (connection, " org.pantheon.gala" , " /io/elementary/gala/window_menu" );
36+ var action_group = DBusActionGroup . get (connection, " org.pantheon.gala" , " /io/elementary/gala/window_menu" );
5637
57- private void perform_action (Gala .ActionType type ) {
58- if (wm_proxy != null ) {
59- try {
60- wm_proxy. perform_action (type);
61- } catch (Error e) {
62- warning (" Failed to perform Gala action over DBus: %s " , e. message);
63- }
64- }
38+ window_menu = new Gtk .Menu .from_model (menu_model);
39+ window_menu. insert_action_group (" window-menu" , action_group);
6540 }
6641
67- public void show_window_menu (Gala .WindowFlags flags , int display_width , int display_height , int x , int y ) throws DBusError , IOError {
68- if (window_menu == null ) {
69- window_menu = new WindowMenu ();
70- window_menu. perform_action. connect (perform_action);
71- }
72-
73- window_menu. update (flags);
74-
42+ public void show_window_menu (int display_width , int display_height , int x , int y ) throws DBusError , IOError {
7543 show_menu (window_menu, display_width, display_height, x, y, true );
7644 }
7745
0 commit comments