1
# -*- coding: utf-8 -*-
3
# config.py -- Config dialog
5
# Copyright (C) 2008 - B. Clausius
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2, or (at your option)
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
# Parts from "Interactive Python-GTK Console" (stolen from epiphany's console.py)
22
# Copyright (C), 1998 James Henstridge <james@daa.com.au>
23
# Copyright (C), 2005 Adam Hooper <adamh@densi.com>
24
# Bits from gedit Python Console Plugin
25
# Copyrignt (C), 2005 Raphaël Slinckx
28
from gi.repository import Gio, Gtk, Gdk
30
__all__ = ('PythonConsoleConfigWidget')
33
class PythonConsoleConfigWidget(object):
35
CONSOLE_KEY_BASE = 'org.gnome.eog.plugins.pythonconsole'
36
CONSOLE_KEY_COMMAND_COLOR = 'command-color'
37
CONSOLE_KEY_ERROR_COLOR = 'error-color'
39
def __init__(self, datadir):
42
self._ui_path = os.path.join(datadir, 'config.ui')
43
self._settings = Gio.Settings.new(self.CONSOLE_KEY_BASE)
44
self._ui = Gtk.Builder()
45
self._ui.set_translation_domain('eog-plugins')
47
def configure_widget(self):
48
self._ui.add_objects_from_file(self._ui_path, ["grid"])
50
self.set_colorbutton_color(self._ui.get_object('colorbutton-command'),
51
self._settings.get_string(self.CONSOLE_KEY_COMMAND_COLOR))
52
self.set_colorbutton_color(self._ui.get_object('colorbutton-error'),
53
self._settings.get_string(self.CONSOLE_KEY_ERROR_COLOR))
55
self._ui.connect_signals(self)
57
widget = self._ui.get_object('grid')
62
def set_colorbutton_color(colorbutton, value):
63
color = Gdk.color_parse(value)
66
colorbutton.set_color(color)
68
def on_colorbutton_command_color_set(self, colorbutton):
69
self._settings.set_string(self.CONSOLE_KEY_COMMAND_COLOR,
70
colorbutton.get_color().to_string())
72
def on_colorbutton_error_color_set(self, colorbutton):
73
self._settings.set_string(self.CONSOLE_KEY_ERROR_COLOR,
74
colorbutton.get_color().to_string())