gtk3 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/extconf.rb +1 -0
  3. data/ext/gtk3/rb-gtk3-tree-view.c +4 -0
  4. data/ext/gtk3/rb-gtk3.c +245 -60
  5. data/lib/gtk3/box.rb +22 -0
  6. data/lib/gtk3/builder.rb +50 -29
  7. data/lib/gtk3/deprecated.rb +7 -0
  8. data/lib/gtk3/entry-buffer.rb +28 -0
  9. data/lib/gtk3/list-store.rb +2 -20
  10. data/lib/gtk3/loader.rb +6 -0
  11. data/lib/gtk3/menu-item.rb +8 -7
  12. data/lib/gtk3/tree-iter.rb +25 -1
  13. data/lib/gtk3/tree-model.rb +41 -0
  14. data/lib/gtk3/tree-store.rb +7 -6
  15. data/lib/gtk3/widget.rb +18 -1
  16. data/sample/gtk-demo/TODO +45 -39
  17. data/sample/gtk-demo/assistant.rb +123 -0
  18. data/sample/gtk-demo/builder.rb +75 -38
  19. data/sample/gtk-demo/button_box.rb +100 -0
  20. data/sample/gtk-demo/colorsel.rb +49 -65
  21. data/sample/gtk-demo/css_accordion.rb +33 -55
  22. data/sample/gtk-demo/css_basics.rb +55 -80
  23. data/sample/gtk-demo/css_multiplebgs.rb +112 -0
  24. data/sample/gtk-demo/css_pixbufs.rb +84 -0
  25. data/sample/gtk-demo/css_shadows.rb +101 -0
  26. data/sample/gtk-demo/cursors.rb +114 -0
  27. data/sample/gtk-demo/dialog.rb +105 -115
  28. data/sample/gtk-demo/entry_buffer.rb +44 -0
  29. data/sample/gtk-demo/entry_completion.rb +40 -52
  30. data/sample/gtk-demo/expander.rb +60 -26
  31. data/sample/gtk-demo/filtermodel.rb +119 -0
  32. data/sample/gtk-demo/font_features.rb +117 -0
  33. data/sample/gtk-demo/headerbar.rb +57 -0
  34. data/sample/gtk-demo/iconview_edit.rb +79 -0
  35. data/sample/gtk-demo/infobar.rb +75 -59
  36. data/sample/gtk-demo/links.rb +53 -40
  37. data/sample/gtk-demo/main.rb +353 -43
  38. data/sample/gtk-demo/main.ui +9 -9
  39. data/sample/gtk-demo/markup.rb +46 -0
  40. data/sample/gtk-demo/menus.rb +111 -162
  41. data/sample/gtk-demo/modelbutton.rb +47 -0
  42. data/sample/gtk-demo/overlay.rb +61 -0
  43. data/sample/gtk-demo/overlay2.rb +75 -0
  44. data/sample/gtk-demo/panes.rb +114 -133
  45. data/sample/gtk-demo/pickers.rb +70 -0
  46. data/sample/gtk-demo/popover.rb +110 -0
  47. data/sample/gtk-demo/printing.rb +68 -83
  48. data/sample/gtk-demo/revealer.rb +53 -0
  49. data/sample/gtk-demo/scale.rb +26 -0
  50. data/sample/gtk-demo/search_entry2.rb +107 -0
  51. data/sample/gtk-demo/sidebar.rb +68 -0
  52. data/sample/gtk-demo/sizegroup.rb +93 -105
  53. data/sample/gtk-demo/spinner.rb +53 -50
  54. data/sample/gtk-demo/stack.rb +28 -0
  55. data/sample/gtk-demo/test_mod.rb +22 -0
  56. data/sample/gtk-demo/textmask.rb +61 -0
  57. data/sample/gtk-demo/theming_style_classes.rb +16 -12
  58. data/sample/misc/app-menu.ui +19 -0
  59. data/sample/misc/button-menu.ui +19 -0
  60. data/sample/misc/icons-theme-viewer.rb +65 -0
  61. data/sample/misc/menu.rb +3 -3
  62. data/sample/misc/menus_from_resources.gresource.xml +8 -0
  63. data/sample/misc/menus_from_resources.rb +91 -0
  64. data/sample/misc/statusicon.rb +1 -1
  65. data/sample/misc/toolbar-menu.ui +23 -0
  66. data/sample/misc/treestore.rb +63 -0
  67. data/sample/tutorial/README.md +368 -6
  68. data/test/test-gtk-box.rb +13 -0
  69. data/test/test-gtk-builder.rb +1 -1
  70. data/test/test-gtk-clipboard.rb +124 -0
  71. data/test/test-gtk-container.rb +3 -3
  72. data/test/test-gtk-entry-buffer.rb +32 -0
  73. data/test/test-gtk-list-store.rb +30 -12
  74. data/test/test-gtk-menu.rb +32 -0
  75. data/test/test-gtk-tree-iter.rb +61 -5
  76. data/test/test-gtk-tree-path.rb +26 -1
  77. data/test/test-gtk-tree-sortable.rb +35 -0
  78. data/test/test-gtk-tree-store.rb +34 -0
  79. data/test/test-gtk-widget.rb +33 -2
  80. metadata +55 -19
  81. data/sample/gtk-demo/button-box.rb +0 -82
@@ -1,75 +1,53 @@
1
- # This sample code is a port of gtk3/demos/gtk-demo/css_accordion.c. The
2
- # CSS files used in this sample code are copied from gtk3/demos/gtk-demo.
3
- # They are licensed under the terms of the GNU Lesser General Public
4
- # License, version 2.1 or (at your option) later.
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
5
3
  #
6
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
7
- #
8
- # This library is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU Lesser General Public
10
- # License as published by the Free Software Foundation; either
11
- # version 2.1 of the License, or (at your option) any later version.
12
- #
13
- # This library is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- # Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public
19
- # License along with this library; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
4
  =begin
22
5
  = CSS Theming/CSS Accordion
23
6
 
24
7
  A simple accordion demo written using CSS transitions and multiple backgrounds
25
8
  =end
9
+ module CssAccordionDemo
10
+ def self.run_demo(main_window)
11
+ window = Gtk::Window.new(:toplevel)
12
+ window.screen = main_window.screen
26
13
 
27
- require "common"
28
-
29
- module Demo
30
- class CssAccordion < BasicWindow
31
- def initialize
32
- super("CSS Accordion")
33
- set_default_size(600, 300)
34
-
35
- container = Gtk::Box.new(:horizontal, 0)
36
- container.set_halign(:center)
37
- container.set_valign(:center)
38
- add(container)
39
-
40
- child = Gtk::Button.new(:label => "This")
41
- container.add(child)
14
+ window.set_title("CSS Accordion")
15
+ window.set_default_size(600, 300)
42
16
 
43
- child = Gtk::Button.new(:label => "Is")
44
- container.add(child)
17
+ container = Gtk::Box.new(:horizontal, 0)
18
+ container.set_halign(:center)
19
+ container.set_valign(:center)
45
20
 
46
- child = Gtk::Button.new(:label => "A")
47
- container.add(child)
21
+ window.add(container)
48
22
 
49
- child = Gtk::Button.new(:label => "CSS")
23
+ %w(This Is A CSS Accordion :-).each do |label|
24
+ child = Gtk::Button.new(:label => label)
50
25
  container.add(child)
26
+ end
51
27
 
52
- child = Gtk::Button.new(:label => "Accordion")
53
- container.add(child)
28
+ provider = Gtk::CssProvider.new
29
+ provider.load_from_resource("/css_accordion/css_accordion.css")
54
30
 
55
- child = Gtk::Button.new(:label => ":-)")
56
- container.add(child)
31
+ style_context = window.style_context
32
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
57
33
 
58
- provider = Gtk::CssProvider.new
59
- Dir.chdir(__dir__) do
60
- provider.load(:data => File.read("css_accordion.css"))
61
- end
34
+ apply_style(window, provider)
62
35
 
63
- apply_css(self, provider)
36
+ if !window.visible?
37
+ window.show_all
38
+ else
39
+ window.destroy
64
40
  end
65
41
 
66
- def apply_css(widget, provider)
67
- widget.style_context.add_provider(provider, GLib::MAXUINT)
68
- if widget.is_a?(Gtk::Container)
69
- widget.each_all do |child|
70
- apply_css(child, provider)
71
- end
72
- end
42
+ window
43
+ end
44
+
45
+ def self.apply_style(widget, provider)
46
+ style_context = widget.style_context
47
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
48
+ return unless widget.respond_to?(:children)
49
+ widget.children.each do |child|
50
+ apply_style(child, provider)
73
51
  end
74
52
  end
75
53
  end
@@ -1,103 +1,78 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
1
3
  #
2
- # This sample code is a port of gtk3/demos/gtk-demo/css_basic.c. The
3
- # CSS file used in this sample code is copied from gtk3/demos/gtk-demo.
4
- # They are licensed under the terms of the GNU Lesser General Public
5
- # License, version 2.1 or (at your option) later.
6
- #
7
- # Copyright (C) 2013 Ruby-GNOME2 Project Team
8
- #
9
- # This library is free software; you can redistribute it and/or
10
- # modify it under the terms of the GNU Lesser General Public
11
- # License as published by the Free Software Foundation; either
12
- # version 2.1 of the License, or (at your option) any later version.
13
- #
14
- # This library is distributed in the hope that it will be useful,
15
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- # Lesser General Public License for more details.
18
- #
19
- # You should have received a copy of the GNU Lesser General Public
20
- # License along with this library; if not, write to the Free Software
21
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
4
  =begin
23
5
  = CSS Theming/CSS Basics
24
6
 
25
7
  Gtk themes are written using CSS. Every widget is build of multiple items
26
8
  that you can style very similarly to a regular website.
27
9
  =end
28
-
29
- require "common"
30
-
31
- module Demo
32
- class CssBasics < BasicWindow
33
- def initialize
34
- super("CSS Basics")
35
- set_default_size(400, 300)
36
-
37
- text = Gtk::TextBuffer.new
38
- text.create_tag("warning", "underline" => Pango::AttrUnderline::SINGLE)
39
- text.create_tag("error", "underline" => Pango::AttrUnderline::ERROR)
40
-
41
- provider = Gtk::CssProvider.new
42
-
43
- container = Gtk::ScrolledWindow.new(nil, nil)
44
- add(container)
45
- child = Gtk::TextView.new(text)
46
- container.add(child)
47
- text.signal_connect("changed") do |_text|
48
- css_text_changed(_text, provider)
10
+ module CssBasicsDemo
11
+ def self.run_demo(main_window)
12
+ window = Gtk::Window.new(:toplevel)
13
+ window.set_title("CSS Basics")
14
+ window.set_transient_for(main_window)
15
+ window.set_default_size(400, 300)
16
+
17
+ text = Gtk::TextBuffer.new
18
+ text.create_tag("warning", "underline" => Pango::UNDERLINE_SINGLE)
19
+ text.create_tag("error", "underline" => Pango::UNDERLINE_ERROR)
20
+ default_css = Gio::Resources.lookup_data("/css_basics/css_basics.css", 0)
21
+ text.text = default_css
22
+
23
+ provider = Gtk::CssProvider.new
24
+ provider.load_from_data(default_css)
25
+
26
+ container = Gtk::ScrolledWindow.new
27
+ window.add(container)
28
+
29
+ child = Gtk::TextView.new(text)
30
+ container.add(child)
31
+
32
+ text.signal_connect "changed" do |buffer|
33
+ buffer.remove_all_tags(buffer.start_iter, buffer.end_iter)
34
+ modified_text = buffer.get_text(buffer.start_iter,
35
+ buffer.end_iter,
36
+ false)
37
+ begin
38
+ provider.load_from_data(modified_text)
39
+ rescue
40
+ provider.load_from_data(default_css)
49
41
  end
50
42
 
51
- text.text = File.read(File.join(__dir__, "css_basics.css"))
52
-
53
- provider.signal_connect("parsing-error") do |_provider, section, error|
54
- p section
55
- p error
56
- show_parsing_error(section, error, child.buffer)
57
- end
58
-
59
- apply_css(self, provider)
43
+ Gtk::StyleContext.reset_widgets
60
44
  end
61
45
 
62
- private
63
- def show_parsing_error(section, error, buffer)
64
- p buffer.methods.grep /iter/
65
- start = buffer.get_iter_at_line_index(section.start_line,
66
- section.start_position)
67
-
68
- end_ = buffer.get_iter_at_line_index(section.end_line,
69
- section.end_position)
70
-
71
- if error == Gtk::CssProvider::ERROR ||
72
- error == Gtk::CssProvider::ERROR_DEPRECATED
46
+ provider.signal_connect "parsing-error" do |_css_provider, section, error|
47
+ start_i = text.get_iter_at(:line => section.start_line,
48
+ :index => section.start_position)
49
+ end_i = text.get_iter_at(:line => section.end_line,
50
+ :index => section.end_position)
51
+ tag_name = nil
52
+ if error == Gtk::CssProviderError::DEPRECATED
73
53
  tag_name = "warning"
74
54
  else
75
55
  tag_name = "error"
76
56
  end
77
-
78
- buffer.apply_tag_by_name(buffer, tag_name, start, end_)
57
+ text.apply_tag_by_name(tag_name, start_i, end_i)
79
58
  end
80
59
 
81
- def css_text_changed(buffer, provider)
82
- start = buffer.start_iter
83
- end_ = buffer.end_iter
84
- buffer.remove_all_tags(start, end_)
60
+ apply_style(window, provider)
85
61
 
86
- text = buffer.get_text(start, end_, false)
87
- Dir.chdir(__dir__) do
88
- provider.load(:data => text)
89
- end
90
-
91
- Gtk::StyleContext.reset_widgets
62
+ if !window.visible?
63
+ window.show_all
64
+ else
65
+ window.destroy
92
66
  end
67
+ window
68
+ end
93
69
 
94
- def apply_css(widget, provider)
95
- widget.style_context.add_provider(provider, GLib::MAXUINT)
96
- if widget.is_a?(Gtk::Container)
97
- widget.each_all do |child|
98
- apply_css(child, provider)
99
- end
100
- end
70
+ def self.apply_style(widget, provider)
71
+ style_context = widget.style_context
72
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
73
+ return unless widget.respond_to?(:children)
74
+ widget.children.each do |child|
75
+ apply_style(child, provider)
101
76
  end
102
77
  end
103
78
  end
@@ -0,0 +1,112 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = CSS Theming/Multiple Backgrounds
6
+
7
+ Gtk themes are written using CSS. Every widget is build of multiple items
8
+ that you can style very similarly to a regular website.
9
+ =end
10
+ module CssMultiplebgsDemo
11
+ def self.run_demo(main_window)
12
+ window = Gtk::Window.new(:toplevel)
13
+ window.screen = main_window.screen
14
+ window.title = "Mutiple Backgrounds"
15
+ window.transient_for = main_window
16
+ window.set_default_size(400, 300)
17
+
18
+ container = Gtk::Overlay.new
19
+ container.add_events([:enter_notify_mask, :leave_notify_mask, :pointer_motion_mask])
20
+ window.add(container)
21
+
22
+ child = Gtk::DrawingArea.new
23
+ child.name = "canvas"
24
+
25
+ child.signal_connect "draw" do |widget, cr|
26
+ context = widget.style_context
27
+ Gtk.render_background(context, cr, 0, 0,
28
+ widget.allocated_width,
29
+ widget.allocated_height)
30
+ Gtk.render_frame(context, cr, 0, 0,
31
+ widget.allocated_width,
32
+ widget.allocated_height)
33
+ false
34
+ end
35
+ container.add(child)
36
+
37
+ child = Gtk::Button.new
38
+ child.add_events([:enter_notify_mask, :leave_notify_mask, :pointer_motion_mask])
39
+ child.name = "bricks-button"
40
+ child.halign = :center
41
+ child.valign = :center
42
+ child.set_size_request(250, 84)
43
+ container.add_overlay(child)
44
+
45
+ paned = Gtk::Paned.new(:vertical)
46
+ container.add_overlay(paned)
47
+
48
+ # Need a filler so we get a handle
49
+ child = Gtk::Box.new(:vertical, 0)
50
+ paned.add(child)
51
+
52
+ text = Gtk::TextBuffer.new
53
+ text.create_tag("warning", "underline" => :single)
54
+ text.create_tag("error", "underline" => :error)
55
+ default_css = Gio::Resources.lookup_data("/css_multiplebgs/css_multiplebgs.css")
56
+ text.text = default_css
57
+
58
+ provider = Gtk::CssProvider.new
59
+ provider.load_from_data(default_css)
60
+
61
+ container = Gtk::ScrolledWindow.new
62
+ paned.add(container)
63
+
64
+ child = Gtk::TextView.new(text)
65
+ container.add(child)
66
+
67
+ text.signal_connect "changed" do |buffer|
68
+ buffer.remove_all_tags(buffer.start_iter, buffer.end_iter)
69
+ modified_text = buffer.get_text(buffer.start_iter,
70
+ buffer.end_iter,
71
+ false)
72
+ begin
73
+ provider.load_from_data(modified_text)
74
+ rescue
75
+ provider.load_from_data(default_css)
76
+ end
77
+
78
+ Gtk::StyleContext.reset_widgets
79
+ end
80
+
81
+ provider.signal_connect "parsing-error" do |_css_provider, section, error|
82
+ start_i = text.get_iter_at(:line => section.start_line,
83
+ :index => section.start_position)
84
+ end_i = text.get_iter_at(:line => section.end_line,
85
+ :index => section.end_position)
86
+ tag_name = nil
87
+ if error == Gtk::CssProviderError::DEPRECATED
88
+ tag_name = "warning"
89
+ else
90
+ tag_name = "error"
91
+ end
92
+ text.apply_tag_by_name(tag_name, start_i, end_i)
93
+ end
94
+ apply_style(window, provider)
95
+
96
+ if !window.visible?
97
+ window.show_all
98
+ else
99
+ window.destroy
100
+ end
101
+ window
102
+ end
103
+
104
+ def self.apply_style(widget, provider)
105
+ style_context = widget.style_context
106
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
107
+ return unless widget.respond_to?(:children)
108
+ widget.children.each do |child|
109
+ apply_style(child, provider)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,84 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = CSS Theming/Animated Backgrounds
6
+
7
+ This demo is done in honour of the Pixbufs demo further down.
8
+ It is done exclusively with CSS as the background of the window.
9
+ =end
10
+ module CssPixbufsDemo
11
+ def self.run_demo(main_window)
12
+ window = Gtk::Window.new(:toplevel)
13
+ window.set_title("Animated Backgrounds")
14
+ window.set_transient_for(main_window)
15
+ window.set_default_size(400, 300)
16
+
17
+ text = Gtk::TextBuffer.new
18
+ text.create_tag("warning", "underline" => Pango::UNDERLINE_SINGLE)
19
+ text.create_tag("error", "underline" => Pango::UNDERLINE_ERROR)
20
+ default_css = Gio::Resources.lookup_data("/css_pixbufs/gtk.css", 0)
21
+ text.text = default_css
22
+
23
+ provider = Gtk::CssProvider.new
24
+ provider.load_from_data(default_css)
25
+
26
+ paned = Gtk::Paned.new(:vertical)
27
+ window.add(paned)
28
+
29
+ child = Gtk::Box.new(:vertical, 0)
30
+ paned.add(child)
31
+
32
+ container = Gtk::ScrolledWindow.new
33
+ paned.add(container)
34
+
35
+ child = Gtk::TextView.new(text)
36
+ container.add(child)
37
+
38
+ text.signal_connect "changed" do |buffer|
39
+ buffer.remove_all_tags(buffer.start_iter, buffer.end_iter)
40
+ modified_text = buffer.get_text(buffer.start_iter,
41
+ buffer.end_iter,
42
+ false)
43
+ begin
44
+ provider.load_from_data(modified_text)
45
+ rescue
46
+ provider.load_from_data(default_css)
47
+ end
48
+
49
+ Gtk::StyleContext.reset_widgets
50
+ end
51
+
52
+ provider.signal_connect "parsing-error" do |_css_provider, section, error|
53
+ start_i = text.get_iter_at(:line => section.start_line,
54
+ :index => section.start_position)
55
+ end_i = text.get_iter_at(:line => section.end_line,
56
+ :index => section.end_position)
57
+ tag_name = nil
58
+ if error == Gtk::CssProviderError::DEPRECATED
59
+ tag_name = "warning"
60
+ else
61
+ tag_name = "error"
62
+ end
63
+ text.apply_tag_by_name(tag_name, start_i, end_i)
64
+ end
65
+
66
+ apply_style(window, provider)
67
+
68
+ if !window.visible?
69
+ window.show_all
70
+ else
71
+ window.destroy
72
+ end
73
+ window
74
+ end
75
+
76
+ def self.apply_style(widget, provider)
77
+ style_context = widget.style_context
78
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
79
+ return unless widget.respond_to?(:children)
80
+ widget.children.each do |child|
81
+ apply_style(child, provider)
82
+ end
83
+ end
84
+ end