gtk3 3.0.9-x86-mingw32 → 3.1.0-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -14,7 +14,7 @@
14
14
 
15
15
  Look at the Image demo for additional pixbuf usage examples.
16
16
  =end
17
- module PixbufsDemo
17
+ class PixbufsDemo
18
18
  IMAGES_NAMES = %w(/pixbufs/apple-red.png /pixbufs/gnome-applets.png
19
19
  /pixbufs/gnome-calendar.png /pixbufs/gnome-foot.png
20
20
  /pixbufs/gnome-gmush.png /pixbufs/gnome-gimp.png
@@ -23,20 +23,20 @@ module PixbufsDemo
23
23
  BACKGROUND_NAME = "/pixbufs/background.jpg"
24
24
  CYCLE_TIME = 3_000_000
25
25
 
26
- def self.run_demo(main_window)
27
- window = Gtk::Window.new(:toplevel)
28
- window.screen = main_window.screen
29
- window.resizable = false
26
+ def initialize(main_window)
27
+ @window = Gtk::Window.new(:toplevel)
28
+ @window.screen = main_window.screen
29
+ @window.resizable = false
30
30
 
31
- background_pixbuf = load_pixbuf(window, BACKGROUND_NAME)
31
+ background_pixbuf = load_pixbuf(BACKGROUND_NAME)
32
32
  other_pixbufs = []
33
33
  IMAGES_NAMES.each do |img|
34
- other_pixbufs << load_pixbuf(window, img)
34
+ other_pixbufs << load_pixbuf(img)
35
35
  end
36
36
 
37
37
  width = background_pixbuf.width
38
38
  height = background_pixbuf.height
39
- window.set_size_request(width, height)
39
+ @window.set_size_request(width, height)
40
40
 
41
41
  frame = GdkPixbuf::Pixbuf.new(:colorspace => :rgb,
42
42
  :has_alpha => false,
@@ -49,7 +49,7 @@ module PixbufsDemo
49
49
  cr.paint
50
50
  true
51
51
  end
52
- window.add(da)
52
+ @window.add(da)
53
53
  start_time = 0
54
54
  da.add_tick_callback do |_widget, frame_clock|
55
55
  background_pixbuf.copy_area(0, 0, width, height, frame, 0, 0)
@@ -77,10 +77,11 @@ module PixbufsDemo
77
77
 
78
78
  dest = r1.intersect(r2)
79
79
  next unless dest
80
- frame.composite!(other_pixbufs[i], dest.x, dest.y, dest.width,
81
- dest.height, xpos, ypos, k, k,
82
- :nearest,
83
- if (i & 1) == 1
80
+ frame.composite!(other_pixbufs[i], :dest_x => dest.x, :dest_y => dest.y,
81
+ :dest_width => dest.width, :dest_height => dest.height,
82
+ :offset_x => xpos, :offset_y => ypos, :scale_x => k,
83
+ :scale_y => k, :interpolation_type => :nearest,
84
+ :overall_alpha => if (i & 1) == 1
84
85
  [
85
86
  127, (255 * Math.sin(f * 2.0 * Math::PI)).abs
86
87
  ].max
@@ -89,23 +90,26 @@ module PixbufsDemo
89
90
  127, (255 * Math.cos(f * 2.0 * Math::PI)).abs
90
91
  ].max
91
92
  end)
92
-
93
93
  end
94
94
  da.queue_draw
95
95
  GLib::Source::CONTINUE
96
96
  end
97
+ end
97
98
 
98
- if !window.visible?
99
- window.show_all
99
+ def run
100
+ if !@window.visible?
101
+ @window.show_all
100
102
  else
101
- window.destroy
103
+ @window.destroy
102
104
  end
103
- window
105
+ @window
104
106
  end
105
107
 
106
- def self.show_message_dialog_on(window, error)
108
+ private
109
+
110
+ def show_message_dialog_on(error)
107
111
  message = "Failed to load an image: #{error.message}"
108
- dialog = Gtk::MessageDialog.new(:parent => window,
112
+ dialog = Gtk::MessageDialog.new(:parent => @window,
109
113
  :flags => :destroy_with_parent,
110
114
  :type => :error,
111
115
  :buttons => :close,
@@ -114,14 +118,12 @@ module PixbufsDemo
114
118
  dialog.show
115
119
  end
116
120
 
117
- def self.load_pixbuf(window, image_name)
121
+ def load_pixbuf(image_name)
118
122
  begin
119
- # Is it OK? should we implement gdk_pixbuf_new_from_resource instead?
120
- #Gtk::Image.new(:resource => image_name).pixbuf
121
123
  GdkPixbuf::Pixbuf.new(:resource => image_name)
122
124
  rescue StandardError => e
123
- show_message_dialog_on(window, e)
124
- window.destroy
125
+ show_message_dialog_on(e)
126
+ @window.destroy
125
127
  end
126
128
  end
127
129
  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,76 +8,34 @@
8
8
  GtkPopovers can be attached to any widget, and will be displayed
9
9
  within the same window, but on top of all its content.
10
10
  =end
11
- module PopoverDemo
12
- def self.run_demo(main_window)
13
- window = Gtk::Window.new(:toplevel)
14
- window.screen = main_window.screen
11
+ class PopoverDemo
12
+ def initialize(main_window)
13
+ @window = Gtk::Window.new(:toplevel)
14
+ @window.screen = main_window.screen
15
15
  box = Gtk::Box.new(:vertical, 24)
16
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
17
+ @window.add(box)
29
18
 
19
+ widget = add_toggle_button_with_popover
30
20
  box.add(widget)
31
21
 
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
-
22
+ widget = add_custom_entry_with_complex_popover
51
23
  box.add(widget)
52
24
 
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
-
25
+ widget = add_calendar_with_popover
70
26
  box.add(widget)
27
+ end
71
28
 
72
- if !window.visible?
73
- window.show_all
29
+ def run
30
+ if !@window.visible?
31
+ @window.show_all
74
32
  else
75
- window.destroy
33
+ @window.destroy
76
34
  end
77
- window
35
+ @window
78
36
  end
79
37
 
80
- def self.create_popover(parent, child, pos)
38
+ def create_popover(parent, child, pos)
81
39
  popover = Gtk::Popover.new(parent)
82
40
  popover.position = pos
83
41
  popover.add(child)
@@ -86,7 +44,7 @@ module PopoverDemo
86
44
  popover
87
45
  end
88
46
 
89
- def self.create_complex_popover(parent, pos)
47
+ def create_complex_popover(parent, pos)
90
48
  builder = Gtk::Builder.new(:resource => "/popover/popover.ui")
91
49
  window = builder["window"]
92
50
  content = window.child
@@ -101,10 +59,59 @@ module PopoverDemo
101
59
  popover
102
60
  end
103
61
 
104
- class CustomEntry < Gtk::Entry
105
- attr_accessor :popover_icon_pos
106
- def initialize
107
- super
62
+ def add_toggle_button_with_popover
63
+ widget = Gtk::ToggleButton.new(:label => "Button")
64
+ label = Gtk::Label.new("This popover does not grab input")
65
+ toggle_popover = create_popover(widget, label, :top)
66
+ toggle_popover.modal = false
67
+ widget.signal_connect "toggled" do |button|
68
+ toggle_popover.visible = button.active?
69
+ end
70
+ widget
71
+ end
72
+
73
+ def add_custom_entry_with_complex_popover
74
+ widget = CustomEntry.new
75
+ entry_popover = create_complex_popover(widget, :top)
76
+ widget.set_icon_from_icon_name(:primary, "edit-find")
77
+ widget.set_icon_from_icon_name(:secondary, "edit-clear")
78
+ widget.signal_connect "icon-press" do |entry, icon_pos, _event|
79
+ rect = entry.get_icon_area(icon_pos)
80
+ entry_popover.pointing_to = rect
81
+ entry_popover.show
82
+ entry.popover_icon_pos = icon_pos
83
+ end
84
+
85
+ widget.signal_connect "size-allocate" do |entry, _allocation|
86
+ if entry_popover.visible?
87
+ popover_pos = entry.popover_icon_pos
88
+ rect = entry.get_icon_area(popover_pos)
89
+ entry_popover.pointing_to = rect
90
+ end
91
+ end
92
+ widget
93
+ end
94
+
95
+ def add_calendar_with_popover
96
+ widget = Gtk::Calendar.new
97
+ widget.signal_connect "day-selected" do |calendar|
98
+ event = Gtk.current_event
99
+ if event.type == :button_press
100
+ x, y = event.window.coords_to_parent(event.x, event.y)
101
+ allocation = calendar.allocation
102
+ rect = Gdk::Rectangle.new(x - allocation.x, y - allocation.y, 1, 1)
103
+ cal_popover = create_popover(calendar, CustomEntry.new, :bottom)
104
+ cal_popover.pointing_to = rect
105
+ cal_popover.show
106
+ end
108
107
  end
108
+ widget
109
+ end
110
+ end
111
+
112
+ class CustomEntry < Gtk::Entry
113
+ attr_accessor :popover_icon_pos
114
+ def initialize
115
+ super
109
116
  end
110
117
  end
@@ -8,96 +8,56 @@
8
8
  in a cross-platform way.
9
9
 
10
10
  =end
11
- module PrintingDemo
11
+ class PrintingDemo
12
12
  HEADER_HEIGHT = 10 * 72 / 25.4
13
13
  HEADER_GAP = 3 * 72 / 25.4
14
14
 
15
- def self.run_demo(main_window)
16
- print_operation = Gtk::PrintOperation.new
17
-
18
- resource_name = File.expand_path(__FILE__)
19
- font_size = 12.0
20
- num_pages = 0
21
- lines_per_page = 0
22
- lines = []
23
-
24
- print_operation.signal_connect "begin-print" do |operation, context|
25
- height = context.height - HEADER_HEIGHT - HEADER_GAP
26
- lines_per_page = (height / font_size).floor
27
- File.open(resource_name, "r") do |file|
28
- file.each_line do |line|
29
- lines << line
30
- end
31
- end
32
- num_pages = lines.size / (lines_per_page + 1)
33
- operation.n_pages = num_pages
15
+ def initialize(main_window)
16
+ @print_operation = Gtk::PrintOperation.new
17
+ @main_window = main_window
18
+ @resource_name = File.expand_path(__FILE__)
19
+ @font_size = 12.0
20
+ @num_pages = 0
21
+ @lines_per_page = 0
22
+ @lines = []
23
+
24
+ @print_operation.signal_connect "begin-print" do |operation, context|
25
+ configure_pagination(operation, context)
34
26
  end
35
27
 
36
- print_operation.signal_connect "draw-page" do |_operation, context, page_nr|
37
- cr = context.cairo_context
38
- width = context.width
39
- cr.rectangle(0, 0, width, HEADER_HEIGHT)
40
- cr.set_source_rgb(0.8, 0.8, 0.8)
41
- cr.fill_preserve
42
-
43
- cr.set_source_rgb(0, 0, 0)
44
- cr.line_width = 1
45
- cr.stroke
46
-
47
- layout = context.create_pango_layout
48
- desc = Pango::FontDescription.new("sans 14")
49
- layout.font_description = desc
50
-
51
- layout.text = resource_name
52
- text_width, text_height = layout.pixel_size
28
+ @print_operation.signal_connect "draw-page" do |_oper, context, page_nr|
29
+ cr = initialize_cairo_context(context)
53
30
 
54
- if text_width > width
55
- layout.width = width
56
- layout.ellipsize = :start
57
- text_width, text_height = layout.pixel_size
58
- end
59
- cr.move_to((width - text_width) / 2,
60
- (HEADER_HEIGHT - text_height) / 2)
31
+ layout = initialize_pango_layout_title(context)
32
+ cr.move_to((@width - @text_width) / 2,
33
+ (HEADER_HEIGHT - @text_height) / 2)
61
34
  cr.show_pango_layout(layout)
62
35
 
63
- layout.text = "#{page_nr + 1}/#{num_pages}"
64
- layout.width = -1
65
- text_width, text_height = layout.pixel_size
66
-
67
- cr.move_to(width - text_width - 4,
68
- (HEADER_HEIGHT - text_height) / 2)
36
+ initialize_pango_layout_page_nb(layout, page_nr)
37
+ cr.move_to(@width - @text_width - 4,
38
+ (HEADER_HEIGHT - @text_height) / 2)
69
39
  cr.show_pango_layout(layout)
70
40
 
71
- layout = context.create_pango_layout
72
- desc = Pango::FontDescription.new("monospace")
73
- desc.size = font_size * Pango::SCALE
74
- layout.font_description = desc
75
-
76
- cr.move_to(0, HEADER_HEIGHT + HEADER_GAP)
77
- start_line = page_nr * lines_per_page
78
-
79
- lines[start_line, lines_per_page].each do |line|
80
- layout.text = line
81
- cr.show_pango_layout(layout)
82
- cr.rel_move_to(0, font_size)
83
- end
41
+ initialize_pango_layout_page_content(context, cr, page_nr)
84
42
  end
85
43
 
86
- print_operation.signal_connect "end-print" do
44
+ @print_operation.signal_connect "end-print" do
87
45
  puts "End of print"
88
46
  end
89
47
 
90
- print_operation.use_full_page = false
91
- print_operation.unit = :points
92
- print_operation.embed_page_setup = true
48
+ @print_operation.use_full_page = false
49
+ @print_operation.unit = :points
50
+ @print_operation.embed_page_setup = true
93
51
 
94
52
  settings = Gtk::PrintSettings.new
95
53
  settings.set(:ouput_basename, "gtk-demo")
96
54
 
97
- print_operation.print_settings = settings
55
+ @print_operation.print_settings = settings
56
+ end
98
57
 
58
+ def run
99
59
  begin
100
- print_operation.run(:print_dialog, main_window)
60
+ @print_operation.run(:print_dialog, @main_window)
101
61
  rescue => error
102
62
  dialog = Gtk::MessageDialog.new(:parent => main_window,
103
63
  :flags => :destroy_with_parent,
@@ -110,4 +70,69 @@ module PrintingDemo
110
70
  dialog.show
111
71
  end
112
72
  end
73
+
74
+ private
75
+
76
+ def configure_pagination(operation, context)
77
+ height = context.height - HEADER_HEIGHT - HEADER_GAP
78
+ @lines_per_page = (height / @font_size).floor
79
+ File.open(@resource_name, "r") do |file|
80
+ file.each_line do |line|
81
+ @lines << line
82
+ end
83
+ end
84
+ @num_pages = @lines.size / (@lines_per_page + 1)
85
+ operation.n_pages = @num_pages
86
+ end
87
+
88
+ def initialize_cairo_context(context)
89
+ cr = context.cairo_context
90
+ @width = context.width
91
+ cr.rectangle(0, 0, @width, HEADER_HEIGHT)
92
+ cr.set_source_rgb(0.8, 0.8, 0.8)
93
+ cr.fill_preserve
94
+
95
+ cr.set_source_rgb(0, 0, 0)
96
+ cr.line_width = 1
97
+ cr.stroke
98
+ cr
99
+ end
100
+
101
+ def initialize_pango_layout_title(context)
102
+ layout = context.create_pango_layout
103
+ desc = Pango::FontDescription.new("sans 14")
104
+ layout.font_description = desc
105
+
106
+ layout.text = @resource_name
107
+ @text_width, @text_height = layout.pixel_size
108
+
109
+ if @text_width > @width
110
+ layout.width = @width
111
+ layout.ellipsize = :start
112
+ @text_width, @text_height = layout.pixel_size
113
+ end
114
+ layout
115
+ end
116
+
117
+ def initialize_pango_layout_page_nb(layout, page_nr)
118
+ layout.text = "#{page_nr + 1}/#{@num_pages}"
119
+ layout.width = -1
120
+ @text_width, @text_height = layout.pixel_size
121
+ end
122
+
123
+ def initialize_pango_layout_page_content(context, cr, page_nr)
124
+ layout = context.create_pango_layout
125
+ desc = Pango::FontDescription.new("monospace")
126
+ desc.size = @font_size * Pango::SCALE
127
+ layout.font_description = desc
128
+
129
+ cr.move_to(0, HEADER_HEIGHT + HEADER_GAP)
130
+ start_line = page_nr * @lines_per_page
131
+
132
+ @lines[start_line, @lines_per_page].each do |line|
133
+ layout.text = line
134
+ cr.show_pango_layout(layout)
135
+ cr.rel_move_to(0, @font_size)
136
+ end
137
+ end
113
138
  end