Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gtk gtk
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,431
    • Issues 1,431
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 245
    • Merge requests 245
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • gtkgtk
  • Issues
  • #1959

Closed
Open
Created Jun 19, 2019 by Ondřej Tůma@mcbig

GtkPaned: setting position sometimes results in unexpected position

Steps to reproduce

When I click on Switch button, then i want to change the paned orientation and set position to 50%. Some when in past that works, at this moment, i got position which you can see on screenshots.

Here is my simple application for python3 with gi:

from gi import require_version
require_version('Gtk', '3.0')        # noqa

from gi.repository import Gtk

WIDTH = 800
HEIGHT = 400


class Window(Gtk.Window):
    def __init__(self):
        super(Window, self).__init__()
        self.set_default_size(WIDTH, HEIGHT)

        box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        self.add(box)

        button = Gtk.Button.new_with_label("Switch")
        button.connect("clicked", self.on_clicked)
        box.pack_start(button, False, False, 0)

        self.paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
        box.pack_start(self.paned, True, True, 0)

        left_scroll = Gtk.ScrolledWindow()
        left_scroll.add(Gtk.TextView())
        self.paned.pack1(left_scroll, True, False)

        right_scroll = Gtk.ScrolledWindow()
        right_scroll.add(Gtk.TextView())
        self.paned.pack2(right_scroll, True, False)

    def on_clicked(self, button):
        if self.paned.get_orientation() == Gtk.Orientation.VERTICAL:
            self.paned.set_orientation(Gtk.Orientation.HORIZONTAL)
            self.paned.set_position(self.paned.get_allocated_width()/2)
        else:
            self.paned.set_orientation(Gtk.Orientation.VERTICAL)
            self.paned.set_position(self.paned.get_allocated_height()/2)


win = Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()

Current behavior

When i try to set position to 50%, i count it from allocated_size/2. Yes the allocated size returns right number. After set this position, i still got right number, but after event (in next event for example), i got another bad position from paned.

Version information

Linux Debian 10 - Buster (Testing), stable in few next weeks on amd64 libgtk-3-0 3.24.5-1 gir1.2-gtk-3.0 3.24.5-1 python3-gi 3.30.4-1

Running on X11 with 2048x1152, but the same on Wayland, or on 3840x2160 with 200% scale.

I'm not sure when i start observe this problem, and i was thing that is in my application Formiko (https://github.com/ondratu/formiko), then I try in this simple test application with the same behavior.

Additional information

After start: Snímek_z_2019-06-19_07-30-32

First click: Snímek_z_2019-06-19_07-30-35

Second click: Snímek_z_2019-06-19_07-30-38

Edited Jun 19, 2019 by Daniel Boles
Assignee
Assign to
Time tracking