Libhandy: Click event on GtkStackSidebar item. Selecting same page twice subsequently

Hello,
I want to use Libhandy and its auto-adaptive window in my application.
Libhandy’s HdyLeaflet window adapts nicely to both smaller (phone screens) and larger (tablet or PC) screens.

I made a small test that is entirely based on the Libhandy’s example code.

My question:
My question concerns the sidebar labels when the GUI is in (small) phone view mode.
Please study screenshots “Radio1.png” and “Radio2.png”.
When I first click one of the sidebar labels, for example I click the “Show page2”, and it shows me the page2.
Then I return to the sidebar menu (via “<” back button).
NOW IT IS IMPOSSIBLE TO CLICK THE SAME ( “Show page2”) LABEL AGAIN. .
It cannot be selected twice subsequently.

Please help.

Here is my code Radio.tar.xz
https://drive.google.com/open?id=1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt

It requires the libhandy-0.0-dev package.

$ sudo apt install libhandy-0.0-dev
Or git clone it from https://source.puri.sm/Librem5/libhandy
Follow the instructions.

Unpack the Radio.tar.xz, then do:
$ cd Radio
$ meson . _build --reconfigure
$ ninja -C _build

Run it:
$ _build/src/radio

Libhandy docs:
http://honk.sigxcpu.org/projects/libhandy/doc/

ps. I have added the GtkStack (and GtkStackSidebar) pages manually in the code (in main.c).
This is what I know best. I am not very frequent user of Glade (GUI editor).

Screenshots Radio1.png, Radio2.png and Radio3.png:
https://drive.google.com/open?id=1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt

Cumprimentos
Osmo Moma Antero and Bica
Kind, wine drinking lad from Portugal

I have asked Adrien to take a look at the post as he is the maintainer and might not have signed up here.

Hi Osmo, the cause of you problem isn’t libhandy but GtkStackSidebar, as it doesn’t let you know when its selected row has been activated again. I suggest that you build a custom sidebar based on GtkListBox and change the visible page when one of its elements has been activated, or that you report the issue to GTK for example so GtkStackSidebar sends a signal when one of its elements is activated.

Hello Adrien,
Thanks for your explanation.

Yes indeed , one can see the functionality in GtkInspector. GtkInspector is a useful tool.

Running the sample in GtkInspector.
$ gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
$ GTK_DEBUG=interactive _build/src/radio

It shows the state of widgets while using the GUI.
This is what I got.

  1. When large screen. Both sidebar menu and content are visible:
    HIDDEN WIDGETS: back
    SHOWN WIDGETS: sidebar, header_bar, content_box, header_box, sub_header_bar, scrolled_window

  2. When narrow screen. The side shows a menu (sidebar menu visible).
    HIDDEN WIDGETS: back, scrolled_window, sub_header_bar
    SHOWN WIDGETS: sidebar, header_bar, content_box, header_box

  3. When narrow screen. The side shows a content page (content visible).
    HIDDEN WIDGETS: sidebar, header_bar
    SHOWN WIDGETS: back, sub_header_bar, content_box, header_box, scrolled_window

I will now add some logic to the RadioWindow class so it selects/unselects the GtkListBoxRow (and its GtkLabel) depeneding on the state of the GUI.

Some thoughts:
When user expands the GUI (to large screen mode where both sidebar menu and content page are visible).
The code must re-select the GtkListBoxRow (label) that had been de-selected earlier (in narrow mode).
It might add a small delay when re-selecting the sidebar row (GtkListBoxRow).
The GUI must always select/display right sidebar row when content page is visible in large screen mode.

Screenshot.

@sri, thanks too.

Cumprimentos
Osmo Moma e Bica
Portugal

1 Like

Olá, boa tarde,

I made some changes, and I think the GUI now works great.

Demo video clip “Screencast 2019-04-12 12:34:53.mp4” at
https://drive.google.com/open?id=1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt

I Had to take into account that the components of the HdyLeaflet-GUI have transition delay (child-transition-type and duration) set. The slide duration is normally 200ms.
I may set this duration slightly shorter, like 120ms.

EDIT: Forgot to mention:
I removed the GtkStackSidebar from the .ui as suggested earlier.
I now use GtkListBox and GtkListBoxRow directly. It is easy to add both icon + labels to the sidebar rows.
Nice feature.

This adaptable GUI is my template for any future projects.
The apps will run fine on phones (Purism, Librem 5) and tablets, PCs alike.

Any comments?

Até logo,
Osmo Moma

Re-hello all,

Look, I can see a small malfuNction (bug) both in the handy-demo and in my own test application.

The HdyLeaflet window misbehaves if the window has a certain size (or edging close to that size).
Please take a look this screencapture clip: “Screencast 2019-04-12 21:25:05.mp4” on
https://drive.google.com/open?id=1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt

When the window goes berserk, there is no way to make it sane again.
One has to exit the app.

This is a small issue during development , but may cause trouble later.
Version of my libhandy is 0.0.9-1.

$ apt-cache show libhandy-0.0-dev
Package: libhandy-0.0-dev
Architecture: amd64
Version: 0.0.9-1
Source: libhandy
Origin: Ubuntu
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Guido Günther agx@sigxcpu.org
Bugs: OpenID transaction in progress

Kindly
Osmo Moma

EDIT:
It seems to go into an eternal loop. At least the header-bar and its buttons start flashing.
Sometimes it prints this message:

(handy-demo:10887): Gtk-CRITICAL **: 09:05:23.290: gtk_widget_draw: assertion ‘!widget->priv->alloc_needed’ failed,

In my application:
(gnome-radio:20873): Gtk-WARNING **: 13:29:44.830: Negative content width -19 (allocation 5, extents 12x12) while allocating gadget (node label, owner GtkLabel)
… _window_notify_fold_cb
… _window_notify_fold_cb

and
(gnome-radio:25390): Gtk-WARNING **: 14:20:33.180: Negative content width -4 (allocation 20, extents 12x12) while allocating gadget (node label, owner GtkLabel)

I tested and compiled the latest code from https://source.puri.sm/Librem5/libhandy

EDIT:
I suspect there is an oddity in HdyHeaderGroup (header_group) widget.
My knowledge is rather limited about this.

An interim, breaf solution is this:

text removed
My solution did not work very well after all.

Re-hello,

Would someone take a look at my (test) application.
Why does the headerbar start flashing in some cases. :wink:

The code:
Radio-011.tar.xz

$ cd Radio
$ meson . _build --reconfigure
$ ninja -C _build

Run:
$ _build/src/gnome-radio

Video clips:
“Screencast 2019-04-16 19:20:27.mp4”
“Screencast 2019-04-17 09:28:58.mp4”

Ref:
https://drive.google.com/open?id=1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.