class PanesDemo

# Copyright © 2016 Ruby-GNOME2 Project Team # This program is licenced under the same licence as Ruby-GNOME2. #

Paned Widgets

The GtkPaned Widget divides its content area into two panes
with a divider in between that the user can adjust. A separate
child is placed into each pane. GtkPaned widgets can be split
horizontally or vertically.

There are a number of options that can be set for each pane.
This test contains both a horizontal and a vertical GtkPaned
widget, and allows you to adjust the options for each side of
each widget.

Public Class Methods

new(main_window) click to toggle source
# File gtk3/sample/gtk-demo/panes.rb, line 18
def initialize(main_window)
  @window = Gtk::Window.new(:toplevel)
  @window.screen = main_window.screen
  @window.title = "Paned Widgets"

  vbox = Gtk::Box.new(:vertical, 0)
  @window.add(vbox)

  vpaned = Gtk::Paned.new(:vertical)
  vbox.pack_start(vpaned, :expand => true, :fill => true, :padding => 0)
  vpaned.margin = 5

  @hpaned = Gtk::Paned.new(:horizontal)
  vpaned.add1(@hpaned)

  frame = Gtk::Frame.new
  frame.shadow_type = :in
  frame.set_size_request(60, 60)
  @hpaned.add1(frame)

  button = Gtk::Button.new(:label => "_Hi there", :use_underline => true)
  frame.add(button)

  frame = Gtk::Frame.new
  frame.shadow_type = :in
  frame.set_size_request(80, 60)
  @hpaned.add2(frame)

  frame = Gtk::Frame.new
  frame.shadow_type = :in
  frame.set_size_request(60, 80)
  vpaned.add2(frame)

  # Now create toggle buttons to control sizing
  buttons = create_pane_options("Horizontal",
                                "Left",
                                "Right")
  vbox.pack_start(buttons, :expand => false, :fill => false, :padding => 0)
  buttons = create_pane_options("Vertical",
                                "Top",
                                "Bottom")
  vbox.pack_start(buttons, :expand => false, :fill => false, :padding => 0)
  vbox.show_all
end

Public Instance Methods

run() click to toggle source
# File gtk3/sample/gtk-demo/panes.rb, line 63
def run
  if !@window.visible?
    @window.show_all
  else
    @window.destroy
  end
  @window
end