From 76521cd7576b630e1605952b22ece0299fc65902 Mon Sep 17 00:00:00 2001 From: glenux Date: Wed, 20 Jul 2011 22:05:23 +0000 Subject: [PATCH] sshfs-mapper qasim-gui: Split appart notification part. git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1695 eaee96b3-f302-0410-b096-c6cfd47f7835 --- qasim-gui/qasim.rb | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/qasim-gui/qasim.rb b/qasim-gui/qasim.rb index 4e207d4..14d9bd2 100755 --- a/qasim-gui/qasim.rb +++ b/qasim-gui/qasim.rb @@ -11,8 +11,30 @@ end module Qasim + NAME="Qasim" VERSION="0.1" + def dbus_notify title, body, icon + bus = Qt::DBusConnection.sessionBus + if !bus.connected? + $stderr.puts("Cannot connect to the D-BUS session bus.\n" \ + "To start it, run:\n" \ + "\teval `dbus-launch --auto-syntax`\n") + exit 1 + end + msg = Qt::DBusMessage.create_method_call( 'org.freedesktop.Notifications', + '/org/freedesktop/Notifications', + 'org.freedesktop.Notifications', + 'Notify' ) + msg.arguments = [ NAME, Qt::Variant.from_value( 0, "unsigned int" ), + icon, title, body, [], {}, -1 ] + rep = bus.call( msg ) + # if rep.type == Qt::DBusMessage + + # si.showMessage("Qasim", + # "Sorry dude", 2, 5000 ) + end + def build_app app = Qt::Application.new(ARGV) @@ -24,25 +46,8 @@ module Qasim si.icon = std_icon si.show + dbus_notify "Hello", "World", 'dialog-information' - bus = Qt::DBusConnection.sessionBus - if !bus.connected? - $stderr.puts("Cannot connect to the D-BUS session bus.\n" \ - "To start it, run:\n" \ - "\teval `dbus-launch --auto-syntax`\n") - exit 1 - end - msg = Qt::DBusMessage.create_method_call( 'org.freedesktop.Notifications', - '/org/freedesktop/Notifications', - 'org.freedesktop.Notifications', - 'Notify' ) - msg.arguments = [ 'Coucou', Qt::Variant.from_value( 0, "unsigned int" ), - 'dialog-information', 'Title', 'blah', [], {}, -1 ] - rep = bus.call( msg ) - # if rep.type == Qt::DBusMessage - -# si.showMessage("Qasim", -# "Sorry dude", 2, 5000 ) si.setToolTip("Qasim %s" % VERSION);