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
This module documents a class that creates the window for the document
25
@author: Lateef Alabi-Oki
26
@organization: The Scribes Project
27
@copyright: Copyright © 2006 Lateef Alabi-Oki
28
@license: GNU GPLv2 or Later
29
@contact: mystilleef@gmail.com
34
This class creates the window for the document browser window.
37
def __init__(self, editor, manager):
39
Initialize an instance of this class.
41
@param self: Reference to the BrowserWindow instance.
42
@type self: A BrowserWindow object.
44
@param manager: Reference to the Manager instance
45
@type manager: A Manager object.
47
@param editor: Reference to the text editor.
48
@type editor: An Editor object.
50
self.__init_attributes(editor, manager)
51
self.__set_properties()
52
self.__sig_id1 = self.__manager.connect("destroy", self.__destroy_cb)
53
self.__sig_id2 = self.__manager.connect("show-window", self.__show_window_cb)
54
self.__sig_id3 = self.__manager.connect("hide-window", self.__hide_window_cb)
55
self.__sig_id4 = self.__window.connect("delete-event", self.__delete_event_cb)
56
self.__sig_id5 = self.__window.connect("key-press-event", self.__key_press_event_cb)
57
from gobject import idle_add
59
self.__window.set_property("sensitive", True)
61
def __init_attributes(self, editor, manager):
63
Initialize data attributes.
65
@param self: Reference to the Window instance.
66
@type self: A Window object.
68
@param manager: Reference to the Manager instance
69
@type manager: A Manager object.
71
@param editor: Reference to the text editor.
72
@type editor: An Editor object.
74
self.__manager = manager
75
self.__editor = editor
76
self.__window = manager.glade.get_widget("Window")
77
self.__sig_id1 = self.__status_id = None
80
def __set_properties(self):
82
Define the default behavior of the dialog.
84
@param self: Reference to the Window instance.
85
@type self: A Window object.
87
self.__window.set_transient_for(self.__editor.window)
92
Show the document browser.
94
@param self: Reference to the Window instance.
95
@type self: A Window object.
97
self.__editor.emit("show-dialog", self.__window)
98
from i18n import msg0001
99
self.__status_id = self.__editor.feedback.set_modal_message(msg0001, "open")
100
self.__window.show_all()
105
Hide the document browser.
107
@param self: Reference to the Window instance.
108
@type self: A Window object.
110
self.__editor.emit("hide-dialog", self.__window)
111
self.__editor.feedback.unset_modal_message(self.__status_id)
119
@param self: Reference to the Window instance.
120
@type self: A Window object.
122
self.__editor.disconnect_signal(self.__sig_id1, self.__manager)
123
self.__editor.disconnect_signal(self.__sig_id2, self.__manager)
124
self.__editor.disconnect_signal(self.__sig_id3, self.__manager)
125
self.__editor.disconnect_signal(self.__sig_id4, self.__window)
126
self.__editor.disconnect_signal(self.__sig_id5, self.__window)
127
self.__window.destroy()
132
def __destroy_cb(self, *args):
134
Handles callback when "destroy" signal is emitted.
136
@param self: Reference to the Window instance.
137
@type self: An Window object.
142
def __hide_window_cb(self, *args):
144
Handles callback when "destroy" signal is emitted.
146
@param self: Reference to the Window instance.
147
@type self: An Window object.
152
def __show_window_cb(self, *args):
154
Handles callback when "destroy" signal is emitted.
156
@param self: Reference to the Window instance.
157
@type self: An Window object.
159
from gobject import idle_add
160
idle_add(self.__show)
163
def __delete_event_cb(self, *args):
165
Handles callback when "destroy" signal is emitted.
167
@param self: Reference to the Window instance.
168
@type self: An Window object.
173
def __key_press_event_cb(self, window, event):
175
Handles callback when "destroy" signal is emitted.
177
@param self: Reference to the Window instance.
178
@type self: An Window object.
180
from gtk import keysyms
181
if event.keyval != keysyms.Escape: return False