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,118 +1,106 @@
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: sizegroup.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $
5
4
  =begin
6
- = Size Groups
7
-
8
- Gtk::SizeGroup provides a mechanism for grouping a number of
9
- widgets together so they all request the same amount of space.
10
- This is typically useful when you want a column of widgets to
11
- have the same size, but you can't use a Gtk::Table widget.
12
-
13
- Note that size groups only affect the amount of space requested,
14
- not the size that the widgets finally receive. If you want the
15
- widgets in a Gtk::SizeGroup to actually be the same size, you need
16
- to pack them in such a way that they get the size they request
17
- and not more. For example, if you are packing your widgets
18
- into a table, you would not include the Gtk::FILL flag.
5
+ = Size Groups
6
+
7
+ GtkSizeGroup provides a mechanism for grouping a number of
8
+ widgets together so they all request the same amount of space.
9
+ This is typically useful when you want a column of widgets to
10
+ have the same size, but you can't use a GtkTable widget.
11
+
12
+ Note that size groups only affect the amount of space requested,
13
+ not the size that the widgets finally receive. If you want the
14
+ widgets in a GtkSizeGroup to actually be the same size, you need
15
+ to pack them in such a way that they get the size they request
16
+ and not more. For example, if you are packing your widgets
17
+ into a table, you would not include the GTK_FILL flag.
19
18
  =end
20
- require 'common'
21
-
22
- module Demo
23
- class SizeGroup < Gtk::Dialog
24
- def initialize
25
- super('GtkSizeGroup', nil, 0,
26
- [Gtk::Stock::CLOSE, Gtk::ResponseType::NONE])
27
-
28
- color_options = %w(Red Green Blue)
29
- dash_options = %w(Solid Dashed Dotted)
30
- end_options = %w(Square Round Arrow)
31
-
32
- set_resizable(false)
33
-
34
- signal_connect('response') do
35
- destroy
36
- end
37
-
38
- vbox = Gtk::VBox.new(false, 5)
39
- self.vbox.pack_start(vbox, :expand => true, :fill => true, :padding => 0)
40
- vbox.set_border_width(5)
41
-
42
- size_group = Gtk::SizeGroup.new(Gtk::SizeGroup::HORIZONTAL)
43
-
44
- ## Create one frame holding color options
45
- frame = Gtk::Frame.new('Color Options')
46
- vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
47
-
48
- table = Gtk::Table.new(2, 2, false)
49
- table.set_border_width(5)
50
- table.set_row_spacings(5)
51
- table.set_column_spacings(10)
52
- frame.add(table)
53
-
54
- add_row(table, 0, size_group, '_Foreground', color_options)
55
- add_row(table, 1, size_group, '_Background', color_options)
56
-
57
- ## And another frame holding line style options
58
- frame = Gtk::Frame.new('Line Options')
59
- vbox.pack_start(frame, :expand => false, :fill => false, :padding => 0)
60
-
61
- table = Gtk::Table.new(2, 2, false)
62
- table.set_border_width(5)
63
- table.set_row_spacings(5)
64
- table.set_column_spacings(10)
65
- frame.add(table)
66
-
67
- add_row(table, 0, size_group, '_Dashing', dash_options)
68
- add_row(table, 1, size_group, '_Line ends', end_options)
69
-
70
- # And a check button to turn grouping on and off
71
- check_button = Gtk::CheckButton.new('_Enable grouping', true)
72
- vbox.pack_start(check_button, :expand => false, :fill => false, :padding => 0)
73
-
74
- check_button.set_active(true)
75
- check_button.signal_connect('toggled', size_group) do |check_button, size_group|
76
- new_mode = if check_button.active?
77
- Gtk::SizeGroup::HORIZONTAL
78
- else
79
- Gtk::SizeGroup::VERTICAL
80
- end
81
- size_group.set_mode(new_mode)
19
+ module SizegroupDemo
20
+ def self.run_demo(main_window)
21
+ color_options = %w(Red Green Blue)
22
+ dash_options = %w(Solid Dashed Dotted)
23
+ end_options = %w(Square Round Double Arrow)
24
+
25
+ window = Gtk::Window.new(:toplevel)
26
+ window.screen = main_window.screen
27
+ window.set_title("Size Groups")
28
+ window.set_resizable(false)
29
+
30
+ vbox = Gtk::Box.new(:vertical, 5)
31
+ window.add(vbox)
32
+ vbox.set_border_width(5)
33
+
34
+ size_group = Gtk::SizeGroup.new(:horizontal)
35
+
36
+ # Create one frame holding color options
37
+ frame = Gtk::Frame.new("Color Options")
38
+ vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
39
+
40
+ table = Gtk::Grid.new
41
+ table.set_border_width(5)
42
+ table.set_row_spacing(5)
43
+ table.set_column_spacing(10)
44
+ frame.add(table)
45
+
46
+ add_row(table, 0, size_group, "_Foreground", color_options)
47
+ add_row(table, 1, size_group, "_Background", color_options)
48
+
49
+ # And another frame holding line style options
50
+ frame = Gtk::Frame.new("Line options")
51
+ vbox.pack_start(frame, :expand => false, :fill => false, :padding => 0)
52
+
53
+ table = Gtk::Grid.new
54
+ table.set_border_width(5)
55
+ table.set_row_spacing(5)
56
+ table.set_column_spacing(10)
57
+ frame.add(table)
58
+
59
+ add_row(table, 0, size_group, "_Dashing", dash_options)
60
+ add_row(table, 1, size_group, "_Line ends", end_options)
61
+
62
+ # And a check button to turn grouping on and off
63
+ check_button = Gtk::CheckButton.new("_Enable grouping")
64
+ check_button.set_use_underline(true)
65
+ vbox.pack_start(check_button, :expand => false, :fill => false, :padding => 0)
66
+
67
+ check_button.signal_connect("toggled") do |widget|
68
+ if widget.active?
69
+ size_group.set_mode(:horizontal)
70
+ else
71
+ size_group.set_mode(:none)
82
72
  end
83
73
  end
84
74
 
85
- def add_row(table, row, size_group, label_text, options)
86
- label = Gtk::Label.new(label_text, true)
87
- label.set_alignment(0, 1)
88
- table.attach(label,
89
- 0, 1, row, row + 1,
90
- Gtk::EXPAND | Gtk::FILL, 0,
91
- 0, 0)
92
-
93
- option_menu = create_option_menu(options)
94
- label.set_mnemonic_widget(option_menu)
95
- size_group.add_widget(option_menu)
96
- table.attach(option_menu,
97
- 1, 2, row, row + 1,
98
- 0, 0,
99
- 0, 0)
75
+ if !window.visible?
76
+ window.show_all
77
+ else
78
+ window.destroy
100
79
  end
80
+ window
81
+ end
101
82
 
102
- def create_option_menu(strings)
103
- menu = Gtk::Menu.new
104
-
105
- strings.each do |str|
106
- menu_item = Gtk::MenuItem.new(str)
107
- menu_item.show
108
-
109
- menu.append(menu_item)
110
- end
111
-
112
- option_menu = Gtk::OptionMenu.new
113
- option_menu.set_menu(menu)
83
+ def self.add_row(table, row, size_group, label_text, options)
84
+ label = Gtk::Label.new(label_text, :use_underline => true)
85
+ label.set_halign(:start)
86
+ label.set_valign(:baseline)
87
+ label.set_hexpand(true)
88
+ table.attach(label, 0, row, 1, 1)
89
+
90
+ combo_box = create_combo_box(options)
91
+ label.set_mnemonic_widget(combo_box)
92
+ combo_box.set_halign(:end)
93
+ combo_box.set_valign(:baseline)
94
+ size_group.add_widget(combo_box)
95
+ table.attach(combo_box, 1, row, 1, 1)
96
+ end
114
97
 
115
- return option_menu
98
+ def self.create_combo_box(options)
99
+ combo_box = Gtk::ComboBoxText.new
100
+ options.each do |o|
101
+ combo_box.append_text(o)
116
102
  end
103
+ combo_box.set_active(0)
104
+ combo_box
117
105
  end
118
106
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013 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
4
  =begin
@@ -6,54 +6,57 @@
6
6
 
7
7
  GtkSpinner allows to show that background activity is on-going.
8
8
  =end
9
- require 'common'
10
-
11
- module Demo
12
- class Spinner < Gtk::Dialog
13
- def initialize
14
- super(:title => 'Spinner',
15
- :parent => nil,
16
- :flags => nil,
17
- :buttons => [[:close, :none]])
18
-
19
- signal_connect(:response) {self.destroy}
20
- signal_connect(:destroy) {self.destroy}
21
-
22
- self.resizable = false
23
-
24
- vbox = Gtk::Box.new :vertical, 5
25
-
26
- self.content_area.pack_start vbox, :expand => true, :fill => true, :padding => 0
27
- vbox.border_width = 5
28
-
29
- # Sensitive
30
- hbox = Gtk::Box.new :horizontal, 5
31
- @spinner_sensitive = Gtk::Spinner.new
32
- hbox.add @spinner_sensitive
33
- hbox.add Gtk::Entry.new
34
- vbox.add hbox
35
-
36
- # Disabled
37
- hbox = Gtk::Box.new :horizontal, 5
38
- @spinner_insensitive = Gtk::Spinner.new
39
- hbox.add @spinner_insensitive
40
- hbox.add Gtk::Entry.new
41
- vbox.add hbox
42
- hbox.sensitive = false
43
-
44
- button = Gtk::Button.new :stock_id => :media_play
45
- button.signal_connect(:clicked) do
46
- @spinner_sensitive.start
47
- @spinner_insensitive.start
48
- end
49
- vbox.add button
50
-
51
- button = Gtk::Button.new :stock_id => :media_stop
52
- button.signal_connect(:clicked) do
53
- @spinner_sensitive.stop
54
- @spinner_insensitive.stop
55
- end
56
- vbox.add button
9
+ module SpinnerDemo
10
+ def self.run_demo(main_window)
11
+ window = Gtk::Dialog.new(:title => "Spinner",
12
+ :parent => main_window,
13
+ :flags => nil,
14
+ :buttons => [[:close, :none]])
15
+
16
+ window.set_resizable(false)
17
+ window.signal_connect("response") { window.destroy }
18
+ window.signal_connect("destroy") { window.destroy }
19
+
20
+ content_area = window.content_area
21
+
22
+ vbox = Gtk::Box.new(:vertical, 5)
23
+ content_area.pack_start(vbox, :expand => true, :fill => true, :padding => 0)
24
+ vbox.set_border_width(5)
25
+
26
+ # Sensitive
27
+ hbox = Gtk::Box.new(:horizontal, 5)
28
+ spinner_sensitive = Gtk::Spinner.new
29
+ hbox.add(spinner_sensitive)
30
+ hbox.add(Gtk::Entry.new)
31
+ vbox.add(hbox)
32
+
33
+ # Disabled
34
+ hbox = Gtk::Box.new(:horizontal, 5)
35
+ spinner_insensitive = Gtk::Spinner.new
36
+ hbox.add(spinner_insensitive)
37
+ hbox.add(Gtk::Entry.new)
38
+ vbox.add(hbox)
39
+ hbox.set_sensitive(false)
40
+
41
+ button = Gtk::Button.new(:stock_id => :media_play)
42
+ button.signal_connect "clicked" do
43
+ spinner_sensitive.start
44
+ spinner_insensitive.start
57
45
  end
46
+ vbox.add(button)
47
+
48
+ button = Gtk::Button.new(:stock_id => :media_stop)
49
+ button.signal_connect "clicked" do
50
+ spinner_sensitive.stop
51
+ spinner_insensitive.stop
52
+ end
53
+ vbox.add(button)
54
+
55
+ if !window.visible?
56
+ window.show_all
57
+ else
58
+ window.destroy
59
+ end
60
+ window
58
61
  end
59
- end
62
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = Stack
6
+
7
+ GtkStack is a container that shows a single child at a time,
8
+ with nice transitions when the visible child changes.
9
+
10
+ GtkStackSwitcher adds buttons to control which child is visible.
11
+ =end
12
+
13
+ module StackDemo
14
+ def self.run_demo(main_window)
15
+ builder = Gtk::Builder.new(:resource => "/stack/stack.ui")
16
+ builder.connect_signals {}
17
+ window = builder["window1"]
18
+ window.screen = main_window.screen
19
+
20
+ window.signal_connect("destroy") { window.destroyed(window) }
21
+
22
+ if !window.visible?
23
+ window.show_all
24
+ else
25
+ window.destroy
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2008-2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = test demo
6
+
7
+ Demonstrates the demo interface.
8
+ =end
9
+ module TestModDemo
10
+
11
+ def self.run_demo(window)
12
+ puts "ok"
13
+ window = Gtk::Window.new(:toplevel)
14
+ window.add(Gtk::Label.new("This is a test"))
15
+
16
+ if !window.visible?
17
+ window.show_all
18
+ else
19
+ window.destroy
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2015 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = Pango/Text Mask
6
+
7
+ This demo shows how to use PangoCairo to draw text with more than
8
+ just a single color.
9
+ =end
10
+ module TextmaskDemo
11
+ def self.run_demo(_main_window)
12
+ window = Gtk::Window.new(:toplevel)
13
+ window.set_resizable(true)
14
+ window.set_size_request(400, 200)
15
+ window.set_title("Text Mask")
16
+
17
+ da = Gtk::DrawingArea.new
18
+
19
+ window.add(da)
20
+
21
+ da.signal_connect "draw" do |_widget, cr|
22
+ cr.save
23
+
24
+ layout = da.create_pango_layout("Pango power!\nPango power!\nPango power!")
25
+ desc = Pango::FontDescription.new("sans bold 34")
26
+ layout.font_description = desc
27
+
28
+ cr.move_to(30, 20)
29
+ cr.pango_layout_path(layout)
30
+
31
+ pattern = Cairo::LinearPattern.new(0.0, 0.0,
32
+ da.allocated_width,
33
+ da.allocated_height)
34
+
35
+ pattern.add_color_stop(0.0, 1.0, 0.0, 0.0)
36
+ pattern.add_color_stop(0.2, 1.0, 0.0, 0.0)
37
+ pattern.add_color_stop(0.3, 1.0, 1.0, 0.0)
38
+ pattern.add_color_stop(0.4, 0.0, 1.0, 0.0)
39
+ pattern.add_color_stop(0.6, 0.0, 1.0, 1.0)
40
+ pattern.add_color_stop(0.7, 0.0, 0.0, 1.0)
41
+ pattern.add_color_stop(0.8, 1.0, 0.0, 1.0)
42
+ pattern.add_color_stop(1.0, 1.0, 0.0, 1.0)
43
+ cr.set_source(pattern)
44
+ cr.fill_preserve
45
+
46
+ cr.set_source_rgb(0.0, 0.0, 0.0)
47
+ cr.set_line_width(0.5)
48
+ cr.stroke
49
+ cr.restore
50
+ true
51
+ end
52
+
53
+ if !window.visible?
54
+ window.show_all
55
+ else
56
+ window.destroy
57
+ end
58
+
59
+ window
60
+ end
61
+ end
@@ -4,7 +4,7 @@
4
4
  # This is licensed under the terms of the GNU Lesser General Public
5
5
  # License, version 2.1 or (at your option) later.
6
6
  #
7
- # Copyright (C) 2014 Ruby-GNOME2 Project Team
7
+ # Copyright (C) 2014-2015 Ruby-GNOME2 Project Team
8
8
  #
9
9
  # This library is free software; you can redistribute it and/or
10
10
  # modify it under the terms of the GNU Lesser General Public
@@ -30,19 +30,23 @@ of GTK+ are used for certain effects: primary toolbars,
30
30
  inline toolbars and linked buttons.
31
31
  =end
32
32
 
33
- require "common"
33
+ module ThemingStyleClassesDemo
34
+ def self.run_demo(main_window)
35
+ window = Gtk::Window.new(:toplevel)
36
+ window.screen = main_window.screen
37
+ window.set_title("Style Classes")
38
+ window.set_border_width(12)
34
39
 
35
- module Demo
36
- class ThemingStyleClasses < BasicWindow
37
- def initialize
38
- super("Style Claases")
39
- self.border_width = 12
40
+ builder = Gtk::Builder.new(:resource => "/theming_style_classes/theming.ui")
41
+ grid = builder["grid"]
42
+ grid.show_all
43
+ window.add(grid)
40
44
 
41
- builder = Gtk::Builder.new
42
- builder.add("theming.ui")
43
-
44
- grid = builder.get_object("grid")
45
- add(grid)
45
+ if !window.visible?
46
+ window.show_all
47
+ else
48
+ window.destroy
46
49
  end
50
+ window
47
51
  end
48
52
  end