diff --git a/src/models/runners/basic.vala b/src/models/runners/basic.vala index 928f4bc..751b9f0 100644 --- a/src/models/runners/basic.vala +++ b/src/models/runners/basic.vala @@ -10,6 +10,6 @@ namespace ProtonPlus.Models.Runners { public abstract string get_directory_name (string release_name); - public abstract string get_directory_name_reverse (string release_name); + public abstract string get_directory_name_reverse (string directory_name); } } \ No newline at end of file diff --git a/src/widgets/application.vala b/src/widgets/application.vala index f2f4527..da81409 100644 --- a/src/widgets/application.vala +++ b/src/widgets/application.vala @@ -1,6 +1,6 @@ namespace ProtonPlus.Widgets { public class Application : Adw.Application { - public static Window window; + public static Window window { get; set; } construct { application_id = Constants.APP_ID; diff --git a/src/widgets/description-dialog.vala b/src/widgets/description-dialog.vala index 308ae1a..ec505a7 100644 --- a/src/widgets/description-dialog.vala +++ b/src/widgets/description-dialog.vala @@ -4,6 +4,7 @@ namespace ProtonPlus.Widgets { Adw.ToolbarView toolbar_view { get; set; } Adw.WindowTitle window_title { get; set; } + Adw.ButtonContent web_button_content { get; set; } Gtk.Button web_button { get; set; } Adw.HeaderBar header_bar { get; set; } Gtk.ScrolledWindow scrolled_window { get; set; } @@ -12,7 +13,12 @@ namespace ProtonPlus.Widgets { construct { window_title = new Adw.WindowTitle (_("More information"), ""); - web_button = new Gtk.Button.from_icon_name ("world-www-symbolic"); + web_button_content = new Adw.ButtonContent (); + web_button_content.set_icon_name ("world-www-symbolic"); + web_button_content.set_label (_("Open")); + + web_button = new Gtk.Button (); + web_button.set_child (web_button_content); web_button.set_tooltip_text (_("Open in your web browser")); web_button.clicked.connect (web_button_clicked); @@ -42,15 +48,11 @@ namespace ProtonPlus.Widgets { set_content (toolbar_view); set_transient_for (Application.window); set_modal (true); - - notify["release"].connect (release_changed); } public DescriptionDialog (Models.Release release) { this.release = release; - } - void release_changed () { window_title.set_subtitle (release.displayed_title); description_label.set_label (release.description); } diff --git a/src/widgets/info-box.vala b/src/widgets/info-box.vala index 486c0b9..e9c03ed 100644 --- a/src/widgets/info-box.vala +++ b/src/widgets/info-box.vala @@ -1,7 +1,5 @@ namespace ProtonPlus.Widgets { public class InfoBox : Gtk.Box { - public bool installed_only { get; set; } - public Gtk.Button sidebar_button { get; set; } Menu menu_model { get; set; } Gtk.MenuButton menu_button { get; set; } @@ -39,8 +37,6 @@ namespace ProtonPlus.Widgets { launcher_boxes = new List (); - notify["installed-only"].connect (installed_only_changed); - append (toolbar_view); } @@ -55,18 +51,5 @@ namespace ProtonPlus.Widgets { launcher_boxes.append (launcher_box); } } - - void installed_only_changed () { - foreach (var box in launcher_boxes) { - foreach (var group in box.group_rows) { - foreach (var runner in group.runner_rows) { - runner.load_more_row.set_visible (!installed_only); - foreach (var release in runner.release_rows) { - release.show_installed_only (installed_only); - } - } - } - } - } } } \ No newline at end of file diff --git a/src/widgets/launcher-box.vala b/src/widgets/launcher-box.vala index 6d3cd75..2941a40 100644 --- a/src/widgets/launcher-box.vala +++ b/src/widgets/launcher-box.vala @@ -1,18 +1,16 @@ namespace ProtonPlus.Widgets { public class LauncherBox : Gtk.Widget { Models.Launcher launcher { get; set; } + Gtk.BinLayout bin_layout { get; set; } Gtk.Box content { get; set; } Adw.Clamp clamp { get; set; } Gtk.ScrolledWindow scrolled_window { get; set; } - public List group_rows; public LauncherBox (Models.Launcher launcher) { this.launcher = launcher; - group_rows = new List (); - - var bin = new Gtk.BinLayout (); - set_layout_manager (bin); + bin_layout = new Gtk.BinLayout (); + set_layout_manager (bin_layout); content = new Gtk.Box (Gtk.Orientation.VERTICAL, 15); @@ -28,7 +26,6 @@ namespace ProtonPlus.Widgets { foreach (var group in launcher.groups) { var runner_group = new RunnerGroup (group); - group_rows.append (runner_group); content.append (runner_group); } } diff --git a/src/widgets/release-row.vala b/src/widgets/release-row.vala index d50e31c..94adbf5 100644 --- a/src/widgets/release-row.vala +++ b/src/widgets/release-row.vala @@ -43,7 +43,5 @@ namespace ProtonPlus.Widgets { protected abstract void remove_button_clicked (); protected abstract void info_button_clicked (); - - public abstract void show_installed_only (bool installed_only); } } \ No newline at end of file diff --git a/src/widgets/release-rows/basic.vala b/src/widgets/release-rows/basic.vala index 0ecb05e..be6e40d 100644 --- a/src/widgets/release-rows/basic.vala +++ b/src/widgets/release-rows/basic.vala @@ -76,10 +76,6 @@ namespace ProtonPlus.Widgets.ReleaseRows { description_dialog.present (); } - public override void show_installed_only (bool installed_only) { - set_visible (installed_only ? release.state == Models.Release.State.UP_TO_DATE || release.state == Models.Release.State.UPDATE_AVAILABLE : true); - } - void release_displayed_title_changed () { set_title (release.displayed_title); } diff --git a/src/widgets/release-rows/steamtinkerlaunch.vala b/src/widgets/release-rows/steamtinkerlaunch.vala index 9124d8b..eddf8f3 100644 --- a/src/widgets/release-rows/steamtinkerlaunch.vala +++ b/src/widgets/release-rows/steamtinkerlaunch.vala @@ -13,15 +13,11 @@ namespace ProtonPlus.Widgets.ReleaseRows { upgrade_button.clicked.connect (upgrade_button_clicked); input_box.append (upgrade_button); - - notify["release"].connect (release_changed); } public SteamTinkerLaunch (Models.Releases.SteamTinkerLaunch release) { this.release = release; - } - void release_changed () { install_dialog.initialize (release); remove_dialog.initialize (release); upgrade_dialog.initialize (release); @@ -200,10 +196,6 @@ namespace ProtonPlus.Widgets.ReleaseRows { } } - public override void show_installed_only (bool installed_only) { - set_visible (installed_only ? release.state == Models.Release.State.UP_TO_DATE || release.state == Models.Release.State.UPDATE_AVAILABLE : true); - } - void release_displayed_title_changed () { set_title (release.displayed_title); } diff --git a/src/widgets/runner-group.vala b/src/widgets/runner-group.vala index 8f94998..3ccb26a 100644 --- a/src/widgets/runner-group.vala +++ b/src/widgets/runner-group.vala @@ -1,16 +1,11 @@ namespace ProtonPlus.Widgets { public class RunnerGroup : Adw.PreferencesGroup { - public List runner_rows; - public RunnerGroup (Models.Group group) { - runner_rows = new List (); - set_title (group.title); set_description (group.description); foreach (var runner in group.runners) { var runner_row = new RunnerRow (runner); - runner_rows.append (runner_row); add (runner_row); } } diff --git a/src/widgets/runner-row.vala b/src/widgets/runner-row.vala index a4a5178..2a58c86 100644 --- a/src/widgets/runner-row.vala +++ b/src/widgets/runner-row.vala @@ -2,14 +2,11 @@ namespace ProtonPlus.Widgets { public class RunnerRow : Adw.ExpanderRow { Models.Runner runner { get; set; } Gtk.Spinner spinner { get; set; } - public LoadMoreRow load_more_row { get; set; } - public List release_rows; + LoadMoreRow load_more_row { get; set; } public RunnerRow (Models.Runner runner) { this.runner = runner; - release_rows = new List (); - load_more_row = new LoadMoreRow (); load_more_row.activated.connect (load_more_row_activated); @@ -33,11 +30,9 @@ namespace ProtonPlus.Widgets { foreach (var release in releases) { if (release is Models.Releases.Basic || release is Models.Releases.GitHubAction) { var row = new Widgets.ReleaseRows.Basic ((Models.Releases.Basic) release); - release_rows.append (row); add_row (row); } else if (release is Models.Releases.SteamTinkerLaunch) { var row = new Widgets.ReleaseRows.SteamTinkerLaunch ((Models.Releases.SteamTinkerLaunch) release); - release_rows.append (row); add_row (row); } } diff --git a/src/widgets/sidebar.vala b/src/widgets/sidebar.vala index 9253cce..3ed5842 100644 --- a/src/widgets/sidebar.vala +++ b/src/widgets/sidebar.vala @@ -1,55 +1,33 @@ namespace ProtonPlus.Widgets { public class Sidebar : Gtk.Box { public Gtk.Button sidebar_button { get; set; } - public Gtk.Switch installed_only_switch { get; set; } - - Gtk.ListBox list_box; + Adw.ToolbarView toolbar_view { get; set; } + Adw.WindowTitle window_title { get; set; } + Adw.HeaderBar header_bar { get; set; } + Gtk.ListBox list_box { get; set; } construct { sidebar_button = new Gtk.Button.from_icon_name ("layout-sidebar-symbolic"); sidebar_button.set_tooltip_text (_("Toggle Sidebar")); - var window_title = new Adw.WindowTitle ("ProtonPlus", ""); + window_title = new Adw.WindowTitle ("ProtonPlus", ""); - var header = new Adw.HeaderBar (); - header.set_title_widget (window_title); - header.pack_start (sidebar_button); + header_bar = new Adw.HeaderBar (); + header_bar.set_title_widget (window_title); + header_bar.pack_start (sidebar_button); list_box = new Gtk.ListBox (); list_box.set_activate_on_single_click (true); list_box.set_selection_mode (Gtk.SelectionMode.SINGLE); list_box.add_css_class ("navigation-sidebar"); list_box.set_hexpand (true); - list_box.row_selected.connect ((row) => { - this.activate_action_variant ("win.load-info-box", row.get_index ()); - }); - - installed_only_switch = new Gtk.Switch (); - installed_only_switch.set_tooltip_text (_("Only display the runners that are currently installed on your system")); - - var installed_only_label = new Gtk.Label (_("Only Installed")); - installed_only_label.set_hexpand (true); - installed_only_label.set_halign (Gtk.Align.START); - - var installed_only_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5); - installed_only_box.set_margin_bottom (15); - installed_only_box.set_margin_top (15); - installed_only_box.set_margin_start (20); - installed_only_box.set_margin_end (20); - installed_only_box.set_vexpand (true); - installed_only_box.set_valign (Gtk.Align.END); - installed_only_box.append (installed_only_label); - installed_only_box.append (installed_only_switch); + list_box.row_selected.connect (list_box_row_selected); - var content = new Gtk.Box (Gtk.Orientation.VERTICAL, 5); - content.append (list_box); - content.append (installed_only_box); + toolbar_view = new Adw.ToolbarView (); + toolbar_view.add_top_bar (header_bar); + toolbar_view.set_content (list_box); - var toolbar_view = new Adw.ToolbarView (); - toolbar_view.add_top_bar (header); - toolbar_view.set_content (content); - - this.append (toolbar_view); + append (toolbar_view); } public void initialize (List launchers) { @@ -64,5 +42,9 @@ namespace ProtonPlus.Widgets { list_box.select_row (list_box.get_row_at_index (0)); } } + + void list_box_row_selected (Gtk.ListBoxRow? row) { + activate_action_variant ("win.load-info-box", row.get_index ()); + } } } \ No newline at end of file diff --git a/src/widgets/status-box.vala b/src/widgets/status-box.vala index b645ffe..17e9ab7 100644 --- a/src/widgets/status-box.vala +++ b/src/widgets/status-box.vala @@ -1,20 +1,22 @@ namespace ProtonPlus.Widgets { public class StatusBox : Gtk.Box { + Adw.ToolbarView toolbar_view { get; set; } + Adw.HeaderBar header_bar { get; set; } Adw.StatusPage status_page { get; set; } construct { - var header = new Adw.HeaderBar (); - header.add_css_class ("flat"); + header_bar = new Adw.HeaderBar (); + header_bar.add_css_class ("flat"); status_page = new Adw.StatusPage (); status_page.set_vexpand (true); status_page.set_hexpand (true); - var toolbar_view = new Adw.ToolbarView (); - toolbar_view.add_top_bar (header); + toolbar_view = new Adw.ToolbarView (); + toolbar_view.add_top_bar (header_bar); toolbar_view.set_content (status_page); - this.append (toolbar_view); + append (toolbar_view); } public void initialize (string? icon_name, string title, string description) { diff --git a/src/widgets/window.vala b/src/widgets/window.vala index 06cef76..e41ccbf 100644 --- a/src/widgets/window.vala +++ b/src/widgets/window.vala @@ -5,9 +5,12 @@ namespace ProtonPlus.Widgets { int tasks { get; set; } Adw.OverlaySplitView overlay_split_view { get; set; } + Adw.NavigationPage info_page { get; set; } + Adw.NavigationPage sidebar_page { get; set; } Widgets.StatusBox status_box { get; set; } Widgets.InfoBox info_box { get; set; } Widgets.Sidebar sidebar { get; set; } + Adw.Breakpoint breakpoint { get; set; } construct { set_application ((Adw.Application) GLib.Application.get_default ()); @@ -23,11 +26,9 @@ namespace ProtonPlus.Widgets { status_box = new Widgets.StatusBox (); - var info_page = new Adw.NavigationPage.with_tag (info_box = new Widgets.InfoBox (), "InfoBox", "main"); + info_page = new Adw.NavigationPage.with_tag (info_box = new Widgets.InfoBox (), "InfoBox", "main"); - var sidebar_page = new Adw.NavigationPage.with_tag (sidebar = new Widgets.Sidebar (), "Sidebar", "sidebar"); - - sidebar.installed_only_switch.notify["active"].connect (() => info_box.installed_only = sidebar.installed_only_switch.active); + sidebar_page = new Adw.NavigationPage.with_tag (sidebar = new Widgets.Sidebar (), "Sidebar", "sidebar"); overlay_split_view = new Adw.OverlaySplitView (); overlay_split_view.set_sidebar (sidebar_page); @@ -41,7 +42,7 @@ namespace ProtonPlus.Widgets { info_box.sidebar_button.clicked.connect (() => overlay_split_view.set_show_sidebar (!overlay_split_view.get_show_sidebar ())); - var breakpoint = new Adw.Breakpoint (Adw.BreakpointCondition.parse ("max-width: 625px")); + breakpoint = new Adw.Breakpoint (Adw.BreakpointCondition.parse ("max-width: 625px")); breakpoint.add_setter (overlay_split_view, "collapsed", true); add_breakpoint (breakpoint);