gtk3assist 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -3,8 +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)
7
- gir_ffi (0.4.0)
6
+ gir_ffi (0.4.1)
8
7
  ffi (~> 1.0.8)
9
8
  indentation (~> 0.0.6)
10
9
  gir_ffi-gtk (0.4.0)
@@ -17,7 +16,6 @@ GEM
17
16
  rake
18
17
  rdoc
19
18
  json (1.7.5)
20
- json (1.7.5-java)
21
19
  rake (0.9.2.2)
22
20
  rdoc (3.12)
23
21
  json (~> 1.4)
@@ -32,7 +30,6 @@ GEM
32
30
  xml-simple (1.1.1)
33
31
 
34
32
  PLATFORMS
35
- java
36
33
  ruby
37
34
 
38
35
  DEPENDENCIES
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/gtk3assist.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gtk3assist"
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
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"]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/gtk3assist_builder.rb",
31
31
  "lib/gtk3assist_combobox.rb",
32
32
  "lib/gtk3assist_msgbox.rb",
33
+ "lib/gtk3assist_threadding.rb",
33
34
  "lib/gtk3assist_treeview.rb",
34
35
  "spec/gtk3assist_builder.glade",
35
36
  "spec/gtk3assist_builder_spec.rb",
data/lib/gtk3assist.rb CHANGED
@@ -9,11 +9,4 @@ class Gtk3assist
9
9
  raise "Still not defined: '#{name}'." if !Gtk3assist.const_defined?(name)
10
10
  return Gtk3assist.const_get(name)
11
11
  end
12
-
13
- #Enables other threads to be run and interrupts to be used (<CTRL> + <C>).
14
- def self.enable_threadding
15
- return nil if @enable_threadding
16
- @enable_threadding = true
17
- GLib.idle_add(GLib::PRIORITY_DEFAULT_IDLE, Proc.new{Thread.pass; true}, nil, nil)
18
- end
19
12
  end
@@ -0,0 +1,37 @@
1
+ class Gtk3assist::Threadding
2
+ #Enables other threads to be run and interrupts to be used (<CTRL> + <C>).
3
+ def self.enable_threadding(args = nil)
4
+ #Never start this more than once.
5
+ return nil if @enable_threadding
6
+ @enable_threadding = true
7
+
8
+ #Amount of time to check if a new thread wants to run.
9
+ if args and args[:sleep]
10
+ @time = args[:sleep]
11
+ else
12
+ @time = 100
13
+ end
14
+
15
+ #Call the method (which then calls itself based on timings).
16
+ enable_threadding_pass
17
+ end
18
+
19
+ private
20
+
21
+ #Passes to another running thread. Based on the time something else is running, the pass will be called again as soon as possible or waiting a small amount of time to check again if not.
22
+ def self.enable_threadding_pass(*args)
23
+ t_begin = Time.now.to_f
24
+ Thread.pass
25
+ t_run = Time.now.to_f - t_begin
26
+
27
+ if t_run < 0.0001
28
+ #Run again after a small amount of time to prevent 100% CPU.
29
+ GLib.timeout_add(GLib::PRIORITY_DEFAULT_IDLE, @time, self.method(:enable_threadding_pass), nil, nil)
30
+ return false
31
+ else
32
+ #Run again on next idle.
33
+ GLib.idle_add(GLib::PRIORITY_DEFAULT_IDLE, self.method(:enable_threadding_pass), nil, nil)
34
+ return false
35
+ end
36
+ end
37
+ 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.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -101,6 +101,7 @@ files:
101
101
  - lib/gtk3assist_builder.rb
102
102
  - lib/gtk3assist_combobox.rb
103
103
  - lib/gtk3assist_msgbox.rb
104
+ - lib/gtk3assist_threadding.rb
104
105
  - lib/gtk3assist_treeview.rb
105
106
  - spec/gtk3assist_builder.glade
106
107
  - spec/gtk3assist_builder_spec.rb
@@ -121,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
122
  requirements:
122
123
  - - ">="
123
124
  - !ruby/object:Gem::Version
124
- hash: -1109653689086949800
125
+ hash: -4599824558676846179
125
126
  segments:
126
127
  - 0
127
128
  version: "0"