Question

I want to resize borderless window with paned (seperator) object, If you know terminal application guake does this with motion-notify-event

here is the code:

self.resizer.connect('motion-notify-event', self.on_resizer_drag)

def on_resizer_drag(self, widget, event):
    """Method that handles the resize drag. It does not actuall
    moves the main window. It just set the new window size in
    gconf.
    """
    (x, y), mod = event.device.get_state(widget.window)
    if not 'GDK_BUTTON1_MASK' in mod.value_names:
        return

    max_height = self.window.get_screen().get_height()
    percent = y / (max_height / 100)

    if percent < 1:
        percent = 1

    self.client.set_int(KEY('/general/window_height'), int(percent))

Resizer is paned object but this code using pygtk (gtk2) I'm using python-gobject with gtk3 event.device.get_state(window) method is deprecated or changed. This is not work for me, any advice or solution about resize window borderless window with object drag?

Was it helpful?

Solution

I implemented Guake's code to Gtk3 by myself.

first connect motion notify event, resizer is paned object.

self.resizer.connect('motion-notify-event', self.on_resize)

next write resize event

def on_resize(self, widget, event):
    if Gdk.ModifierType.BUTTON1_MASK & event.get_state() != 0:
        mouse_y = event.device.get_position()[2]
        new_height = mouse_y - self.get_position()[1]
        if new_height > 0:
            self.resize(self.get_allocation().width, new_height)
            self.show()

now you can expand your window with gutter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top