gtk3 3.0.9-x64-mingw32 → 3.1.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/rb-gtk3-private.h +1 -0
  3. data/ext/gtk3/rb-gtk3-spin-button.c +85 -0
  4. data/ext/gtk3/rb-gtk3.c +3 -0
  5. data/lib/2.2/gtk3.so +0 -0
  6. data/lib/2.3/gtk3.so +0 -0
  7. data/lib/gtk3/deprecated.rb +0 -8
  8. data/lib/gtk3/loader.rb +1 -7
  9. data/lib/gtk3/tree-model.rb +2 -0
  10. data/sample/gtk-demo/TODO +10 -10
  11. data/sample/gtk-demo/assistant.rb +44 -39
  12. data/sample/gtk-demo/builder.rb +71 -50
  13. data/sample/gtk-demo/button_box.rb +39 -28
  14. data/sample/gtk-demo/clipboard.rb +139 -46
  15. data/sample/gtk-demo/colorsel.rb +50 -36
  16. data/sample/gtk-demo/css_accordion.rb +18 -17
  17. data/sample/gtk-demo/css_basics.rb +60 -47
  18. data/sample/gtk-demo/css_multiplebgs.rb +92 -71
  19. data/sample/gtk-demo/css_pixbufs.rb +61 -48
  20. data/sample/gtk-demo/css_shadows.rb +63 -50
  21. data/sample/gtk-demo/cursors.rb +95 -64
  22. data/sample/gtk-demo/dialog.rb +95 -78
  23. data/sample/gtk-demo/drawingarea.rb +138 -171
  24. data/sample/gtk-demo/editable_cells.rb +169 -130
  25. data/sample/gtk-demo/entry_buffer.rb +15 -13
  26. data/sample/gtk-demo/entry_completion.rb +22 -17
  27. data/sample/gtk-demo/expander.rb +39 -31
  28. data/sample/gtk-demo/filtermodel.rb +67 -63
  29. data/sample/gtk-demo/font_features.rb +91 -60
  30. data/sample/gtk-demo/glarea.rb +277 -0
  31. data/sample/gtk-demo/headerbar.rb +17 -15
  32. data/sample/gtk-demo/hypertext.rb +146 -167
  33. data/sample/gtk-demo/iconview.rb +132 -91
  34. data/sample/gtk-demo/iconview_edit.rb +49 -38
  35. data/sample/gtk-demo/infobar.rb +81 -62
  36. data/sample/gtk-demo/links.rb +35 -30
  37. data/sample/gtk-demo/list_store.rb +169 -114
  38. data/sample/gtk-demo/listbox.rb +183 -0
  39. data/sample/gtk-demo/main.rb +32 -21
  40. data/sample/gtk-demo/markup.rb +65 -52
  41. data/sample/gtk-demo/menus.rb +57 -58
  42. data/sample/gtk-demo/modelbutton.rb +11 -9
  43. data/sample/gtk-demo/modelbutton.ui +3 -0
  44. data/sample/gtk-demo/overlay.rb +39 -32
  45. data/sample/gtk-demo/overlay2.rb +68 -54
  46. data/sample/gtk-demo/panes.rb +56 -68
  47. data/sample/gtk-demo/pickers.rb +46 -45
  48. data/sample/gtk-demo/pixbufs.rb +27 -25
  49. data/sample/gtk-demo/popover.rb +70 -63
  50. data/sample/gtk-demo/printing.rb +94 -69
  51. data/sample/gtk-demo/revealer.rb +46 -38
  52. data/sample/gtk-demo/rotated_text.rb +75 -54
  53. data/sample/gtk-demo/scale.rb +10 -8
  54. data/sample/gtk-demo/search_entry.rb +195 -0
  55. data/sample/gtk-demo/search_entry2.rb +71 -59
  56. data/sample/gtk-demo/sidebar.rb +20 -19
  57. data/sample/gtk-demo/sizegroup.rb +36 -35
  58. data/sample/gtk-demo/spinbutton.rb +128 -0
  59. data/sample/gtk-demo/spinner.rb +55 -40
  60. data/sample/gtk-demo/stack.rb +11 -8
  61. data/sample/gtk-demo/textmask.rb +14 -13
  62. data/sample/gtk-demo/textscroll.rb +16 -12
  63. data/sample/gtk-demo/theming_style_classes.rb +14 -12
  64. data/sample/gtk-demo/transparent.rb +17 -13
  65. data/sample/misc/treemodelfilter.rb +1 -1
  66. metadata +24 -19
@@ -1,110 +1,151 @@
1
- # Copyright (c) 2005 Ruby-GNOME2 Project Team
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: iconview.rb,v 1.7 2007/08/05 15:41:31 mutoh Exp $
5
4
  =begin
6
- = Icon View (IconView)
5
+ = Icon View/Icon View Basics
7
6
 
8
- The Gtk::IconView widget is used to display and manipulate icons.
9
- It uses a Gtk::TreeModel for data storage, so the list store example
10
- might be helpful.
7
+ The GtkIconView widget is used to display and manipulate icons.
8
+ It uses a GtkTreeModel for data storage, so the list store
9
+ example might be helpful.
11
10
  =end
11
+ class IconviewDemo
12
+ COL_PATH, COL_DISPLAY_NAME, COL_PIXBUF, COL_IS_DIRECTORY = (0..3).to_a
13
+ FOLDER_NAME = "/iconview/gnome-fs-directory.png".freeze
14
+ FILE_NAME = "/iconview/gnome-fs-regular.png".freeze
15
+
16
+ def initialize(main_window)
17
+ @window = Gtk::Window.new(:toplevel)
18
+ @window.screen = main_window.screen
19
+ @window.title = "Icon View Basics"
20
+ @window.set_default_size(650, 400)
21
+ load_pixbufs
22
+
23
+ vbox = Gtk::Box.new(:vertical, 0)
24
+ @window.add(vbox)
25
+
26
+ tool_bar = Gtk::Toolbar.new
27
+ vbox.pack_start(tool_bar, :expand => false, :fill => false, :padding => 0)
28
+
29
+ up_button = Gtk::ToolButton.new
30
+ up_button.label = "_Up"
31
+ up_button.use_underline = true
32
+ up_button.icon_name = "go-up"
33
+ up_button.is_important = true
34
+ up_button.sensitive = false
35
+ tool_bar.insert(up_button, -1)
36
+
37
+ home_button = Gtk::ToolButton.new
38
+ home_button.label = "_Home"
39
+ home_button.use_underline = true
40
+ home_button.icon_name = "go-home"
41
+ home_button.is_important = true
42
+ tool_bar.insert(home_button, -1)
43
+
44
+ sw = Gtk::ScrolledWindow.new
45
+ sw.shadow_type = :etched_in
46
+ sw.set_policy(:automatic, :automatic)
47
+ vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)
48
+
49
+ # Create the store and fill it with the contents of '/'
50
+ @parent = "/"
51
+ create_store
52
+ fill_store
53
+
54
+ icon_view = Gtk::IconView.new(:model => @store)
55
+ icon_view.selection_mode = :multiple
56
+
57
+ # Connect to the "clicked" signal of the "Up" tool button
58
+ up_button.signal_connect "clicked" do
59
+ @parent = File.dirname(@parent)
60
+ fill_store
12
61
 
62
+ # Maybe de-sensitive the up button
63
+ up_button.sensitive = @parent == "/"
64
+ end
13
65
 
14
- require 'common'
15
-
16
- module Demo
17
- class IconView < Demo::BasicWindow
18
- COL_PATH, COL_DISPLAY_NAME, COL_IS_DIR, COL_PIXBUF = (0..3).to_a
19
-
20
- def fill_store
21
- @store.clear
22
- Dir.glob(File.join(@parent, "*")).each do |path|
23
- is_dir = FileTest.directory?(path)
24
- iter = @store.append
25
- # set COL_DISPLAY_NAME first because changing an iter will trigger the
26
- # sort function; if we set something else first, the value of
27
- # COL_DISPLAY_NAME for this row will be "nil" and the sort function will fail
28
- #puts path
29
- #puts GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8")
30
- #puts File.basename(GLib.convert(GLib.filename_to_utf8(path), "Shift_JIS", "UTF-8"))
31
- # iter[COL_DISPLAY_NAME] = File.basename(GLib.filename_to_utf8(path))
32
- iter[COL_DISPLAY_NAME] = GLib.filename_to_utf8(path)
33
- iter[COL_PATH] = path
34
- iter[COL_IS_DIR] = is_dir
35
- iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf
36
- end
66
+ # Connect to the "clicked" signal of the "Home" too button
67
+ home_button.signal_connect "clicked" do
68
+ @parent = ENV["HOME"]
69
+ fill_store
70
+ up_button.sensitive = true
37
71
  end
38
72
 
39
- def initialize
40
- super('Gtk::IconView demo')
41
- @file_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-regular.png"))
42
- @folder_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-directory.png"))
43
-
44
- @store = Gtk::ListStore.new(String, String, TrueClass, Gdk::Pixbuf)
45
- @parent = "/"
46
-
47
- @store.set_default_sort_func do |a, b|
48
- if !a[COL_IS_DIR] and b[COL_IS_DIR]
49
- 1
50
- elsif a[COL_IS_DIR] and !b[COL_IS_DIR]
51
- -1
52
- else
53
- a[COL_DISPLAY_NAME] <=> b[COL_DISPLAY_NAME]
54
- end
73
+ # We now set which model columns that correspond to the text
74
+ # and pixbbuf of each of item
75
+ icon_view.text_column = COL_DISPLAY_NAME
76
+ icon_view.pixbuf_column = COL_PIXBUF
77
+
78
+ # Connec the "item-activated" signal
79
+ icon_view.signal_connect "item-activated" do |_widget, tree_path|
80
+ iter = @store.get_iter(tree_path)
81
+ path = iter[COL_PATH]
82
+ directory = iter[COL_IS_DIRECTORY]
83
+ if directory
84
+ @parent = path
85
+ fill_store
86
+ up_button.sensitive = true
55
87
  end
56
- @store.set_sort_column_id(Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID,
57
- Gtk::SortType::ASCENDING)
88
+ end
89
+ sw.add(icon_view)
90
+ icon_view.grab_focus
91
+ end
58
92
 
59
- fill_store
60
- set_default_size(650, 400)
61
- set_border_width(8)
93
+ def run
94
+ if !@window.visible?
95
+ @window.show_all
96
+ else
97
+ @window.destroy
98
+ end
99
+ @window
100
+ end
62
101
 
63
- vbox = Gtk::Box.new(:vertical)
64
- add(vbox)
102
+ private
65
103
 
66
- toolbar = Gtk::Toolbar.new
67
- vbox.pack_start(toolbar, :expand => false, :fill => false, :padding => 0)
104
+ def load_pixbufs
105
+ # Loads the images for the demo and returns whether the operation succeeded
106
+ return if @file_pixbuf
68
107
 
69
- up_button = Gtk::ToolButton.new(:stock_id => :go_up)
70
- up_button.important = true
71
- up_button.sensitive = false
72
- toolbar.insert(up_button, -1)
73
- up_button.signal_connect("clicked") do
74
- @parent = File.dirname(@parent)
75
- fill_store
76
- up_button.sensitive = @parent != "/"
77
- end
108
+ @file_pixbuf = GdkPixbuf::Pixbuf.new(:resource => FILE_NAME)
109
+ return false unless @file_pixbuf
78
110
 
79
- home_button = Gtk::ToolButton.new(:stock_id => :home)
80
- home_button.important = true
81
- toolbar.insert(home_button, -1)
82
- home_button.signal_connect("clicked") do
83
- @parent = GLib.home_dir
84
- fill_store
85
- up_button.sensitive = true
86
- end
111
+ @folder_pixbuf = GdkPixbuf::Pixbuf.new(:resource => FOLDER_NAME)
112
+ return false unless @folder_pixbuf
113
+ end
87
114
 
88
- sw = Gtk::ScrolledWindow.new
89
- sw.shadow_type = :etched_in
90
- sw.set_policy(:automatic, :automatic)
91
- vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)
92
-
93
- iconview = Gtk::IconView.new(@store)
94
- iconview.selection_mode = :multiple
95
- iconview.text_column = COL_DISPLAY_NAME
96
- iconview.pixbuf_column = COL_PIXBUF
97
- iconview.signal_connect("item_activated") do |iview, path|
98
- iter = @store.get_iter(path)
99
- if iter[COL_DISPLAY_NAME]
100
- @parent = iter[COL_PATH]
101
- fill_store
102
- up_button.sensitive = true
103
- end
104
- end
105
- sw.add(iconview)
106
- iconview.grab_focus
115
+ def create_store
116
+ @store = Gtk::ListStore.new(String, String, GdkPixbuf::Pixbuf, TrueClass)
117
+
118
+ # Set sort column and function
119
+ @store.set_default_sort_func do |_model, a, b|
120
+ sort_function(a, b)
107
121
  end
122
+ @store.set_sort_column_id(Gtk::TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
123
+ :ascending)
108
124
  end
109
- end
110
125
 
126
+ def fill_store
127
+ @store.clear
128
+ Dir.glob(File.join(@parent, "*")).each do |path|
129
+ is_dir = FileTest.directory?(path)
130
+ iter = @store.append
131
+ iter[COL_DISPLAY_NAME] = File.basename(path) || "-"
132
+ iter[COL_PATH] = path
133
+ iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf
134
+ iter[COL_IS_DIRECTORY] = is_dir
135
+ end
136
+ end
137
+
138
+ def sort_function(a, b)
139
+ if !a[COL_IS_DIRECTORY] and b[COL_IS_DIRECTORY]
140
+ 1
141
+ elsif a[COL_IS_DIRECTORY] and !b[COL_IS_DIRECTORY]
142
+ -1
143
+ elsif !a[COL_DISPLAY_NAME] and b[COL_DISPLAY_NAME]
144
+ 1
145
+ elsif a[COL_DISPLAY_NAME] and !b[COL_DISPLAY_NAME]
146
+ -1
147
+ else
148
+ a[COL_DISPLAY_NAME] <=> b[COL_DISPLAY_NAME]
149
+ end
150
+ end
151
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (c) 2015-2016 Ruby-GNOME2 Project Team
2
2
  # This program is licenced under the same licence as Ruby-GNOME2.
3
3
  #
4
4
  =begin
@@ -8,27 +8,53 @@
8
8
  This example also demonstrates using the generic GtkCellLayout
9
9
  interface to set up cell renderers in an icon view.
10
10
  =end
11
- module IconviewEditDemo
11
+ class IconviewEditDemo
12
12
  COL_TEXT = 0
13
13
  NUM_COLS = 1
14
- def self.run_demo(main_window)
15
- window = Gtk::Window.new(:toplevel)
16
- window.screen = main_window.screen
17
- window.set_title("Editing and Drag-and-drop")
14
+ def initialize(main_window)
15
+ @window = Gtk::Window.new(:toplevel)
16
+ @window.screen = main_window.screen
17
+ @window.title = "Editing and Drag-and-drop"
18
18
 
19
- store = create_store
20
- fill_store(store)
19
+ initialize_store
20
+ initialize_icon_view
21
21
 
22
- icon_view = Gtk::IconView.new(:model => store)
23
- icon_view.set_selection_mode(:single)
24
- icon_view.set_item_orientation(:horizontal)
25
- icon_view.set_columns(2)
26
- icon_view.set_reorderable(true)
22
+ icon_view_add_renderer_pixbuf
23
+ icon_view_add_renderer_text
27
24
 
25
+ @window.add(@icon_view)
26
+ end
27
+
28
+ def run
29
+ if !@window.visible?
30
+ @window.show_all
31
+ else
32
+ @window.destroy
33
+ end
34
+ @window
35
+ end
36
+
37
+ def initialize_store
38
+ @store = Gtk::ListStore.new(String)
39
+
40
+ %w(Red Green Blue Yellow).each do |color|
41
+ @store.append.set_values([color])
42
+ end
43
+ end
44
+
45
+ def initialize_icon_view
46
+ @icon_view = Gtk::IconView.new(:model => @store)
47
+ @icon_view.selection_mode = :single
48
+ @icon_view.item_orientation = :horizontal
49
+ @icon_view.columns = 2
50
+ @icon_view.reorderable = true
51
+ end
52
+
53
+ def icon_view_add_renderer_pixbuf
28
54
  renderer = Gtk::CellRendererPixbuf.new
29
- icon_view.pack_start(renderer, true)
55
+ @icon_view.pack_start(renderer, true)
30
56
 
31
- icon_view.set_cell_data_func(renderer) do |_layout, cell_renderer, model, iter|
57
+ @icon_view.set_cell_data_func(renderer) do |_layout, cell_renderer, model, iter|
32
58
  text = model.get_value(iter, COL_TEXT)
33
59
  if text
34
60
  color = Gdk::RGBA.parse(text)
@@ -39,41 +65,26 @@ module IconviewEditDemo
39
65
  (color.blue * 255).to_i << 8 |
40
66
  (color.alpha * 255).to_i
41
67
  end
42
- pixbuf = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 24, 24)
68
+ pixbuf = GdkPixbuf::Pixbuf.new(:colorspace => :rgb, :has_alpha => true,
69
+ :bits_per_sample => 8,
70
+ :width => 24, :height => 24)
43
71
  pixbuf.fill!(pixel) if pixel
44
72
  cell_renderer.set_property("pixbuf", pixbuf)
45
73
  end
46
74
  end
75
+ end
47
76
 
77
+ def icon_view_add_renderer_text
48
78
  renderer = Gtk::CellRendererText.new
49
- icon_view.pack_start(renderer, true)
79
+ @icon_view.pack_start(renderer, true)
50
80
  renderer.set_property("editable", true)
51
81
  renderer.signal_connect("edited") do |_cell, path_string, text|
52
- model = icon_view.model
82
+ model = @icon_view.model
53
83
  path = Gtk::TreePath.new(path_string)
54
84
  iter = model.get_iter(path)
55
85
  iter[COL_TEXT] = text
56
86
  end
57
87
 
58
- icon_view.set_attributes(renderer, "text" => COL_TEXT)
59
- window.add(icon_view)
60
-
61
- if !window.visible?
62
- window.show_all
63
- else
64
- window.destroy
65
- end
66
- window
67
- end
68
-
69
- def self.create_store
70
- store = Gtk::ListStore.new(String)
71
- store
72
- end
73
-
74
- def self.fill_store(store)
75
- %w(Red Green Blue Yellow).each do |color|
76
- store.append.set_values([color])
77
- end
88
+ @icon_view.set_attributes(renderer, "text" => COL_TEXT)
78
89
  end
79
90
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (c) 2015-2016 Ruby-GNOME2 Project Team
2
2
  # This program is licenced under the same licence as Ruby-GNOME2.
3
3
  #
4
4
  =begin
@@ -6,89 +6,108 @@
6
6
 
7
7
  Info bar widgets are used to report important messages to the user.
8
8
  =end
9
- module InfobarDemo
10
- def self.run_demo(main_window)
11
- actions = Gtk::Box.new(:horizontal, 0)
9
+ class InfobarDemo
10
+ def initialize(main_window)
11
+ @actions = Gtk::Box.new(:horizontal, 0)
12
12
 
13
- window = Gtk::Window.new(:toplevel)
14
- window.screen = main_window.screen
15
- window.set_title("Info Bars")
16
- window.set_border_width(8)
13
+ @window = Gtk::Window.new(:toplevel)
14
+ @window.screen = main_window.screen
15
+ @window.set_title("Info Bars")
16
+ @window.set_border_width(8)
17
17
 
18
- vbox = Gtk::Box.new(:vertical, 0)
19
- window.add(vbox)
18
+ @vbox = Gtk::Box.new(:vertical, 0)
19
+ @window.add(@vbox)
20
20
 
21
- generate_simple_infobar_and_button("info", vbox, actions)
22
- generate_simple_infobar_and_button("warning", vbox, actions)
21
+ generate_simple_infobar("info")
22
+ generate_simple_infobar("warning")
23
23
 
24
- bar = Gtk::InfoBar.new
25
- bar.add_button("_OK", Gtk::ResponseType::OK)
26
- bar.set_show_close_button(true)
27
- bar.signal_connect "response" do |info_bar, response_id|
28
- info_bar.hide if response_id == Gtk::ResponseType::CLOSE
29
- dialog = Gtk::MessageDialog.new(:parent => info_bar.toplevel,
30
- :flags => [:modal, :destroy_with_parent],
31
- :type => :info,
32
- :buttons => :ok,
33
- :message => "You clicked a button on an info bar")
34
- dialog.secondary_text = "Your response has id #{response_id}"
35
- dialog.signal_connect("response") { |widget| widget.destroy }
36
- dialog.show_all
37
- end
24
+ generate_infobar_with_dialog
38
25
 
39
- vbox.pack_start(bar,
40
- :expand => false,
41
- :fill => false,
42
- :padding => 0)
43
-
44
- bar.set_message_type(:question)
45
- label = Gtk::Label.new("This is an info bar with message type Gtk::MessageType::QUESTION")
46
- label.set_line_wrap(true)
47
- label.set_xalign(0)
48
-
49
- bar.content_area.pack_start(label, :expand => false, :fill => false, :padding => 0)
50
-
51
- button = Gtk::ToggleButton.new(:label => "Question")
52
- button.bind_property("active", bar, "visible", :bidirectional)
53
- actions.add(button)
54
- button.set_active(false)
55
-
56
- generate_simple_infobar_and_button("error", vbox, actions)
57
- generate_simple_infobar_and_button("other", vbox, actions)
26
+ generate_simple_infobar("error")
27
+ generate_simple_infobar("other")
58
28
 
59
29
  frame = Gtk::Frame.new("Info bars")
60
- vbox.pack_start(frame, :expand => false, :fill => false, :padding => 8)
30
+ @vbox.pack_start(frame, :expand => false, :fill => false, :padding => 8)
61
31
 
62
32
  vbox2 = Gtk::Box.new(:vertical, 8)
63
- vbox2.set_border_width(8)
33
+ vbox2.border_width = 8
64
34
  frame.add(vbox2)
65
35
 
66
36
  label = Gtk::Label.new("An example of different info bars")
67
37
  vbox2.pack_start(label, :expand => false, :fill => false, :padding => 0)
68
- actions.show_all
69
- vbox2.pack_start(actions, :expand => false, :fill => false, :padding => 0)
38
+ @actions.show_all
39
+ vbox2.pack_start(@actions, :expand => false, :fill => false, :padding => 0)
40
+ end
70
41
 
71
- if !window.visible?
72
- window.show_all
42
+ def run
43
+ if !@window.visible?
44
+ @window.show_all
73
45
  else
74
- window.destroy
46
+ @window.destroy
75
47
  end
76
- window
48
+ @window
77
49
  end
78
50
 
79
- def self.generate_simple_infobar_and_button(message_type, bar_parent, button_parent)
80
- bar = Gtk::InfoBar.new
81
- bar_parent.pack_start(bar, :expand => false, :fill => false, :padding => 0)
82
- bar.set_message_type(message_type.to_sym)
51
+ private
83
52
 
84
- label = Gtk::Label.new("This is an info bar with message type Gtk::MessageType::#{message_type.upcase}")
85
- label.set_line_wrap(true)
86
- label.set_xalign(0)
53
+ def generate_infobar_label(message)
54
+ label = Gtk::Label.new(message)
55
+ label.line_wrap = true
56
+ label.xalign = 0
57
+ label
58
+ end
87
59
 
60
+ def add_a_label_message_in_an_infobar(bar, message)
61
+ label = generate_infobar_label(message)
88
62
  bar.content_area.pack_start(label, :expand => false, :fill => false, :padding => 0)
63
+ end
64
+
65
+ def generate_simple_infobar(message_type)
66
+ bar = Gtk::InfoBar.new
67
+ @vbox.pack_start(bar, :expand => false, :fill => false, :padding => 0)
68
+ bar.message_type = message_type.to_sym
89
69
 
90
- button = Gtk::ToggleButton.new(:label => "Message")
70
+ message = "This is an info bar with message type Gtk::MessageType::#{message_type.upcase}"
71
+ add_a_label_message_in_an_infobar(bar, message)
72
+
73
+ link_bar_to_a_toggle_button(bar, message_type.capitalize)
74
+ end
75
+
76
+ def link_bar_to_a_toggle_button(bar, message)
77
+ button = Gtk::ToggleButton.new(:label => message)
91
78
  button.bind_property("active", bar, "visible", :bidirectional)
92
- button_parent.add(button)
79
+ @actions.add(button)
80
+ button
81
+ end
82
+
83
+ def generate_infobar_with_dialog
84
+ bar = Gtk::InfoBar.new
85
+ bar.add_button("_OK", Gtk::ResponseType::OK)
86
+ bar.show_close_button = true
87
+
88
+ manage_response_event_of_infobar(bar)
89
+
90
+ @vbox.pack_start(bar, :expand => false, :fill => false, :padding => 0)
91
+
92
+ bar.message_type = :question
93
+ message = "This is an info bar with message type Gtk::MessageType::QUESTION"
94
+ add_a_label_message_in_an_infobar(bar, message)
95
+
96
+ button = link_bar_to_a_toggle_button(bar, "Question")
97
+ button.active = false
98
+ end
99
+
100
+ def manage_response_event_of_infobar(bar)
101
+ bar.signal_connect "response" do |info_bar, response_id|
102
+ info_bar.hide if response_id == Gtk::ResponseType::CLOSE
103
+ dialog = Gtk::MessageDialog.new(:parent => info_bar.toplevel,
104
+ :flags => [:modal, :destroy_with_parent],
105
+ :type => :info,
106
+ :buttons => :ok,
107
+ :message => "You clicked a button on an info bar")
108
+ dialog.secondary_text = "Your response has id #{response_id}"
109
+ dialog.signal_connect("response", &:destroy)
110
+ dialog.show_all
111
+ end
93
112
  end
94
113
  end