1
# -*- coding: utf-8 -*-
2
# Copyright © 2006 Lateef Alabi-Oki
4
# This file is part of Scribes.
6
# Scribes is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# Scribes 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
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Scribes; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22
Documents a class that creates the window for the preferences dialog.
24
@author: Lateef Alabi-Oki
25
@organization: The Scribes Project
26
@copyright: Copyright © 2006 Lateef Alabi-Oki
27
@license: GNU GPLv2 or Later
28
@contact: mystilleef@gmail.com
31
from SCRIBES.sdialog import Dialog
33
class PreferencesWindow(Dialog):
35
This class creates the window for the preferences dialog.
38
def __init__(self, manager, editor):
40
Initialize an instance of this class.
42
@param self: Reference to the PreferencesWindow instance.
43
@type self: A PreferencesWindow object.
45
@param manager: Reference to the PreferencesManager instance
46
@type manager: A PreferencesManager object.
48
@param editor: Reference to the text editor.
49
@type editor: An Editor object.
52
self.__init_attributes(manager, editor)
53
self.__set_properties()
54
self.__signal_id = self.__manager.connect("destroy", self.__window_destroy_cb)
56
def show_dialog(self):
58
Show the document browser.
60
@param self: Reference to the PreferencesWindow instance.
61
@type self: A PreferencesWindow object.
63
self.__editor.emit("show-dialog", self)
64
from i18n import msg0009
65
self.__status_id = self.__editor.feedback.set_modal_message(msg0009, "preferences")
66
Dialog.show_dialog(self)
69
def hide_dialog(self):
71
Hide the document browser.
73
@param self: Reference to the PreferencesWindow instance.
74
@type self: A PreferencesWindow object.
76
self.__editor.emit("hide-dialog", self)
77
self.__editor.feedback.unset_modal_message(self.__status_id)
78
Dialog.hide_dialog(self)
81
def __window_destroy_cb(self, manager):
83
Handles callback when "destroy" signal is emitted.
85
@param self: Reference to the PreferencesWindow instance.
86
@type self: An PreferencesWindow object.
88
@param manager: Reference to the PreferencesManager.
89
@type manager: An PreferencesManager object.
91
from SCRIBES.utils import disconnect_signal, delete_attributes
92
disconnect_signal(self.__signal_id, self.__manager)
94
delete_attributes(self)
99
def __init_attributes(self, manager, editor):
101
Initialize data attributes.
103
@param self: Reference to the PreferencesWindow instance.
104
@type self: A PreferencesWindow object.
106
@param manager: Reference to the PreferencesManager instance
107
@type manager: A PreferencesManager object.
109
@param editor: Reference to the text editor.
110
@type editor: An Editor object.
112
self.__manager = manager
113
self.__editor = editor
114
self.__signal_id = None
115
self.__status_id = None
118
def __set_properties(self):
120
Define the default behavior of the dialog.
122
@param self: Reference to the PreferencesWindow instance.
123
@type self: A PreferencesWindow object.
125
self.set_property("name", "PreferencesDialog")
126
from i18n import msg0010
127
self.set_property("title", msg0010)
128
from SCRIBES.utils import calculate_resolution_independence
129
width, height = calculate_resolution_independence(self.__editor.window, 2.56, 2.56)
130
self.set_property("default-width", width)
131
self.set_transient_for(self.__editor.window)