elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.21k stars 379 forks source link

[BUG] Show-truncated in labels and buttons #1083

Open gh0stzk opened 5 months ago

gh0stzk commented 5 months ago

Checklist before submitting an issue

Description of the bug

In the new version eww 0.6.0 my calendar widget broke showing 3 points instead of the time "08:35" for example.

Shot-2024-04-22-083934

I solved it by adding :show-truncated "false" to labels.

I don't know why it was truncated, it's only 2 digits... anyway...


My powermenu widget uses eventbox and a buttons, not labels and is broken, this is how it looks now,

Shot-2024-04-22-085947

It should show the glyphs for shutdown, restart, etc.

I don't know if this is related to :show-truncated

Reproducing the issue

My powermenu.yuck

(defwidget powermenu []
     (box :class "powermenu"
          :orientation "v"
          :space-evenly "false"
          (lock-power-restart)))

(defwidget lock-power-restart []
    (box :class "powermenu"
         :orientation "v"
         :spacing 10
    (eventbox :cursor "pointer"
        (button :class "powermenu lock" 
                :onclick "physlock -d"
                :tooltip "Lock session"
                ""))
    (eventbox :cursor "pointer"
        (button :class "powermenu exit" 
                :onclick "bspc quit" 
                :tooltip "Logout bspwm"
                ""))
    (eventbox :cursor "pointer"
        (button :class "powermenu reboot" 
                :onclick "systemctl reboot"
                :tooltip "Restart"
                ""))
    (eventbox :cursor "pointer"
        (button :class "powermenu shutdown" 
                :onclick "systemctl poweroff"
                :tooltip "Shutdown"
                ""))     
  )
)

;; Power Menu ;;
(defwindow powermenu
    :geometry (geometry :x "0%"
                        :y "0%"
                        :anchor "center right")
    :wm-ignore false
    (powermenu))

My powermenu.scss


window>.powermenu {
  margin: 0.5rem;
  background-color: $bg;
}

.powermenu {
  font-family: "Font Awesome 6 Free Solid";
  font-size: 1.5rem;
  padding: 0.3rem;
  border-radius: 0.5rem;

  &.shutdown {
    color: $red;
  }

  &.reboot {
    color: $green;
  }

  &.lock {
    color: $yellow;
  }

  &.exit {
    color: $magenta;
  }

  button {
    background-color: $bg-alt;
    padding: 1.2rem;

    &:hover {
      background-color: lighten($color: $bg-alt, $amount: 4%);
    }
  }
}

Expected behaviour

Power buttons must show a glyphs

Additional context

Eww log shows nothing..

 2024-04-22T15:18:37.171Z INFO  eww::app    > Opening window powermenu as 'powermenu'
 2024-04-22T15:18:37.171Z INFO  eww::ipc_server > IPC server initialized
Rayzeq commented 5 months ago

This is because eww now uses gtk's truncation system, and gtk somehow decided that there wasn't enough space to display your text. Setting :show-truncated "false" solves the problem because this feature isn't supported by gtk, so eww reverts to the old truncation system, which won't truncate anything if you don't set :limit-with. I made a pull request to disable truncation by default (see #1084), but while waiting for it to be merged, you can indeed use :show-truncated "false" to disable it. It may also be possible to disable it by using :hexpand or :width on the right widgets. For anything that isn't a label, having a string as a child implicitly creates a label, which means that

(button "a")

is exactly the same as

(button (label :text "a"))

So, for your powermenu, you'd fix it by using

(button :class "powermenu shutdown" 
        :onclick "systemctl poweroff"
        :tooltip "Shutdown"
        (label :show-truncated false
             :text ""))

@kStor2poche may also be interested in this post

kStor2poche commented 5 months ago

Yup, I already fixed it this way, thanks anyway.

gh0stzk commented 5 months ago

Thank you, already fix it adding a label to the buttons.