From d1c1f681cb2574848c02f6172874a33dfe3338b9 Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Tue, 31 Jan 2023 08:09:44 -0500 Subject: [PATCH 1/6] Adding build script to automating the build. --- build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..a8e9a741 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +export DISPLAY=:0.0 +killall io.elementary.switchboard -9 +sudo rm -fr build/ +sudo meson build --prefix=/usr +cd build/ +sudo ninja +sudo ninja install +cd ../ +io.elementary.switchboard From f4ce9644e6cf4916d61b2582e51365fbaaa1d06d Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Sat, 4 Feb 2023 10:56:26 -0500 Subject: [PATCH 2/6] Init Gnome Remote Desktop Support --- src/Widgets/GnomeRemoteDesktopPage.vala | 143 ++++++++++++++++++++++++ src/Widgets/SettingsView.vala | 6 + src/meson.build | 2 + 3 files changed, 151 insertions(+) create mode 100755 src/Widgets/GnomeRemoteDesktopPage.vala diff --git a/src/Widgets/GnomeRemoteDesktopPage.vala b/src/Widgets/GnomeRemoteDesktopPage.vala new file mode 100755 index 00000000..19de9680 --- /dev/null +++ b/src/Widgets/GnomeRemoteDesktopPage.vala @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2023 elementary LLC (https://launchpad.net/switchboard-plug-sharing) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + */ + +public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { + public NM.Client client { get; construct; } + GLib.Settings vnc_settings; + GLib.Settings rdp_settings; + + Gtk.Switch useLegicyVNCMode_switch; + Gtk.Switch remoteControl_switch; + Gtk.Entry deviceName_entry; + Gtk.Label vnc_url_label; + Gtk.Entry rdp_url_entry; + Gtk.Entry vnc_url_entry; + Gtk.Entry password_entry; + + public GnomeRemoteDesktopPage () { + base ("Remote Desktop", + _("Remote Desktop"), + "preferences-desktop-remote-desktop", + _("While enabled this machine will be viable on the network allowing other computer find, connect or control this machine remotely with or with out a password"), + _("While disabled this machine will be hidden from other computer on the network & can not connected to or controlled remotely by other computer even if the IPaddress is know")); + + vnc_settings = new GLib.Settings ("org.gnome.desktop.remote-desktop.vnc"); + rdp_settings = new GLib.Settings ("org.gnome.desktop.remote-desktop.rdp"); + + vnc_settings.bind ("enable", useLegicyVNCMode_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + vnc_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + vnc_settings.set_boolean("view-only", remoteControl_switch.state); + + rdp_settings.bind ("enable", service_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + rdp_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + rdp_settings.set_boolean("view-only", remoteControl_switch.state); + + + service_switch.notify ["active"].connect (() => { + set_service_state (); + }); + + + set_service_state (); + } + + construct { + + try { + client = new NM.Client (); + } catch (Error e) { + critical (e.message); + } + + var useLegicyVNCMode_label = new Gtk.Label (_("Use Legicy VNC Mode")); + ((Gtk.Misc) useLegicyVNCMode_label).xalign = 1.0f; + + var viewOnly_label = new Gtk.Label (_("Remote Control")); + ((Gtk.Misc) viewOnly_label).xalign = 1.0f; + + var deviceName_label = new Gtk.Label (_("Device Name")); + ((Gtk.Misc) deviceName_label).xalign = 1.0f; + + var rdp_url_label = new Gtk.Label (_("RDP URL")); + ((Gtk.Misc) rdp_url_label).xalign = 1.0f; + + vnc_url_label = new Gtk.Label (_("VNC URL")); + ((Gtk.Misc) vnc_url_label).xalign = 1.0f; + + var password_label = new Gtk.Label (_("Password")); + ((Gtk.Misc) password_label).xalign = 1.0f; + + useLegicyVNCMode_switch = new Gtk.Switch(); + useLegicyVNCMode_switch.halign = Gtk.Align.START; + useLegicyVNCMode_switch.state_set.connect ((state) => { + vnc_url_label.visible = state; + vnc_url_entry.visible = state; + return false; + }); + + remoteControl_switch = new Gtk.Switch(); + remoteControl_switch.halign = Gtk.Align.START; + + deviceName_entry = new Gtk.Entry(); + deviceName_entry.halign = Gtk.Align.START; + deviceName_entry.text = "rdp://"+client.hostname; + + vnc_url_entry = new Gtk.Entry(); + vnc_url_entry.halign = Gtk.Align.START; + vnc_url_entry.text = "vnc://"+client.hostname+".local"; + vnc_url_entry.editable = false; + + + rdp_url_entry = new Gtk.Entry(); + rdp_url_entry.halign = Gtk.Align.START; + rdp_url_entry.text = "rdp://"+client.hostname+".local"; + rdp_url_entry.editable = false; + + password_entry = new Gtk.Entry(); + password_entry.halign = Gtk.Align.START; + password_entry.text = client.hostname; + password_entry.set_visibility (false); + + content_grid.attach (useLegicyVNCMode_label, 0, 0, 1, 1); + content_grid.attach (useLegicyVNCMode_switch, 1, 0, 1, 1); + content_grid.attach (viewOnly_label, 0, 1, 1, 1); + content_grid.attach (remoteControl_switch, 1, 1, 1, 1); + content_grid.attach (deviceName_label, 0, 2, 1, 1); + content_grid.attach (deviceName_entry, 1, 2, 1, 1); + content_grid.attach (vnc_url_label, 0, 3, 1, 1); + content_grid.attach (vnc_url_entry, 1, 3, 1, 1); + content_grid.attach (rdp_url_label, 0, 4, 1, 1); + content_grid.attach (rdp_url_entry, 1, 4, 1, 1); + content_grid.attach (password_label, 0, 5, 1, 1); + content_grid.attach (password_entry, 1, 5, 1, 1); + + link_button.label = _("Network settingsā€¦"); + link_button.tooltip_text = _("Open Network settings"); + link_button.uri = "settings://network/network"; + link_button.no_show_all = false; + } + + private void set_service_state () { + if (rdp_settings.get_boolean ("enable")) { + update_state (ServiceState.ENABLED); + } else { + update_state (ServiceState.DISABLED); + } + } +} diff --git a/src/Widgets/SettingsView.vala b/src/Widgets/SettingsView.vala index 158f4161..ec31f919 100644 --- a/src/Widgets/SettingsView.vala +++ b/src/Widgets/SettingsView.vala @@ -27,6 +27,12 @@ public class Sharing.Widgets.SettingsView : Gtk.Stack { settings_pages.@set (dlna_page.id, dlna_page); this.add_named (dlna_page, dlna_page.id); + + GnomeRemoteDesktopPage grd_page = new GnomeRemoteDesktopPage (); + + settings_pages.@set (grd_page.id, grd_page); + + this.add_named (grd_page, grd_page.id); } public SettingsPage[] get_settings_pages () { diff --git a/src/meson.build b/src/meson.build index ab3e90c6..c78cafe2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -24,6 +24,8 @@ shared_module( dependency('gobject-2.0'), dependency('granite'), dependency('gtk+-3.0'), + dependency('libnm', version: '>=1.20.6'), + dependency('libnma'), switchboard_dep ], install: true, From 691c438c4c56e8f72971fbeefbd0513c64a7de05 Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Wed, 8 Feb 2023 08:19:58 -0500 Subject: [PATCH 3/6] Invest Remote Control switch behavior by adding SettingsBindFlags.INVERT_BOOLEAN Remote Control switch work like the one in Gnome Control Panel -> Sharing -> Remote Desktop where ON = OFF & OFF = ON Setting Key is called view-only & Remote Control sound batter. --- src/Widgets/GnomeRemoteDesktopPage.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/GnomeRemoteDesktopPage.vala b/src/Widgets/GnomeRemoteDesktopPage.vala index 19de9680..239b7580 100755 --- a/src/Widgets/GnomeRemoteDesktopPage.vala +++ b/src/Widgets/GnomeRemoteDesktopPage.vala @@ -41,11 +41,11 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { rdp_settings = new GLib.Settings ("org.gnome.desktop.remote-desktop.rdp"); vnc_settings.bind ("enable", useLegicyVNCMode_switch, "active", SettingsBindFlags.NO_SENSITIVITY); - vnc_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + vnc_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY|SettingsBindFlags.INVERT_BOOLEAN); vnc_settings.set_boolean("view-only", remoteControl_switch.state); rdp_settings.bind ("enable", service_switch, "active", SettingsBindFlags.NO_SENSITIVITY); - rdp_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + rdp_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY|SettingsBindFlags.INVERT_BOOLEAN); rdp_settings.set_boolean("view-only", remoteControl_switch.state); From 92c79362505b69f8e212a6b46d43c9fe27771ff4 Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Wed, 8 Feb 2023 08:27:49 -0500 Subject: [PATCH 4/6] add build.sh .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5975d974..ef4fb69b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ build/ +build.sh \ No newline at end of file From 3fd4a65c7371626e77f9b22eab35528709f4cf14 Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Wed, 8 Feb 2023 10:10:51 -0500 Subject: [PATCH 5/6] Hide vnc_url on launcher is useLegicyVNCMode_switch is off This commit fix a bug that was created when I add Gnome Remote Desktop Support panel to this repo witch does not hide the vnc_url & it label when the switch is turn off. --- src/Widgets/GnomeRemoteDesktopPage.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Widgets/GnomeRemoteDesktopPage.vala b/src/Widgets/GnomeRemoteDesktopPage.vala index 239b7580..8744a394 100755 --- a/src/Widgets/GnomeRemoteDesktopPage.vala +++ b/src/Widgets/GnomeRemoteDesktopPage.vala @@ -48,11 +48,15 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { rdp_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY|SettingsBindFlags.INVERT_BOOLEAN); rdp_settings.set_boolean("view-only", remoteControl_switch.state); - service_switch.notify ["active"].connect (() => { set_service_state (); }); - + + vnc_settings.changed ["enable"].connect ((state) => { + bool is_visible = vnc_settings.get_boolean(state) + vnc_url_label.visible = is_visible; + vnc_url_entry.visible = is_visible; + }); set_service_state (); } From 72da5f41b779a799e654cb5359a4be608e10df28 Mon Sep 17 00:00:00 2001 From: DJABhipHop Date: Thu, 9 Feb 2023 10:44:06 -0500 Subject: [PATCH 6/6] Fix Spelling Mistake Note: Spelling of "Legicy" should be "Legacy". --- src/Widgets/GnomeRemoteDesktopPage.vala | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Widgets/GnomeRemoteDesktopPage.vala b/src/Widgets/GnomeRemoteDesktopPage.vala index 8744a394..e486af3a 100755 --- a/src/Widgets/GnomeRemoteDesktopPage.vala +++ b/src/Widgets/GnomeRemoteDesktopPage.vala @@ -22,7 +22,7 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { GLib.Settings vnc_settings; GLib.Settings rdp_settings; - Gtk.Switch useLegicyVNCMode_switch; + Gtk.Switch useLegacyVNCMode_switch; Gtk.Switch remoteControl_switch; Gtk.Entry deviceName_entry; Gtk.Label vnc_url_label; @@ -40,7 +40,7 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { vnc_settings = new GLib.Settings ("org.gnome.desktop.remote-desktop.vnc"); rdp_settings = new GLib.Settings ("org.gnome.desktop.remote-desktop.rdp"); - vnc_settings.bind ("enable", useLegicyVNCMode_switch, "active", SettingsBindFlags.NO_SENSITIVITY); + vnc_settings.bind ("enable", useLegacyVNCMode_switch, "active", SettingsBindFlags.NO_SENSITIVITY); vnc_settings.bind ("view-only", remoteControl_switch, "active", SettingsBindFlags.NO_SENSITIVITY|SettingsBindFlags.INVERT_BOOLEAN); vnc_settings.set_boolean("view-only", remoteControl_switch.state); @@ -69,8 +69,8 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { critical (e.message); } - var useLegicyVNCMode_label = new Gtk.Label (_("Use Legicy VNC Mode")); - ((Gtk.Misc) useLegicyVNCMode_label).xalign = 1.0f; + var useLegacyVNCMode_label = new Gtk.Label (_("Use Legacy VNC Mode")); + ((Gtk.Misc) useLegacyVNCMode_label).xalign = 1.0f; var viewOnly_label = new Gtk.Label (_("Remote Control")); ((Gtk.Misc) viewOnly_label).xalign = 1.0f; @@ -87,9 +87,9 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { var password_label = new Gtk.Label (_("Password")); ((Gtk.Misc) password_label).xalign = 1.0f; - useLegicyVNCMode_switch = new Gtk.Switch(); - useLegicyVNCMode_switch.halign = Gtk.Align.START; - useLegicyVNCMode_switch.state_set.connect ((state) => { + useLegacyVNCMode_switch = new Gtk.Switch(); + useLegacyVNCMode_switch.halign = Gtk.Align.START; + useLegacyVNCMode_switch.state_set.connect ((state) => { vnc_url_label.visible = state; vnc_url_entry.visible = state; return false; @@ -118,8 +118,8 @@ public class Sharing.Widgets.GnomeRemoteDesktopPage : SettingsPage { password_entry.text = client.hostname; password_entry.set_visibility (false); - content_grid.attach (useLegicyVNCMode_label, 0, 0, 1, 1); - content_grid.attach (useLegicyVNCMode_switch, 1, 0, 1, 1); + content_grid.attach (useLegacyVNCMode_label, 0, 0, 1, 1); + content_grid.attach (useLegacyVNCMode_switch, 1, 0, 1, 1); content_grid.attach (viewOnly_label, 0, 1, 1, 1); content_grid.attach (remoteControl_switch, 1, 1, 1, 1); content_grid.attach (deviceName_label, 0, 2, 1, 1);