~sir-rainbow/+junk/scribes-on-win

« back to all changes in this revision

Viewing changes to plugins/Preferences/Window.py

  • Committer: goldenmyst
  • Date: 2007-09-25 17:15:52 UTC
  • Revision ID: goldenmyst@goldenmyst-desktop-20070925171552-mvrhxdd39iibs0sr
New branch. New Trigger Management System. New Trigger API. New Plugin Management System. Fix for bug triggered by PyGTK+ version 2.11 or better.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Copyright © 2006 Lateef Alabi-Oki
 
3
#
 
4
# This file is part of Scribes.
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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
 
19
# USA
 
20
 
 
21
"""
 
22
Documents a class that creates the window for the preferences dialog.
 
23
 
 
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
 
29
"""
 
30
 
 
31
from SCRIBES.sdialog import Dialog
 
32
 
 
33
class PreferencesWindow(Dialog):
 
34
        """
 
35
        This class creates the window for the preferences dialog.
 
36
        """
 
37
 
 
38
        def __init__(self, manager, editor):
 
39
                """
 
40
                Initialize an instance of this class.
 
41
 
 
42
                @param self: Reference to the PreferencesWindow instance.
 
43
                @type self: A PreferencesWindow object.
 
44
 
 
45
                @param manager: Reference to the PreferencesManager instance
 
46
                @type manager: A PreferencesManager object.
 
47
 
 
48
                @param editor: Reference to the text editor.
 
49
                @type editor: An Editor object.
 
50
                """
 
51
                Dialog.__init__(self)
 
52
                self.__init_attributes(manager, editor)
 
53
                self.__set_properties()
 
54
                self.__signal_id = self.__manager.connect("destroy", self.__window_destroy_cb)
 
55
 
 
56
        def show_dialog(self):
 
57
                """
 
58
                Show the document browser.
 
59
 
 
60
                @param self: Reference to the PreferencesWindow instance.
 
61
                @type self: A PreferencesWindow object.
 
62
                """
 
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)
 
67
                return
 
68
 
 
69
        def hide_dialog(self):
 
70
                """
 
71
                Hide the document browser.
 
72
 
 
73
                @param self: Reference to the PreferencesWindow instance.
 
74
                @type self: A PreferencesWindow object.
 
75
                """
 
76
                self.__editor.emit("hide-dialog", self)
 
77
                self.__editor.feedback.unset_modal_message(self.__status_id)
 
78
                Dialog.hide_dialog(self)
 
79
                return
 
80
 
 
81
        def __window_destroy_cb(self, manager):
 
82
                """
 
83
                Handles callback when "destroy" signal is emitted.
 
84
 
 
85
                @param self: Reference to the PreferencesWindow instance.
 
86
                @type self: An PreferencesWindow object.
 
87
 
 
88
                @param manager: Reference to the PreferencesManager.
 
89
                @type manager: An PreferencesManager object.
 
90
                """
 
91
                from SCRIBES.utils import disconnect_signal, delete_attributes
 
92
                disconnect_signal(self.__signal_id, self.__manager)
 
93
                self.destroy()
 
94
                delete_attributes(self)
 
95
                del self
 
96
                self = None
 
97
                return
 
98
 
 
99
        def __init_attributes(self, manager, editor):
 
100
                """
 
101
                Initialize data attributes.
 
102
 
 
103
                @param self: Reference to the PreferencesWindow instance.
 
104
                @type self: A PreferencesWindow object.
 
105
 
 
106
                @param manager: Reference to the PreferencesManager instance
 
107
                @type manager: A PreferencesManager object.
 
108
 
 
109
                @param editor: Reference to the text editor.
 
110
                @type editor: An Editor object.
 
111
                """
 
112
                self.__manager = manager
 
113
                self.__editor = editor
 
114
                self.__signal_id = None
 
115
                self.__status_id = None
 
116
                return
 
117
 
 
118
        def __set_properties(self):
 
119
                """
 
120
                Define the default behavior of the dialog.
 
121
 
 
122
                @param self: Reference to the PreferencesWindow instance.
 
123
                @type self: A PreferencesWindow object.
 
124
                """
 
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)
 
132
                return