cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #02817
[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins/DbusDemosRuby into lp:cairo-dock-plug-ins
Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins/DbusDemosRuby into lp:cairo-dock-plug-ins.
Requested reviews:
Cairo-Dock Team (cairo-dock-team)
For more details, see:
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins/DbusDemosRuby/+merge/50076
Recreating and updating demo_ruby applet to work with CDApplet interface
--
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins/DbusDemosRuby/+merge/50076
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins/DbusDemosRuby into lp:cairo-dock-plug-ins.
=== added directory 'Dbus/demos/demo_ruby'
=== added file 'Dbus/demos/demo_ruby/README'
--- Dbus/demos/demo_ruby/README 1970-01-01 00:00:00 +0000
+++ Dbus/demos/demo_ruby/README 2011-02-17 00:21:22 +0000
@@ -0,0 +1,19 @@
+In order to use this applet, it is necessary to install Ruby, Rubygems and the gems dbus and parseconfig.
+
+# Installation process (Debian/Ubuntu)
+
+[+] Ruby 1.8: sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 acpi
+[+] Rubygems: (sudo) apt-get install rubygems
+[+] Gem parseconfig: (sudo) gem install parseconfig
+[+] Gem Dbus: (sudo) gem install ruby-dbus
+
+# Tips
+
+When running Cairo-Dock through terminal, for example, cairo-dock -c, check if any message regarding execution permission is being shown. If so, set execution permission to the applet, chmod a+x 755 demo_ruby
+
+# Contact me
+
+Any doubt, suggestion or anything else, except asking for some money, I would be pleased to received a message from you.
+
+Author: Eduardo Mucelli Rezende Oliveira
+E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
=== added file 'Dbus/demos/demo_ruby/demo_ruby'
--- Dbus/demos/demo_ruby/demo_ruby 1970-01-01 00:00:00 +0000
+++ Dbus/demos/demo_ruby/demo_ruby 2011-02-17 00:21:22 +0000
@@ -0,0 +1,127 @@
+#!/usr/bin/ruby
+
+# This is a part of the external demo_ruby applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# This very simple applet features a counter from 0 to max_value. It displays the counter on the icon with a gauge and a quick info.
+# Scroll on the icon increase or decrease the counter
+# The menu offers the possibility to set some default value
+# Left click on the icon will set a random value
+# Middle click on the icon will raise a dialog asking you to set the value you want
+# If you drop some text on the icon, it will be used as the icon's label
+# Be aware to the messages, they are very wise :-)
+
+%w{rubygems dbus parseconfig CDApplet}.each { |x| require x } # requirements, do not forget CDApplet, it is not like Python
+
+class String
+ def to_b # string to boolean
+ ["true", "1", "T", "t"].include?(self.downcase)
+ end
+end
+
+class Applet < CDApplet
+ attr_accessor :counter, :configuration
+ def initialize
+ self.counter = 0
+ super
+ end
+ def start
+ self.icon.ShowDialog("I'm connected to Cairo-Dock !", 4) # show a dialog with this message for 4 seconds
+ self.icon.SetQuickInfo("#{self.counter}") # write the counter value on the icon
+ self.icon.AddDataRenderer("gauge", 1, self.configuration['theme']) # set 1 gauge with the theme read in config
+ self.icon.RenderValues([Float(self.counter)/self.configuration['max_value']]) # draw the gauge with an initial value
+
+ self.sub_icons.AddSubIcons(["icon 1", "firefox-3.0", "id1", "icon 3", "thunderbird", "id3", "icon 4", "nautilus", "id4"])
+ self.sub_icons.RemoveSubIcon("id2") # remove the 2nd icon of our sub-dock
+ self.sub_icons.SetQuickInfo("1", "id1") # write the ID on each icon of the sub-dock
+ self.sub_icons.SetQuickInfo("3", "id3")
+ self.sub_icons.SetQuickInfo("4", "id4")
+ end
+
+ def get_config keyfile
+ self.configuration = {}
+ self.configuration['max_value'] = keyfile.params['Configuration']['max value'].to_i
+ self.configuration['theme'] = keyfile.params['Configuration']['theme']
+ self.configuration['yes_no'] = keyfile.params['Configuration']['yesno'].to_b
+ end
+
+ # callbacks on the main icon
+ def on_click iState
+ p "[+] roger, right-click"
+ render_counter (self.counter+10)
+ end
+ def on_middle_click
+ p "[+] yes sir, middle-click received"
+ self.icon.AskValue("Set the value you want", self.counter, self.configuration['max_value'])
+ end
+ def on_build_menu
+ p "[+] let's build the menu"
+ self.icon.PopulateMenu(["Reset the counter", "Set Medium Value", "Set Max Value"])
+ end
+ def on_menu_select param
+ p "[+] let me guess, somebody chose the menu identified by the ID #{param}"
+ if param == 0
+ render_counter 0
+ elsif param == 1
+ render_counter self.configuration['max_value']/2
+ else
+ render_counter self.configuration['max_value']
+ end
+ end
+ def on_scroll scroll_up
+ p "[+] is there anybody out there scrolling #{scroll_up ? "up" : "down"} on my icon ?"
+ if scroll_up
+ count = [self.configuration['max_value'], self.counter + 1].min
+ else
+ count = self.counter - 1
+ end
+ render_counter count
+ end
+ def on_drop_data dropped_data
+ print "[+] ops, someone let #{dropped_data} fall into my icon"
+ self.icon.SetLabel(dropped_data)
+ end
+ def on_answer answer
+ p "[+] answer: #{answer}"
+ render_counter answer
+ end
+
+ # callbacks on the applet
+ def stop
+ p "[+] bye bye"
+ exit
+ end
+ def reload
+ p "[+] our module was reloaded, welcome back!"
+ self.icon.AddDataRenderer("gauge", 1, myApplet.config['theme'])
+ self.icon.RenderValues([Float(self.counter)/self.configuration['max_value']])
+ self.sub_icons.RemoveSubIcon("any")
+ self.sub_icons.AddSubIcons(["icon 1", "firefox-3.0", "id1", "icon 2", "natilus", "id2", "icon 3", "thunderbird", "id3"])
+ end
+
+ # callbacks on the sub-icons
+ def on_click_sub_icon state, icon_id
+ p "[+] something tells me that you clicked on the icon #{icon_id}"
+ end
+
+ def render_counter cont
+ self.counter = cont # equivalent to the set_count method in demo_python
+ percent = Float(self.counter) / self.configuration['max_value']
+ self.icon.RenderValues([percent])
+ self.icon.SetQuickInfo("#{self.counter.to_i}")
+ end
+end
+
+Applet.new.run
=== added file 'Dbus/demos/demo_ruby/icon'
Binary files Dbus/demos/demo_ruby/icon 1970-01-01 00:00:00 +0000 and Dbus/demos/demo_ruby/icon 2011-02-17 00:21:22 +0000 differ
=== modified file 'Dbus/interfaces/ruby/CDApplet.rb'
--- Dbus/interfaces/ruby/CDApplet.rb 2011-02-12 03:01:04 +0000
+++ Dbus/interfaces/ruby/CDApplet.rb 2011-02-17 00:21:22 +0000
@@ -1,9 +1,9 @@
#!/usr/bin/ruby
-# This is a part of the external Ruby Battery applet for Cairo-Dock
-#
-# Author: Eduardo Mucelli Rezende Oliveira
-# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+# This is a part of the external Ruby Interface for Cairo-Dock
+
+# Author: Fabounet and Eduardo Mucelli Rezende Oliveira
+# E-mail: fabounet@xxxxxxxxxxxx, edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -263,7 +263,7 @@
end
self.sub_icons.on_signal("on_click_sub_icon") do |iState, sub_icon_id|
- self.on_click_sub_icon iState sub_icon_id
+ self.on_click_sub_icon iState, sub_icon_id
end
self.sub_icons.on_signal("on_middle_click_sub_icon") do |sub_icon_id|
@@ -271,7 +271,7 @@
end
self.sub_icons.on_signal("on_scroll_sub_icon") do |bScrollUp, sub_icon_id|
- self.on_scroll_sub_icon bScrollUp sub_icon_id
+ self.on_scroll_sub_icon bScrollUp, sub_icon_id
end
self.sub_icons.on_signal("on_build_menu_sub_icon") do |sub_icon_id|
@@ -279,7 +279,7 @@
end
self.sub_icons.on_signal("on_drop_data_sub_icon") do |cReceivedData, sub_icon_id|
- self.on_drop_data_sub_icon cReceivedData sub_icon_id
+ self.on_drop_data_sub_icon cReceivedData, sub_icon_id
end
end
Follow ups