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
@@ -0,0 +1,101 @@
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/Shadows
6
+
7
+ This demo shows how to use CSS shadows.
8
+ =end
9
+ module CssShadowsDemo
10
+ def self.run_demo(main_window)
11
+ window = Gtk::Window.new(:toplevel)
12
+ window.set_title("Shadows")
13
+ window.set_transient_for(main_window)
14
+ window.set_default_size(400, 300)
15
+
16
+ paned = Gtk::Paned.new(:vertical)
17
+ window.add(paned)
18
+
19
+ child = create_toolbar
20
+ paned.add(child)
21
+
22
+ text = Gtk::TextBuffer.new
23
+ text.create_tag("warning", "underline" => :single)
24
+ text.create_tag("error", "underline" => :error)
25
+ default_css = Gio::Resources.lookup_data("/css_shadows/gtk.css")
26
+ text.text = default_css
27
+
28
+ provider = Gtk::CssProvider.new
29
+ provider.load_from_data(default_css)
30
+
31
+ container = Gtk::ScrolledWindow.new
32
+ paned.add(container)
33
+
34
+ child = Gtk::TextView.new(text)
35
+ container.add(child)
36
+
37
+ text.signal_connect "changed" do |buffer|
38
+ buffer.remove_all_tags(buffer.start_iter, buffer.end_iter)
39
+ modified_text = buffer.get_text(buffer.start_iter,
40
+ buffer.end_iter,
41
+ false)
42
+ begin
43
+ provider.load_from_data(modified_text)
44
+ rescue
45
+ provider.load_from_data(default_css)
46
+ end
47
+
48
+ Gtk::StyleContext.reset_widgets
49
+ end
50
+
51
+ provider.signal_connect "parsing-error" do |_css_provider, section, error|
52
+ start_i = text.get_iter_at(:line => section.start_line,
53
+ :index => section.start_position)
54
+ end_i = text.get_iter_at(:line => section.end_line,
55
+ :index => section.end_position)
56
+ tag_name = nil
57
+ if error == Gtk::CssProviderError::DEPRECATED
58
+ tag_name = "warning"
59
+ else
60
+ tag_name = "error"
61
+ end
62
+ text.apply_tag_by_name(tag_name, start_i, end_i)
63
+ end
64
+ apply_style(window, provider)
65
+
66
+ if !window.visible?
67
+ window.show_all
68
+ else
69
+ window.destroy
70
+ end
71
+ window
72
+ end
73
+
74
+ def self.create_toolbar
75
+ toolbar = Gtk::Toolbar.new
76
+ toolbar.set_valign(:center)
77
+
78
+ item = Gtk::ToolButton.new
79
+ item.set_icon_name("go-next")
80
+ toolbar.insert(item, -1)
81
+
82
+ item = Gtk::ToolButton.new
83
+ item.set_icon_name("go-previous")
84
+ toolbar.insert(item, -1)
85
+
86
+ item = Gtk::ToolButton.new(:label => "Hello World")
87
+ item.set_is_important(true)
88
+ toolbar.insert(item, -1)
89
+
90
+ toolbar
91
+ end
92
+
93
+ def self.apply_style(widget, provider)
94
+ style_context = widget.style_context
95
+ style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
96
+ return unless widget.respond_to?(:children)
97
+ widget.children.each do |child|
98
+ apply_style(child, provider)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,114 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = Cursors
6
+
7
+ Demonstrates a useful set of available cursors.
8
+ =end
9
+ module CursorsDemo
10
+ def self.run_demo(main_window)
11
+ window = Gtk::Window.new(:toplevel)
12
+ window.screen = main_window.screen
13
+ window.set_title("Cursors")
14
+ window.set_default_size(500, 500)
15
+
16
+ sw = Gtk::ScrolledWindow.new(nil, nil)
17
+ sw.set_policy(:never, :automatic)
18
+ window.add(sw)
19
+
20
+ box = Gtk::Box.new(:vertical, 0)
21
+ box.set_property("margin-start", 20)
22
+ box.set_property("margin-end", 20)
23
+ box.set_property("margin-bottom", 20)
24
+ sw.add(box)
25
+
26
+ section = Section.new(box, "General")
27
+ %w(default none).each do |cursor_name|
28
+ section.add_button(cursor_name)
29
+ end
30
+
31
+ section = Section.new(box, "Link & Status")
32
+ %w(context-menu help
33
+ pointer progress wait).each do |cursor_name|
34
+ section.add_button(cursor_name)
35
+ end
36
+
37
+ section = Section.new(box, "Selection")
38
+ %w(cell crosshair text vertical-text).each do |cursor_name|
39
+ section.add_button(cursor_name)
40
+ end
41
+
42
+ section = Section.new(box, "Drag & Drop")
43
+ %w(alias copy move no-drop
44
+ not-allowed grab grabbing).each do |cursor_name|
45
+ section.add_button(cursor_name)
46
+ end
47
+
48
+ section = Section.new(box, "Resize & Scrolling")
49
+ %w(all-scroll col-resize row-resize n-resize
50
+ e-resize s-resize w-resize ne-resize nw-resize
51
+ se-resize sw-resize ew-resize ns-resize nesw-resize
52
+ nwse-resize).each do |cursor_name|
53
+ section.add_button(cursor_name)
54
+ end
55
+
56
+ section = Section.new(box, "Zoom")
57
+ %w(zoom-in zoom-out).each do |cursor_name|
58
+ section.add_button(cursor_name)
59
+ end
60
+
61
+ if !window.visible?
62
+ window.show_all
63
+ else
64
+ window.destroy
65
+ end
66
+ window
67
+ end
68
+
69
+ class Section
70
+ def initialize(container, title)
71
+ label = Gtk::Label.new(title)
72
+ label.set_xalign(0.0)
73
+ label.set_margin_top(10)
74
+ label.set_margin_bottom(10)
75
+ container.pack_start(label, :expand => false, :fill => true, :padding => 0)
76
+
77
+ @section = Gtk::FlowBox.new
78
+ @section.set_halign(:start)
79
+ @section.set_selection_mode(:none)
80
+ @section.set_min_children_per_line(2)
81
+ @section.set_min_children_per_line(20)
82
+ container.pack_start(@section, :expand => false, :fill => true, :padding => 0)
83
+ end
84
+
85
+ def add_button(css_name)
86
+ cursor = Gdk::Cursor.new(css_name)
87
+ image = nil
88
+ if !cursor
89
+ image = Gtk::Image.new(:icon_name => "image-missing", :size => :menu)
90
+ else
91
+ path = "/cursors/#{css_name.tr('-', '_')}_cursor.png"
92
+ image = Gtk::Image.new(:resource => path)
93
+ end
94
+ image.set_size_request(32, 32)
95
+
96
+ button = Gtk::Button.new
97
+ button.add(image)
98
+ button.style_context.add_class("image-button")
99
+ button.signal_connect("clicked") do |_widget|
100
+ apply_cursor(cursor)
101
+ end
102
+ button.set_tooltip_text(css_name)
103
+ @section.add(button)
104
+ end
105
+
106
+ private
107
+
108
+ def apply_cursor(cursor)
109
+ toplevel = @section.toplevel
110
+ window = toplevel.window
111
+ window.set_cursor(cursor)
112
+ end
113
+ end
114
+ end
@@ -1,137 +1,127 @@
1
- # Copyright (c) 2003-2005 Ruby-GNOME2 Project Team
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
2
  # This program is licenced under the same licence as Ruby-GNOME2.
3
3
  #
4
- # $Id: dialog.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $
5
4
  =begin
6
- = Dialog and Message Boxes
5
+ = Dialogs and Message Boxes
7
6
 
8
- Dialog widgets are used to pop up a transient window for user feedback.
7
+ Dialog widgets are used to pop up a transient window for user feedback.
9
8
  =end
10
-
11
- require 'common'
12
-
13
- module Demo
14
- class Dialog < Demo::BasicWindow
15
- def initialize
16
- @count = 1
17
-
18
- super('Dialogs')
19
- set_border_width(8)
20
-
21
- frame = Gtk::Frame.new('Dialogs')
22
- add(frame)
23
-
24
- vbox = Gtk::VBox.new(false, 8)
25
- vbox.set_border_width(8)
26
- frame.add(vbox)
27
-
28
- # Standard message dialog
29
- hbox = Gtk::Box.new(:horizontal, 0)
30
- vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
31
- button = Gtk::Button.new('_Message Dialog', true)
32
- button.signal_connect('clicked') do
33
- message_dialog_clicked
34
- end
35
- hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
36
-
37
- vbox.pack_start(Gtk::HSeparator.new, :expand => false, :fill => false, :padding => 0)
38
-
39
- # Interactive dialog
40
- hbox = Gtk::Box.new(:horizontal, 8)
41
- vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
42
- vbox2 = Gtk::VBox.new(false, 0)
43
-
44
- button = Gtk::Button.new('_Interactive Dialog')
45
- button.signal_connect('clicked') do
46
- interactive_dialog_clicked
47
- end
48
- hbox.pack_start(vbox2, :expand => false, :fill => false, :padding => 0)
49
- vbox2.pack_start(button, :expand => false, :fill => false, :padding => 0)
50
-
51
- table = Gtk::Table.new(2, 2, false)
52
- table.set_row_spacings(4)
53
- table.set_column_spacings(4)
54
- hbox.pack_start(table, :expand => false, :fill => false, :padding => 0)
55
-
56
- label = Gtk::Label.new('_Entry 1', true)
57
- table.attach_defaults(label, 0, 1, 0, 1)
58
-
59
- @entry1 = Gtk::Entry.new
60
- table.attach_defaults(@entry1, 1, 2, 0, 1)
61
- label.set_mnemonic_widget(@entry1)
62
-
63
- label = Gtk::Label.new('E_ntry 2', true)
64
-
65
- table.attach_defaults(label, 0, 1, 1, 2)
66
-
67
- @entry2 = Gtk::Entry.new
68
- table.attach_defaults(@entry2, 1, 2, 1, 2)
69
- label.set_mnemonic_widget(@entry2)
70
- end
71
-
72
- def message_dialog_clicked
73
- dialog = Gtk::MessageDialog.new(self,
74
- Gtk::Dialog::MODAL |
75
- Gtk::Dialog::DESTROY_WITH_PARENT,
76
- Gtk::MessageDialog::INFO,
77
- Gtk::MessageDialog::BUTTONS_OK,
78
- <<EOS)
79
- This message box has been popped up the following
9
+ module DialogDemo
10
+ def self.run_demo(main_window)
11
+ window = Gtk::Window.new(:toplevel)
12
+ window.screen = main_window.screen
13
+ window.title = "Dialogs and Message Boxes"
14
+ window.border_width = 8
15
+
16
+ frame = Gtk::Frame.new("Dialogs")
17
+ window.add(frame)
18
+
19
+ vbox = Gtk::Box.new(:vertical, 8)
20
+ vbox.border_width = 8
21
+ frame.add(vbox)
22
+
23
+ # Standard message dialog
24
+ hbox = Gtk::Box.new(:horizontal, 8)
25
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
26
+ button = Gtk::Button.new(:label => "_Message Dialog",
27
+ :use_underline => true)
28
+ i = 0
29
+
30
+ button.signal_connect "clicked" do
31
+ dialog = Gtk::MessageDialog.new(:parent => window,
32
+ :flags => [:modal, :destroy_with_parent],
33
+ :type => :info,
34
+ :buttons => :ok_cancel,
35
+ :message => <<-MESSAGE)
36
+ This message has been popped up the following
80
37
  number of times:
81
-
82
- #{@count}
83
- EOS
38
+ MESSAGE
39
+ dialog.secondary_text = "#{i}"
84
40
  dialog.run
85
41
  dialog.destroy
86
- @count += 1
42
+ i += 1
87
43
  end
88
44
 
89
- def interactive_dialog_clicked
90
- dialog = Gtk::Dialog.new('Interactive Dialog',
91
- self,
92
- Gtk::Dialog::MODAL |
93
- Gtk::Dialog::DESTROY_WITH_PARENT,
94
- [Gtk::Stock::OK, Gtk::ResponseType::OK],
95
- ["_Non-stock Button", Gtk::ResponseType::CANCEL]
96
- )
97
-
98
- hbox = Gtk::Box.new(:horizontal, 0)
99
- hbox.set_border_width(8)
100
- dialog.vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
101
-
102
- stock = Gtk::Image.new(Gtk::Stock::DIALOG_QUESTION, Gtk::IconSize::DIALOG)
103
- hbox.pack_start(stock, :expand => false, :fill => false, :padding => 0)
104
-
105
- table = Gtk::Table.new(2, 2, false)
106
- table.set_row_spacings(4)
107
- table.set_column_spacings(4)
108
- hbox.pack_start(table, :expand => true, :fill => true, :padding => 0)
109
- label = Gtk::Label.new('_Entry 1', true)
110
- table.attach_defaults(label,
111
- 0, 1, 0, 1)
45
+ hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
46
+ vbox.pack_start(Gtk::Separator.new(:horizontal),
47
+ :expand => false,
48
+ :fill => false,
49
+ :padding => 0)
50
+
51
+ # Interactive dialog
52
+ hbox = Gtk::Box.new(:horizontal, 8)
53
+ vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
54
+ vbox2 = Gtk::Box.new(:vertical, 0)
55
+
56
+ button = Gtk::Button.new(:label => "_Interactive Dialog",
57
+ :use_underline => true)
58
+
59
+ hbox.pack_start(vbox2, :expand => false, :fill => false, :padding => 0)
60
+ vbox2.pack_start(button, :expand => false, :fill => false, :padding => 0)
61
+
62
+ table = Gtk::Grid.new
63
+ table.row_spacing = 4
64
+ table.column_spacing = 4
65
+ hbox.pack_start(table, :expand => false, :fill => false, :padding => 0)
66
+
67
+ label = Gtk::Label.new("_Entry 1", :use_underline => true)
68
+ table.attach(label, 0, 0, 1, 1)
69
+
70
+ entry1 = Gtk::Entry.new
71
+ table.attach(entry1, 1, 0, 1, 1)
72
+ label.set_mnemonic_widget(entry1)
73
+
74
+ entry2 = Gtk::Entry.new
75
+ label = Gtk::Label.new("E_ntry 2", :use_underline => true)
76
+ table.attach(entry2, 1, 1, 1, 1)
77
+
78
+ button.signal_connect "clicked" do
79
+ dialog = Gtk::Dialog.new(:parent => window,
80
+ :title => "Interactive Dialog",
81
+ :flags => [:modal, :destroy_with_parent],
82
+ :buttons => [["_OK", :ok],
83
+ ["_Cancel", :cancel]]
84
+ )
85
+ content_area = dialog.content_area
86
+ local_hbox = Gtk::Box.new(:horizontal, 8)
87
+ local_hbox.border_width = 8
88
+ content_area.pack_start(local_hbox)
89
+
90
+ image = Gtk::Image.new(:icon_name => "dialog-question", :size => :dialog)
91
+ local_hbox.pack_start(image)
92
+
93
+ local_table = Gtk::Grid.new
94
+ local_table.row_spacing = 4
95
+ local_table.column_spacing = 4
96
+ local_hbox.pack_start(local_table, :expand => false, :fill => false, :padding => 0)
97
+
98
+ label = Gtk::Label.new("_Entry 1", :use_underline => true)
99
+ local_table.attach(label, 0, 0, 1, 1)
100
+
112
101
  local_entry1 = Gtk::Entry.new
113
- local_entry1.text = @entry1.text
114
- table.attach_defaults(local_entry1, 1, 2, 0, 1)
102
+ local_table.attach(local_entry1, 1, 0, 1, 1)
115
103
  label.set_mnemonic_widget(local_entry1)
116
104
 
117
- label = Gtk::Label.new('E_ntry 2', true)
118
- table.attach_defaults(label,
119
- 0, 1, 1, 2)
120
-
121
105
  local_entry2 = Gtk::Entry.new
122
- local_entry2.text = @entry2.text
123
- table.attach_defaults(local_entry2, 1, 2, 1, 2)
124
- label.set_mnemonic_widget(local_entry2)
106
+ label = Gtk::Label.new("E_ntry 2", :use_underline => true)
107
+ local_table.attach(local_entry2, 1, 1, 1, 1)
125
108
 
126
- hbox.show_all
109
+ local_hbox.show_all
127
110
  response = dialog.run
128
111
 
129
- if response == Gtk::ResponseType::OK
130
- @entry1.text = local_entry1.text
131
- @entry2.text = local_entry2.text
112
+ if response == :ok
113
+ entry1.text = local_entry1.text
114
+ entry2.text = local_entry2.text
132
115
  end
116
+
133
117
  dialog.destroy
134
118
  end
119
+
120
+ if !window.visible?
121
+ window.show_all
122
+ else
123
+ window.destroy
124
+ end
125
+ window
135
126
  end
136
127
  end
137
-