gtk3 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -1
- data/ext/gtk3/rbgtk-image.c +66 -1
- data/ext/gtk3/rbgtk-tree-view.c +1 -0
- data/sample/gtk-demo/stock_browser.rb +74 -76
- metadata +27 -27
data/Rakefile
CHANGED
@@ -17,6 +17,5 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
17
17
|
package.windows.packages = []
|
18
18
|
package.windows.dependencies = []
|
19
19
|
package.required_ruby_version = ">= 1.9.2"
|
20
|
-
package.post_install_message = "This library is experimental."
|
21
20
|
end
|
22
21
|
package_task.define
|
data/ext/gtk3/rbgtk-image.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2011-2013 Ruby-GNOME2 Project Team
|
4
4
|
* Copyright (C) 2002-2005 Masao Mutoh
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -83,12 +83,77 @@ rg_clear(VALUE self)
|
|
83
83
|
return self;
|
84
84
|
}
|
85
85
|
|
86
|
+
static GtkIconSize
|
87
|
+
icon_size_from_ruby(GtkImage *image, VALUE rb_size)
|
88
|
+
{
|
89
|
+
GtkIconSize size;
|
90
|
+
|
91
|
+
if (NIL_P(rb_size)) {
|
92
|
+
g_object_get(image,
|
93
|
+
"icon-size", &size,
|
94
|
+
NULL);
|
95
|
+
if (size == GTK_ICON_SIZE_INVALID) {
|
96
|
+
size = GTK_ICON_SIZE_BUTTON;
|
97
|
+
}
|
98
|
+
} else {
|
99
|
+
size = RVAL2GTKICONSIZE(rb_size);
|
100
|
+
}
|
101
|
+
|
102
|
+
return size;
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
rg_set_from_icon_set(int argc, VALUE *argv, VALUE self)
|
107
|
+
{
|
108
|
+
GtkImage *image;
|
109
|
+
VALUE rb_icon_set, rb_size;
|
110
|
+
|
111
|
+
image = RVAL2GTKIMAGE(self);
|
112
|
+
rb_scan_args(argc, argv, "11", &rb_icon_set, &rb_size);
|
113
|
+
gtk_image_set_from_icon_set(image,
|
114
|
+
RVAL2GTKICONSET(rb_icon_set),
|
115
|
+
icon_size_from_ruby(image, rb_size));
|
116
|
+
return self;
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
rg_set_from_stock(int argc, VALUE *argv, VALUE self)
|
121
|
+
{
|
122
|
+
GtkImage *image;
|
123
|
+
VALUE rb_stock, rb_size;
|
124
|
+
VALUE rb_buffer;
|
125
|
+
|
126
|
+
image = RVAL2GTKIMAGE(self);
|
127
|
+
rb_scan_args(argc, argv, "11", &rb_stock, &rb_size);
|
128
|
+
gtk_image_set_from_stock(image,
|
129
|
+
RVAL2GLIBID(rb_stock, rb_buffer),
|
130
|
+
icon_size_from_ruby(image, rb_size));
|
131
|
+
return self;
|
132
|
+
}
|
133
|
+
|
134
|
+
static VALUE
|
135
|
+
rg_set_from_gicon(int argc, VALUE *argv, VALUE self)
|
136
|
+
{
|
137
|
+
GtkImage *image;
|
138
|
+
VALUE rb_gicon, rb_size;
|
139
|
+
|
140
|
+
image = RVAL2GTKIMAGE(self);
|
141
|
+
rb_scan_args(argc, argv, "11", &rb_gicon, &rb_size);
|
142
|
+
gtk_image_set_from_gicon(image,
|
143
|
+
RVAL2GICON(rb_gicon),
|
144
|
+
icon_size_from_ruby(image, rb_size));
|
145
|
+
return self;
|
146
|
+
}
|
147
|
+
|
86
148
|
void
|
87
149
|
Init_gtk_image(VALUE mGtk)
|
88
150
|
{
|
89
151
|
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_IMAGE, "Image", mGtk);
|
90
152
|
RG_DEF_METHOD(initialize, -1);
|
91
153
|
RG_DEF_METHOD(clear, 0);
|
154
|
+
RG_DEF_METHOD(set_from_icon_set, -1);
|
155
|
+
RG_DEF_METHOD(set_from_stock, -1);
|
156
|
+
RG_DEF_METHOD(set_from_gicon, -1);
|
92
157
|
|
93
158
|
G_DEF_CLASS(GTK_TYPE_IMAGE_TYPE, "Type", RG_TARGET_NAMESPACE);
|
94
159
|
|
data/ext/gtk3/rbgtk-tree-view.c
CHANGED
@@ -14,15 +14,13 @@ require 'common'
|
|
14
14
|
|
15
15
|
module Demo
|
16
16
|
class StockBrowser < BasicWindow
|
17
|
-
Item =
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
:type_label, :const_label, :id_label, :label_accel_label,
|
25
|
-
:icon_image)
|
17
|
+
Item = Struct.new('Item',
|
18
|
+
:stock_id, :label, :modifier, :keyval, :translation_domain)
|
19
|
+
ItemInfo = Struct.new('ItemInfo',
|
20
|
+
:id, :item, :small_icon, :const, :accel_str)
|
21
|
+
ItemDisplay = Struct.new('ItemDisplay',
|
22
|
+
:type_label, :const_label, :id_label, :label_accel_label,
|
23
|
+
:icon_image)
|
26
24
|
|
27
25
|
def initialize
|
28
26
|
super('Stock Icons and Items')
|
@@ -34,7 +32,7 @@ module Demo
|
|
34
32
|
add(hbox)
|
35
33
|
|
36
34
|
sw = Gtk::ScrolledWindow.new
|
37
|
-
sw.set_policy(
|
35
|
+
sw.set_policy(:never, :automatic)
|
38
36
|
hbox.pack_start(sw, :expand => false, :fill => false, :padding => 0)
|
39
37
|
|
40
38
|
model = create_model
|
@@ -52,43 +50,43 @@ module Demo
|
|
52
50
|
cell_renderer = Gtk::CellRendererText.new
|
53
51
|
column.pack_start(cell_renderer, :expand => true)
|
54
52
|
column.set_cell_data_func(cell_renderer) do |column, cell, model, iter|
|
55
|
-
|
53
|
+
cell.text = iter[0].const
|
56
54
|
end
|
57
55
|
|
58
56
|
treeview.append_column(column)
|
59
57
|
|
60
58
|
cell_renderer = Gtk::CellRendererText.new
|
61
59
|
treeview.insert_column(-1, 'Label', cell_renderer) do |col, cell, model, iter|
|
62
|
-
|
63
|
-
|
60
|
+
info = iter[0]
|
61
|
+
cell.text = info.item.label if info
|
64
62
|
end
|
65
63
|
|
66
64
|
cell_renderer = Gtk::CellRendererText.new
|
67
65
|
treeview.insert_column(-1, 'Accel', cell_renderer) do |col, cell, model, iter|
|
68
|
-
|
69
|
-
|
66
|
+
info = iter[0]
|
67
|
+
cell.text = info.accel_str if info
|
70
68
|
end
|
71
69
|
|
72
70
|
cell_renderer = Gtk::CellRendererText.new
|
73
71
|
treeview.insert_column(-1, 'ID', cell_renderer) do |col, cell, model, iter|
|
74
|
-
|
75
|
-
|
72
|
+
info = iter[0]
|
73
|
+
cell.text = info.id if info
|
76
74
|
end
|
77
75
|
|
78
76
|
align = Gtk::Alignment.new(0.5, 0.0, 0.0, 0.0)
|
79
|
-
hbox.pack_end(align, false, false, 0)
|
77
|
+
hbox.pack_end(align, :expand => false, :fill => false, :padding => 0)
|
80
78
|
|
81
79
|
frame = Gtk::Frame.new('Selected Item')
|
82
80
|
align.add(frame)
|
83
81
|
|
84
|
-
vbox = Gtk::
|
82
|
+
vbox = Gtk::Box.new(:vertical, 8)
|
85
83
|
vbox.border_width = 4
|
86
84
|
frame.add(vbox)
|
87
85
|
|
88
86
|
display = ItemDisplay.new
|
89
87
|
class << treeview
|
90
|
-
|
91
|
-
|
88
|
+
@display = nil
|
89
|
+
attr_accessor :display
|
92
90
|
end
|
93
91
|
treeview.display = display
|
94
92
|
|
@@ -107,10 +105,10 @@ module Demo
|
|
107
105
|
vbox.pack_start(display.id_label, :expand => false, :fill => false, :padding => 0)
|
108
106
|
|
109
107
|
selection = treeview.selection
|
110
|
-
selection.mode =
|
108
|
+
selection.mode = :single
|
111
109
|
|
112
110
|
selection.signal_connect('changed') do |s|
|
113
|
-
|
111
|
+
selection_changed(s)
|
114
112
|
end
|
115
113
|
end
|
116
114
|
|
@@ -119,54 +117,54 @@ module Demo
|
|
119
117
|
|
120
118
|
list_ids = Gtk::Stock.ids
|
121
119
|
list_ids.sort! do |a, b|
|
122
|
-
|
120
|
+
a.to_s <=> b.to_s
|
123
121
|
end
|
124
122
|
list_ids.each do |stock_id|
|
125
|
-
|
123
|
+
info = ItemInfo.new
|
126
124
|
|
127
|
-
|
125
|
+
info.id = stock_id
|
128
126
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
127
|
+
begin
|
128
|
+
info.item = Item.new(*Gtk::Stock.lookup(stock_id))
|
129
|
+
rescue ArgumentError
|
130
|
+
info.item = Item.new
|
131
|
+
end
|
134
132
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
133
|
+
# only show icons for stock IDs that have default icons
|
134
|
+
icon_set = Gtk::IconFactory.lookup_default(info.id.to_s)
|
135
|
+
if icon_set
|
136
|
+
# See what sizes this stock icon really exists at
|
137
|
+
sizes = icon_set.sizes
|
140
138
|
|
141
|
-
|
142
|
-
|
139
|
+
# Use menu size if it exists, otherwise first size found
|
140
|
+
size = sizes.find do |s| s == :menu end || sizes.first
|
143
141
|
|
144
|
-
|
142
|
+
info.small_icon = render_icon_pixbuf(info.id, size)
|
145
143
|
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
unless size == :menu
|
145
|
+
# Make the result the proper size for our thumbnail
|
146
|
+
w, h = Gtk::IconSize.lookup(size)
|
149
147
|
|
150
|
-
|
151
|
-
|
152
|
-
|
148
|
+
scaled = info.small_icon.scale(w, h, Gdk::Pixbuf::INTERP_BILINEAR)
|
149
|
+
info.small_icon = scaled
|
150
|
+
end
|
153
151
|
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
else
|
153
|
+
info.small_icon = nil
|
154
|
+
end
|
157
155
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
156
|
+
if info.item.keyval
|
157
|
+
info.accel_str = Gtk::Accelerator.to_name(info.item.keyval,
|
158
|
+
info.item.modifier)
|
159
|
+
else
|
160
|
+
info.accel_str = ''
|
161
|
+
end
|
164
162
|
|
165
|
-
|
163
|
+
info.const = id_to_const(info.id)
|
166
164
|
|
167
|
-
|
168
|
-
|
169
|
-
|
165
|
+
iter = store.append
|
166
|
+
iter[0] = info
|
167
|
+
iter[1] = info.id
|
170
168
|
end
|
171
169
|
|
172
170
|
return store
|
@@ -180,40 +178,40 @@ module Demo
|
|
180
178
|
info = iter[0]
|
181
179
|
|
182
180
|
display.type_label.label = if info.small_icon and info.item.label
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
181
|
+
'Icon and Item'
|
182
|
+
elsif info.small_icon
|
183
|
+
'Icon Only'
|
184
|
+
elsif info.item.label
|
185
|
+
'Item Only'
|
186
|
+
else
|
187
|
+
'???????'
|
188
|
+
end
|
191
189
|
display.const_label.label = info.const
|
192
190
|
display.id_label.label = info.id
|
193
191
|
|
194
192
|
if info.item.label
|
195
|
-
|
196
|
-
|
193
|
+
str = "%s %s" % [info.item.label, info.accel_str]
|
194
|
+
display.label_accel_label.set_text(str, true)
|
197
195
|
else
|
198
|
-
|
196
|
+
display.label_accel_label.set_text('')
|
199
197
|
end
|
200
198
|
|
201
199
|
if info.small_icon
|
202
|
-
|
200
|
+
display.icon_image.set_from_stock(info.id, get_largest_size(info.id))
|
203
201
|
else
|
204
|
-
|
202
|
+
display.icon_image.pixbuf = nil
|
205
203
|
end
|
206
204
|
end
|
207
205
|
|
208
206
|
def get_largest_size(symbol)
|
209
207
|
set = Gtk::IconFactory.lookup_default(symbol.id2name)
|
210
|
-
best_size =
|
208
|
+
best_size = :invalid
|
211
209
|
best_pixels = 0
|
212
210
|
|
213
211
|
sizes = set.sizes
|
214
212
|
sizes.collect! do |i|
|
215
|
-
|
216
|
-
|
213
|
+
width, height = Gtk::IconSize.lookup(i)
|
214
|
+
[i, width * height]
|
217
215
|
end
|
218
216
|
return (sizes.max do |a, b| a[1] <=> b[1] end)[0]
|
219
217
|
end
|
@@ -223,8 +221,8 @@ module Demo
|
|
223
221
|
|
224
222
|
s = id.id2name
|
225
223
|
if s =~ /^gtk-/
|
226
|
-
|
227
|
-
|
224
|
+
const += 'Gtk::Stock::'
|
225
|
+
s[0,4] = ''
|
228
226
|
end
|
229
227
|
|
230
228
|
const += s.upcase.gsub(/-/, '_')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,104 +9,104 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: glib2
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.
|
21
|
+
version: 2.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.
|
29
|
+
version: 2.0.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: gio2
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.0.
|
37
|
+
version: 2.0.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.0.
|
45
|
+
version: 2.0.1
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: atk
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.0.
|
53
|
+
version: 2.0.1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0.
|
61
|
+
version: 2.0.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: pango
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - '='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.0.
|
69
|
+
version: 2.0.1
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.0.
|
77
|
+
version: 2.0.1
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: gdk_pixbuf2
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 2.0.
|
85
|
+
version: 2.0.1
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2.0.
|
93
|
+
version: 2.0.1
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: gdk3
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 2.0.
|
101
|
+
version: 2.0.1
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.0.
|
109
|
+
version: 2.0.1
|
110
110
|
description: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
|
111
111
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
112
112
|
executables: []
|
@@ -538,7 +538,7 @@ files:
|
|
538
538
|
- test/test_gtk_widget.rb
|
539
539
|
homepage: http://ruby-gnome2.sourceforge.jp/
|
540
540
|
licenses: []
|
541
|
-
post_install_message:
|
541
|
+
post_install_message:
|
542
542
|
rdoc_options: []
|
543
543
|
require_paths:
|
544
544
|
- lib
|