Top «Prev(2007-03-08) Latest Next(2007-03-21)» Edit

pterjan's diary


2007-03-09

  Tray update

Reading a discussion on IRC, I revived a small Ruby script I had written last year in ten minutes after someone asked for it on LinuxFR. It basically creates a small trayicon telling you if you have new packages available, original isn't it ?

So, I decided to port it from gtktrayicon to GtkStatusIcon, and it was really trivial. The code is more simple now, and even better (I no longer hardcode the icon size).

2c2
< require 'gtktrayicon'
---
> require 'gtk2'
14,15c14,15
<                               $icon.set(Gtk::Stock::NO, Gtk::IconSize::SMALL_TOOLBAR)
<                               $tooltips.set_tip($tray, "\n#{count.to_s} new packages available:\n#{packages}", nil)
---
>                               $icon.stock=Gtk::Stock::NO
>                               $icon.tooltip="\n#{count.to_s} new packages available:\n#{packages}"
17,18c17,18
<                               $icon.set(Gtk::Stock::YES, Gtk::IconSize::SMALL_TOOLBAR)
<                               $tooltips.set_tip($tray, "\nThe system is up to date.\n", nil)
---
>                               $icon.stock=Gtk::Stock::YES
>                               $icon.tooltip="\nThe system is up to date.\n"
28,32c28,30
< $tray = Gtk::TrayIcon.new("update")
< $icon=Gtk::Image.new(Gtk::Stock::REFRESH, Gtk::IconSize::SMALL_TOOLBAR)
< $tray.add($icon)
< $tooltips = Gtk::Tooltips.new
< $tooltips.set_tip($tray, "loading...", nil)
---
> $icon = Gtk::StatusIcon.new
> $icon.stock=Gtk::Stock::REFRESH
> $icon.tooltip="loading...";
47,50c45,46
< $tray.add_events(Gdk::Event::BUTTON_PRESS_MASK)
< $tray.add_events(Gdk::Event::BUTTON_RELEASE_MASK)
< $tray.signal_connect('button-release-event') { |w, e|
<         menu.popup(nil, nil, e.button, e.time) if e.button == 3
---
> $icon.signal_connect('popup-menu') { |w, button, time|
>         menu.popup(nil, nil, button, time)
63d58
< $tray.show_all


2004|06|07|08|09|11|
2005|01|02|05|06|07|08|09|10|11|12|
2006|01|02|03|06|08|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|12|
2011|02|04|06|
2012|01|05|11|
2013|01|02|04|06|
2014|02|
2015|06|
2017|05|07|12|