1
# -*- coding: utf-8 -*-
2
# Copyright © 2008 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 modules documents a class that manages essential components of the
23
open dialog file chooser.
25
@author: Lateef Alabi-Oki
26
@organization: Scribes
27
@copyright: Copyright © 2008 Lateef Alabi-Oki
28
@license: GNU GPLv3 or Later
29
@contact: mystilleef@gmail.com
32
from gobject import GObject, SIGNAL_RUN_LAST, TYPE_NONE, TYPE_PYOBJECT
34
class Manager(GObject):
36
This class manages the components of the filechooser window.
40
"destroy": (SIGNAL_RUN_LAST, TYPE_NONE, ()),
41
"show-window": (SIGNAL_RUN_LAST, TYPE_NONE, ()),
42
"hide-window": (SIGNAL_RUN_LAST, TYPE_NONE, ()),
43
"load-file": (SIGNAL_RUN_LAST, TYPE_NONE, ()),
44
"error": (SIGNAL_RUN_LAST, TYPE_NONE, (TYPE_PYOBJECT,)),
45
"encoding": (SIGNAL_RUN_LAST, TYPE_NONE, (TYPE_PYOBJECT,)),
48
def __init__(self, editor):
52
@param self: Reference to the Manager instance.
53
@type self: A Manager object.
55
@param editor: Reference to the text editor.
56
@type editor: An Editor object.
58
GObject.__init__(self)
59
self.__init_attributes(editor)
60
self.__sig_id1 = self.connect("encoding", self.__encoding_cb)
61
from EncodingComboBox import ComboBox
62
ComboBox(editor, self)
63
from OpenButton import Button
65
from ComboBoxEntry import ComboBoxEntry
66
ComboBoxEntry(editor, self)
67
from CancelButton import Button
69
from Window import Window
72
def __init_attributes(self, editor):
74
Initialize data attributes.
76
@param self: Reference to the Manager instance.
77
@type self: A Manager object.
79
@param editor: Reference to the text editor.
80
@type editor: An Editor object.
82
self.__editor = editor
83
from os.path import join, split
84
current_folder = split(globals()["__file__"])[0]
85
glade_file = join(current_folder, "RemoteDialog.glade")
86
from gtk.glade import XML
87
self.__glade = XML(glade_file, "Window", "scribes")
88
self.__encoding = None
91
def __get_glade(self):
94
def __get_encoding(self):
95
return self.__encoding
97
glade = property(__get_glade)
98
encoding = property(__get_encoding)
100
def show_dialog(self):
102
Show the open file chooser dialog.
104
@param self: Reference to the Manager instance.
105
@type self: A Manager object.
107
self.emit("show-window")
112
Handles callback when the "destroy" signal is emitted.
114
@param self: Reference to the Manager instance.
115
@type self: A Manager object.
117
self.__editor.disconnect_signal(self.__sig_id1, self)
123
def __encoding_cb(self, manager, encoding):
125
Handles callback when encoding information changes.
127
@param self: Reference to the Manager instance.
128
@type self: A Manager object.
130
self.__encoding = encoding