Skip to content

Commit

Permalink
internal/ui: update to newer Libadwaita widgets and fix a bunch of UI…
Browse files Browse the repository at this point in the history
… bugs (#106)

* internal/ui: switch to `ConnectDrop()`

* internal/ui: fix `AdvertiseRouteButton`

* internal/ui: switch to the new `AdwNavigationSplitView`

* internal/ui: disable the title for the second header bar

* internal/ui: enable navigation via the peer stack

* internal/ui: fix breakpoint

* internal/ui: fix clicking on the file send row

Fixes #104.

* internal/ui: fix some more missing activatable widgets

* meta: add `v0.11.1` to metainfo
  • Loading branch information
DeedleFake authored Apr 4, 2024
1 parent a478233 commit e37ea77
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 126 deletions.
8 changes: 8 additions & 0 deletions dev.deedles.Trayscale.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
<content_rating type="oars-1.1" />

<releases>
<release version="v0.11.1" date="2024-04-04">
<description>
<ul>
<li>Update to use new Libadwaita widgets.</li>
<li>Fix a bunch of UI bugs.</li>
</ul>
</description>
</release>
<release version="v0.11.0" date="2024-03-17">
<description>
<ul>
Expand Down
9 changes: 2 additions & 7 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,9 @@ func (a *App) onAppActivate(ctx context.Context) {
return true
})

contentVariant := glib.NewVariantString("content")
a.win.PeersStack.NotifyProperty("visible-child", func() {
if a.win.PeersStack.VisibleChild() != nil {
a.win.Leaflet.Navigate(adw.NavigationDirectionForward)
}
})

a.win.BackButton.ConnectClicked(func() {
a.win.Leaflet.Navigate(adw.NavigationDirectionBack)
a.win.SplitView.ActivateAction("navigation.push", contentVariant)
})

a.win.ConnectCloseRequest(func() bool {
Expand Down
3 changes: 1 addition & 2 deletions internal/ui/mainwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ type MainWindow struct {
*adw.ApplicationWindow `gtk:"MainWindow"`

ToastOverlay *adw.ToastOverlay
Leaflet *adw.Leaflet
SplitView *adw.NavigationSplitView
StatusSwitch *gtk.Switch
MainMenuButton *gtk.MenuButton
BackButton *gtk.Button
PeersStack *gtk.Stack
WorkSpinner *gtk.Spinner
}
Expand Down
125 changes: 59 additions & 66 deletions internal/ui/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.16.0 -->
<!-- Created with Cambalache 0.17.2 -->
<interface>
<!-- interface-name mainwindow.ui -->
<requires lib="gtk" version="4.12"/>
Expand All @@ -8,83 +8,76 @@
<property name="content">ToastOverlay</property>
<property name="default-height">600</property>
<property name="default-width">800</property>
<property name="height-request">400</property>
<property name="title">Trayscale</property>
<property name="width-request">200</property>
<child>
<object class="AdwBreakpoint">
<!-- Custom fragments -->
<condition>max-width: 400sp</condition>
<setter object="SplitView" property="collapsed">True</setter>
</object>
</child>
<child>
<object class="AdwToastOverlay" id="ToastOverlay">
<child>
<object class="AdwLeaflet" id="Leaflet">
<property name="can-navigate-back">True</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="width-request">360</property>
<child>
<object class="AdwHeaderBar">
<property name="show-end-title-buttons">False</property>
<child type="start">
<object class="GtkSwitch" id="StatusSwitch"/>
</child>
<child type="end">
<object class="GtkMenuButton" id="MainMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="primary">True</property>
<!-- Custom fragments -->
<property name="menu-model">MainMenu</property>
<object class="AdwNavigationSplitView" id="SplitView">
<property name="content">
<object class="AdwNavigationPage">
<property name="child">
<object class="AdwToolbarView">
<property name="content">
<object class="GtkStack" id="PeersStack">
<property name="transition-type">slide-up-down</property>
</object>
</property>
<child type="top">
<object class="AdwHeaderBar">
<property name="show-start-title-buttons">False</property>
<property name="show-title">False</property>
<child type="end">
<object class="GtkSpinner" id="WorkSpinner"/>
</child>
</object>
</child>
<!-- Custom fragments -->
<binding name="show-end-title-buttons">
<lookup name="folded">Leaflet</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkStackSidebar">
<property name="stack">PeersStack</property>
<property name="vexpand">True</property>
<property name="width-request">270</property>
</object>
</child>
</property>
<property name="tag">content</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar">
<property name="show-start-title-buttons">False</property>
<child type="start">
<object class="GtkButton" id="BackButton">
<property name="has-frame">False</property>
<property name="icon-name">go-previous-symbolic</property>
<!-- Custom fragments -->
<binding name="visible">
<lookup name="folded">Leaflet</lookup>
</binding>
</property>
<property name="max-sidebar-width">360.0</property>
<property name="min-sidebar-width">200.0</property>
<property name="sidebar">
<object class="AdwNavigationPage">
<property name="child">
<object class="AdwToolbarView">
<property name="content">
<object class="GtkStackSidebar">
<property name="stack">PeersStack</property>
</object>
</property>
<child type="top">
<object class="AdwHeaderBar">
<property name="show-end-title-buttons">False</property>
<child type="start">
<object class="GtkSwitch" id="StatusSwitch"/>
</child>
<child type="end">
<object class="GtkMenuButton" id="MainMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="primary">True</property>
<!-- Custom fragments -->
<property name="menu-model">MainMenu</property>
</object>
</child>
</object>
</child>
<child type="title">
<object class="GtkBox"/>
</child>
<child type="end">
<object class="GtkSpinner" id="WorkSpinner"/>
</child>
<!-- Custom fragments -->
<binding name="show-start-title-buttons">
<lookup name="folded">Leaflet</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkStack" id="PeersStack">
<property name="transition-type">slide-up-down</property>
<property name="vexpand">True</property>
</object>
</child>
</property>
<property name="tag">sidebar</property>
<property name="title">Trayscale</property>
</object>
</child>
<!-- Custom fragments -->
</property>
</object>
</child>
</object>
Expand Down
4 changes: 1 addition & 3 deletions internal/ui/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ func (a *App) newPeerPage(status tsutil.Status, peer *ipnstate.PeerStatus) *peer
if !page.self {
page.container.AddController(page.container.DropTarget)
page.container.DropTarget.SetGTypes([]glib.Type{gio.GTypeFile})
// BUG: ConnectDrop() doesn't work. See
// https://github.com/diamondburned/gotk4/issues/107#issuecomment-1685377125
page.container.DropTarget.Connect("drop", func(val *glib.Value, x, y float64) bool {
page.container.DropTarget.ConnectDrop(func(val *glib.Value, x, y float64) bool {
file, ok := val.Object().Cast().(*gio.File)
if !ok {
return true
Expand Down
21 changes: 14 additions & 7 deletions internal/ui/peerpage.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.16.0 -->
<!-- Created with Cambalache 0.17.2 -->
<interface>
<requires lib="gtk" version="4.12"/>
<requires lib="libadwaita" version="1.3"/>
Expand All @@ -20,6 +20,7 @@
<property name="title">Options</property>
<child>
<object class="AdwActionRow" id="AdvertiseExitNodeRow">
<property name="activatable-widget">AdvertiseExitNodeSwitch</property>
<property name="title">Advertise exit node</property>
<child>
<object class="GtkSwitch" id="AdvertiseExitNodeSwitch">
Expand All @@ -31,6 +32,7 @@
</child>
<child>
<object class="AdwActionRow" id="AllowLANAccessRow">
<property name="activatable-widget">AllowLANAccessSwitch</property>
<property name="title">Allow LAN access</property>
<child>
<object class="GtkSwitch" id="AllowLANAccessSwitch">
Expand All @@ -42,6 +44,7 @@
</child>
<child>
<object class="AdwActionRow" id="AcceptRoutesRow">
<property name="activatable-widget">AcceptRoutesSwitch</property>
<property name="title">Accept routes</property>
<child>
<object class="GtkSwitch" id="AcceptRoutesSwitch">
Expand All @@ -64,11 +67,13 @@
<child>
<object class="AdwActionRow" id="SendFileRow">
<property name="action-name">peer.sendfile</property>
<property name="icon-name">document-send-symbolic</property>
<property name="activatable-widget">SendFileButton</property>
<property name="subtitle">Click or drag and drop here</property>
<property name="title">Send a file to remote machine</property>
<child>
<object class="GtkButton" id="SendFileButton">
<property name="has-frame">False</property>
<property name="icon-name">document-send-symbolic</property>
<property name="margin-bottom">12</property>
<property name="margin-top">12</property>
</object>
Expand All @@ -79,6 +84,12 @@
</child>
<child>
<object class="AdwPreferencesGroup" id="AdvertisedRoutesGroup">
<property name="header-suffix">
<object class="GtkButton" id="AdvertiseRouteButton">
<property name="has-frame">False</property>
<property name="icon-name">list-add-symbolic</property>
</object>
</property>
<property name="title">Advertised Routes</property>
</object>
</child>
Expand Down Expand Up @@ -194,7 +205,7 @@
<property name="title">Misc.</property>
<child>
<object class="AdwActionRow" id="ExitNodeRow">
<property name="icon-name">security-high-symbolic</property>
<property name="activatable-widget">ExitNodeSwitch</property>
<property name="title">Use as exit node</property>
<child>
<object class="GtkSwitch" id="ExitNodeSwitch">
Expand Down Expand Up @@ -270,8 +281,4 @@
<object class="GtkDropTarget" id="DropTarget">
<property name="actions">copy</property>
</object>
<object class="GtkButton" id="AdvertiseRouteButton">
<property name="has-frame">False</property>
<property name="icon-name">list-add-symbolic</property>
</object>
</interface>
2 changes: 1 addition & 1 deletion internal/ui/preferences.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.16.0 -->
<!-- Created with Cambalache 0.17.2 -->
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.3"/>
Expand Down
Loading

0 comments on commit e37ea77

Please sign in to comment.