Re: problem with width_for_height

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 09.03.2015 um 19:49 schrieb Detlef Reichl:
> Hi,
> 
> I have an application, where I get the warning:
> 
> Gtk-CRITICAL **:gtk_widget_get_preferred_width_for_height: assertion
> 'height >= 0' failed
> 
> and some times the widgets get wrong widths. It comes from a
> Gtk::ComboBoxText that is in this widget hierarchy (from the
> ComboBoxText the parents up to the main window):
> 
> "Gtk::Box"
> "Gtk::Box"
> "Gtk::Box"
> "Gtk::Frame"
> "Gtk::Revealer"
> "Gtk::Box"
> "Gtk::Viewport"
> "Gtk::ScrolledWindow"
> "Gtk::Box"
> "Gtk::Box"
> "Gtk::Window"
> 
> Unless the ComboBox isn't shown, the warning does not appear. I do not
> change any widget size requisitions by hand in the complete GUI. What is
> so special with the combo box and what do I have to honor if I use them?
> I've read the docs about "width for hight management" but from my point
> of view it only affects own container implementations, which I don't use.
> 
> I use gtk 3.14.5 with ruby-gtk from git/master.
> 

Hi,

I searched a little bit further and made the smallest possible example.
If you toggle the togglebutton and then shrink the window to the
smallest height, you will get the warning from my first post. The
warning comes from the function gtk_bin_get_preferred_width_for_height.
If you follow the height parameter of the function, it will go down to 0.

Because the border_width of the Gtk::Revealer is set to 1 in the
example, the gtk_widget_get_preferred_width_for_height function will fail.

It seems, that the Gtk::Bin that this function is called for, is the
Gtk::ComboBox in the example. So the bug seems to be in Gtk::ComboBox.
Also it seems so, that it is necessary that VBoxes and HBoxes are used
together. For now I did not get further.

Cheers, detlef


#!/usr/bin/env ruby

require 'gtk3'

class Win < Gtk::Window
    def initialize
        super

        vBox = Gtk::Box.new :vertical
        add vBox

        hBox = Gtk::Box.new :horizontal
        vBox.pack_start hBox, :expand => true, :fill => true

        # The drawing area is only for filling the space
        drawing = Gtk::DrawingArea.new
        hBox.pack_start drawing, :expand => true, :fill => true

        revealer = Gtk::Revealer.new
        # The border_width has to be > 0 to show the warning
        revealer.border_width = 1
        revealer.transition_duration = 200
        hBox.pack_start revealer

        button = Gtk::ToggleButton.new 'toggle'
        vBox.pack_start button
        button.signal_connect(:toggled) do
            revealer.reveal_child = button.active?
        end
        button.active = true

        boxV = Gtk::Box.new :vertical
        revealer.add boxV
        combo = nil
        0.upto(1) do |i|
            boxH = Gtk::Box.new :horizontal
            boxV.pack_start boxH
            label = Gtk::Label.new "line#{i}"
            boxH.pack_start label
            combo = Gtk::ComboBoxText.new
            0.upto(10) {|c| combo.append_text "combo entry #{c}"}
            boxH.pack_start combo, :expand => false, :fill => false
        end
        combo.active = 1
        show_all
    end
end

win = Win.new
Gtk.main



> I'm very obliged for any hints!
> detlef
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> https://mail.gnome.org/mailman/listinfo/gtk-list
> 

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux