1
# -*- coding: utf-8 -*-
2
# Copyright © 2005 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 USA
21
This module documents a class that implements the about popup menu item
24
@author: Lateef Alabi-Oki
25
@organization: The Scribes Project
26
@copyright: Copyright © 2005 Lateef Alabi-Oki
27
@license: GNU GPLv2 or Later
28
@contact: mystilleef@gmail.com
31
from gtk import ImageMenuItem
33
class AboutPopupMenuItem(ImageMenuItem):
35
This class creates the about popup menu item for the text editor.
38
def __init__(self, editor):
40
Initialize the popup menu item.
42
@param self: Reference to the ScribesAboutMenuItem instance.
43
@type self: A ScribesAboutMenuItem object.
45
@param editor: Reference to the text editor.
46
@type editor: An Editor object.
48
from gtk import STOCK_ABOUT
49
ImageMenuItem.__init__(self, STOCK_ABOUT)
50
self.__init_attributes(editor)
51
self.__signal_id_1 = self.connect("activate", self.__popup_activate_cb)
52
self.__signal_id_2 = self.__editor.textview.connect("focus-in-event", self.__focus_in_event_cb)
54
def __init_attributes(self, editor):
56
Initialize the popup menu item's attributes.
58
@param self: Reference to the ScribesAboutMenuItem instance.
59
@type self: A ScribesAboutMenuItem object.
61
@param editor: Reference to the text editor.
62
@type editor: An Editor object.
64
self.__editor = editor
65
self.__signal_id_1 = None
66
self.__signal_id_2 = None
69
def __popup_activate_cb(self, menuitem):
71
Handles callback when the "activate" signal is emitted.
73
@param self: Reference to the ScribesAboutMenuItem instance.
74
@type self: A ScribesAboutMenuItem object.
76
@param menuitem: A menuitem for the ScribesAboutMenuItem.
77
@type menuitem: A gtk.MenuItem object.
79
@return: True to propagate signals to parent widgets.
80
@type: A Boolean Object.
82
self.__editor.triggermanager.trigger("show_about_dialog")
85
def __focus_in_event_cb(self, textview, event):
87
Handles callback when the "focus-in-event" signal is emitted.
89
@param self: Reference to the AboutPopupMenuItem instance.
90
@type self: An AboutPopupMenuItem object.
92
@param textview: Reference to the editor's view.
93
@type textview: A ScribesTextView object.
95
@param event: An event that occurs when the popup is hidden.
96
@type event: A gtk.Event object.
98
@return: True to propagate signals to parent widgets.
99
@type: A Boolean Object.
101
if self.__signal_id_1 and self.handler_is_connected(self.__signal_id_1):
102
self.disconnect(self.__signal_id_1)
103
if self.__signal_id_2 and self.__editor.textview.handler_is_connected(self.__signal_id_2):
104
self.__editor.textview.disconnect(self.__signal_id_2)
106
del self.__editor, self.__signal_id_1, self.__signal_id_2