gtk3assist 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ GEM
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
5
  ffi (1.0.11)
6
+ ffi (1.0.11-java)
6
7
  gir_ffi (0.4.0)
7
8
  ffi (~> 1.0.8)
8
9
  indentation (~> 0.0.6)
@@ -16,6 +17,7 @@ GEM
16
17
  rake
17
18
  rdoc
18
19
  json (1.7.5)
20
+ json (1.7.5-java)
19
21
  rake (0.9.2.2)
20
22
  rdoc (3.12)
21
23
  json (~> 1.4)
@@ -30,6 +32,7 @@ GEM
30
32
  xml-simple (1.1.1)
31
33
 
32
34
  PLATFORMS
35
+ java
33
36
  ruby
34
37
 
35
38
  DEPENDENCIES
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/gtk3assist.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gtk3assist"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2012-09-16"
12
+ s.date = "2012-09-19"
13
13
  s.description = "A class for making it easier to develop Gtk3 based applications with the 'gir_ffi-gtk'-gem."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -39,7 +39,7 @@ class Gtk3assist::Treeview
39
39
  def init_liststore
40
40
  liststore_args = []
41
41
  @columns.each do |col_data|
42
- if col_data[:type] == :string
42
+ if col_data[:type] == :string or !col_data[:type]
43
43
  liststore_args << GObject::TYPE_STRING
44
44
  else
45
45
  raise "Unknown column-type: '#{col_data[:type]}'."
@@ -81,6 +81,9 @@ class Gtk3assist::Treeview
81
81
 
82
82
  #Add a new row to the treeview.
83
83
  def add_row(args)
84
+ raise "''args' wasnt a hash." if !args.is_a?(Hash)
85
+ raise "No ':data'-array was given." if !args[:data]
86
+
84
87
  if @model.is_a?(Gtk::ListStore)
85
88
  data = []
86
89
  @columns.each do |col_data|
@@ -101,7 +104,7 @@ class Gtk3assist::Treeview
101
104
  data.each do |val|
102
105
  col_data = @columns[count]
103
106
 
104
- if col_data[:type] == :string
107
+ if col_data[:type] == :string or !col_data[:type]
105
108
  @model.set_value(iter, count, val.to_s)
106
109
  else
107
110
  raise "Unknown column-type: '#{col_data[:type]}'."
@@ -109,6 +112,8 @@ class Gtk3assist::Treeview
109
112
 
110
113
  count += 1
111
114
  end
115
+
116
+ return {:iter => iter}
112
117
  else
113
118
  raise "Unknown model: '#{@model.class.name}'."
114
119
  end
@@ -121,18 +126,28 @@ class Gtk3assist::Treeview
121
126
 
122
127
  while iter_cur
123
128
  match = true
129
+ sel_val = @tv.get_selection.iter_is_selected(iter_cur) rescue false
130
+ match = false if args and args[:selected] and !sel_val
124
131
 
125
132
  if match
126
- data = []
133
+ data = {}
134
+ count = 0
135
+
127
136
  @columns.each do |col_data|
128
- if col_data[:type] == :string
129
- data << @model.get_value(iter_cur, 1).get_string
137
+ if col_data[:type] == :string or !col_data[:type]
138
+ data[col_data[:id]] = @model.get_value(iter_cur, count).get_string
130
139
  else
131
140
  raise "Unknown column-type: '#{col_data[:type]}'."
132
141
  end
142
+
143
+ count += 1
133
144
  end
134
145
 
135
- y << {:data => data}
146
+ y << {
147
+ :sel => sel_val,
148
+ :data => data,
149
+ :iter => iter_cur
150
+ }
136
151
  end
137
152
 
138
153
  break if !@model.iter_next(iter_cur)
@@ -145,4 +160,13 @@ class Gtk3assist::Treeview
145
160
  return enum
146
161
  end
147
162
  end
163
+
164
+ #Returns the first selected row found.
165
+ def sel
166
+ self.rows(:selected => true).each do |data|
167
+ return data if data[:sel]
168
+ end
169
+
170
+ return nil
171
+ end
148
172
  end
@@ -30,7 +30,7 @@ describe "Gtk3assist_combobox" do
30
30
  raise "Expected selected title to be 'Kasper' but it wasnt: '#{data[:data][:title]}'." if data[:data][:title] != "Christina"
31
31
 
32
32
  count = 0
33
- cba.rows do |data|
33
+ cba.items do |data|
34
34
  #puts data
35
35
  count += 1
36
36
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gtk3assist
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-09-16 00:00:00 Z
13
+ date: 2012-09-19 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gir_ffi-gtk
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- hash: 4372892411458411621
124
+ hash: -4051244528406198022
125
125
  segments:
126
126
  - 0
127
127
  version: "0"