Changeset 227:50c3ae93007d


Ignore:
Timestamp:
06/05/12 18:20:01 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added a Help menu with the manual and the about dialog

Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r159 r227  
    1313
    1414data_files = [("sounds", glob(os.path.join("sounds", "*.*")))]
     15data_files.append((os.path.join("doc", "manual", "en"),
     16                   glob(os.path.join("doc", "manual", "en", "*.*"))))
     17data_files.append((os.path.join("doc", "manual", "hu"),
     18                   glob(os.path.join("doc", "manual", "hu", "*.*"))))
    1519if os.name=="nt":
    1620    import py2exe
    1721
    1822    data_files.append(("", ["logo.ico"]))
     23    data_files.append(("", ["logo.png"]))
    1924
    2025    msvcrDir = os.environ["MSVCRDIR"] if "MSVCRDIR" in os.environ else None
  • src/mlx/gui/common.py

    r226 r227  
    6060    WEIGHT_BOLD = pango.WEIGHT_BOLD
    6161
     62    pixbuf_new_from_file = gdk.pixbuf_new_from_file
     63
    6264    def text2unicode(text):
    6365        """Convert the given text, returned by a Gtk widget, to Unicode."""
     
    6769    pygobject = True
    6870    from gi.repository import Gdk as gdk
     71    from gi.repository import GdkPixbuf as gdkPixbuf
    6972    from gi.repository import Gtk as gtk
    7073    from gi.repository import GObject as gobject
     
    109112    WEIGHT_BOLD = pango.Weight.BOLD
    110113
     114    pixbuf_new_from_file = gdkPixbuf.Pixbuf.new_from_file
     115
    111116    import codecs
    112117    _utf8Decoder = codecs.getdecoder("utf-8")
     
    208213#------------------------------------------------------------------------------
    209214
    210 WINDOW_TITLE_BASE = "MAVA Logger X " + _const.VERSION
     215PROGRAM_NAME = "MAVA Logger X"
     216
     217WINDOW_TITLE_BASE = PROGRAM_NAME + " " + _const.VERSION
    211218
    212219#------------------------------------------------------------------------------
  • src/mlx/gui/gui.py

    r226 r227  
    11# The main file for the GUI
     2# -*- coding: utf-8 -*-
    23
    34from statusicon import StatusIcon
     
    2122import mlx.web as web
    2223import mlx.singleton as singleton
    23 from  mlx.i18n import xstr
     24from  mlx.i18n import xstr, getLanguage
    2425from mlx.pirep import PIREP
    2526
     
    2829import sys
    2930import datetime
     31import webbrowser
    3032
    3133#------------------------------------------------------------------------------
     
    3335class GUI(fs.ConnectionListener):
    3436    """The main GUI class."""
     37    _authors = [ ("Váradi", "István", "prog_test"),
     38                 ("Galyassy", "Tamás", "negotiation"),
     39                 ("Petrovszki", "Gábor", "test"),
     40                 ("Zsebényi-Loksa", "Gergely", "test"),
     41                 ("Kurják", "Ákos", "test"),
     42                 ("Radó", "Iván", "test") ]
     43
    3544    def __init__(self, programDirectory, config):
    3645        """Construct the GUI."""
     
    158167        self._pilotHotkeyIndex = None
    159168        self._checklistHotkeyIndex = None
     169
     170        self._aboutDialog = None
    160171
    161172    @property
     
    872883        showDebugMenuItem.connect("toggled", self._toggleDebugLog)
    873884        viewMenu.append(showDebugMenuItem)
     885
     886        helpMenuItem = gtk.MenuItem(xstr("menu_help"))
     887        helpMenu = gtk.Menu()
     888        helpMenuItem.set_submenu(helpMenu)
     889        menuBar.append(helpMenuItem)
     890
     891        manualMenuItem = gtk.ImageMenuItem(gtk.STOCK_HELP)
     892        manualMenuItem.set_use_stock(True)
     893        manualMenuItem.set_label(xstr("menu_help_manual"))
     894        manualMenuItem.add_accelerator("activate", accelGroup,
     895                                       ord(xstr("menu_help_manual_key")),
     896                                       CONTROL_MASK, ACCEL_VISIBLE)
     897        manualMenuItem.connect("activate", self._showManual)
     898        helpMenu.append(manualMenuItem)
     899
     900        helpMenu.append(gtk.SeparatorMenuItem())
     901       
     902        aboutMenuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
     903        aboutMenuItem.set_use_stock(True)
     904        aboutMenuItem.set_label(xstr("menu_help_about"))
     905        aboutMenuItem.add_accelerator("activate", accelGroup,
     906                                      ord(xstr("menu_help_about_key")),
     907                                      CONTROL_MASK, ACCEL_VISIBLE)
     908        aboutMenuItem.connect("activate", self._showAbout)
     909        helpMenu.append(aboutMenuItem)
    874910
    875911        return menuBar
     
    12321268                else:
    12331269                    print "gui.GUI._handleHotkeys: unhandled hotkey index:", index
     1270
     1271    def _showManual(self, menuitem):
     1272        """Show the user's manual."""
     1273        webbrowser.open(url ="file://" +
     1274                        os.path.join(self._programDirectory, "doc", "manual",
     1275                                     getLanguage(), "index.html"),
     1276                        new = 1)
     1277
     1278    def _showAbout(self, menuitem):
     1279        """Show the about dialog."""
     1280        dialog = self._getAboutDialog()
     1281        dialog.show_all()
     1282        dialog.run()
     1283        dialog.hide()
     1284
     1285    def _getAboutDialog(self):
     1286        """Get the about dialog.
     1287
     1288        If it does not exist yet, it will be created."""
     1289        if self._aboutDialog is None:
     1290            self._aboutDialog = dialog = gtk.AboutDialog()
     1291            dialog.set_transient_for(self._mainWindow)
     1292            dialog.set_modal(True)
     1293           
     1294            logoPath = os.path.join(self._programDirectory, "logo.png")
     1295            logo = pixbuf_new_from_file(logoPath)
     1296            dialog.set_logo(logo)
     1297                               
     1298            dialog.set_program_name(PROGRAM_NAME)
     1299            dialog.set_version(const.VERSION)
     1300            dialog.set_copyright("(c) 2012 by István Váradi")
     1301
     1302            isHungarian = getLanguage()=="hu"
     1303            authors = []
     1304            for (familyName, firstName, role) in GUI._authors:
     1305                authors.append("%s %s (%s)" % \
     1306                               (familyName if isHungarian else firstName,
     1307                                firstName if isHungarian else familyName,
     1308                                xstr("about_role_" + role)))           
     1309            dialog.set_authors(authors)
     1310
     1311            dialog.set_license(xstr("about_license"))
     1312
     1313        return self._aboutDialog
  • src/mlx/i18n.py

    r222 r227  
    1818    _Strings.set(language)
    1919   
     20#------------------------------------------------------------------------------
     21
     22def getLanguage():
     23    """Get the two-letter language code."""
     24    language = _Strings.current().getLanguage()
     25    underscoreIndex = language.find("_")
     26    return language[:underscoreIndex] if underscoreIndex>0 else language
     27
    2028#------------------------------------------------------------------------------
    2129
     
    5260        on, until no underscore remains.
    5361
    54         If nothing is found this way, the
    55         """
     62        If nothing is found this way, the fallback will be returned."""
    5663        while language:
    5764            if language in _Strings._instances:
     
    8996        """Construct an empty strings object."""
    9097        self._strings = {}
     98        self._language = languages[0]
    9199        for language in languages:
    92100            _Strings._instances[language] = self
     
    106114        This releases the string dictionary to free space."""
    107115        self._strings = {}
     116
     117    def getLanguage(self):
     118        """Get the language."""
     119        return self._language
    108120
    109121    def add(self, id, s):
     
    178190        self.add("menu_view_debug_key", "d")
    179191       
     192        self.add("menu_help", "Help")
     193        self.add("menu_help_manual", "_User's manual")
     194        self.add("menu_help_manual_key", "u")
     195        self.add("menu_help_about", "_About")
     196        self.add("menu_help_about_key", "a")
     197
    180198        self.add("tab_flight", "_Flight")
    181199        self.add("tab_flight_tooltip", "Flight wizard")
     
    936954        self.add("pirepView_tab_log_tooltip", "The flight log.")
    937955
     956        self.add("about_license",
     957                 "This program is in the public domain.")
     958
     959        self.add("about_role_prog_test", "programming, testing")
     960        self.add("about_role_negotiation", "negotiation")
     961        self.add("about_role_test", "testing")
     962
    938963#------------------------------------------------------------------------------
    939964
     
    9921017        self.add("menu_view_debug_key", "d")
    9931018       
     1019        self.add("menu_help", "Segítség")
     1020        self.add("menu_help_manual", "_Felhasználói kézikönyv")
     1021        self.add("menu_help_manual_key", "f")
     1022        self.add("menu_help_about", "_Névjegy")
     1023        self.add("menu_help_about_key", "n")
     1024
    9941025        self.add("tab_flight", "_Járat")
    9951026        self.add("tab_flight_tooltip", "Járat varázsló")
     
    17661797        self.add("pirepView_tab_log_tooltip", "A repülési napló.")
    17671798
     1799        self.add("about_license",
     1800                 "A program köztulajdonban van.")
     1801
     1802        self.add("about_role_prog_test", "programozás, tesztelés")
     1803        self.add("about_role_negotiation", "tárgyalások")
     1804        self.add("about_role_test", "tesztelés")
     1805
    17681806#------------------------------------------------------------------------------
    17691807
Note: See TracChangeset for help on using the changeset viewer.