Skip to content
  • PBS's avatar
    Rework Popovers and Containers management · a60eea40
    PBS authored
    Avoid situations that require manual unparent()ing, signal_destroy(),
    and present()ing popovers in size_allocate_vfunc() as much as possible.
    Prefer more automatic and less fragile solutions.
    
    To show a popover over a widget, one of the following patterns is used:
    
    * If the widget is a Gtk container, like a Box or a Grid, simply attach
      it with set_parent(). Nothing else is required.
    
    * If the widget is an intrinisically childless Gtk widget, like a Widget
      or a DrawingArea, call
    
          containerize(*this);
          set_layout_manager(Gtk::BinLayout::create());
    
      in the constructor, and then the rest is the same as above.
    
    * For any widget, put it inside a PopoverBin and attach the popover with
      setPopover().
    
    * In very rare circumstances where none of the above are viable, we have
      to resort to the manual management we wanted to avoid. Currently this
      is only done by SpinButton.
    
    Eventually upstream is expected to add some version of PopoverBin, as
    well as make layout managers more ubiquitous. So in the future, either
    1+2 or 3 may become the preferred way to deal with popovers. Until it's
    clear which, we'll use whatever fits best in a given situation.
    
    Main changes:
    
    * Get rid of menuize.cpp. Popovers now look like menus and have working
      hover logic all by themselves. The only other thing it did was
      set_flags(NESTED), which is now done where necessary.
    * Remove delete_all(), since it now double-deletes.
    * Remove UI::on_hide_reset(), since it leaked the C instance,
      and is largely superseded by PopoverBin's single-popover policy.
    * Add containerize(), use to reimplement Bin/ColorItem/Ruler/PopoverBin.
    * Shift responsibility of parenting popovers from popover constructors
      to their callers.
    * Remove UI::autohide_tooltip - not necessary anymore - tested.
    
    Other fixes:
    
    * Fix crash in filter editor by avoiding get_color_with_class() in
      snapshot_vfunc().
    * Fix criticals due to Bin not measuring child and under-allocating.
    * Fix popovers on spinbuttons not appearing, by changing the event
      propagation phase in on_popup_menu().
    * Move set_overflow() call from toolbars.cpp to Bin, since not supposed
      to call it except on custom widgets.
    * Ensure GtkCheckButton uses <property name="child"> instead of <child>
      in glade files. Only page-properties.glade had this problem.
    * ColorPalette: Put menubutton inside a box, and attach the secondary
      popover to the box rather than to the menubutton.
    a60eea40