~noskcaj/ubuntu/utopic/eog-plugins/merge

« back to all changes in this revision

Viewing changes to plugins/pythonconsole/config.py

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Josselin Mouette, Martin Pitt, Michael Biebl
  • Date: 2012-05-10 15:08:48 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20120510150848-e316o2pnsm7m16ep
Tags: 3.4.0-1
[ Josselin Mouette ]
* Replace python-gobject by python-gi.

[ Martin Pitt ]
* debian/control.in: Bump clutter and eog dependencies as per configure.ac.
* debian/copyright: Rewrite using copyright 1.0 format.
* debian/control.in: Bump to Standards-Version 3.9.3.
* debian/control.in: Add Enhances: eog (Closes: #653258, LP: #697406)

[ Michael Biebl ]
* New upstream release.
* Set pkg-gnome-maintainers@lists.alioth.debian.org as Maintainer.
* Add Build-Depends on gsettings-desktop-schemas-dev and a Depends on
  gsettings-desktop-schemas for the org.gnome.desktop.interface gsettings
  schema file used by the pythonconsole plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# config.py -- Config dialog
 
4
#
 
5
# Copyright (C) 2008 - B. Clausius
 
6
#
 
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)
 
10
# any later version.
 
11
#
 
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.
 
16
#
 
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.
 
20
 
 
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
 
26
 
 
27
import os
 
28
from gi.repository import Gio, Gtk, Gdk
 
29
 
 
30
__all__ = ('PythonConsoleConfigWidget')
 
31
 
 
32
 
 
33
class PythonConsoleConfigWidget(object):
 
34
 
 
35
    CONSOLE_KEY_BASE = 'org.gnome.eog.plugins.pythonconsole'
 
36
    CONSOLE_KEY_COMMAND_COLOR = 'command-color'
 
37
    CONSOLE_KEY_ERROR_COLOR = 'error-color'
 
38
 
 
39
    def __init__(self, datadir):
 
40
        object.__init__(self)
 
41
 
 
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')
 
46
 
 
47
    def configure_widget(self):
 
48
        self._ui.add_objects_from_file(self._ui_path, ["grid"])
 
49
 
 
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))
 
54
 
 
55
        self._ui.connect_signals(self)
 
56
 
 
57
        widget = self._ui.get_object('grid')
 
58
 
 
59
        return widget
 
60
 
 
61
    @staticmethod
 
62
    def set_colorbutton_color(colorbutton, value):
 
63
        color = Gdk.color_parse(value)
 
64
 
 
65
        if color is not None:
 
66
            colorbutton.set_color(color)
 
67
 
 
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())
 
71
 
 
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())
 
75
 
 
76
# ex:et:ts=4: