tweet 0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/bin/ttime +36 -0
  2. data/bin/tweet +30 -0
  3. data/bin/tweetd +126 -0
  4. data/doc/classes/SimplePop.html +125 -0
  5. data/doc/classes/SimplePop.src/M000009.html +59 -0
  6. data/doc/classes/SimplePop.src/M000010.html +43 -0
  7. data/doc/classes/SimplePopWindow.html +126 -0
  8. data/doc/classes/SimplePopWindow.src/M000005.html +77 -0
  9. data/doc/classes/SimplePopWindow.src/M000006.html +36 -0
  10. data/doc/classes/SyslogNotifier.html +113 -0
  11. data/doc/classes/SyslogNotifier.src/M000003.html +34 -0
  12. data/doc/classes/SyslogNotifier.src/M000004.html +39 -0
  13. data/doc/classes/Tweet/Monitor.html +236 -0
  14. data/doc/classes/Tweet/Monitor.src/M000028.html +53 -0
  15. data/doc/classes/Tweet/Monitor.src/M000029.html +38 -0
  16. data/doc/classes/Tweet/Monitor.src/M000030.html +40 -0
  17. data/doc/classes/Tweet/Monitor.src/M000031.html +31 -0
  18. data/doc/classes/Tweet/Monitor.src/M000032.html +32 -0
  19. data/doc/classes/Tweet/Monitor.src/M000033.html +65 -0
  20. data/doc/classes/Tweet/Monitor.src/M000034.html +38 -0
  21. data/doc/classes/Tweet/Note.html +272 -0
  22. data/doc/classes/Tweet/Note.src/M000020.html +32 -0
  23. data/doc/classes/Tweet/Note.src/M000021.html +30 -0
  24. data/doc/classes/Tweet/Note.src/M000022.html +30 -0
  25. data/doc/classes/Tweet/Note.src/M000023.html +30 -0
  26. data/doc/classes/Tweet/Note.src/M000024.html +30 -0
  27. data/doc/classes/Tweet/Note.src/M000025.html +30 -0
  28. data/doc/classes/Tweet/Note.src/M000026.html +30 -0
  29. data/doc/classes/Tweet/Note.src/M000027.html +30 -0
  30. data/doc/classes/Tweet/Notifier.html +147 -0
  31. data/doc/classes/Tweet/Notifier.src/M000018.html +34 -0
  32. data/doc/classes/Tweet/Notifier.src/M000019.html +30 -0
  33. data/doc/classes/Tweet.html +336 -0
  34. data/doc/classes/Tweet.src/M000011.html +42 -0
  35. data/doc/classes/Tweet.src/M000012.html +30 -0
  36. data/doc/classes/Tweet.src/M000013.html +30 -0
  37. data/doc/classes/Tweet.src/M000014.html +30 -0
  38. data/doc/classes/Tweet.src/M000015.html +30 -0
  39. data/doc/classes/Tweet.src/M000016.html +30 -0
  40. data/doc/classes/Tweet.src/M000017.html +30 -0
  41. data/doc/classes/XOSDNotifier.html +113 -0
  42. data/doc/classes/XOSDNotifier.src/M000007.html +36 -0
  43. data/doc/classes/XOSDNotifier.src/M000008.html +38 -0
  44. data/doc/created.rid +1 -0
  45. data/doc/files/README.html +228 -0
  46. data/doc/files/bin/ttime.html +112 -0
  47. data/doc/files/bin/tweet.html +111 -0
  48. data/doc/files/bin/tweetd.html +163 -0
  49. data/doc/files/bin/tweetd.src/M000001.html +51 -0
  50. data/doc/files/bin/tweetd.src/M000002.html +30 -0
  51. data/doc/files/lib/tweet_rb.html +178 -0
  52. data/doc/files/plugins/simplepop_rb.html +97 -0
  53. data/doc/files/plugins/syslog_rb.html +101 -0
  54. data/doc/files/plugins/xosd_rb.html +96 -0
  55. data/doc/fr_class_index.html +53 -0
  56. data/doc/fr_file_index.html +53 -0
  57. data/doc/fr_method_index.html +79 -0
  58. data/doc/index.html +26 -0
  59. data/doc/rdoc-style.css +175 -0
  60. data/images/comments.png +0 -0
  61. data/lib/tweet.rb +437 -0
  62. data/plugins/simplepop.rb +128 -0
  63. data/plugins/syslog.rb +24 -0
  64. data/plugins/xosd.rb +23 -0
  65. metadata +142 -0
data/bin/ttime ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # = ttime
4
+ #
5
+ # == Synopsis
6
+ #
7
+ # A timer for tea. Or, I suppose, other things.
8
+ #
9
+ # == Usage
10
+ #
11
+ # ttime [minutes]
12
+ # You can even use fractional minutes.
13
+ #
14
+ # == Author
15
+ #
16
+ # Payton Swick, 2006
17
+
18
+ require 'rubygems'
19
+ require 'tweet'
20
+ require 'daemons'
21
+
22
+ minutes = ARGV[0]
23
+ unless minutes and minutes !~ /[A-Za-z]/
24
+ puts "ttime: a timer for tea or other things - uses tweet for notification."
25
+ puts "usage: ttime [number of minutes]"
26
+ puts "You can even use fractional minutes, eg: 1.3"
27
+ exit
28
+ end
29
+
30
+ Tweet.message("ttime starting...\\n(#{minutes} minute#{minutes.to_f==1 ? "":"s"})", 2)
31
+ print "ttime timing #{minutes} minute"+(minutes.to_f==1?"":"s")+"...\n"
32
+
33
+ Daemons.daemonize
34
+ sleep(minutes.to_f*60)
35
+
36
+ Tweet.message("ttime complete for #{minutes} minute"+(minutes.to_f==1?"":"s")+"!\\n#{Time.now.to_s}")
data/bin/tweet ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # = tweet
4
+ #
5
+ # == Synopsis
6
+ #
7
+ # Contacts a running tweetd server and prints text
8
+ # specified as an argument.
9
+ #
10
+ # == Usage
11
+ #
12
+ # tweet "<message text>" [duration]
13
+ #
14
+ # == Author
15
+ #
16
+ # Payton Swick, 2006
17
+ #
18
+
19
+ require 'rubygems'
20
+ require 'tweet'
21
+
22
+ msg = ARGV[0] if (defined? ARGV[0]) && ARGV[0].class == String
23
+ if not msg
24
+ puts "tweet: a simple script to send a message to tweetd."
25
+ puts "usage: tweet [message] [duration]"
26
+ puts "Duration may be omitted in which case the duration (if used by a plugin) will be infinite."
27
+ exit
28
+ end
29
+
30
+ Tweet.message(msg, ARGV[1])
data/bin/tweetd ADDED
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # = Tweet
4
+ #
5
+ # == Synopsis
6
+ #
7
+ # A generalized notification daemon. Can be petitioned by an arbitrary
8
+ # application to activate a notification. Notifications can be customized by
9
+ # the user via a plugin architecture. Examples include a GTK2 popup dialog, a
10
+ # syslog entry, or an email alert.
11
+ #
12
+ # Can also be required in a ruby script to access a running Tweet daemon (see
13
+ # Tweet.notify, Tweet.message, Tweet.running?, Tweet.stop).
14
+ #
15
+ # The website is here: http://tweet.rubyforge.org/
16
+ #
17
+ # == Usage
18
+ #
19
+ # tweetd [options]
20
+ #
21
+ # == Requirements
22
+ #
23
+ # - Ruby 1.8
24
+ #
25
+ # == Author
26
+ #
27
+ # Payton Swick, 2006
28
+ #
29
+ # == License Creative Commons GPL license.
30
+ # http://creativecommons.org/licenses/GPL/2.0/
31
+ #
32
+
33
+ require 'rubygems'
34
+ require 'tweet'
35
+ require 'pathname'
36
+ require 'daemons'
37
+
38
+ @config_dir = Pathname.new("#{ENV['HOME']}/.tweet")
39
+ @config_file = Pathname.new("#{@config_dir}/config")
40
+ @pri = Tweet::PRI['INFO']
41
+ @plugins_dir = Pathname.new("#{Tweet.where_am_i?}/plugins")
42
+ @requested_plugins = []
43
+ @config_requested_plugins = []
44
+ @plugins = []
45
+ @notifiers = []
46
+ @no_plugins = true
47
+ daemonize = false
48
+
49
+ # Read and parse the config file, if one exists. Create the default config
50
+ # file if no config file currently exists.
51
+ def parse_config
52
+ unless @config_dir.exist?
53
+ @config_dir.mkpath
54
+ end
55
+
56
+ unless @config_file.exist?
57
+ @config_file.open('w') do |file|
58
+ file << "---
59
+ plugin:
60
+ - SyslogNotifier
61
+ - SimplePop
62
+ "
63
+ end
64
+ end
65
+
66
+ if (@config_file.exist?) && (@config_file.readable?)
67
+ config = YAML.load_file(@config_file.to_s)
68
+ @pri = config['priority'] if config['priority']
69
+ @plugins_dir = Pathname.new(config['plugins']) if config['plugins']
70
+ if config['plugin']
71
+ config['plugin'].each { |plugin| @config_requested_plugins << plugin }
72
+ end
73
+ end
74
+ end
75
+
76
+ def register_plugins
77
+ Dir["#{@plugins_dir}/*.rb"].each { |x| load x }
78
+ end
79
+
80
+ parse_config
81
+
82
+ require 'optparse'
83
+ opts = OptionParser.new
84
+ opts.version = Tweet::VERSION
85
+ opts.program_name = "tweetd"
86
+ opts.separator "A notification daemon."
87
+ opts.separator ""
88
+ opts.separator "Options:"
89
+ opts.on("-h", "--help", "Print this help message and exit.") { puts opts.ver; puts opts; exit }
90
+ opts.on("-v", "--version", "Print version number and exit.") { puts "#{File.basename($0)} version #{Tweet::VERSION}"; exit }
91
+ opts.on("-c", "--config", "=FILE", "Use FILE as the config file (default: #{@config_file}).") { |file| @config_file = file; parse_config }
92
+ opts.on("-p", "--priority", "=LEVEL", Integer, "Don't print notifications lower (larger number) than LEVEL priority; run -L for list.") { |val| @pri = val }
93
+ opts.on("-L", "--priorities", "--list-priorities", "List all available priority levels and associated numbers (higher priority has lower number).") { (Tweet::PRI.sort { |a, b| a[1] <=> b[1]}).each { |lvl, num| puts "#{lvl} = #{num}" }; exit }
94
+ opts.on("-g", "--plugins", "=DIRECTORY", "Use the plugins directory DIRECTORY.") { |dir| $: << dir; @plugins_dir = Pathname.new(dir) }
95
+ opts.on("-n", "--notifier", "--plugin", "=PLUGIN", "Use the plugin PLUGIN; run -l for a list.") { |plugin| @requested_plugins << plugin }
96
+ opts.on("-l", "--list", "--list-plugins", "List all available plugins.") { register_plugins; Tweet::Notifier.registered_notifiers.each { |n| puts n }; exit }
97
+ opts.on("-d", "--daemon", "Start in the background.") { daemonize = true }
98
+ opts.on("-D", "--nodaemon", "Start in the foreground (default).") { daemonize = false }
99
+ opts.on("-i", "--info", "Prints info about running tweetd, if one exists.") { puts "tweetd is #{(Tweet.running?)? '' : 'not '}running"; exit }
100
+ opts.on("-q", "--quit", "Stop any running daemons.") { Tweet.stop; exit }
101
+ opts.parse(ARGV)
102
+
103
+ # Create a block to be executed when we start.
104
+ starttweet = Proc.new do
105
+ puts "Tweet starting (listening on port #{Tweet::PORT}), displaying notifications of level #{@pri} or higher."
106
+ tweetd = Tweet::Monitor.new(@pri)
107
+ register_plugins
108
+ @requested_plugins = @config_requested_plugins if @requested_plugins.empty?
109
+ unless @requested_plugins.all? { |p| tweetd.activate_notifier(p) }
110
+ $stderr.puts "Some plugins you specified are not registered. Run with -l to see registered plugins you can use."
111
+ exit
112
+ end
113
+ puts "No plugins specified. Running tweetd would be useless." if @requested_plugins.empty?
114
+ puts "Loaded plugins: #{@requested_plugins.join(', ')}"
115
+ tweetd.start
116
+ tweetd.join
117
+ end
118
+
119
+ if Tweet.running?
120
+ puts "Tweet appears to already be running. Use tweetd -q to stop it."
121
+ exit
122
+ end
123
+ if daemonize == true
124
+ Daemons.daemonize
125
+ end
126
+ starttweet.call
@@ -0,0 +1,125 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Class: SimplePop</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Class</span><br />SimplePop</td>
55
+ <td align="right">
56
+ <table cellspacing=0 cellpadding=2>
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../files/plugins/simplepop_rb.html">plugins/simplepop.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ <a href="Tweet/Notifier.html">
67
+ Tweet::Notifier
68
+ </a>
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </td>
73
+ </tr>
74
+ </table>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+ <div id="content">
79
+
80
+ <div class="description"><p>
81
+ GTK2 slider-window-based notifier plugin for tweet.
82
+ </p>
83
+ </div>
84
+
85
+
86
+
87
+ <div class="sectiontitle">Methods</div>
88
+ <ul>
89
+ <li><a href="#M000009">new</a></li>
90
+ <li><a href="#M000010">show</a></li>
91
+ </ul>
92
+
93
+
94
+
95
+
96
+ <div class="sectiontitle">Constants</div>
97
+ <table border='0' cellpadding='5'>
98
+ <tr valign='top'>
99
+ <td class="attr-name">XSCREENSAVER_WATCH</td>
100
+ <td>=</td>
101
+ <td class="attr-value">false</td>
102
+ </tr>
103
+ </table>
104
+
105
+
106
+ <div class="sectiontitle">Public Class methods</div>
107
+ <div class="method">
108
+ <div class="title">
109
+ <a name="M000009"></a><b>new</b>()
110
+ [ <a href="javascript:openCode('SimplePop.src/M000009.html')">source</a> ]
111
+ </div>
112
+ </div>
113
+ <div class="sectiontitle">Public Instance methods</div>
114
+ <div class="method">
115
+ <div class="title">
116
+ <a name="M000010"></a><b>show</b>(note)
117
+ [ <a href="javascript:openCode('SimplePop.src/M000010.html')">source</a> ]
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+ </div>
123
+
124
+ </body>
125
+ </html>
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head><title>new (SimplePop)</title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
+ <style>
9
+ .ruby-comment { color: green; font-style: italic }
10
+ .ruby-constant { color: #4433aa; font-weight: bold; }
11
+ .ruby-identifier { color: #222222; }
12
+ .ruby-ivar { color: #2233dd; }
13
+ .ruby-keyword { color: #3333FF; font-weight: bold }
14
+ .ruby-node { color: #777777; }
15
+ .ruby-operator { color: #111111; }
16
+ .ruby-regexp { color: #662222; }
17
+ .ruby-value { color: #662222; font-style: italic }
18
+ .kw { color: #3333FF; font-weight: bold }
19
+ .cmt { color: green; font-style: italic }
20
+ .str { color: #662222; font-style: italic }
21
+ .re { color: #662222; }
22
+ </style>
23
+ </head>
24
+ <body bgcolor="white">
25
+ <pre><span class="ruby-comment cmt"># File plugins/simplepop.rb, line 9</span>
26
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
27
+ <span class="ruby-ivar">@current_messages</span> = []
28
+
29
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Gtk</span>.<span class="ruby-identifier">main_level</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
30
+ <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
31
+ <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-identifier">init</span>
32
+ <span class="ruby-constant">Gtk</span>.<span class="ruby-identifier">main</span>
33
+ <span class="ruby-keyword kw">end</span>
34
+ <span class="ruby-keyword kw">end</span>
35
+
36
+ <span class="ruby-ivar">@suspend_popups</span> = <span class="ruby-keyword kw">false</span>
37
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">XSCREENSAVER_WATCH</span>
38
+ <span class="ruby-keyword kw">begin</span>
39
+ <span class="ruby-identifier">xscreensaver</span> = <span class="ruby-value">`which xscreensaver-command`</span>
40
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xscreensaver</span>
41
+ <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
42
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-node">&quot;|#{xscreensaver} -watch&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ss</span><span class="ruby-operator">|</span>
43
+ <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
44
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">ss</span>.<span class="ruby-identifier">gets</span>
45
+ <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^LOCK|^BLANK/</span>
46
+ <span class="ruby-ivar">@suspend_popups</span> = <span class="ruby-keyword kw">true</span>
47
+ <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^UNBLANK/</span>
48
+ <span class="ruby-ivar">@suspend_popups</span> = <span class="ruby-keyword kw">false</span>
49
+ <span class="ruby-keyword kw">end</span>
50
+ <span class="ruby-keyword kw">end</span>
51
+ <span class="ruby-keyword kw">end</span>
52
+ <span class="ruby-keyword kw">end</span>
53
+ <span class="ruby-keyword kw">end</span>
54
+ <span class="ruby-keyword kw">rescue</span>
55
+ <span class="ruby-keyword kw">end</span>
56
+ <span class="ruby-keyword kw">end</span>
57
+ <span class="ruby-keyword kw">end</span></pre>
58
+ </body>
59
+ </html>
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head><title>show (SimplePop)</title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
+ <style>
9
+ .ruby-comment { color: green; font-style: italic }
10
+ .ruby-constant { color: #4433aa; font-weight: bold; }
11
+ .ruby-identifier { color: #222222; }
12
+ .ruby-ivar { color: #2233dd; }
13
+ .ruby-keyword { color: #3333FF; font-weight: bold }
14
+ .ruby-node { color: #777777; }
15
+ .ruby-operator { color: #111111; }
16
+ .ruby-regexp { color: #662222; }
17
+ .ruby-value { color: #662222; font-style: italic }
18
+ .kw { color: #3333FF; font-weight: bold }
19
+ .cmt { color: green; font-style: italic }
20
+ .str { color: #662222; font-style: italic }
21
+ .re { color: #662222; }
22
+ </style>
23
+ </head>
24
+ <body bgcolor="white">
25
+ <pre><span class="ruby-comment cmt"># File plugins/simplepop.rb, line 42</span>
26
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show</span>(<span class="ruby-identifier">note</span>)
27
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@suspend_popups</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
28
+
29
+ <span class="ruby-comment cmt"># Create a new window.</span>
30
+ <span class="ruby-identifier">element</span> = <span class="ruby-constant">SimplePopWindow</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">note</span>, <span class="ruby-identifier">note</span>.<span class="ruby-identifier">duration</span>, <span class="ruby-ivar">@current_messages</span>.<span class="ruby-identifier">last</span>)
31
+
32
+ <span class="ruby-comment cmt"># Add the new window to the list of windows.</span>
33
+ <span class="ruby-ivar">@current_messages</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">element</span>
34
+
35
+ <span class="ruby-comment cmt"># Call notify which calls Gtk.main (blocks) until the window is clicked or</span>
36
+ <span class="ruby-comment cmt"># times out.</span>
37
+ <span class="ruby-identifier">element</span>.<span class="ruby-identifier">notify</span> <span class="ruby-comment cmt"># blocks until hidden.</span>
38
+
39
+ <span class="ruby-comment cmt"># Remove the stored reference to this window.</span>
40
+ <span class="ruby-ivar">@current_messages</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">element</span>
41
+ <span class="ruby-keyword kw">end</span></pre>
42
+ </body>
43
+ </html>
@@ -0,0 +1,126 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head>
7
+ <title>Class: SimplePopWindow</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
10
+
11
+ <script language="JavaScript" type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function toggleSource( id )
15
+ {
16
+ var elem
17
+ var link
18
+
19
+ if( document.getElementById )
20
+ {
21
+ elem = document.getElementById( id )
22
+ link = document.getElementById( "l_" + id )
23
+ }
24
+ else if ( document.all )
25
+ {
26
+ elem = eval( "document.all." + id )
27
+ link = eval( "document.all.l_" + id )
28
+ }
29
+ else
30
+ return false;
31
+
32
+ if( elem.style.display == "block" )
33
+ {
34
+ elem.style.display = "none"
35
+ link.innerHTML = "show source"
36
+ }
37
+ else
38
+ {
39
+ elem.style.display = "block"
40
+ link.innerHTML = "hide source"
41
+ }
42
+ }
43
+
44
+ function openCode( url )
45
+ {
46
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
47
+ }
48
+ // ]]>
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
54
+ <td class="file-title"><span class="file-title-prefix">Class</span><br />SimplePopWindow</td>
55
+ <td align="right">
56
+ <table cellspacing=0 cellpadding=2>
57
+ <tr valign="top">
58
+ <td>In:</td>
59
+ <td>
60
+ <a href="../files/plugins/simplepop_rb.html">plugins/simplepop.rb</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>Parent:</td>
65
+ <td>
66
+ Gtk::Window
67
+ </td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ </table>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+ <div id="content">
77
+
78
+
79
+
80
+
81
+ <div class="sectiontitle">Methods</div>
82
+ <ul>
83
+ <li><a href="#M000005">new</a></li>
84
+ <li><a href="#M000006">notify</a></li>
85
+ </ul>
86
+
87
+
88
+
89
+
90
+
91
+ <div class="sectiontitle">Attributes</div>
92
+ <table border='0' cellpadding='5'>
93
+ <tr valign='top'>
94
+ <td class='attr-rw'>
95
+ [R]
96
+ </td>
97
+ <td class='attr-name'>start_y</td>
98
+ <td class='attr-desc'></td>
99
+ </tr>
100
+ </table>
101
+
102
+ <div class="sectiontitle">Public Class methods</div>
103
+ <div class="method">
104
+ <div class="title">
105
+ <a name="M000005"></a><b>new</b>(note, duration=0, highest=nil)
106
+ [ <a href="javascript:openCode('SimplePopWindow.src/M000005.html')">source</a> ]
107
+ </div>
108
+ </div>
109
+ <div class="sectiontitle">Public Instance methods</div>
110
+ <div class="method">
111
+ <div class="title">
112
+ <a name="M000006"></a><b>notify</b>()
113
+ [ <a href="javascript:openCode('SimplePopWindow.src/M000006.html')">source</a> ]
114
+ </div>
115
+ <div class="description">
116
+ <p>
117
+ Activates the notification by displaying the window.
118
+ </p>
119
+ </div>
120
+ </div>
121
+ </div>
122
+
123
+ </div>
124
+
125
+ </body>
126
+ </html>
@@ -0,0 +1,77 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+ <html>
6
+ <head><title>new (SimplePopWindow)</title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
+ <style>
9
+ .ruby-comment { color: green; font-style: italic }
10
+ .ruby-constant { color: #4433aa; font-weight: bold; }
11
+ .ruby-identifier { color: #222222; }
12
+ .ruby-ivar { color: #2233dd; }
13
+ .ruby-keyword { color: #3333FF; font-weight: bold }
14
+ .ruby-node { color: #777777; }
15
+ .ruby-operator { color: #111111; }
16
+ .ruby-regexp { color: #662222; }
17
+ .ruby-value { color: #662222; font-style: italic }
18
+ .kw { color: #3333FF; font-weight: bold }
19
+ .cmt { color: green; font-style: italic }
20
+ .str { color: #662222; font-style: italic }
21
+ .re { color: #662222; }
22
+ </style>
23
+ </head>
24
+ <body bgcolor="white">
25
+ <pre><span class="ruby-comment cmt"># File plugins/simplepop.rb, line 65</span>
26
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">note</span>, <span class="ruby-identifier">duration</span>=<span class="ruby-value">0</span>, <span class="ruby-identifier">highest</span>=<span class="ruby-keyword kw">nil</span>)
27
+ <span class="ruby-ivar">@note</span> = <span class="ruby-identifier">note</span>
28
+ <span class="ruby-ivar">@duration</span> = <span class="ruby-identifier">duration</span>
29
+ <span class="ruby-ivar">@width</span> = <span class="ruby-value">260</span>
30
+ <span class="ruby-ivar">@height</span> = <span class="ruby-value">80</span>
31
+
32
+ <span class="ruby-keyword kw">super</span>(<span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Window</span><span class="ruby-operator">::</span><span class="ruby-constant">POPUP</span>)
33
+
34
+ <span class="ruby-identifier">resize</span>(<span class="ruby-ivar">@width</span>,<span class="ruby-ivar">@height</span>)
35
+ <span class="ruby-identifier">stick</span>
36
+ <span class="ruby-identifier">title</span> = <span class="ruby-ivar">@note</span>.<span class="ruby-identifier">title</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@note</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:title</span>
37
+ <span class="ruby-identifier">title</span> = <span class="ruby-ivar">@note</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">title</span>
38
+
39
+ <span class="ruby-ivar">@root_win</span> = <span class="ruby-constant">Gdk</span><span class="ruby-operator">::</span><span class="ruby-constant">Window</span>.<span class="ruby-identifier">default_root_window</span>
40
+ <span class="ruby-ivar">@start_x</span> = <span class="ruby-ivar">@root_win</span>.<span class="ruby-identifier">geometry</span>[<span class="ruby-value">2</span>]<span class="ruby-operator">-</span><span class="ruby-ivar">@width</span><span class="ruby-operator">-</span><span class="ruby-value">10</span>
41
+ <span class="ruby-ivar">@start_y</span> = <span class="ruby-ivar">@root_win</span>.<span class="ruby-identifier">geometry</span>[<span class="ruby-value">3</span>]<span class="ruby-operator">-</span><span class="ruby-ivar">@height</span>
42
+ <span class="ruby-ivar">@start_y</span> = (<span class="ruby-identifier">highest</span>.<span class="ruby-identifier">start_y</span><span class="ruby-operator">-</span><span class="ruby-ivar">@height</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">highest</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:start_y</span>
43
+ <span class="ruby-identifier">screen_top</span> = <span class="ruby-value">0</span>
44
+ <span class="ruby-ivar">@start_y</span> = <span class="ruby-ivar">@root_win</span>.<span class="ruby-identifier">geometry</span>[<span class="ruby-value">3</span>]<span class="ruby-operator">-</span><span class="ruby-ivar">@height</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@start_y</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">screen_top</span>
45
+ <span class="ruby-identifier">move</span>(<span class="ruby-ivar">@start_x</span>,<span class="ruby-ivar">@start_y</span>)
46
+
47
+ <span class="ruby-ivar">@note</span> = <span class="ruby-ivar">@note</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;&lt;&quot;</span>, <span class="ruby-value str">&quot;&amp;lt;&quot;</span>)
48
+ <span class="ruby-ivar">@note</span> = <span class="ruby-ivar">@note</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;&gt;&quot;</span>, <span class="ruby-value str">&quot;&amp;gt;&quot;</span>)
49
+
50
+ <span class="ruby-ivar">@button</span> = <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Button</span>.<span class="ruby-identifier">new</span>
51
+ <span class="ruby-identifier">frame</span> = <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Frame</span>.<span class="ruby-identifier">new</span>
52
+ <span class="ruby-identifier">button_box</span> = <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">HBox</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-value">0</span>)
53
+ <span class="ruby-identifier">image</span> = <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Stock</span><span class="ruby-operator">::</span><span class="ruby-constant">DIALOG_WARNING</span>, <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">IconSize</span><span class="ruby-operator">::</span><span class="ruby-constant">DIALOG</span>)
54
+ <span class="ruby-identifier">label</span> = <span class="ruby-constant">Gtk</span><span class="ruby-operator">::</span><span class="ruby-constant">Label</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@note</span>)
55
+
56
+ <span class="ruby-identifier">label</span>.<span class="ruby-identifier">width_chars</span> = (<span class="ruby-ivar">@width</span><span class="ruby-operator">-</span><span class="ruby-identifier">image</span>.<span class="ruby-identifier">width_request</span>)<span class="ruby-operator">/</span><span class="ruby-value">10</span>
57
+ <span class="ruby-identifier">col</span> = (<span class="ruby-ivar">@width</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">image</span>.<span class="ruby-identifier">width_request</span>)<span class="ruby-operator">/</span><span class="ruby-value">10</span>
58
+ <span class="ruby-identifier">col</span> = <span class="ruby-value">40</span>
59
+ <span class="ruby-identifier">wrapped_text</span> = <span class="ruby-identifier">label</span>.<span class="ruby-identifier">text</span>
60
+ <span class="ruby-identifier">wrapped_text</span> = <span class="ruby-identifier">wrapped_text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/</span>, <span class="ruby-value str">&quot;\\1\\3\n&quot;</span>)
61
+ <span class="ruby-identifier">wrapped_text</span> = <span class="ruby-identifier">wrapped_text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>)[<span class="ruby-value">0</span> <span class="ruby-operator">..</span> <span class="ruby-value">4</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
62
+ <span class="ruby-identifier">label</span>.<span class="ruby-identifier">set_markup</span>(<span class="ruby-node">&quot;&lt;small&gt;#{wrapped_text}&lt;/small&gt;&quot;</span>)
63
+
64
+ <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">button_box</span>)
65
+ <span class="ruby-identifier">button_box</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">image</span>)
66
+ <span class="ruby-identifier">button_box</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">label</span>)
67
+ <span class="ruby-ivar">@button</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">frame</span>)
68
+
69
+ <span class="ruby-ivar">@button</span>.<span class="ruby-identifier">signal_connect</span>(<span class="ruby-value str">'clicked'</span>) { <span class="ruby-ivar">@sleep_thread</span>.<span class="ruby-identifier">kill</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@sleep_thread</span> }
70
+ <span class="ruby-identifier">add</span>(<span class="ruby-ivar">@button</span>)
71
+
72
+ <span class="ruby-identifier">realize</span>
73
+ <span class="ruby-ivar">@window</span> = <span class="ruby-identifier">window</span> <span class="ruby-comment cmt"># The GDK window object this uses.</span>
74
+ <span class="ruby-identifier">show_all</span>
75
+ <span class="ruby-keyword kw">end</span></pre>
76
+ </body>
77
+ </html>