17 feb. 2010 : PHP-GTK Application descriptions can now be submitted in Brazilian Portuguese too. Thanks Bruno Bandeira !.

German and Italian still missing: who will contribute the translated categories for these languages ? Contact the team to offer your translations !

Desktop Gadget - a small widget moving around your screen

DesktopGadget demo 1 The DesktopGadget is a small window moving around you desktop screen ; it's a container widget and is able to contains usefull object for short information or notification.

Details

DesktopGadget demo2 DesktopGadget demo3 DesktopGadget is :

  • as small as possible and display short messages or notification ; in given code, this is just a literal clock ; I intend to build a Google calendar gadget notifier.
  • this visual gadget is movable all arround the screen ; there is some options in script code to change display and position (on top, on desktop ...)
  • position is saved in a configuration file using Config class
  • given code is fully object oriented and allow some changes
  • if you can write some php-code and have some Gtk skill, you could be able to write some (un)usefull gadgets.

The most interesting part of code is at the end and show you how it's very easy to add some gadgets :

<?php
# include some classes code before ...

# an example gadget (it's just a gtkWidget)
class ClockGadget extends GtkLabel{
    protected
$timeout_id;
    protected
$format;

    public function
__construct($format = 'd/m - H:i:s'){
       
parent::__construct();
       
$this->format=$format;
       
$this->timeout_id = Gtk::timeout_add(1000, array($this, 'on_timeout'));
       
$this->modify_font(new PangoFontDescription('Sans 7'));
       
$this->on_timeout();
    }

    public function
on_timeout(){
       
$this->set_text(date($this->format));
        return
true;
    }
}


$gadget = new DesktopGadget($title='Desktop Gadget');
$gadget->pack_start($clock = new ClockGadget());

Gtk::main();
?>

Restrictions

You should have write acces to directory where this script is running to save gadget position.

Source Code

source code is provided as a link below for free as LGPL licence ; also available here

Links

  • GtkWindow API : set_skip_taskbar_hint, set_skip_pager_hint, set_keep_above, (un)stick, set_decorated and custructor

Todo

  • write some gadgets : google calendar, hosts pinging, email watcher for example
  • write a configuration interface
AttachmentSize
desktop-gadget.php_.txt10.05 KB