Skip to content

Commit

Permalink
refactor: Convert rest of general settings to modern libadwaita compo…
Browse files Browse the repository at this point in the history
…nents

Signed-off-by: Felicitas Pojtinger <[email protected]>
  • Loading branch information
pojntfx committed Jul 19, 2024
1 parent 979ed32 commit 1e8b6ab
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 28 deletions.
21 changes: 9 additions & 12 deletions internal/components/main_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ func AddMainMenu(
mpvCommandInput := preferencesBuilder.GetObject("mpv-command-input").Cast().(*adw.EntryRow)
verbosityLevelInput := preferencesBuilder.GetObject("verbosity-level-input").Cast().(*adw.SpinRow)
remoteGatewaySwitchInput := preferencesBuilder.GetObject("htorrent-remote-gateway-switch").Cast().(*gtk.Switch)
remoteGatewayURLInput := preferencesBuilder.GetObject("htorrent-url-input").Cast().(*gtk.Entry)
remoteGatewayUsernameInput := preferencesBuilder.GetObject("htorrent-username-input").Cast().(*gtk.Entry)
remoteGatewayPasswordInput := preferencesBuilder.GetObject("htorrent-password-input").Cast().(*gtk.Entry)
remoteGatewayURLRow := preferencesBuilder.GetObject("htorrent-url-row").Cast().(*adw.ActionRow)
remoteGatewayUsernameRow := preferencesBuilder.GetObject("htorrent-username-row").Cast().(*adw.ActionRow)
remoteGatewayPasswordRow := preferencesBuilder.GetObject("htorrent-password-row").Cast().(*adw.ActionRow)
remoteGatewayURLInput := preferencesBuilder.GetObject("htorrent-url-input").Cast().(*adw.EntryRow)
remoteGatewayUsernameInput := preferencesBuilder.GetObject("htorrent-username-input").Cast().(*adw.EntryRow)
remoteGatewayPasswordInput := preferencesBuilder.GetObject("htorrent-password-input").Cast().(*adw.PasswordEntryRow)
weronURLInput := preferencesBuilder.GetObject("weron-url-input").Cast().(*gtk.Entry)
weronICEInput := preferencesBuilder.GetObject("weron-ice-input").Cast().(*gtk.Entry)
weronTimeoutInput := preferencesBuilder.GetObject("weron-timeout-input").Cast().(*adw.SpinRow)
Expand Down Expand Up @@ -96,13 +93,13 @@ func AddMainMenu(

syncSensitivityState := func() {
if remoteGatewaySwitchInput.State() {
remoteGatewayURLRow.SetSensitive(true)
remoteGatewayUsernameRow.SetSensitive(true)
remoteGatewayPasswordRow.SetSensitive(true)
remoteGatewayURLInput.SetEditable(true)
remoteGatewayUsernameInput.SetEditable(true)
remoteGatewayPasswordInput.SetEditable(true)
} else {
remoteGatewayURLRow.SetSensitive(false)
remoteGatewayUsernameRow.SetSensitive(false)
remoteGatewayPasswordRow.SetSensitive(false)
remoteGatewayURLInput.SetEditable(false)
remoteGatewayUsernameInput.SetEditable(false)
remoteGatewayPasswordInput.SetEditable(false)
}
}
preferencesDialog.ConnectShow(syncSensitivityState)
Expand Down
73 changes: 57 additions & 16 deletions internal/resources/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,63 @@
</child>

<child>
<object class="AdwActionRow" id="htorrent-url-row">
<object class="AdwEntryRow" id="htorrent-url-input">
<property name="title" translatable="yes">URL</property>
<property name="subtitle" translatable="yes">API address of the remote gateway</property>
<property name="activatable-widget">htorrent-url-input</property>
<property name="sensitive">false</property>
<property name="editable">false</property>

<child>
<object class="GtkEntry" id="htorrent-url-input">
<object class="GtkMenuButton">
<style>
<class name="flat"></class>
<class name="circular"></class>
</style>

<property name="icon-name">help-about</property>
<property name="tooltip-text">Show help</property>
<property name="valign">center</property>
<property name="popover">htorrent-url-input-popover</property>
</object>
</child>
</object>
</child>

<child>
<object class="AdwActionRow" id="htorrent-username-row">
<object class="AdwEntryRow" id="htorrent-username-input">
<property name="title" translatable="yes">Username</property>
<property name="subtitle" translatable="yes">The remote gateway's username</property>
<property name="activatable-widget">htorrent-username-input</property>
<property name="sensitive">false</property>
<property name="editable">false</property>

<child>
<object class="GtkEntry" id="htorrent-username-input">
<object class="GtkMenuButton">
<style>
<class name="flat"></class>
<class name="circular"></class>
</style>

<property name="icon-name">help-about</property>
<property name="tooltip-text">Show help</property>
<property name="valign">center</property>
<property name="popover">htorrent-username-input-popover</property>
</object>
</child>
</object>
</child>

<child>
<object class="AdwActionRow" id="htorrent-password-row">
<object class="AdwPasswordEntryRow" id="htorrent-password-input">
<property name="title" translatable="yes">Password</property>
<property name="subtitle" translatable="yes">The remote gateway's password</property>
<property name="activatable-widget">htorrent-password-input</property>
<property name="sensitive">false</property>
<property name="editable">false</property>

<child>
<object class="GtkEntry" id="htorrent-password-input">
<object class="GtkMenuButton">
<style>
<class name="flat"></class>
<class name="circular"></class>
</style>

<property name="icon-name">help-about</property>
<property name="tooltip-text">Show help</property>
<property name="valign">center</property>
<property name="visibility">false</property>
<property name="popover">htorrent-password-input-popover</property>
</object>
</child>
</object>
Expand Down Expand Up @@ -220,4 +237,28 @@
</object>
</child>
</object>

<object class="GtkPopover" id="htorrent-url-input-popover">
<child>
<object class="GtkLabel">
<property name="label">API address of the remote gateway</property>
</object>
</child>
</object>

<object class="GtkPopover" id="htorrent-username-input-popover">
<child>
<object class="GtkLabel">
<property name="label">The remote gateway's username</property>
</object>
</child>
</object>

<object class="GtkPopover" id="htorrent-password-input-popover">
<child>
<object class="GtkLabel">
<property name="label">The remote gateway's password</property>
</object>
</child>
</object>
</interface>

0 comments on commit 1e8b6ab

Please sign in to comment.