gtk3 3.0.7-x64-mingw32 → 3.0.8-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gtk3/extconf.rb +1 -0
- data/ext/gtk3/rb-gtk3-tree-view.c +4 -0
- data/ext/gtk3/rb-gtk3.c +245 -60
- data/lib/2.2/gtk3.so +0 -0
- data/lib/2.3/gtk3.so +0 -0
- data/lib/gtk3/box.rb +22 -0
- data/lib/gtk3/builder.rb +50 -29
- data/lib/gtk3/deprecated.rb +7 -0
- data/lib/gtk3/entry-buffer.rb +28 -0
- data/lib/gtk3/list-store.rb +2 -20
- data/lib/gtk3/loader.rb +6 -0
- data/lib/gtk3/menu-item.rb +8 -7
- data/lib/gtk3/tree-iter.rb +25 -1
- data/lib/gtk3/tree-model.rb +41 -0
- data/lib/gtk3/tree-store.rb +7 -6
- data/lib/gtk3/widget.rb +18 -1
- data/sample/gtk-demo/TODO +45 -39
- data/sample/gtk-demo/assistant.rb +123 -0
- data/sample/gtk-demo/builder.rb +75 -38
- data/sample/gtk-demo/button_box.rb +100 -0
- data/sample/gtk-demo/colorsel.rb +49 -65
- data/sample/gtk-demo/css_accordion.rb +33 -55
- data/sample/gtk-demo/css_basics.rb +55 -80
- data/sample/gtk-demo/css_multiplebgs.rb +112 -0
- data/sample/gtk-demo/css_pixbufs.rb +84 -0
- data/sample/gtk-demo/css_shadows.rb +101 -0
- data/sample/gtk-demo/cursors.rb +114 -0
- data/sample/gtk-demo/dialog.rb +105 -115
- data/sample/gtk-demo/entry_buffer.rb +44 -0
- data/sample/gtk-demo/entry_completion.rb +40 -52
- data/sample/gtk-demo/expander.rb +60 -26
- data/sample/gtk-demo/filtermodel.rb +119 -0
- data/sample/gtk-demo/font_features.rb +117 -0
- data/sample/gtk-demo/headerbar.rb +57 -0
- data/sample/gtk-demo/iconview_edit.rb +79 -0
- data/sample/gtk-demo/infobar.rb +75 -59
- data/sample/gtk-demo/links.rb +53 -40
- data/sample/gtk-demo/main.rb +353 -43
- data/sample/gtk-demo/main.ui +9 -9
- data/sample/gtk-demo/markup.rb +46 -0
- data/sample/gtk-demo/menus.rb +111 -162
- data/sample/gtk-demo/modelbutton.rb +47 -0
- data/sample/gtk-demo/overlay.rb +61 -0
- data/sample/gtk-demo/overlay2.rb +75 -0
- data/sample/gtk-demo/panes.rb +114 -133
- data/sample/gtk-demo/pickers.rb +70 -0
- data/sample/gtk-demo/popover.rb +110 -0
- data/sample/gtk-demo/printing.rb +68 -83
- data/sample/gtk-demo/revealer.rb +53 -0
- data/sample/gtk-demo/scale.rb +26 -0
- data/sample/gtk-demo/search_entry2.rb +107 -0
- data/sample/gtk-demo/sidebar.rb +68 -0
- data/sample/gtk-demo/sizegroup.rb +93 -105
- data/sample/gtk-demo/spinner.rb +53 -50
- data/sample/gtk-demo/stack.rb +28 -0
- data/sample/gtk-demo/test_mod.rb +22 -0
- data/sample/gtk-demo/textmask.rb +61 -0
- data/sample/gtk-demo/theming_style_classes.rb +16 -12
- data/sample/misc/app-menu.ui +19 -0
- data/sample/misc/button-menu.ui +19 -0
- data/sample/misc/icons-theme-viewer.rb +65 -0
- data/sample/misc/menu.rb +3 -3
- data/sample/misc/menus_from_resources.gresource.xml +8 -0
- data/sample/misc/menus_from_resources.rb +91 -0
- data/sample/misc/statusicon.rb +1 -1
- data/sample/misc/toolbar-menu.ui +23 -0
- data/sample/misc/treestore.rb +63 -0
- data/sample/tutorial/README.md +368 -6
- data/test/test-gtk-box.rb +13 -0
- data/test/test-gtk-builder.rb +1 -1
- data/test/test-gtk-clipboard.rb +124 -0
- data/test/test-gtk-container.rb +3 -3
- data/test/test-gtk-entry-buffer.rb +32 -0
- data/test/test-gtk-list-store.rb +30 -12
- data/test/test-gtk-menu.rb +32 -0
- data/test/test-gtk-tree-iter.rb +61 -5
- data/test/test-gtk-tree-path.rb +26 -1
- data/test/test-gtk-tree-sortable.rb +35 -0
- data/test/test-gtk-tree-store.rb +34 -0
- data/test/test-gtk-widget.rb +33 -2
- metadata +57 -22
- data/lib/2.0/gtk3.so +0 -0
- data/lib/2.1/gtk3.so +0 -0
- data/sample/gtk-demo/button-box.rb +0 -82
@@ -0,0 +1,75 @@
|
|
1
|
+
# Copyright (c) 2015 Ruby-GNOME2 Project Team
|
2
|
+
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
|
+
#
|
4
|
+
=begin
|
5
|
+
= Overlay/Decorative Overlay
|
6
|
+
|
7
|
+
Another example of an overlay with some decorative
|
8
|
+
and some interactive controls.
|
9
|
+
=end
|
10
|
+
module Overlay2Demo
|
11
|
+
def self.run_demo(_main_window)
|
12
|
+
window = Gtk::Window.new(:toplevel)
|
13
|
+
window.set_default_size(500, 510)
|
14
|
+
window.set_title("Decorative Overlay")
|
15
|
+
|
16
|
+
overlay = Gtk::Overlay.new
|
17
|
+
|
18
|
+
sw = Gtk::ScrolledWindow.new
|
19
|
+
sw.set_policy(:automatic, :automatic)
|
20
|
+
|
21
|
+
text = Gtk::TextView.new
|
22
|
+
buffer = text.buffer
|
23
|
+
buffer.text = "Dear Diary..."
|
24
|
+
|
25
|
+
tag = buffer.create_tag("top-margin", "pixels-above-lines" => 0)
|
26
|
+
|
27
|
+
word_end = buffer.start_iter
|
28
|
+
word_end.forward_word_end
|
29
|
+
buffer.apply_tag(tag, buffer.start_iter, word_end)
|
30
|
+
|
31
|
+
window.add(overlay)
|
32
|
+
overlay.add(sw)
|
33
|
+
sw.add(text)
|
34
|
+
|
35
|
+
image = Gtk::Image.new(:resource => "/overlay2/decor1.png")
|
36
|
+
overlay.add_overlay(image)
|
37
|
+
overlay.set_overlay_pass_through(image, true)
|
38
|
+
image.set_halign(:start)
|
39
|
+
image.set_valign(:start)
|
40
|
+
|
41
|
+
image = Gtk::Image.new(:resource => "/overlay2/decor2.png")
|
42
|
+
overlay.add_overlay(image)
|
43
|
+
overlay.set_overlay_pass_through(image, true)
|
44
|
+
image.set_halign(:end)
|
45
|
+
image.set_valign(:end)
|
46
|
+
|
47
|
+
adjustment = Gtk::Adjustment.new(0, 0, 100, 1, 1, 0)
|
48
|
+
adjustment.signal_connect "value-changed" do |widget|
|
49
|
+
value = widget.value
|
50
|
+
text.set_left_margin(value)
|
51
|
+
tag.set_property("pixels-above-lines", value)
|
52
|
+
end
|
53
|
+
|
54
|
+
scale = Gtk::Scale.new(:horizontal, adjustment)
|
55
|
+
scale.set_draw_value(false)
|
56
|
+
scale.set_size_request(120, -1)
|
57
|
+
scale.set_margin_start(20)
|
58
|
+
scale.set_margin_end(20)
|
59
|
+
scale.set_margin_bottom(20)
|
60
|
+
overlay.add_overlay(scale)
|
61
|
+
scale.set_halign(:start)
|
62
|
+
scale.set_valign(:end)
|
63
|
+
scale.set_tooltip_text("Margin")
|
64
|
+
|
65
|
+
adjustment.value = 100
|
66
|
+
overlay.show_all
|
67
|
+
|
68
|
+
if !window.visible?
|
69
|
+
window.show_all
|
70
|
+
else
|
71
|
+
window.destroy
|
72
|
+
end
|
73
|
+
window
|
74
|
+
end
|
75
|
+
end
|
data/sample/gtk-demo/panes.rb
CHANGED
@@ -1,156 +1,137 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2016 Ruby-GNOME2 Project Team
|
2
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
3
|
#
|
4
|
-
# $Id: panes.rb,v 1.5 2005/02/12 23:06:07 kzys Exp $
|
5
4
|
=begin
|
6
|
-
=
|
5
|
+
= Paned Widgets
|
7
6
|
|
8
|
-
The
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
The GtkPaned Widget divides its content area into two panes
|
8
|
+
with a divider in between that the user can adjust. A separate
|
9
|
+
child is placed into each pane. GtkPaned widgets can be split
|
10
|
+
horizontally or vertically.
|
12
11
|
|
13
|
-
There are a number of options that can be set for each pane.
|
14
|
-
This test contains both a horizontal
|
15
|
-
|
16
|
-
|
12
|
+
There are a number of options that can be set for each pane.
|
13
|
+
This test contains both a horizontal and a vertical GtkPaned
|
14
|
+
widget, and allows you to adjust the options for each side of
|
15
|
+
each widget.
|
17
16
|
=end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
module PanesDemo
|
18
|
+
def self.run_demo(main_window)
|
19
|
+
window = Gtk::Window.new(:toplevel)
|
20
|
+
window.screen = main_window.screen
|
21
|
+
window.title = "Paned Widgets"
|
22
|
+
window.border_width = 0
|
23
|
+
|
24
|
+
vbox = Gtk::Box.new(:vertical, 0)
|
25
|
+
window.add(vbox)
|
26
|
+
|
27
|
+
vpaned = Gtk::Paned.new(:vertical)
|
28
|
+
vbox.pack_start(vpaned, :expand => true, :fill => true, :padding => 0)
|
29
|
+
vpaned.border_width = 5
|
30
|
+
|
31
|
+
hpaned = Gtk::Paned.new(:horizontal)
|
32
|
+
vpaned.add1(hpaned)
|
33
|
+
|
34
|
+
frame = Gtk::Frame.new
|
35
|
+
frame.shadow_type = :in
|
36
|
+
frame.set_size_request(60, 60)
|
37
|
+
hpaned.add1(frame)
|
38
|
+
|
39
|
+
button = Gtk::Button.new(:label => "_Hi there", :use_underline => true)
|
40
|
+
frame.add(button)
|
41
|
+
|
42
|
+
frame = Gtk::Frame.new
|
43
|
+
frame.shadow_type = :in
|
44
|
+
frame.set_size_request(80, 60)
|
45
|
+
hpaned.add2(frame)
|
46
|
+
|
47
|
+
frame = Gtk::Frame.new
|
48
|
+
frame.shadow_type = :in
|
49
|
+
frame.set_size_request(60, 80)
|
50
|
+
vpaned.add2(frame)
|
51
|
+
|
52
|
+
# Now create toggle buttons to control sizing
|
53
|
+
buttons = create_pane_options(hpaned,
|
54
|
+
"Horizontal",
|
55
|
+
"Left",
|
56
|
+
"Right")
|
57
|
+
vbox.pack_start(buttons, :expand => false, :fill => false, :padding => 0)
|
58
|
+
buttons = create_pane_options(hpaned,
|
59
|
+
"Vertical",
|
60
|
+
"Top",
|
61
|
+
"Bottom")
|
62
|
+
vbox.pack_start(buttons, :expand => false, :fill => false, :padding => 0)
|
63
|
+
vbox.show_all
|
64
|
+
|
65
|
+
if !window.visible?
|
66
|
+
window.show_all
|
67
|
+
else
|
68
|
+
window.destroy
|
69
|
+
end
|
70
|
+
window
|
71
|
+
end
|
25
72
|
|
26
|
-
|
27
|
-
|
73
|
+
def self.create_pane_options(paned, frame_label, label1, label2)
|
74
|
+
child1 = paned.child1
|
75
|
+
child2 = paned.child2
|
28
76
|
|
29
|
-
|
30
|
-
|
31
|
-
vpaned.border_width = 5
|
77
|
+
frame = Gtk::Frame.new(frame_label)
|
78
|
+
frame.border_width = 4
|
32
79
|
|
33
|
-
|
34
|
-
|
80
|
+
table = Gtk::Grid.new
|
81
|
+
frame.add(table)
|
35
82
|
|
36
|
-
|
37
|
-
|
38
|
-
frame.set_size_request(60, 60)
|
39
|
-
hpaned.add1(frame)
|
83
|
+
label = Gtk::Label.new(label1)
|
84
|
+
table.attach(label, 0, 0, 1, 1)
|
40
85
|
|
41
|
-
|
42
|
-
|
86
|
+
check_button = Gtk::CheckButton.new("_Resize")
|
87
|
+
check_button.use_underline = true
|
88
|
+
table.attach(check_button, 0, 1, 1, 1)
|
89
|
+
check_button.signal_connect "toggled" do
|
90
|
+
resize = paned.child_get_property(child1, "resize")
|
91
|
+
shrink = paned.child_get_property(child1, "shrink")
|
43
92
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
hpaned.add2(frame)
|
93
|
+
paned.remove(child1)
|
94
|
+
paned.pack1(child1, :resize => !resize, :shrink => shrink)
|
95
|
+
end
|
48
96
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
97
|
+
check_button = Gtk::CheckButton.new("_Shrink")
|
98
|
+
check_button.use_underline = true
|
99
|
+
table.attach(check_button, 0, 2, 1, 1)
|
100
|
+
check_button.active = true
|
101
|
+
check_button.signal_connect "toggled" do
|
102
|
+
resize = paned.child_get_property(child1, "resize")
|
103
|
+
shrink = paned.child_get_property(child1, "shrink")
|
53
104
|
|
54
|
-
|
105
|
+
paned.remove(child1)
|
106
|
+
paned.pack1(child1, :resize => resize, :shrink => !shrink)
|
107
|
+
end
|
55
108
|
|
56
|
-
|
57
|
-
|
58
|
-
:expand => false, :fill => false, :padding => 0)
|
109
|
+
label = Gtk::Label.new(label2)
|
110
|
+
table.attach(label, 1, 0, 1, 1)
|
59
111
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
112
|
+
check_button = Gtk::CheckButton.new("_Resize")
|
113
|
+
check_button.use_underline = true
|
114
|
+
table.attach(check_button, 1, 1, 1, 1)
|
115
|
+
check_button.active = true
|
116
|
+
check_button.signal_connect "toggled" do
|
117
|
+
resize = paned.child_get_property(child2, "resize")
|
118
|
+
shrink = paned.child_get_property(child2, "shrink")
|
64
119
|
|
65
|
-
|
66
|
-
|
67
|
-
frame.border_width = 4
|
68
|
-
|
69
|
-
table = Gtk::Table.new(3, 2, true)
|
70
|
-
frame.add(table)
|
71
|
-
|
72
|
-
label = Gtk::Label.new(label1)
|
73
|
-
table.attach_defaults(label, 0, 1, 0, 1)
|
74
|
-
|
75
|
-
check_button = Gtk::CheckButton.new('_Resize', true)
|
76
|
-
table.attach_defaults(check_button, 0, 1, 1, 2)
|
77
|
-
check_button.signal_connect('toggled') do
|
78
|
-
toggle_resize(paned.child1)
|
79
|
-
end
|
80
|
-
|
81
|
-
check_button = Gtk::CheckButton.new('_Shrink', true)
|
82
|
-
table.attach_defaults(check_button, 0, 1, 2, 3)
|
83
|
-
check_button.active = true
|
84
|
-
check_button.signal_connect('toggled') do
|
85
|
-
toggle_shrink(paned.child1)
|
86
|
-
end
|
87
|
-
|
88
|
-
label = Gtk::Label.new(label2)
|
89
|
-
table.attach_defaults(label, 1, 2, 0, 1)
|
90
|
-
|
91
|
-
check_button = Gtk::CheckButton.new('_Resize')
|
92
|
-
table.attach_defaults(check_button, 1, 2, 1, 2)
|
93
|
-
check_button.active = true
|
94
|
-
check_button.signal_connect('toggled') do
|
95
|
-
toggle_resize(paned.child2)
|
96
|
-
end
|
97
|
-
|
98
|
-
check_button = Gtk::CheckButton.new('_Shrink')
|
99
|
-
table.attach_defaults(check_button, 1, 2, 2, 3)
|
100
|
-
check_button.active = true
|
101
|
-
check_button.signal_connect('toggled') do
|
102
|
-
toggle_shrink(paned.child2)
|
103
|
-
end
|
104
|
-
|
105
|
-
return frame
|
120
|
+
paned.remove(child2)
|
121
|
+
paned.pack2(child2, :resize => !resize, :shrink => shrink)
|
106
122
|
end
|
107
123
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
paned.child2_resize?
|
116
|
-
end
|
117
|
-
|
118
|
-
shrink = if is_child1
|
119
|
-
paned.child1_shrink?
|
120
|
-
else
|
121
|
-
paned.child2_shrink?
|
122
|
-
end
|
123
|
-
|
124
|
-
child.parent.remove(child)
|
125
|
-
if is_child1
|
126
|
-
paned.pack1(child, !resize, shrink)
|
127
|
-
else
|
128
|
-
paned.pack2(child, !resize, shrink)
|
129
|
-
end
|
130
|
-
end
|
124
|
+
check_button = Gtk::CheckButton.new("_Shrink")
|
125
|
+
check_button.use_underline = true
|
126
|
+
table.attach(check_button, 1, 2, 1, 1)
|
127
|
+
check_button.active = true
|
128
|
+
check_button.signal_connect "toggled" do
|
129
|
+
resize = paned.child_get_property(child2, "resize")
|
130
|
+
shrink = paned.child_get_property(child2, "shrink")
|
131
131
|
|
132
|
-
|
133
|
-
paned
|
134
|
-
is_child1 = (child == paned.child1)
|
135
|
-
|
136
|
-
resize = if is_child1
|
137
|
-
paned.child1_resize?
|
138
|
-
else
|
139
|
-
paned.child2_resize?
|
140
|
-
end
|
141
|
-
|
142
|
-
shrink = if is_child1
|
143
|
-
paned.child1_shrink?
|
144
|
-
else
|
145
|
-
paned.child2_shrink?
|
146
|
-
end
|
147
|
-
|
148
|
-
child.parent.remove(child)
|
149
|
-
if is_child1
|
150
|
-
paned.pack1(child, resize, !shrink)
|
151
|
-
else
|
152
|
-
paned.pack2(child, resize, !shrink)
|
153
|
-
end
|
132
|
+
paned.remove(child2)
|
133
|
+
paned.pack2(child2, :resize => resize, :shrink => !shrink)
|
154
134
|
end
|
135
|
+
frame
|
155
136
|
end
|
156
137
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright (c) 2015 Ruby-GNOME2 Project Team
|
2
|
+
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
|
+
#
|
4
|
+
=begin
|
5
|
+
= Pickers
|
6
|
+
|
7
|
+
These widgets are mainly intended for use in preference dialogs.
|
8
|
+
They allow to select colors, fonts, files, directories and applications.
|
9
|
+
=end
|
10
|
+
module PickersDemo
|
11
|
+
def self.run_demo(main_window)
|
12
|
+
window = Gtk::Window.new(:toplevel)
|
13
|
+
window.screen = main_window.screen
|
14
|
+
window.set_title("Pickers")
|
15
|
+
window.set_border_width(10)
|
16
|
+
|
17
|
+
table = Gtk::Grid.new
|
18
|
+
table.set_row_spacing(3)
|
19
|
+
table.set_column_spacing(10)
|
20
|
+
window.add(table)
|
21
|
+
|
22
|
+
label = Gtk::Label.new("Color:")
|
23
|
+
label.set_halign(:start)
|
24
|
+
label.set_valign(:center)
|
25
|
+
label.set_hexpand(true)
|
26
|
+
picker = Gtk::ColorButton.new
|
27
|
+
table.attach(label, 0, 0, 1, 1)
|
28
|
+
table.attach(picker, 1, 0, 1, 1)
|
29
|
+
|
30
|
+
label = Gtk::Label.new("Font:")
|
31
|
+
label.set_halign(:start)
|
32
|
+
label.set_valign(:center)
|
33
|
+
label.set_hexpand(true)
|
34
|
+
picker = Gtk::FontButton.new
|
35
|
+
table.attach(label, 0, 1, 1, 1)
|
36
|
+
table.attach(picker, 1, 1, 1, 1)
|
37
|
+
|
38
|
+
label = Gtk::Label.new("File:")
|
39
|
+
label.set_halign(:start)
|
40
|
+
label.set_valign(:center)
|
41
|
+
label.set_hexpand(true)
|
42
|
+
picker = Gtk::FileChooserButton.new("Pick a file", :open)
|
43
|
+
table.attach(label, 0, 2, 1, 1)
|
44
|
+
table.attach(picker, 1, 2, 1, 1)
|
45
|
+
|
46
|
+
label = Gtk::Label.new("Folder:")
|
47
|
+
label.set_halign(:start)
|
48
|
+
label.set_valign(:center)
|
49
|
+
label.set_hexpand(true)
|
50
|
+
picker = Gtk::FileChooserButton.new("Pick a folder", :select_folder)
|
51
|
+
table.attach(label, 0, 3, 1, 1)
|
52
|
+
table.attach(picker, 1, 3, 1, 1)
|
53
|
+
|
54
|
+
label = Gtk::Label.new("Mail:")
|
55
|
+
label.set_halign(:start)
|
56
|
+
label.set_valign(:center)
|
57
|
+
label.set_hexpand(true)
|
58
|
+
picker = Gtk::AppChooserButton.new("x-scheme-handler/mailto")
|
59
|
+
picker.set_show_dialog_item(true)
|
60
|
+
table.attach(label, 0, 4, 1, 1)
|
61
|
+
table.attach(picker, 1, 4, 1, 1)
|
62
|
+
|
63
|
+
if !window.visible?
|
64
|
+
window.show_all
|
65
|
+
else
|
66
|
+
window.destroy
|
67
|
+
end
|
68
|
+
window
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Copyright (c) 2015 Ruby-GNOME2 Project Team
|
2
|
+
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
|
+
#
|
4
|
+
=begin
|
5
|
+
= Popovers
|
6
|
+
|
7
|
+
A bubble-like window containing contextual information or options.
|
8
|
+
GtkPopovers can be attached to any widget, and will be displayed
|
9
|
+
within the same window, but on top of all its content.
|
10
|
+
=end
|
11
|
+
module PopoverDemo
|
12
|
+
def self.run_demo(main_window)
|
13
|
+
window = Gtk::Window.new(:toplevel)
|
14
|
+
window.screen = main_window.screen
|
15
|
+
box = Gtk::Box.new(:vertical, 24)
|
16
|
+
box.border_width = 24
|
17
|
+
window.add(box)
|
18
|
+
|
19
|
+
widget = Gtk::ToggleButton.new(:label => "Button")
|
20
|
+
toggle_popover = create_popover(widget,
|
21
|
+
Gtk::Label.new(
|
22
|
+
"This popover does not grab input"
|
23
|
+
),
|
24
|
+
:top)
|
25
|
+
toggle_popover.modal = false
|
26
|
+
widget.signal_connect "toggled" do |button|
|
27
|
+
toggle_popover.visible = button.active?
|
28
|
+
end
|
29
|
+
|
30
|
+
box.add(widget)
|
31
|
+
|
32
|
+
widget = CustomEntry.new
|
33
|
+
entry_popover = create_complex_popover(widget, :top)
|
34
|
+
widget.set_icon_from_icon_name(:primary, "edit-find")
|
35
|
+
widget.set_icon_from_icon_name(:secondary, "edit-clear")
|
36
|
+
widget.signal_connect "icon-press" do |entry, icon_pos, _event|
|
37
|
+
rect = entry.get_icon_area(icon_pos)
|
38
|
+
entry_popover.set_pointing_to(rect)
|
39
|
+
entry_popover.show
|
40
|
+
entry.popover_icon_pos = icon_pos
|
41
|
+
end
|
42
|
+
|
43
|
+
widget.signal_connect "size-allocate" do |entry, _allocation|
|
44
|
+
if entry_popover.visible?
|
45
|
+
popover_pos = entry.popover_icon_pos
|
46
|
+
rect = entry.get_icon_area(popover_pos)
|
47
|
+
entry_popover.set_pointing_to(rect)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
box.add(widget)
|
52
|
+
|
53
|
+
widget = Gtk::Calendar.new
|
54
|
+
widget.signal_connect "day-selected" do |calendar|
|
55
|
+
event = Gtk.current_event
|
56
|
+
if event.type == :button_press
|
57
|
+
x, y = event.window.coords_to_parent(event.x,
|
58
|
+
event.y)
|
59
|
+
allocation = calendar.allocation
|
60
|
+
rect = Gdk::Rectangle.new(x - allocation.x,
|
61
|
+
y - allocation.y,
|
62
|
+
1,
|
63
|
+
1)
|
64
|
+
cal_popover = create_popover(calendar, CustomEntry.new, :bottom)
|
65
|
+
cal_popover.set_pointing_to(rect)
|
66
|
+
cal_popover.show
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
box.add(widget)
|
71
|
+
|
72
|
+
if !window.visible?
|
73
|
+
window.show_all
|
74
|
+
else
|
75
|
+
window.destroy
|
76
|
+
end
|
77
|
+
window
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.create_popover(parent, child, pos)
|
81
|
+
popover = Gtk::Popover.new(parent)
|
82
|
+
popover.position = pos
|
83
|
+
popover.add(child)
|
84
|
+
popover.border_width = 6
|
85
|
+
child.show
|
86
|
+
popover
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.create_complex_popover(parent, pos)
|
90
|
+
builder = Gtk::Builder.new(:resource => "/popover/popover.ui")
|
91
|
+
window = builder["window"]
|
92
|
+
content = window.child
|
93
|
+
content.parent.remove(content)
|
94
|
+
window.destroy
|
95
|
+
popover = create_popover(parent, content, pos)
|
96
|
+
popover.set_size_request(200, -1)
|
97
|
+
popover.vexpand = true
|
98
|
+
popover.margin_start = 10
|
99
|
+
popover.margin_end = 10
|
100
|
+
popover.margin_bottom = 10
|
101
|
+
popover
|
102
|
+
end
|
103
|
+
|
104
|
+
class CustomEntry < Gtk::Entry
|
105
|
+
attr_accessor :popover_icon_pos
|
106
|
+
def initialize
|
107
|
+
super
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|