root/gaphor/tags/gaphor-0.12.5/gaphor/services/helpservice.py

Revision 1374, 3.0 kB (checked in by arj..@yirdis.nl, 2 years ago)

fixed help service

Line 
1 """
2 About and help services. (help browser anyone?)
3 """
4
5
6 import os
7 import pkg_resources
8 import gtk
9 from zope import interface
10 from gaphor.application import Application
11 from gaphor.interfaces import IService, IActionProvider
12 from gaphor.core import _, inject, action, build_action_group
13
14 class HelpService(object):
15
16     interface.implements(IService, IActionProvider)
17
18     menu_xml = """
19       <ui>
20         <menubar name="mainwindow">
21           <menu action="help">
22             <placeholder name="ternary">
23               <menuitem action="help-about" />
24             </placeholder>
25           </menu>
26         </menubar>
27       </ui>
28     """
29
30     gui_manager = inject('gui_manager')
31
32     def __init__(self):
33         pass
34
35     def init(self, app):
36         self.action_group = build_action_group(self)
37
38     def shutdown(self):
39         pass
40
41     @action(name='help-about', stock_id='gtk-about')
42     def about(self):
43         logo_file =  os.path.join(pkg_resources.get_distribution('gaphor').location, 'gaphor', 'ui', 'pixmaps', 'logo.png')
44         logo = gtk.gdk.pixbuf_new_from_file(logo_file)
45         version = Application.distribution.version
46         about = gtk.Dialog("About Gaphor", self.gui_manager.main_window.window, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_OK))
47         about.set_default_response(gtk.RESPONSE_OK)
48         vbox = about.vbox
49
50         image = gtk.Image()
51         image.set_from_pixbuf(logo)
52         vbox.pack_start(image)
53
54         notebook = gtk.Notebook()
55         notebook.set_scrollable(True)
56         #notebook.set_show_border(False)
57         notebook.set_border_width(4)
58         notebook.set_tab_pos(gtk.POS_BOTTOM)
59         vbox.pack_start(notebook)
60
61         tab_vbox = gtk.VBox()
62
63         def add_label(text, padding_x=0, padding_y=0):
64             label = gtk.Label(text)
65             label.set_property('use-markup', True)
66             label.set_padding(padding_x, padding_y)
67             label.set_justify(gtk.JUSTIFY_CENTER)
68             tab_vbox.pack_start(label)
69
70         #add_label('<span size="xx-large" weight="bold">Gaphor</span>')
71         add_label('<span weight="bold">version %s</span>' % version)
72         add_label('<span variant="smallcaps">UML Modeling tool for GNOME</span>', 8, 8)
73         add_label('<span size="small">Copyright (c) 2001-2007 Arjan J. Molenaar</span>', 8, 8)
74         #vbox.pack_start(gtk.HSeparator())
75         notebook.append_page(tab_vbox, gtk.Label('About'))
76
77         tab_vbox = gtk.VBox()
78        
79         add_label('This software is published\n'
80                   'under the terms of the\n'
81                   '<span weight="bold">GNU General Public License v2</span>.\n'
82                   'See the COPYING file for details.', 0, 8)
83         notebook.append_page(tab_vbox, gtk.Label('License'))
84
85         tab_vbox = gtk.VBox()
86        
87         add_label('Gaphor is written by:\n'
88                   'Arjan Molenaar\n'
89                   'Jeroen Vloothuis\n'
90                   'wrobell')
91         add_label('')
92         notebook.append_page(tab_vbox, gtk.Label('Authors'))
93
94         vbox.show_all()
95         about.run()
96         about.destroy()
97
98
99 # vim:sw=4:et:ai
Note: See TracBrowser for help on using the browser.