~ubuntu-branches/debian/sid/guake/sid

« back to all changes in this revision

Viewing changes to src/guake/dbusiface.py

  • Committer: Package Import Robot
  • Author(s): Daniel Echeverry
  • Date: 2015-04-26 19:15:06 UTC
  • mfrom: (1.1.7)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20150426191506-mo8037vk6pueer5b
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8; -*-
 
2
"""
 
3
Copyright (C) 2007-2013 Guake authors
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License as
 
7
published by the Free Software Foundation; either version 2 of the
 
8
License, or (at your option) any later version.
 
9
 
 
10
This program is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public
 
16
License along with this program; if not, write to the
 
17
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
Boston, MA 02110-1301 USA
 
19
"""
 
20
from __future__ import absolute_import
 
21
 
 
22
import dbus
 
23
import dbus.glib
 
24
import dbus.service
 
25
 
 
26
 
 
27
dbus.glib.threads_init()
 
28
 
 
29
DBUS_PATH = '/org/guake/RemoteControl'
 
30
DBUS_NAME = 'org.guake.RemoteControl'
 
31
 
 
32
 
 
33
class DbusManager(dbus.service.Object):
 
34
 
 
35
    def __init__(self, guakeinstance):
 
36
        self.guake = guakeinstance
 
37
        self.bus = dbus.SessionBus()
 
38
        bus_name = dbus.service.BusName(DBUS_NAME, bus=self.bus)
 
39
        super(DbusManager, self).__init__(bus_name, DBUS_PATH)
 
40
 
 
41
    @dbus.service.method(DBUS_NAME)
 
42
    def show_hide(self):
 
43
        self.guake.show_hide()
 
44
 
 
45
    @dbus.service.method(DBUS_NAME)
 
46
    def show(self):
 
47
        self.guake.show()
 
48
        self.guake.set_terminal_focus()
 
49
 
 
50
    @dbus.service.method(DBUS_NAME)
 
51
    def show_from_remote(self):
 
52
        self.guake.show_from_remote()
 
53
        self.guake.set_terminal_focus()
 
54
 
 
55
    @dbus.service.method(DBUS_NAME)
 
56
    def hide(self):
 
57
        self.guake.hide()
 
58
 
 
59
    @dbus.service.method(DBUS_NAME)
 
60
    def hide_from_remote(self):
 
61
        self.guake.hide_from_remote()
 
62
 
 
63
    @dbus.service.method(DBUS_NAME)
 
64
    def fullscreen(self):
 
65
        self.guake.fullscreen()
 
66
 
 
67
    @dbus.service.method(DBUS_NAME, in_signature='s')
 
68
    def add_tab(self, directory=''):
 
69
        self.guake.add_tab(directory)
 
70
 
 
71
    @dbus.service.method(DBUS_NAME, in_signature='i')
 
72
    def select_tab(self, tab_index=0):
 
73
        return self.guake.select_tab(int(tab_index))
 
74
 
 
75
    @dbus.service.method(DBUS_NAME, out_signature='i')
 
76
    def get_selected_tab(self):
 
77
        return self.guake.get_selected_tab()
 
78
 
 
79
    @dbus.service.method(DBUS_NAME, out_signature='i')
 
80
    def get_tab_count(self):
 
81
        return len(self.guake.term_list)
 
82
 
 
83
    @dbus.service.method(DBUS_NAME, in_signature='s')
 
84
    def set_bgcolor(self, bgcolor):
 
85
        self.guake.set_bgcolor(bgcolor)
 
86
 
 
87
    @dbus.service.method(DBUS_NAME, in_signature='s')
 
88
    def set_fgcolor(self, fgcolor):
 
89
        self.guake.set_fgcolor(fgcolor)
 
90
 
 
91
    @dbus.service.method(DBUS_NAME, in_signature='s')
 
92
    def execute_command(self, command):
 
93
        self.guake.execute_command(command)
 
94
 
 
95
    @dbus.service.method(DBUS_NAME, in_signature='i', out_signature='s')
 
96
    def get_tab_name(self, tab_index=0):
 
97
        return self.guake.term_list[int(tab_index)].get_window_title() or ''
 
98
 
 
99
    @dbus.service.method(DBUS_NAME, in_signature='is')
 
100
    def rename_tab(self, tab_index, new_text):
 
101
        self.guake.rename_tab(tab_index, new_text)
 
102
 
 
103
    @dbus.service.method(DBUS_NAME, in_signature='s')
 
104
    def rename_current_tab(self, new_text):
 
105
        self.guake.rename_current_tab(new_text)
 
106
 
 
107
    @dbus.service.method(DBUS_NAME)
 
108
    def show_about(self):
 
109
        self.guake.show_about()
 
110
 
 
111
    @dbus.service.method(DBUS_NAME)
 
112
    def show_prefs(self):
 
113
        self.guake.show_prefs()
 
114
 
 
115
    @dbus.service.method(DBUS_NAME)
 
116
    def quit(self):
 
117
        self.guake.quit()