~ubuntu-branches/ubuntu/oneiric/guake/oneiric

« back to all changes in this revision

Viewing changes to src/dbusiface.py

  • Committer: Bazaar Package Importer
  • Author(s): Sylvestre Ledru
  • Date: 2008-08-11 10:43:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080811104303-0ezz5fon32d6pcqj
Tags: upstream-0.3.1
Import upstream version 0.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8; -*-
 
2
"""
 
3
Copyright (C) 2007 Gabriel Falcão <gabrielteratos@gmail.com>
 
4
Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
 
5
 
 
6
This program is free software; you can redistribute it and/or
 
7
modify it under the terms of the GNU General Public License as
 
8
published by the Free Software Foundation; either version 2 of the
 
9
License, or (at your option) any later version.
 
10
 
 
11
This program is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public
 
17
License along with this program; if not, write to the
 
18
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
Boston, MA 02111-1307, USA.
 
20
"""
 
21
import dbus
 
22
import dbus.service
 
23
import dbus.glib
 
24
import gtk
 
25
import common
 
26
dbus.glib.threads_init()
 
27
 
 
28
 
 
29
class DaemonDBus(dbus.service.Object):
 
30
    def __init__(self, bus_name, guakeinstance):
 
31
        self.guake = guakeinstance
 
32
        object_path = '/DBusInterface'
 
33
        super(DaemonDBus, self).__init__(bus_name, object_path)
 
34
 
 
35
    @dbus.service.method('org.gnome.Guake.DBusInterface')
 
36
    def show_hide(self):
 
37
        self.guake.show_hide()
 
38
 
 
39
    @dbus.service.method('org.gnome.Guake.DBusInterface')
 
40
    def add_tab(self):
 
41
        self.guake.add_tab()
 
42
 
 
43
    @dbus.service.method('org.gnome.Guake.DBusInterface')
 
44
    def show_about(self):
 
45
        self.guake.show_about()
 
46
 
 
47
    @dbus.service.method('org.gnome.Guake.DBusInterface')
 
48
    def show_prefs(self):
 
49
        self.guake.show_prefs()
 
50
 
 
51
    @dbus.service.method('org.gnome.Guake.DBusInterface')
 
52
    def quit(self):
 
53
        self.guake.quit()
 
54
 
 
55
 
 
56
def dbus_init(guakeinstance):
 
57
    try:
 
58
        session_bus = dbus.SessionBus()
 
59
        name = dbus.service.BusName('org.gnome.Guake.DBus', bus=session_bus)
 
60
        return DaemonDBus(name, guakeinstance)
 
61
    except dbus.DBusException:
 
62
        import sys
 
63
        sys.stderr.write(_('Could not connect to dbus session bus.'
 
64
            ' dbus will be unavailable.\n'))
 
65
        return None