knjrbfw 0.0.91 → 0.0.92

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.91
1
+ 0.0.92
data/knjrbfw.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjrbfw}
8
- s.version = "0.0.91"
8
+ s.version = "0.0.92"
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 = %q{2012-08-30}
12
+ s.date = %q{2012-09-03}
13
13
  s.description = %q{Including stuff for HTTP, SSH and much more.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.extra_rdoc_files = [
data/lib/knj/gtk2.rb CHANGED
@@ -190,9 +190,9 @@ class Knj::Gtk2
190
190
  class_str = object.class.to_s
191
191
 
192
192
  if object.is_a?(Gtk::Label) or object.is_a?(Gtk::Button)
193
- object.label = GetText.gettext(object.label)
193
+ object.label = GetText.gettext(object.label) if !object.label.to_s.strip.empty?
194
194
  elsif object.is_a?(Gtk::Window)
195
- object.title = GetText.gettext(object.title)
195
+ object.title = GetText.gettext(object.title) if !object.title.to_s.strip.empty?
196
196
  end
197
197
  end
198
198
  end
data/lib/knj/gtk2_tv.rb CHANGED
@@ -1,20 +1,35 @@
1
1
  #This module contains various helper-methods for handeling stuff regarding treeviews.
2
2
  module Knj::Gtk2::Tv
3
+ ALLOWED_ARGS = [:cols, :reorderable, :sortable, :type]
4
+
3
5
  #Initializes a treeview with a model and a number of columns. Returns a hash containing various data like the renderers.
4
6
  #===Examples
5
7
  # Knj::Gtk2::Tv.init(treeview, ["ID", "Name"])
6
- def self.init(tv, args)
8
+ def self.init(tv, rargs)
7
9
  ret = {
8
10
  :renderers => []
9
11
  }
10
12
 
11
- if args.is_a?(Array)
12
- columns = args
13
- args = {}
13
+ if rargs.is_a?(Array)
14
+ columns = rargs
15
+ rargs = {}
14
16
  else
15
- columns = args[:cols]
17
+ columns = rargs[:cols]
18
+ end
19
+
20
+
21
+ #Default arguments.
22
+ rargs = {
23
+ :reorderable => true,
24
+ :sortable => true
25
+ }.merge!(rargs)
26
+
27
+ rargs.each do |key, val|
28
+ raise "Invalid argument: '#{key}'." if !ALLOWED_ARGS.include?(key)
16
29
  end
17
30
 
31
+
32
+ #Spawn store.
18
33
  model_args = []
19
34
  columns.each do |args|
20
35
  if args.is_a?(String)
@@ -32,7 +47,7 @@ module Knj::Gtk2::Tv
32
47
  end
33
48
  end
34
49
 
35
- if args[:type] == :treestore
50
+ if rargs[:type] == :treestore
36
51
  list_store = Gtk::TreeStore.new(*model_args)
37
52
  else
38
53
  list_store = Gtk::ListStore.new(*model_args)
@@ -79,8 +94,13 @@ module Knj::Gtk2::Tv
79
94
  end
80
95
 
81
96
  col.spacing = 0
82
- col.reorderable = true
83
- col.sort_column_id = count
97
+ col.reorderable = rargs[:reorderable] if !args.key?(:reorderable) or args[:reorderable]
98
+
99
+ if !rargs[:sortable]
100
+ col.sort_column_id = -1
101
+ else
102
+ col.sort_column_id = count
103
+ end
84
104
 
85
105
  if args.key?(:fixed_width)
86
106
  col.sizing = Gtk::TreeViewColumn::FIXED
data/lib/knj/objects.rb CHANGED
@@ -166,7 +166,7 @@ class Knj::Objects
166
166
 
167
167
  if callback.key?("signal") and args.key?("signal") and callback["signal"] == args["signal"]
168
168
  docall = true
169
- elsif callback["signals"] and args["signal"] and callback["signals"].index(args["signal"]) != nil
169
+ elsif callback["signals"] and args["signal"] and callback["signals"].include?(args["signal"])
170
170
  docall = true
171
171
  end
172
172
 
@@ -185,6 +185,7 @@ class Knj::Objects
185
185
 
186
186
  callback["block"].call(*callargs)
187
187
  elsif callback["callback"]
188
+ require "php4r"
188
189
  Php4r.call_user_func(callback["callback"], args)
189
190
  else
190
191
  raise "No valid callback given."
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.91
5
+ version: 0.0.92
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-08-30 00:00:00 +02:00
13
+ date: 2012-09-03 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -392,7 +392,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
392
392
  requirements:
393
393
  - - ">="
394
394
  - !ruby/object:Gem::Version
395
- hash: -1209507472905610326
395
+ hash: -538892594692910848
396
396
  segments:
397
397
  - 0
398
398
  version: "0"