File: example_stack.cc

package info (click to toggle)
gtkmm3.0 3.24.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 22,680 kB
  • sloc: xml: 121,333; cpp: 8,531; sh: 4,250; makefile: 262; perl: 236
file content (73 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Stack
 *
 * Gtk::Stack is a container that shows a single child at a time,
 * with nice transitions when the visible child changes.
 *
 * Gtk::StackSwitcher adds buttons to control which child is visible.
 */

#include <gtkmm.h>

class Example_Stack : public Gtk::Window
{
public:
  Example_Stack();
  ~Example_Stack() override;

protected:

  // Containers
  Gtk::Grid m_grid;
  Gtk::Stack m_stack;

  // Widgets
  Gtk::StackSwitcher m_stack_switcher;
  Gtk::Image m_image;
  Gtk::CheckButton m_check_button;
  Gtk::Spinner m_spinner;

private:
};

//Called by DemoWindow;
Gtk::Window* do_stack()
{
  return new Example_Stack();
}

Example_Stack::Example_Stack()
{
  // Window properties
  set_title("Stack");

  // Build stack
  m_stack.add(m_image, "page1", "Page 1");
  m_stack.add(m_check_button, "page2", "Page 2");
  m_stack.add(m_spinner, "page3");

  // Page 1
  m_image.set_from_icon_name("gtk3-demo", Gtk::ICON_SIZE_DIALOG);

  // Page 2
  m_check_button.set_label("Page 2");
  m_check_button.set_halign(Gtk::ALIGN_CENTER);

  // Page 3
  m_stack.child_property_icon_name(m_spinner) = "face-laugh-symbolic";
  m_spinner.property_active() = true;

  // Stack transition
  m_stack.set_transition_type(Gtk::STACK_TRANSITION_TYPE_CROSSFADE);

  // Layout
  m_stack_switcher.set_stack(m_stack);
  m_grid.attach(m_stack_switcher, 0, 0, 1, 1);
  m_grid.attach(m_stack, 0, 1, 1, 1);
  add(m_grid);

  show_all_children();
}

Example_Stack::~Example_Stack()
{
}