From 4f71ae2f997423339519fa9b9e693cfa6a6a4e9f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 28 Mar 2008 15:54:10 +0000 Subject: - applet: o switch to HAL for detecting new plugged USB devices (no more polling and fix memory leak in libmodprobe (#38601)) git-svn-id: http://svn.mandriva.com/svn/soft/draksnapshot/trunk@241089 99302b65-d5f7-0310-b3dd-f8cd6f4e3d94 --- draksnapshot-applet | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'draksnapshot-applet') diff --git a/draksnapshot-applet b/draksnapshot-applet index d1d1a09..bc48a26 100755 --- a/draksnapshot-applet +++ b/draksnapshot-applet @@ -29,6 +29,7 @@ use interactive; use common; use run_program; use detect_devices; +use dbus_object; use feature 'state'; use Gtk2::Pango; @@ -70,6 +71,29 @@ my %actions = ( 'configure' => { name => N("Configure"), launch => \&configure } ); +my $hal_dn = 'org.freedesktop.Hal'; +my $hal_manager = "$hal_dn.Manager"; +my $manager_path = '/org/freedesktop/Hal/Manager'; + +my $dbus = dbus_object::system_bus(); + +my $do = dbus_object->new($dbus, $hal_dn, $manager_path, $hal_manager); + +my $con = $dbus->{connection}; +$con->add_filter(sub { + my ($_bus, $msg) = @_; + return if $msg->get_member ne 'DeviceAdded'; + my $hal = $dbus->get_service($hal_dn); + my $bool; + eval { + my $device = $hal->get_object(($msg->get_args_list)[0], "$hal_dn.Device"); + $bool = $device->QueryCapability('block') && $device->GetProperty('block.is_volume'); + }; + go2State($bool ? 'disk_found' : 'okay'); + 0; + }); +$con->add_match("type='signal',interface='$hal_manager'"); + my $icon = Gtk2::StatusIcon->new; $icon->signal_connect(popup_menu => sub { my ($_icon, $button, $time) = @_; @@ -91,6 +115,8 @@ $SIG{USR2} = 'IGNORE'; $SIG{CHLD} = \&harvester; run_program::raw({ detach => 1 }, 'ionice', '-p', $$, '-n7'); + +$do->set_gtk2_watch; Gtk2->main; ugtk2::exit(0); -- cgit v1.2.1