From 47ef2cf3fc8a3bb18c663d9b6d97b5a0b6ccf5a7 Mon Sep 17 00:00:00 2001 From: Philipp Unger Date: Sun, 3 Jul 2022 19:58:47 +0200 Subject: [PATCH 01/82] updated to gtk4, compiles again but nothing works yet --- src/actions-popover.vala | 2 +- src/application.vala | 10 +-- src/assistant.vala | 10 +-- src/collection-view-child.vala | 3 +- src/collection-view.vala | 20 ++--- src/connection.vala | 6 +- src/display-view.vala | 132 ++++++++++++++++---------------- src/meson.build | 26 ++++--- src/notifications.vala | 26 +++---- src/onboarding-dialog-page.vala | 2 +- src/onboarding-dialog.vala | 11 +-- src/preferences-widgets.vala | 6 +- src/rdp-connection.vala | 43 ++++++----- src/topbar.vala | 14 ++-- src/ui/assistant.ui | 4 +- src/ui/collection-view.ui | 1 - src/ui/display-view.ui | 5 +- src/ui/onboarding-dialog.ui | 7 +- src/ui/rdp-preferences.ui | 8 +- src/ui/topbar.ui | 2 +- src/ui/vnc-preferences.ui | 14 ++-- src/ui/window.ui | 4 +- src/vnc-connection.vala | 125 ++++++++++++++++-------------- src/window.vala | 72 ++++++++--------- 24 files changed, 279 insertions(+), 274 deletions(-) diff --git a/src/actions-popover.vala b/src/actions-popover.vala index b06687b..d85b348 100644 --- a/src/actions-popover.vala +++ b/src/actions-popover.vala @@ -48,7 +48,7 @@ namespace Connections { menu.append (_("Properties"), "connection.properties"); action.set_enabled (true); - bind_model (menu, null); + // set_menu_model (menu); } private void delete_activated () { diff --git a/src/application.vala b/src/application.vala index ce2dee9..20d6a35 100644 --- a/src/application.vala +++ b/src/application.vala @@ -66,9 +66,9 @@ namespace Connections { private void show_help () { try { - Gtk.show_uri_on_window (main_window, - "help:gnome-connections", - Gtk.get_current_event_time ()); + // Gtk.show_uri_on_window (main_window, + // "help:gnome-connections", + // Gtk.get_current_event_time ()); } catch (GLib.Error error) { warning ("Failed to display help: %s", error.message); } @@ -98,8 +98,8 @@ namespace Connections { public override void startup () { base.startup (); - Hdy.init (); - Hdy.StyleManager.get_default ().color_scheme = PREFER_DARK; + Adw.init (); + Adw.StyleManager.get_default ().color_scheme = PREFER_DARK; } public override void activate () { diff --git a/src/assistant.vala b/src/assistant.vala index b4e5e71..78f1982 100644 --- a/src/assistant.vala +++ b/src/assistant.vala @@ -27,9 +27,9 @@ namespace Connections { [GtkChild] private unowned Gtk.Button create_button; [GtkChild] - private unowned Gtk.RadioButton rdp_radio_button; + private unowned Gtk.ToggleButton rdp_radio_button; [GtkChild] - private unowned Gtk.RadioButton vnc_radio_button; + private unowned Gtk.ToggleButton vnc_radio_button; private bool uri_has_supported_scheme (string uri) { return uri.has_prefix ("rdp://") || uri.has_prefix ("vnc://"); @@ -92,9 +92,9 @@ namespace Connections { [GtkCallback] private void on_help_button_clicked () { try { - Gtk.show_uri_on_window (Application.application.main_window, - "help:gnome-connections/connect", - Gtk.get_current_event_time ()); + // Gtk.show_uri_on_window (Application.application.main_window, + // "help:gnome-connections/connect", + // Gtk.get_current_event_time ()); } catch (GLib.Error error) { warning ("Failed to display help: %s", error.message); } diff --git a/src/collection-view-child.vala b/src/collection-view-child.vala index 1d4c0c5..8deb152 100644 --- a/src/collection-view-child.vala +++ b/src/collection-view-child.vala @@ -50,8 +50,7 @@ namespace Connections { thumbnail_id = 0; if (!connection.connected) { - thumbnail.set_from_icon_name ("org.gnome.Connections-symbolic", - Gtk.IconSize.LARGE_TOOLBAR); + thumbnail.set_from_icon_name ("org.gnome.Connections-symbolic"); return Source.REMOVE; } diff --git a/src/collection-view.vala b/src/collection-view.vala index bb5e1d1..cd863da 100644 --- a/src/collection-view.vala +++ b/src/collection-view.vala @@ -21,7 +21,7 @@ namespace Connections { [GtkTemplate (ui = "/org/gnome/Connections/ui/collection-view.ui")] - public class CollectionView : Gtk.ScrolledWindow { + public class CollectionView : Gtk.Widget { [GtkChild] private unowned Gtk.FlowBox flowbox; [GtkChild] @@ -46,7 +46,7 @@ namespace Connections { child.halign = Gtk.Align.START; var box = new CollectionViewChild (item as Connection); - child.add (box); + child.set_child (box); return child; } @@ -60,15 +60,15 @@ namespace Connections { Application.application.open_connection (item.connection); } - [GtkCallback] - private bool on_button_release_event (Gdk.EventButton event) { - if (event.type != Gdk.EventType.BUTTON_RELEASE || event.button != 3) - return false; + // [GtkCallback] + // private bool on_button_release_event (Gdk.EventButton event) { + // if (event.type != Gdk.EventType.BUTTON_RELEASE || event.button != 3) + // return false; - var child = flowbox.get_child_at_pos ((int) event.x, (int) event.y); + // var child = flowbox.get_child_at_pos ((int) event.x, (int) event.y); - return launch_context_popover_for_child (child); - } + // return launch_context_popover_for_child (child); + // } todo use Gtk.GestureClick private bool launch_context_popover_for_child (Gtk.FlowBoxChild child) { var item = child.get_child () as CollectionViewChild; @@ -76,7 +76,7 @@ namespace Connections { return false; popover.update_for_item (item.connection); - popover.set_relative_to (item.thumbnail); + // popover.set_relative_to (item.thumbnail); popover.show (); return true; diff --git a/src/connection.vala b/src/connection.vala index eb90c07..51c0566 100644 --- a/src/connection.vala +++ b/src/connection.vala @@ -75,9 +75,9 @@ namespace Connections { Notification.OKFunc open = () => { debug ("Opening screenshot file"); try { - Gtk.show_uri_on_window (Application.application.main_window, - File.new_for_path (path).get_uri () + ".png", - Gdk.CURRENT_TIME); + // Gtk.show_uri_on_window (Application.application.main_window, + // File.new_for_path (path).get_uri () + ".png", + // Gdk.CURRENT_TIME); } catch (GLib.Error error) { warning ("Failed to open screenshot: %s", error.message); } diff --git a/src/display-view.vala b/src/display-view.vala index c731038..2926131 100644 --- a/src/display-view.vala +++ b/src/display-view.vala @@ -26,7 +26,7 @@ namespace Connections { [GtkTemplate (ui = "/org/gnome/Connections/ui/display-view.ui")] private class DisplayView : Gtk.Box { [GtkChild] - private unowned EventBox event_box; + private unowned Frame event_box; [GtkChild] private unowned Stack stack; @@ -41,13 +41,13 @@ namespace Connections { private ulong show_display_id; construct { - event_box.set_events (EventMask.POINTER_MOTION_MASK | EventMask.SCROLL_MASK); + //event_box.set_events (EventMask.POINTER_MOTION_MASK | EventMask.SCROLL_MASK); } private void remove_display () { var widget = event_box.get_child (); if (widget != null) - event_box.remove (widget); + event_box.set_child (null); if (connection == null) return; @@ -65,20 +65,20 @@ namespace Connections { this.connection = connection; var display = connection.widget; - display.set_events (display.get_events () & ~EventMask.POINTER_MOTION_MASK); - event_box.add (display); - event_box.show_all (); + //display.set_events (display.get_events () & ~EventMask.POINTER_MOTION_MASK); + // event_box.add (display); + // event_box.show_all (); - ulong draw_id = 0; - draw_id = display.draw.connect (() => { - display.disconnect (draw_id); + // ulong draw_id = 0; + // draw_id = display.draw.connect (() => { + // display.disconnect (draw_id); - /*cursor_id = display.get_window ().notify["cursor"].connect (() => { - event_box.get_window ().set_cursor (display.get_window ().cursor); - });*/ + // /*cursor_id = display.get_window ().notify["cursor"].connect (() => { + // event_box.get_window ().set_cursor (display.get_window ().cursor); + // });*/ - return false; - }); + // return false; + // }); } public void connect_to (Connection connection) { @@ -99,65 +99,65 @@ namespace Connections { stack.set_visible_child_name ("display"); } - [GtkCallback] - private bool on_event_box_event (Gdk.Event event) { - if (event.type == EventType.GRAB_BROKEN) - return false; - - if (event_box.get_child () != null) { - var child = event_box.get_child (); - var offset_x = (get_allocated_width () - child.get_allocated_width ()) / 2.0; - var offset_y = (get_allocated_height () - child.get_allocated_height ()) / 2.0; - - switch (event.get_event_type ()) { - case Gdk.EventType.MOTION_NOTIFY: - event.motion.x -= offset_x; - event.motion.y -= offset_y; - break; - - default: - break; - } - - child.event (event); - } + // [GtkCallback] + // private bool on_event_box_event (Gdk.Event event) { + // if (event.type == EventType.GRAB_BROKEN) + // return false; + + // if (event_box.get_child () != null) { + // var child = event_box.get_child (); + // var offset_x = (get_allocated_width () - child.get_allocated_width ()) / 2.0; + // var offset_y = (get_allocated_height () - child.get_allocated_height ()) / 2.0; + + // switch (event.get_event_type ()) { + // case Gdk.EventType.MOTION_NOTIFY: + // event.motion.x -= offset_x; + // event.motion.y -= offset_y; + // break; + + // default: + // break; + // } + + // child.event (event); + // } - return false; - } + // return false; + // } private uint size_label_timeout; private int width = -1; private int height = -1; - [GtkCallback] - private void on_size_allocate (Gtk.Allocation allocation) { - if (width == allocation.width && height == allocation.height) { - return; - } + // [GtkCallback] + // private void on_size_allocate (Gtk.Allocation allocation) { + // if (width == allocation.width && height == allocation.height) { + // return; + // } - width = allocation.width; - height = allocation.height; + // width = allocation.width; + // height = allocation.height; // Translators: Showing size of widget as WIDTH×HEIGHT here. - size_label.label = _("%d×%d").printf (allocation.width, allocation.height); + // size_label.label = _("%d×%d").printf (allocation.width, allocation.height); - Idle.add (() => { - size_label.visible = true; + // Idle.add (() => { + // size_label.visible = true; - if (size_label_timeout != 0) { - Source.remove (size_label_timeout); - size_label_timeout = 0; - } + // if (size_label_timeout != 0) { + // Source.remove (size_label_timeout); + // size_label_timeout = 0; + // } - size_label_timeout = Timeout.add_seconds (3, () => { - size_label.visible = false; - size_label_timeout = 0; + // size_label_timeout = Timeout.add_seconds (3, () => { + // size_label.visible = false; + // size_label_timeout = 0; - return false; - }); + // return false; + // }); - return false; - }); - } + // return false; + // }); + // } [GtkCallback] private void on_escape_fullscreen_button_clicked () { @@ -165,13 +165,13 @@ namespace Connections { escape_fullscreen_button.visible = false; } - public override bool motion_notify_event (Gdk.EventMotion event) { - if (!Application.application.main_window.fullscreened) - return false; + // public override bool motion_notify_event (Gdk.EventMotion event) { + // if (!Application.application.main_window.fullscreened) + // return false; - escape_fullscreen_button.visible = (event.y < 40); + // escape_fullscreen_button.visible = (event.y < 40); - return base.motion_notify_event (event); - } + // return base.motion_notify_event (event); + // } todo use event controller } } diff --git a/src/meson.build b/src/meson.build index 1f21fc1..a926b42 100644 --- a/src/meson.build +++ b/src/meson.build @@ -27,25 +27,27 @@ connections_deps = [ valac.find_library ('config', dirs: src_dir), cc.find_library('m'), dependency('gio-2.0', version: '>= 2.50'), - dependency('gtk+-3.0', version: '>= 3.22'), - dependency('gtk-vnc-2.0', version: '> 0.4.4'), + dependency('atk'), + dependency('gtk4'), + # dependency('gtk-vnc-2.0', version: '> 0.4.4'), dependency('gvncpulse-1.0'), - dependency('libhandy-1', version: '>= 1.6.0'), + #dependency('libhandy-1', version: '>= 1.6.0'), + dependency('libadwaita-1'), dependency ('libxml-2.0', version: '>= 2.7.8'), dependency ('libsecret-1'), ] -gtk_frdp_dep = dependency('gtk-frdp-0.1', required: false) +# gtk_frdp_dep = dependency('gtk-frdp-0.1', required: false) -if gtk_frdp_dep.found() - connections_deps += gtk_frdp_dep -else - gtk_frdp_dep = subproject('gtk-frdp', default_options: [ - 'package_subdir=' + meson.project_name() - ]) +# if gtk_frdp_dep.found() +# connections_deps += gtk_frdp_dep +# else +# gtk_frdp_dep = subproject('gtk-frdp', default_options: [ +# 'package_subdir=' + meson.project_name() +# ]) - connections_deps += gtk_frdp_dep.get_variable('gtk_frdp_vapi') -endif +# connections_deps += gtk_frdp_dep.get_variable('gtk_frdp_vapi') +# endif gnome = import('gnome') diff --git a/src/notifications.vala b/src/notifications.vala index 5b9b63f..b210ca6 100644 --- a/src/notifications.vala +++ b/src/notifications.vala @@ -20,7 +20,7 @@ */ namespace Connections { - private class NotificationsBar : Gtk.Bin { + private class NotificationsBar : Gtk.Frame { public const int DEFAULT_TIMEOUT = 6; private const int MAX_NOTIFICATIONS = 5; @@ -31,12 +31,12 @@ namespace Connections { } set { - if (_active_notification != null) { - remove (_active_notification); - } + // if (_active_notification != null) { + // remove (_active_notification); + // } _active_notification = value; - add (_active_notification); + // add (_active_notification); } } @@ -96,7 +96,7 @@ namespace Connections { } [GtkTemplate (ui = "/org/gnome/Connections/ui/notification.ui")] - private class Notification : Gtk.Revealer { + private class Notification : Gtk.Widget { public signal void dismissed (); public delegate void OKFunc (); @@ -117,7 +117,7 @@ namespace Connections { owned DismissFunc? dismiss_func, int timeout = NotificationsBar.DEFAULT_TIMEOUT) { this.dismiss_func = (owned)dismiss_func; - set_reveal_child (true); + // set_reveal_child (true); message_label.label = message; @@ -134,7 +134,7 @@ namespace Connections { if (ok_func != null) ok_func (); - set_reveal_child (false); + // set_reveal_child (false); dismissed (); if (notification_timeout_id != 0) { @@ -143,14 +143,14 @@ namespace Connections { } }); - ok_button.show_all (); + ok_button.show (); } } [GtkCallback] public void dismiss () { dismissed (); - set_reveal_child (false); + // set_reveal_child (false); if (dismiss_func != null) dismiss_func (); @@ -162,7 +162,7 @@ namespace Connections { } [GtkTemplate (ui = "/org/gnome/Connections/ui/auth-notification.ui")] - private class AuthNotification : Gtk.Revealer { + private class AuthNotification : Gtk.Widget { public delegate void AuthFunc (string username, string password); private bool auth_pressed; @@ -185,7 +185,7 @@ namespace Connections { owned AuthFunc? auth_func, owned Notification.DismissFunc? dismiss_func, bool need_username) { - set_reveal_child (true); + // set_reveal_child (true); title_label.label = auth_string; @@ -230,7 +230,7 @@ namespace Connections { } public void dismiss () { - set_reveal_child (false); + // set_reveal_child (false); dismissed (); } } diff --git a/src/onboarding-dialog-page.vala b/src/onboarding-dialog-page.vala index 69b8ab7..b38f385 100644 --- a/src/onboarding-dialog-page.vala +++ b/src/onboarding-dialog-page.vala @@ -38,7 +38,7 @@ namespace Connections { """.printf (image); try { - provider.load_from_data (css); + provider.load_from_data (css.data); get_style_context ().add_provider (provider, STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (GLib.Error error) { warning ("Failed to load CSS: %s", error.message); diff --git a/src/onboarding-dialog.vala b/src/onboarding-dialog.vala index bd6780c..4fe8889 100644 --- a/src/onboarding-dialog.vala +++ b/src/onboarding-dialog.vala @@ -20,11 +20,11 @@ */ using Gtk; -using Hdy; +using Adw; namespace Connections { [GtkTemplate (ui = "/org/gnome/Connections/ui/onboarding-dialog.ui")] - private class OnboardingDialog : Hdy.Window { + private class OnboardingDialog : Adw.Window { [GtkChild] private unowned Carousel paginator; [GtkChild] @@ -40,7 +40,8 @@ namespace Connections { pages = new GLib.List (); OnboardingDialogPage? onboarding_page = null; - foreach (var page in paginator.get_children ()) { + for (var i = 0; i < paginator.get_n_pages(); i++) { + var page = paginator.get_nth_page(i); assert (page is OnboardingDialogPage); onboarding_page = page as OnboardingDialogPage; @@ -60,7 +61,7 @@ namespace Connections { if (index >= pages.length ()) return; - paginator.scroll_to (pages.nth_data (index)); + paginator.scroll_to (pages.nth_data (index), true); } [GtkCallback] @@ -69,7 +70,7 @@ namespace Connections { if (index < 0) return; - paginator.scroll_to (pages.nth_data (index)); + paginator.scroll_to (pages.nth_data (index), true); } [GtkCallback] diff --git a/src/preferences-widgets.vala b/src/preferences-widgets.vala index 48cf470..8fb07a9 100644 --- a/src/preferences-widgets.vala +++ b/src/preferences-widgets.vala @@ -20,7 +20,7 @@ */ namespace Connections { - private class PreferencesWindow: Hdy.PreferencesWindow { + private class PreferencesWindow: Adw.PreferencesWindow { protected weak Connection connection; construct { @@ -36,7 +36,7 @@ namespace Connections { } } - private class BooleanProperty: Hdy.ActionRow { + private class BooleanProperty: Adw.ActionRow { public bool active { get; set; } construct { @@ -47,7 +47,7 @@ namespace Connections { bind_property ("active", widget, "active", BindingFlags.BIDIRECTIONAL); - add (widget); + set_child (widget); set_activatable_widget (widget); } } diff --git a/src/rdp-connection.vala b/src/rdp-connection.vala index 84213e8..651f226 100644 --- a/src/rdp-connection.vala +++ b/src/rdp-connection.vala @@ -43,7 +43,7 @@ namespace Connections { var surface = new Cairo.ImageSurface (ARGB32, alloc.width, alloc.height); var context = new Cairo.Context (surface); - widget.draw (context); + // widget.draw (context); return Gdk.pixbuf_get_from_surface (surface, 0, 0, alloc.width, alloc.height); } @@ -51,29 +51,29 @@ namespace Connections { public override bool scaling { set { - display.set_scaling (value); + // display.set_scaling (value); } get { if (!connected) return true; - return display.scaling; + return false; //display.scaling; } } public override int port { get; protected set; default = 3389; } construct { - display = new FrdpDisplay (); - display.hexpand = display.vexpand = true; - display.bind_property ("username", this, "username", BindingFlags.BIDIRECTIONAL); - display.bind_property ("password", this, "password", BindingFlags.BIDIRECTIONAL); + // display = new FrdpDisplay (); + // display.hexpand = display.vexpand = true; + // display.bind_property ("username", this, "username", BindingFlags.BIDIRECTIONAL); + // display.bind_property ("password", this, "password", BindingFlags.BIDIRECTIONAL); - display.rdp_error.connect (on_rdp_connection_error_cb); - display.rdp_connected.connect (() => { show (); }); + // display.rdp_error.connect (on_rdp_connection_error_cb); + // display.rdp_connected.connect (() => { show (); }); //display.rdp_needs_authentication.connect (on_rdp_auth_credential_cb); - display.rdp_auth_failure.connect (auth_failed); + // display.rdp_auth_failure.connect (auth_failed); //display.size_allocate.connect (scale); need_username = need_password = true; @@ -107,16 +107,16 @@ namespace Connections { return; } - display.open_host (host, port); + // display.open_host (host, port); connected = true; scaling = true; - display.grab_focus (); + // display.grab_focus (); } public override void disconnect_it () { - if (connected) - display.close (); + // if (connected) + // display.close (); connected = false; } @@ -142,13 +142,14 @@ namespace Connections { } } - private class FrdpDisplay : Frdp.Display { - public override bool authenticate (out string username, out string password, out string domain) { - username = this.username; - password = this.password; - domain = null; + private class FrdpDisplay : Gtk.DrawingArea { + // : Frdp.Display { + // public override bool authenticate (out string username, out string password, out string domain) { + // username = this.username; + // password = this.password; + // domain = null; - return true; - } + // return true; + // } } } diff --git a/src/topbar.vala b/src/topbar.vala index 2afc5cd..c79b050 100644 --- a/src/topbar.vala +++ b/src/topbar.vala @@ -21,9 +21,9 @@ namespace Connections { [GtkTemplate (ui = "/org/gnome/Connections/ui/topbar.ui")] - private class Topbar : Gtk.Stack { + private class Topbar : Gtk.Widget { [GtkChild] - private unowned Hdy.HeaderBar collection_toolbar; + private unowned Adw.HeaderBar collection_toolbar; [GtkChild] public unowned Gtk.Button search_button; [GtkChild] @@ -89,7 +89,7 @@ namespace Connections { [GtkCallback] private void back_button_clicked () { Application.application.main_window.show_collection_view (); - set_visible_child (collection_toolbar); + // set_visible_child (collection_toolbar); } [GtkCallback] @@ -102,19 +102,19 @@ namespace Connections { public void show_collection_view () { this.connection = null; - set_visible_child (collection_toolbar); + // set_visible_child (collection_toolbar); } public void show_display_view (Connection connection) { this.connection = connection; - set_visible_child (display_toolbar); + // set_visible_child (display_toolbar); - display_toolbar.set_title (connection.get_visible_name ()); + display_toolbar.set_title_widget (new Gtk.Label(connection.get_visible_name ())); } public void set_title (string title) { - collection_toolbar.set_title (title); + collection_toolbar.set_title_widget (new Gtk.Label(title)); } private void ctrl_alt_backspace_activated () { diff --git a/src/ui/assistant.ui b/src/ui/assistant.ui index a6a25eb..0b5c94e 100644 --- a/src/ui/assistant.ui +++ b/src/ui/assistant.ui @@ -58,7 +58,7 @@ - + True RDP (standard for connecting to Windows) @@ -66,7 +66,7 @@ - + True rdp_radio_button VNC (standard for connecting to Linux) diff --git a/src/ui/collection-view.ui b/src/ui/collection-view.ui index f689ebb..330fde9 100644 --- a/src/ui/collection-view.ui +++ b/src/ui/collection-view.ui @@ -38,7 +38,6 @@ start none - diff --git a/src/ui/display-view.ui b/src/ui/display-view.ui index f2239ba..ceed427 100644 --- a/src/ui/display-view.ui +++ b/src/ui/display-view.ui @@ -5,7 +5,6 @@ vertical 0 True - @@ -67,10 +66,10 @@ 980 640 - + True True - + diff --git a/src/ui/onboarding-dialog.ui b/src/ui/onboarding-dialog.ui index f21b280..5bddef8 100644 --- a/src/ui/onboarding-dialog.ui +++ b/src/ui/onboarding-dialog.ui @@ -1,12 +1,11 @@ -