1
# -*- coding: utf-8; -*-
3
Copyright (C) 2007-2013 Guake authors
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.
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.
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
20
from __future__ import absolute_import
27
dbus.glib.threads_init()
29
DBUS_PATH = '/org/guake/RemoteControl'
30
DBUS_NAME = 'org.guake.RemoteControl'
33
class DbusManager(dbus.service.Object):
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)
41
@dbus.service.method(DBUS_NAME)
43
self.guake.show_hide()
45
@dbus.service.method(DBUS_NAME)
48
self.guake.set_terminal_focus()
50
@dbus.service.method(DBUS_NAME)
51
def show_from_remote(self):
52
self.guake.show_from_remote()
53
self.guake.set_terminal_focus()
55
@dbus.service.method(DBUS_NAME)
59
@dbus.service.method(DBUS_NAME)
60
def hide_from_remote(self):
61
self.guake.hide_from_remote()
63
@dbus.service.method(DBUS_NAME)
65
self.guake.fullscreen()
67
@dbus.service.method(DBUS_NAME, in_signature='s')
68
def add_tab(self, directory=''):
69
self.guake.add_tab(directory)
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))
75
@dbus.service.method(DBUS_NAME, out_signature='i')
76
def get_selected_tab(self):
77
return self.guake.get_selected_tab()
79
@dbus.service.method(DBUS_NAME, out_signature='i')
80
def get_tab_count(self):
81
return len(self.guake.term_list)
83
@dbus.service.method(DBUS_NAME, in_signature='s')
84
def set_bgcolor(self, bgcolor):
85
self.guake.set_bgcolor(bgcolor)
87
@dbus.service.method(DBUS_NAME, in_signature='s')
88
def set_fgcolor(self, fgcolor):
89
self.guake.set_fgcolor(fgcolor)
91
@dbus.service.method(DBUS_NAME, in_signature='s')
92
def execute_command(self, command):
93
self.guake.execute_command(command)
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 ''
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)
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)
107
@dbus.service.method(DBUS_NAME)
108
def show_about(self):
109
self.guake.show_about()
111
@dbus.service.method(DBUS_NAME)
112
def show_prefs(self):
113
self.guake.show_prefs()
115
@dbus.service.method(DBUS_NAME)