summaryrefslogtreecommitdiffstats
path: root/draksnapshot-applet
diff options
context:
space:
mode:
authortv <tv@99302b65-d5f7-0310-b3dd-f8cd6f4e3d94>2008-03-28 15:54:10 +0000
committertv <tv@99302b65-d5f7-0310-b3dd-f8cd6f4e3d94>2008-03-28 15:54:10 +0000
commit4f71ae2f997423339519fa9b9e693cfa6a6a4e9f (patch)
tree6cc11297b200d6de190e7db140a01ca9c8ee3749 /draksnapshot-applet
parent1c96f0253a3548a8f56b66687b50760ba5f05670 (diff)
downloaddraksnapshot-4f71ae2f997423339519fa9b9e693cfa6a6a4e9f.tar
draksnapshot-4f71ae2f997423339519fa9b9e693cfa6a6a4e9f.tar.gz
draksnapshot-4f71ae2f997423339519fa9b9e693cfa6a6a4e9f.tar.bz2
draksnapshot-4f71ae2f997423339519fa9b9e693cfa6a6a4e9f.tar.xz
draksnapshot-4f71ae2f997423339519fa9b9e693cfa6a6a4e9f.zip
- 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
Diffstat (limited to 'draksnapshot-applet')
-rwxr-xr-xdraksnapshot-applet26
1 files changed, 26 insertions, 0 deletions
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);