gtk3 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gtk3/container.rb +2 -7
- data/lib/gtk3/dialog.rb +10 -1
- data/lib/gtk3/loader.rb +0 -14
- data/lib/gtk3/tree-selection.rb +0 -2
- data/lib/gtk3/tree-view-column.rb +34 -8
- data/sample/gtk-demo/TODO +19 -20
- data/sample/gtk-demo/assistant.rb +0 -2
- data/sample/gtk-demo/blendmodes.ui +391 -0
- data/sample/gtk-demo/blends.png +0 -0
- data/sample/gtk-demo/button_box.rb +16 -19
- data/sample/gtk-demo/clipboard.rb +2 -3
- data/sample/gtk-demo/cmy.jpg +0 -0
- data/sample/gtk-demo/colorsel.rb +1 -2
- data/sample/gtk-demo/context_menu_cursor.png +0 -0
- data/sample/gtk-demo/css_accordion.css +1 -1
- data/sample/gtk-demo/css_blendmodes.css +77 -0
- data/sample/gtk-demo/cssview.css +1 -1
- data/sample/gtk-demo/data/16x16/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/16x16/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/demo.gresource.xml +15 -2
- data/sample/gtk-demo/demo.ui +2 -1
- data/sample/gtk-demo/dialog.rb +2 -3
- data/sample/gtk-demo/drawingarea.rb +1 -2
- data/sample/gtk-demo/ducky.png +0 -0
- data/sample/gtk-demo/editable_cells.rb +1 -1
- data/sample/gtk-demo/entry_buffer.rb +1 -1
- data/sample/gtk-demo/entry_completion.rb +1 -1
- data/sample/gtk-demo/filtermodel.ui +15 -6
- data/sample/gtk-demo/fishbowl.ui +49 -0
- data/sample/gtk-demo/{glarea-fragment.glsl → glarea-gl.fs.glsl} +0 -0
- data/sample/gtk-demo/{glarea-vertex.glsl → glarea-gl.vs.glsl} +0 -0
- data/sample/gtk-demo/glarea-gles.fs.glsl +7 -0
- data/sample/gtk-demo/glarea-gles.vs.glsl +7 -0
- data/sample/gtk-demo/glarea.rb +15 -6
- data/sample/gtk-demo/hypertext.rb +0 -1
- data/sample/gtk-demo/images.rb +151 -168
- data/sample/gtk-demo/infobar.rb +5 -3
- data/sample/gtk-demo/links.rb +0 -1
- data/sample/gtk-demo/list_store.rb +1 -1
- data/sample/gtk-demo/listbox.ui +1 -1
- data/sample/gtk-demo/main.rb +4 -1
- data/sample/gtk-demo/markup.rb +2 -0
- data/sample/gtk-demo/menus.rb +0 -2
- data/sample/gtk-demo/no_drop_cursor.png +0 -0
- data/sample/gtk-demo/{cairo-arc-negative.rb → old_demos/cairo-arc-negative.rb} +0 -0
- data/sample/gtk-demo/{cairo-arc.rb → old_demos/cairo-arc.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-image.rb → old_demos/cairo-clip-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-rectangle.rb → old_demos/cairo-clip-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip.rb → old_demos/cairo-clip.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-rectangle.rb → old_demos/cairo-curve-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-to.rb → old_demos/cairo-curve-to.rb} +0 -0
- data/sample/gtk-demo/{cairo-dash.rb → old_demos/cairo-dash.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke.rb → old_demos/cairo-fill-and-stroke.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke2.rb → old_demos/cairo-fill-and-stroke2.rb} +0 -0
- data/sample/gtk-demo/{cairo-gradient.rb → old_demos/cairo-gradient.rb} +0 -0
- data/sample/gtk-demo/{cairo-image-pattern.rb → old_demos/cairo-image-pattern.rb} +0 -0
- data/sample/gtk-demo/{cairo-image.rb → old_demos/cairo-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-cap.rb → old_demos/cairo-line-cap.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-join.rb → old_demos/cairo-line-join.rb} +0 -0
- data/sample/gtk-demo/{cairo-long-lines.rb → old_demos/cairo-long-lines.rb} +0 -0
- data/sample/gtk-demo/{cairo-operator.rb → old_demos/cairo-operator.rb} +0 -0
- data/sample/gtk-demo/{cairo-path.rb → old_demos/cairo-path.rb} +0 -0
- data/sample/gtk-demo/{cairo-pattern-fill.rb → old_demos/cairo-pattern-fill.rb} +0 -0
- data/sample/gtk-demo/{cairo-self-intersect.rb → old_demos/cairo-self-intersect.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-align-center.rb → old_demos/cairo-text-align-center.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-extents.rb → old_demos/cairo-text-extents.rb} +0 -0
- data/sample/gtk-demo/{cairo-text.rb → old_demos/cairo-text.rb} +0 -0
- data/sample/gtk-demo/{changedisplay.rb → old_demos/changedisplay.rb} +0 -0
- data/sample/gtk-demo/{common.rb → old_demos/common.rb} +0 -0
- data/sample/gtk-demo/{item_factory.rb → old_demos/item_factory.rb} +0 -0
- data/sample/gtk-demo/{stock_browser.rb → old_demos/stock_browser.rb} +0 -0
- data/sample/gtk-demo/old_demos/textview.rb +436 -0
- data/sample/gtk-demo/{tree_store.rb → old_demos/tree_store.rb} +0 -0
- data/sample/gtk-demo/panes.rb +2 -3
- data/sample/gtk-demo/pickers.rb +6 -5
- data/sample/gtk-demo/popover.rb +2 -7
- data/sample/gtk-demo/popover.ui +1 -0
- data/sample/gtk-demo/revealer.rb +4 -2
- data/sample/gtk-demo/revealer.ui +0 -1
- data/sample/gtk-demo/scale.ui +7 -1
- data/sample/gtk-demo/search_entry.rb +1 -2
- data/sample/gtk-demo/search_entry2.rb +0 -3
- data/sample/gtk-demo/shortcuts-builder.ui +42 -27
- data/sample/gtk-demo/sizegroup.rb +15 -14
- data/sample/gtk-demo/spinner.rb +1 -1
- data/sample/gtk-demo/textview.rb +358 -382
- data/sample/gtk-demo/theming.ui +0 -29
- data/sample/gtk-demo/theming_style_classes.rb +0 -1
- data/sample/gtk-demo/transparent.rb +0 -1
- data/test/test-gtk-tree-view-column.rb +44 -1
- metadata +71 -61
data/sample/gtk-demo/infobar.rb
CHANGED
@@ -13,7 +13,7 @@ class InfobarDemo
|
|
13
13
|
@window = Gtk::Window.new(:toplevel)
|
14
14
|
@window.screen = main_window.screen
|
15
15
|
@window.set_title("Info Bars")
|
16
|
-
@window.
|
16
|
+
@window.margin = 8
|
17
17
|
|
18
18
|
@vbox = Gtk::Box.new(:vertical, 0)
|
19
19
|
@window.add(@vbox)
|
@@ -27,10 +27,12 @@ class InfobarDemo
|
|
27
27
|
generate_simple_infobar("other")
|
28
28
|
|
29
29
|
frame = Gtk::Frame.new("Info bars")
|
30
|
-
@vbox.pack_start(frame, :expand => false, :fill => false, :padding =>
|
30
|
+
@vbox.pack_start(frame, :expand => false, :fill => false, :padding => 0)
|
31
|
+
frame.margin_top = 8
|
32
|
+
frame.margin_bottom = 8
|
31
33
|
|
32
34
|
vbox2 = Gtk::Box.new(:vertical, 8)
|
33
|
-
vbox2.
|
35
|
+
vbox2.margin = 8
|
34
36
|
frame.add(vbox2)
|
35
37
|
|
36
38
|
label = Gtk::Label.new("An example of different info bars")
|
data/sample/gtk-demo/links.rb
CHANGED
@@ -37,7 +37,6 @@ class ListStoreDemo
|
|
37
37
|
@window = Gtk::Window.new(:toplevel)
|
38
38
|
@window.screen = main_window.screen
|
39
39
|
@window.title = "List Store"
|
40
|
-
@window.border_width = 8
|
41
40
|
@timeout = 0
|
42
41
|
@window.signal_connect "delete-event" do
|
43
42
|
@model = nil
|
@@ -46,6 +45,7 @@ class ListStoreDemo
|
|
46
45
|
false
|
47
46
|
end
|
48
47
|
vbox = Gtk::Box.new(:vertical, 8)
|
48
|
+
vbox.margin = 8
|
49
49
|
@window.add(vbox)
|
50
50
|
|
51
51
|
label = Gtk::Label.new(<<-EOF)
|
data/sample/gtk-demo/listbox.ui
CHANGED
data/sample/gtk-demo/main.rb
CHANGED
@@ -73,7 +73,7 @@ def generate_index
|
|
73
73
|
index = []
|
74
74
|
|
75
75
|
scripts.each do |script|
|
76
|
-
next if
|
76
|
+
next if "main.rb" == File.basename(script)
|
77
77
|
title, depend = script_info(script)
|
78
78
|
|
79
79
|
next if depend && !Gtk.const_defined?(depend)
|
@@ -196,6 +196,7 @@ def select_treeview_item(treeview, filename)
|
|
196
196
|
break
|
197
197
|
end
|
198
198
|
end
|
199
|
+
treeview.expand_to_path(to_select)
|
199
200
|
treeview.set_cursor(to_select, treeview.columns[FILENAME_COLUMN])
|
200
201
|
end
|
201
202
|
|
@@ -203,6 +204,8 @@ class Demo < Gtk::Application
|
|
203
204
|
def initialize
|
204
205
|
super("org.gtk.Demo", [:non_unique, :handles_command_line])
|
205
206
|
|
207
|
+
@current_file = nil
|
208
|
+
|
206
209
|
action = Gio::SimpleAction.new("quit")
|
207
210
|
action.signal_connect "activate" do |_action, _parameter|
|
208
211
|
quit
|
data/sample/gtk-demo/markup.rb
CHANGED
@@ -64,6 +64,8 @@ class MarkupDemo
|
|
64
64
|
buffer = @view2.buffer
|
65
65
|
markup = buffer.get_text(buffer.start_iter, buffer.end_iter, false)
|
66
66
|
buffer = @view.buffer
|
67
|
+
start_iter, start_end = buffer.bounds
|
68
|
+
buffer.delete(start_iter, start_end)
|
67
69
|
buffer.insert_markup(buffer.start_iter, markup, -1)
|
68
70
|
@stack.visible_child_name = "formatted"
|
69
71
|
end
|
data/sample/gtk-demo/menus.rb
CHANGED
@@ -28,7 +28,6 @@ class MenusDemo
|
|
28
28
|
@window = Gtk::Window.new(:toplevel)
|
29
29
|
@window.screen = main_window.screen
|
30
30
|
@window.title = "Menus"
|
31
|
-
@window.border_width = 0
|
32
31
|
|
33
32
|
accel_group = Gtk::AccelGroup.new
|
34
33
|
@window.add_accel_group(accel_group)
|
@@ -48,7 +47,6 @@ class MenusDemo
|
|
48
47
|
end
|
49
48
|
|
50
49
|
box2 = Gtk::Box.new(:vertical, 10)
|
51
|
-
box2.border_width = 10
|
52
50
|
box1.pack_start(box2, :expand => false, :fill => true, :padding => 0)
|
53
51
|
|
54
52
|
button = generate_flip_button
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,436 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team
|
3
|
+
# This program is licenced under the same licence as Ruby-GNOME2.
|
4
|
+
#
|
5
|
+
# $Id: textview.rb,v 1.8 2005/02/06 18:25:13 kzys Exp $
|
6
|
+
=begin
|
7
|
+
= Text Widget/Multiple Views
|
8
|
+
|
9
|
+
The Gtk::TextView widget displays a Gtk::TextBuffer.
|
10
|
+
One Gtk::TextBuffer can be displayed by multiple Gtk::TextViews.
|
11
|
+
This demo has two views displaying a single buffer,
|
12
|
+
and shows off the widget's text formatting features.
|
13
|
+
=end
|
14
|
+
require 'common'
|
15
|
+
|
16
|
+
module Demo
|
17
|
+
class TextView < BasicWindow
|
18
|
+
|
19
|
+
GRAY50_WIDTH = 2
|
20
|
+
GRAY50_HEIGHT = 2
|
21
|
+
GRAY50_BITS = [0x02, 0x01].pack("c")
|
22
|
+
@@nest_window = nil
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super("TextView Window")
|
26
|
+
|
27
|
+
set_default_size(450, 450)
|
28
|
+
|
29
|
+
set_title("TextView")
|
30
|
+
set_border_width(0)
|
31
|
+
|
32
|
+
vpaned = Gtk::VPaned.new
|
33
|
+
vpaned.set_border_width(5)
|
34
|
+
add(vpaned)
|
35
|
+
##
|
36
|
+
# For convenience, we just use the autocreated buffer from
|
37
|
+
# the first text view; you could also create the buffer
|
38
|
+
# by itself with Gtk::TextBuffer.new, then later create
|
39
|
+
# a view widget.
|
40
|
+
#
|
41
|
+
view1 = Gtk::TextView.new
|
42
|
+
buffer = view1.buffer
|
43
|
+
view2 = Gtk::TextView.new(buffer)
|
44
|
+
|
45
|
+
sw = Gtk::ScrolledWindow.new(nil, nil)
|
46
|
+
sw.set_policy(:automatic,
|
47
|
+
:automatic)
|
48
|
+
vpaned.add1(sw)
|
49
|
+
|
50
|
+
sw.add(view1)
|
51
|
+
|
52
|
+
sw = Gtk::ScrolledWindow.new(nil, nil)
|
53
|
+
sw.set_policy(:automatic,
|
54
|
+
:automatic)
|
55
|
+
vpaned.add2(sw)
|
56
|
+
|
57
|
+
sw.add(view2)
|
58
|
+
|
59
|
+
create_tags(buffer)
|
60
|
+
insert_text(buffer)
|
61
|
+
|
62
|
+
attach_widgets(view1)
|
63
|
+
attach_widgets(view2)
|
64
|
+
|
65
|
+
vpaned.show_all
|
66
|
+
|
67
|
+
self.show
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_tags(buffer)
|
71
|
+
##
|
72
|
+
# Create a bunch of tags. Note that it's also possible to
|
73
|
+
# create tags with Gtk::TextTag.new then add them to the
|
74
|
+
# tag table for the buffer, Gtk::TextBuffer#create_tag is
|
75
|
+
# just a convenience function. Also note that you don't have
|
76
|
+
# to give tags a name; pass NULL for the name to create an
|
77
|
+
# anonymous tag.
|
78
|
+
#
|
79
|
+
# In any real app, another useful optimization would be to create
|
80
|
+
# a Gtk::TextTagTable in advance, and reuse the same tag table for
|
81
|
+
# all the buffers with the same tag set, instead of creating
|
82
|
+
# new copies of the same tags for every buffer.
|
83
|
+
#
|
84
|
+
# Tags are assigned default priorities in order of addition to the
|
85
|
+
# tag table. That is, tags created later that affect the same text
|
86
|
+
# property affected by an earlier tag will override the earlier
|
87
|
+
# tag. You can modify tag priorities with
|
88
|
+
# Gtk::TextTag#set_priority.
|
89
|
+
#
|
90
|
+
|
91
|
+
buffer.create_tag('heading',
|
92
|
+
'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
93
|
+
'size' => 15 * Pango::SCALE)
|
94
|
+
|
95
|
+
buffer.create_tag("italic",
|
96
|
+
"style" => Pango::FontDescription::STYLE_ITALIC)
|
97
|
+
|
98
|
+
buffer.create_tag("bold",
|
99
|
+
"weight" => Pango::FontDescription::WEIGHT_BOLD)
|
100
|
+
|
101
|
+
buffer.create_tag("big",
|
102
|
+
# points times the PANGO_SCALE factor
|
103
|
+
"size" => 20 * Pango::SCALE)
|
104
|
+
|
105
|
+
buffer.create_tag("xx-small",
|
106
|
+
"scale" => Pango::AttrScale::XX_SMALL)
|
107
|
+
|
108
|
+
buffer.create_tag("x-large",
|
109
|
+
"scale" => Pango::AttrScale::X_LARGE)
|
110
|
+
|
111
|
+
buffer.create_tag("monospace", "family" => "monospace")
|
112
|
+
|
113
|
+
buffer.create_tag("blue_foreground", "foreground" => "blue")
|
114
|
+
|
115
|
+
buffer.create_tag("red_background", "background" => "red")
|
116
|
+
|
117
|
+
stipple = Gdk::Pixmap.create_from_data(nil, GRAY50_BITS, GRAY50_WIDTH,
|
118
|
+
GRAY50_HEIGHT)
|
119
|
+
|
120
|
+
buffer.create_tag("background_stipple",
|
121
|
+
"background_stipple" => stipple)
|
122
|
+
|
123
|
+
buffer.create_tag("foreground_stipple",
|
124
|
+
"foreground_stipple" => stipple)
|
125
|
+
|
126
|
+
buffer.create_tag("big_gap_before_line",
|
127
|
+
"pixels_above_lines" => 30)
|
128
|
+
|
129
|
+
buffer.create_tag("big_gap_after_line",
|
130
|
+
"pixels_below_lines" => 30)
|
131
|
+
|
132
|
+
buffer.create_tag("double_spaced_line",
|
133
|
+
"pixels_inside_wrap" => 10)
|
134
|
+
|
135
|
+
buffer.create_tag("not_editable",
|
136
|
+
"editable" => false)
|
137
|
+
|
138
|
+
buffer.create_tag("word_wrap",
|
139
|
+
"wrap_mode" => :word)
|
140
|
+
|
141
|
+
buffer.create_tag("char_wrap",
|
142
|
+
"wrap_mode" => Gtk::TextTag::WRAP_CHAR)
|
143
|
+
|
144
|
+
buffer.create_tag("no_wrap",
|
145
|
+
"wrap_mode" => :none)
|
146
|
+
|
147
|
+
buffer.create_tag("center",
|
148
|
+
"justification" => Gtk::JUSTIFY_CENTER)
|
149
|
+
|
150
|
+
buffer.create_tag("right_justify",
|
151
|
+
"justification" => Gtk::JUSTIFY_RIGHT)
|
152
|
+
|
153
|
+
buffer.create_tag("wide_margins",
|
154
|
+
"left_margin" => 50,
|
155
|
+
"right_margin" => 50)
|
156
|
+
|
157
|
+
buffer.create_tag("strikethrough",
|
158
|
+
"strikethrough" => true)
|
159
|
+
|
160
|
+
buffer.create_tag("underline",
|
161
|
+
"underline" => Pango::AttrUnderline::SINGLE)
|
162
|
+
|
163
|
+
buffer.create_tag("double_underline",
|
164
|
+
"underline" => Pango::AttrUnderline::DOUBLE)
|
165
|
+
|
166
|
+
buffer.create_tag("superscript",
|
167
|
+
"rise" => 10 * Pango::SCALE, # 10 pixels
|
168
|
+
"size" => 8 * Pango::SCALE) # 8 points
|
169
|
+
|
170
|
+
buffer.create_tag("subscript",
|
171
|
+
"rise" => -10 * Pango::SCALE, # 10 pixels
|
172
|
+
"size" => 8 * Pango::SCALE) # 8 points
|
173
|
+
|
174
|
+
buffer.create_tag("rtl_quote",
|
175
|
+
"wrap_mode" => :word,
|
176
|
+
"direction" => Gtk::Widget::TEXT_DIR_RTL,
|
177
|
+
"indent" => 30,
|
178
|
+
"left_margin" => 20,
|
179
|
+
"right_margin" => 20)
|
180
|
+
end
|
181
|
+
|
182
|
+
def insert_text(buffer)
|
183
|
+
|
184
|
+
##
|
185
|
+
# Demo.find_file looks in the the current directory first,
|
186
|
+
# so you can run gtk-demo without installing GTK, then looks
|
187
|
+
# in the location where the file is installed.
|
188
|
+
#
|
189
|
+
|
190
|
+
filename = Demo.find_file("gtk-logo-rgb.gif")
|
191
|
+
pixbuf = Gdk::Pixbuf.new(filename) if filename
|
192
|
+
|
193
|
+
unless pixbuf
|
194
|
+
$stderr.print "Failed to load image file gtk-logo-rgb.gif\n"
|
195
|
+
exit 1
|
196
|
+
end
|
197
|
+
|
198
|
+
scaled = pixbuf.scale(32, 32, Gdk::Pixbuf::INTERP_BILINEAR)
|
199
|
+
pixbuf = scaled
|
200
|
+
|
201
|
+
##
|
202
|
+
# get start of buffer; each insertion will revalidate the
|
203
|
+
# iterator to point to just after the inserted text.
|
204
|
+
#
|
205
|
+
|
206
|
+
iter = buffer.get_iter_at(:offset => 0)
|
207
|
+
|
208
|
+
buffer.insert(iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n")
|
209
|
+
|
210
|
+
buffer.insert(iter, "Font styles. ", 'heading')
|
211
|
+
|
212
|
+
buffer.insert(iter, "For example, you can have ")
|
213
|
+
buffer.insert(iter, "italic", "italic")
|
214
|
+
buffer.insert(iter, ", ")
|
215
|
+
buffer.insert(iter, "bold", "bold")
|
216
|
+
buffer.insert(iter, ", or ")
|
217
|
+
buffer.insert(iter, "monospace(typewriter)", "monospace")
|
218
|
+
buffer.insert(iter, ", or ")
|
219
|
+
buffer.insert(iter, "big", "big")
|
220
|
+
buffer.insert(iter, " text. ")
|
221
|
+
buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ")
|
222
|
+
buffer.insert(iter, "xx-small", "xx-small")
|
223
|
+
buffer.insert(iter, " or ")
|
224
|
+
buffer.insert(iter, "x-large", "x-large")
|
225
|
+
buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n")
|
226
|
+
|
227
|
+
buffer.insert(iter, "Colors. ", "heading")
|
228
|
+
|
229
|
+
buffer.insert(iter, "Colors such as ")
|
230
|
+
buffer.insert(iter, "a blue foreground", "blue_foreground")
|
231
|
+
buffer.insert(iter, " or ")
|
232
|
+
buffer.insert(iter, "a red background", "red_background")
|
233
|
+
buffer.insert(iter, " or even ")
|
234
|
+
buffer.insert(iter, "a stippled red background",
|
235
|
+
"red_background", "background_stipple")
|
236
|
+
|
237
|
+
buffer.insert(iter, " or ")
|
238
|
+
buffer.insert(iter, "a stippled blue foreground on solid red background",
|
239
|
+
"blue_foreground", "red_background", "foreground_stipple")
|
240
|
+
|
241
|
+
buffer.insert(iter, "(select that to read it) can be used.\n\n")
|
242
|
+
|
243
|
+
buffer.insert(iter, "Underline, strikethrough, and rise. ", "heading")
|
244
|
+
|
245
|
+
buffer.insert(iter, "Strikethrough", "strikethrough")
|
246
|
+
buffer.insert(iter, ", ")
|
247
|
+
buffer.insert(iter, "underline", "underline")
|
248
|
+
buffer.insert(iter, ", ")
|
249
|
+
buffer.insert(iter, "double underline", "double_underline")
|
250
|
+
buffer.insert(iter, ", ")
|
251
|
+
buffer.insert(iter, "superscript", "superscript")
|
252
|
+
buffer.insert(iter, ", and ")
|
253
|
+
buffer.insert(iter, "subscript", "subscript")
|
254
|
+
buffer.insert(iter, " are all supported.\n\n")
|
255
|
+
|
256
|
+
buffer.insert(iter, "Images. ", "heading")
|
257
|
+
|
258
|
+
buffer.insert(iter, "The buffer can have images in it: ")
|
259
|
+
buffer.insert(iter, pixbuf)
|
260
|
+
buffer.insert(iter, pixbuf)
|
261
|
+
buffer.insert(iter, pixbuf)
|
262
|
+
buffer.insert(iter, " for example.\n\n")
|
263
|
+
|
264
|
+
buffer.insert(iter, "Spacing. ", "heading")
|
265
|
+
|
266
|
+
buffer.insert(iter, "You can adjust the amount of space before each line.\n")
|
267
|
+
|
268
|
+
buffer.insert(iter, "This line has a whole lot of space before it.\n",
|
269
|
+
"big_gap_before_line", "wide_margins")
|
270
|
+
buffer.insert(iter, "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n",
|
271
|
+
"big_gap_after_line", "wide_margins")
|
272
|
+
|
273
|
+
buffer.insert(iter, "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n",
|
274
|
+
"double_spaced_line", "wide_margins")
|
275
|
+
|
276
|
+
buffer.insert(iter, "Also note that those lines have extra-wide margins.\n\n")
|
277
|
+
|
278
|
+
buffer.insert(iter, "Editability. ", "heading")
|
279
|
+
|
280
|
+
buffer.insert(iter, "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n",
|
281
|
+
"not_editable")
|
282
|
+
|
283
|
+
buffer.insert(iter, "Wrapping. ", "heading")
|
284
|
+
|
285
|
+
buffer.insert(iter, "This line(and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n")
|
286
|
+
|
287
|
+
buffer.insert(iter, "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", "char_wrap")
|
288
|
+
|
289
|
+
buffer.insert(iter, "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", "no_wrap")
|
290
|
+
|
291
|
+
buffer.insert(iter, "Justification. ", "heading")
|
292
|
+
|
293
|
+
buffer.insert(iter, "\nThis line has center justification.\n", "center")
|
294
|
+
|
295
|
+
buffer.insert(iter, "This line has right justification.\n",
|
296
|
+
"right_justify")
|
297
|
+
|
298
|
+
buffer.insert(iter, "\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", "wide_margins")
|
299
|
+
|
300
|
+
buffer.insert(iter, "Internationalization. ", "heading")
|
301
|
+
|
302
|
+
buffer.insert(iter, "You can put all sorts of Unicode text in the buffer.\n\nGerman(Deutsch Süd) Grüß Gott\nGreek(Ελληνικά) Γειά σας\nHebrew שלום\nJapanese(日本語)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n")
|
303
|
+
|
304
|
+
buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n")
|
305
|
+
buffer.insert(iter, "??? ??? ???? ?? ???? ???????? ????? ?? ???? ?????? ??????? ??????? ?? ???? ?????? ?? ????? ?? ??????? ????? ??????? ??? ?????? ????? ?????? ????? ???? ?? ?????? ?????? ?? ???????? ?????? ????? ?? ???? ???? ????????? ???????. ???? ???? ??? ???????? ????? ?? »????????« ?? ???????.\n\n", "rtl_quote")
|
306
|
+
|
307
|
+
buffer.insert(iter, "You can put widgets in the buffer: Here's a button: ")
|
308
|
+
anchor = buffer.create_child_anchor(iter)
|
309
|
+
buffer.insert(iter, " and a menu: ")
|
310
|
+
anchor = buffer.create_child_anchor(iter)
|
311
|
+
buffer.insert(iter, " and a scale: ")
|
312
|
+
anchor = buffer.create_child_anchor(iter)
|
313
|
+
buffer.insert(iter, " and an animation: ")
|
314
|
+
anchor = buffer.create_child_anchor(iter)
|
315
|
+
buffer.insert(iter, " finally a text entry: ")
|
316
|
+
anchor = buffer.create_child_anchor(iter)
|
317
|
+
buffer.insert(iter, ".\n")
|
318
|
+
|
319
|
+
buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the Gtk::TextBuffer features; it leaves out, for example: invisible/hidden text(doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...")
|
320
|
+
|
321
|
+
# Apply word_wrap tag to whole buffer
|
322
|
+
|
323
|
+
buf_start, buf_end = buffer.bounds
|
324
|
+
buffer.apply_tag("word_wrap", buf_start, buf_end)
|
325
|
+
end
|
326
|
+
|
327
|
+
def find_anchor(iter)
|
328
|
+
while iter.forward_char do
|
329
|
+
return true if iter.child_anchor
|
330
|
+
end
|
331
|
+
return false
|
332
|
+
end
|
333
|
+
|
334
|
+
def attach_widgets(text_view)
|
335
|
+
|
336
|
+
buffer = text_view.buffer;
|
337
|
+
|
338
|
+
iter = buffer.start_iter
|
339
|
+
|
340
|
+
i = 0;
|
341
|
+
while find_anchor(iter) do
|
342
|
+
anchor = iter.child_anchor
|
343
|
+
|
344
|
+
if i == 0
|
345
|
+
widget = Gtk::Button.new("Click Me")
|
346
|
+
widget.signal_connect('clicked') { |button|
|
347
|
+
if @@nest_window and ! @@nest_window.destroyed?
|
348
|
+
@@nest_window.present
|
349
|
+
break
|
350
|
+
end
|
351
|
+
|
352
|
+
buffer = Gtk::TextBuffer.new
|
353
|
+
iter = buffer.start_iter
|
354
|
+
|
355
|
+
buffer.insert(iter, "This buffer is shared by a set of nested text views.\n Nested view:\n")
|
356
|
+
anchor = buffer.create_child_anchor(iter)
|
357
|
+
buffer.insert(iter, "\nDon't do this in real applications, please.\n")
|
358
|
+
|
359
|
+
view = Gtk::TextView.new(buffer)
|
360
|
+
|
361
|
+
recursive_attach_view(0, view, anchor)
|
362
|
+
|
363
|
+
@@nest_window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
|
364
|
+
sw = Gtk::ScrolledWindow.new(nil, nil)
|
365
|
+
sw.set_policy(:automatic,
|
366
|
+
:automatic)
|
367
|
+
|
368
|
+
@@nest_window.add(sw)
|
369
|
+
sw.add(view)
|
370
|
+
|
371
|
+
@@nest_window.set_default_size(300, 400)
|
372
|
+
@@nest_window.show_all
|
373
|
+
}
|
374
|
+
elsif i == 1
|
375
|
+
menu = Gtk::Menu.new
|
376
|
+
widget = Gtk::OptionMenu.new
|
377
|
+
|
378
|
+
menu_item = Gtk::MenuItem.new("Option 1")
|
379
|
+
menu.append(menu_item)
|
380
|
+
menu_item = Gtk::MenuItem.new("Option 2")
|
381
|
+
menu.append(menu_item)
|
382
|
+
menu_item = Gtk::MenuItem.new("Option 3")
|
383
|
+
menu.append(menu_item)
|
384
|
+
|
385
|
+
widget.menu = menu
|
386
|
+
|
387
|
+
elsif i == 2
|
388
|
+
widget = Gtk::HScale.new
|
389
|
+
widget.set_range(0, 100)
|
390
|
+
widget.set_size_request(70, -1)
|
391
|
+
|
392
|
+
elsif i == 3
|
393
|
+
filename = Demo.find_file("floppybuddy.gif")
|
394
|
+
widget = Gtk::Image.new(filename)
|
395
|
+
|
396
|
+
elsif i == 4
|
397
|
+
widget = Gtk::Entry.new
|
398
|
+
|
399
|
+
else
|
400
|
+
#widget = nil; avoids a compiler warning
|
401
|
+
#g_assert_not_reached ;
|
402
|
+
end
|
403
|
+
|
404
|
+
text_view.add_child_at_anchor(widget,
|
405
|
+
anchor)
|
406
|
+
|
407
|
+
widget.show_all
|
408
|
+
i += 1
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
|
413
|
+
def recursive_attach_view(depth, view, anchor)
|
414
|
+
return if depth > 4
|
415
|
+
|
416
|
+
child_view = Gtk::TextView.new(view.buffer)
|
417
|
+
|
418
|
+
# Event box is to add a black border around each child view
|
419
|
+
event_box = Gtk::EventBox.new
|
420
|
+
color = Gdk::Color.parse("black")
|
421
|
+
event_box.modify_bg(Gtk::STATE_NORMAL, color)
|
422
|
+
|
423
|
+
align = Gtk::Alignment.new(0.5, 0.5, 1.0, 1.0)
|
424
|
+
align.set_border_width(1)
|
425
|
+
|
426
|
+
event_box.add(align)
|
427
|
+
align.add(child_view)
|
428
|
+
|
429
|
+
view.add_child_at_anchor(event_box, anchor)
|
430
|
+
|
431
|
+
recursive_attach_view(depth + 1, child_view, anchor)
|
432
|
+
end
|
433
|
+
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|