kopia lustrzana https://github.com/ctjacobs/pyqso
Moving the menu bar over to Glade.
rodzic
98cfa7b9e1
commit
7b3f8d067b
35
bin/pyqso
35
bin/pyqso
|
@ -91,15 +91,15 @@ class PyQSO:
|
|||
|
||||
# Create a Logbook so we can add/remove/edit logs and records,
|
||||
# once connected to the SQLite database.
|
||||
#self.logbook = Logbook(self)
|
||||
#self.logbook.set_scrollable(True)
|
||||
|
||||
#self.toolbox = Toolbox(self)
|
||||
self.logbook = Logbook(self)
|
||||
self.toolbox = Toolbox(self, self.builder)
|
||||
self.menu = Menu(self, self.builder)
|
||||
|
||||
|
||||
# Set up menu and tool bars
|
||||
# These classes depend on the Logbook and Toolbox class,
|
||||
# so pack the logbook and toolbox after the menu and toolbar.
|
||||
#self.menu = Menu(self)
|
||||
|
||||
#self.toolbar = Toolbar(self)
|
||||
|
||||
#vbox_outer.pack_start(self.menu, False, False, 0)
|
||||
|
@ -108,7 +108,28 @@ class PyQSO:
|
|||
#vbox_outer.pack_start(self.toolbox, True, True, 0)
|
||||
#vbox_outer.pack_start(self.statusbar, False, False, 0)
|
||||
|
||||
self.toolbox = Toolbox(self.window, self.builder)
|
||||
if(have_config):
|
||||
if(config.get("general", "show_toolbox") == "False"):
|
||||
self.toolbox.toggle_visible_callback()
|
||||
else:
|
||||
# Hide the Toolbox by default
|
||||
self.toolbox.toggle_visible_callback()
|
||||
|
||||
if(logbook_path is not None):
|
||||
logging.info("Opening logbook: %s" % logbook_path)
|
||||
self.logbook.open(widget=None, path=logbook_path)
|
||||
else:
|
||||
# If no logbook path is specified at the command line,
|
||||
# then check if the user wants to open a default logbook.
|
||||
(section, option) = ("general", "default_logbook")
|
||||
if(have_config and config.has_option(section, option)):
|
||||
open_default_logbook = (config.get(section, option) == "True")
|
||||
(section, option) = ("general", "default_logbook_path")
|
||||
if(open_default_logbook and config.has_option(section, option)):
|
||||
logbook_path = config.get(section, option)
|
||||
if(logbook_path is not None and logbook_path != ""):
|
||||
logging.info("Opening the default logbook: %s" % logbook_path)
|
||||
self.logbook.open(widget=None, path=logbook_path)
|
||||
|
||||
self.window.show_all()
|
||||
|
||||
|
@ -118,7 +139,7 @@ class PyQSO:
|
|||
""" Show the About dialog, which includes license information. """
|
||||
about = Gtk.AboutDialog()
|
||||
about.set_modal(True)
|
||||
about.set_transient_for(parent=self)
|
||||
about.set_transient_for(parent=self.window)
|
||||
about.set_program_name("PyQSO")
|
||||
about.set_version("1.0.0")
|
||||
about.set_authors(["Christian T. Jacobs (2E0ICL)"])
|
||||
|
|
|
@ -6,31 +6,109 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-close</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image10">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-go-back</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image11">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-print</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image12">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-quit</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image13">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-about</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image14">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-add</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image15">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-edit</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image16">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-delete</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image17">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-find-and-replace</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image18">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-open</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-new</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-add</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-connect</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-disconnect</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-delete</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-edit</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-go-forward</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="pyqso">
|
||||
<property name="can_focus">False</property>
|
||||
|
@ -101,6 +179,80 @@
|
|||
<accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_delete_log">
|
||||
<property name="label" translatable="yes">Delete Selected Log</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image7</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_rename_log">
|
||||
<property name="label" translatable="yes">Rename Selected Log</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image8</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_import_log">
|
||||
<property name="label" translatable="yes">Import Log</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image9</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_export_log">
|
||||
<property name="label" translatable="yes">Export Log</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image10</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_print_log">
|
||||
<property name="label" translatable="yes">Print Log</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image11</property>
|
||||
<property name="use_stock">False</property>
|
||||
<accelerator key="p" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_quit">
|
||||
<property name="label" translatable="yes">Quit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image12</property>
|
||||
<property name="use_stock">False</property>
|
||||
<accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -111,9 +263,54 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Records</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu3">
|
||||
<object class="GtkMenu" id="subm_records">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_add_record">
|
||||
<property name="label" translatable="yes">Add Record...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image14</property>
|
||||
<property name="use_stock">False</property>
|
||||
<accelerator key="r" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_edit_record">
|
||||
<property name="label" translatable="yes">Edit Selected Record...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image15</property>
|
||||
<property name="use_stock">False</property>
|
||||
<accelerator key="e" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_delete_record">
|
||||
<property name="label" translatable="yes">Delete Selected Record...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image16</property>
|
||||
<property name="use_stock">False</property>
|
||||
<accelerator key="Delete" signal="activate"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_remove_duplicates">
|
||||
<property name="label" translatable="yes">Remove Duplicate Records</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image17</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -123,6 +320,29 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">View</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="subm_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="mitem_toolbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Toolbox</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="mitem_preferences">
|
||||
<property name="label" translatable="yes">Preferences...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image18</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -131,16 +351,16 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Help</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu4">
|
||||
<object class="GtkMenu" id="subm_help">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem15">
|
||||
<property name="label">gtk-about</property>
|
||||
<object class="GtkImageMenuItem" id="mitem_about">
|
||||
<property name="label">About PyQSO</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="image">image13</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
225
pyqso/menu.py
225
pyqso/menu.py
|
@ -26,224 +26,99 @@ except ImportError:
|
|||
import os.path
|
||||
|
||||
|
||||
class Menu(Gtk.MenuBar):
|
||||
class Menu:
|
||||
|
||||
""" The PyQSO menu bar along the top of the main window. """
|
||||
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent, builder):
|
||||
""" Set up all menu items and connect to the various functions.
|
||||
|
||||
:arg parent: The parent Gtk window.
|
||||
:arg builder: The Gtk builder.
|
||||
"""
|
||||
|
||||
logging.debug("New Menu instance created!")
|
||||
|
||||
# First let's call the constructor of the super class (Gtk.MenuBar)
|
||||
Gtk.MenuBar.__init__(self)
|
||||
|
||||
logging.debug("Setting up the menu bar...")
|
||||
agrp = Gtk.AccelGroup()
|
||||
parent.add_accel_group(agrp)
|
||||
|
||||
self.parent = parent
|
||||
self.builder = builder
|
||||
|
||||
# Collect Gtk menu items and connect signals.
|
||||
self.items = {}
|
||||
|
||||
# LOGBOOK ######
|
||||
mitem_logbook = Gtk.MenuItem("Logbook")
|
||||
self.append(mitem_logbook)
|
||||
subm_logbook = Gtk.Menu()
|
||||
mitem_logbook.set_submenu(subm_logbook)
|
||||
|
||||
# Create logbook
|
||||
mitem_connect = Gtk.ImageMenuItem("Create a New Logbook...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU)
|
||||
mitem_connect.set_image(icon)
|
||||
mitem_connect.connect("activate", parent.logbook.new)
|
||||
subm_logbook.append(mitem_connect)
|
||||
self.items["NEW_LOGBOOK"] = mitem_connect
|
||||
# New logbook
|
||||
self.items["NEW_LOGBOOK"] = self.builder.get_object("mitem_new_logbook")
|
||||
self.items["NEW_LOGBOOK"].connect("activate", parent.logbook.new)
|
||||
|
||||
# Open logbook
|
||||
mitem_connect = Gtk.ImageMenuItem("Open an Existing Logbook...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU)
|
||||
mitem_connect.set_image(icon)
|
||||
mitem_connect.connect("activate", parent.logbook.open)
|
||||
key, mod = Gtk.accelerator_parse("<Control>O")
|
||||
mitem_connect.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_logbook.append(mitem_connect)
|
||||
self.items["OPEN_LOGBOOK"] = mitem_connect
|
||||
self.items["OPEN_LOGBOOK"] = self.builder.get_object("mitem_open_logbook")
|
||||
self.items["OPEN_LOGBOOK"].connect("activate", parent.logbook.open)
|
||||
|
||||
# Close logbook
|
||||
mitem_disconnect = Gtk.ImageMenuItem("Close Logbook")
|
||||
mitem_disconnect.connect("activate", parent.logbook.close)
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
|
||||
mitem_disconnect.set_image(icon)
|
||||
key, mod = Gtk.accelerator_parse("<Control>W")
|
||||
mitem_disconnect.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_logbook.append(mitem_disconnect)
|
||||
self.items["CLOSE_LOGBOOK"] = mitem_disconnect
|
||||
|
||||
subm_logbook.append(Gtk.SeparatorMenuItem())
|
||||
self.items["CLOSE_LOGBOOK"] = self.builder.get_object("mitem_close_logbook")
|
||||
self.items["CLOSE_LOGBOOK"].connect("activate", parent.logbook.close)
|
||||
|
||||
# New log
|
||||
mitem_new = Gtk.ImageMenuItem("New Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.MENU)
|
||||
mitem_new.set_image(icon)
|
||||
mitem_new.connect("activate", parent.logbook.new_log)
|
||||
key, mod = Gtk.accelerator_parse("<Control>N")
|
||||
mitem_new.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_logbook.append(mitem_new)
|
||||
self.items["NEW_LOG"] = mitem_new
|
||||
self.items["NEW_LOG"] = self.builder.get_object("mitem_new_log")
|
||||
self.items["NEW_LOG"].connect("activate", parent.logbook.new_log)
|
||||
|
||||
# Delete the current log
|
||||
mitem_delete = Gtk.ImageMenuItem("Delete Selected Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.MENU)
|
||||
mitem_delete.set_image(icon)
|
||||
mitem_delete.connect("activate", parent.logbook.delete_log)
|
||||
subm_logbook.append(mitem_delete)
|
||||
self.items["DELETE_LOG"] = mitem_delete
|
||||
self.items["DELETE_LOG"] = self.builder.get_object("mitem_delete_log")
|
||||
self.items["DELETE_LOG"].connect("activate", parent.logbook.delete_log)
|
||||
|
||||
# Rename the current log
|
||||
mitem_rename = Gtk.ImageMenuItem("Rename Selected Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.MENU)
|
||||
mitem_rename.set_image(icon)
|
||||
mitem_rename.connect("activate", parent.logbook.rename_log)
|
||||
subm_logbook.append(mitem_rename)
|
||||
self.items["RENAME_LOG"] = mitem_rename
|
||||
|
||||
subm_logbook.append(Gtk.SeparatorMenuItem())
|
||||
self.items["RENAME_LOG"] = self.builder.get_object("mitem_rename_log")
|
||||
self.items["RENAME_LOG"].connect("activate", parent.logbook.rename_log)
|
||||
|
||||
# Import log
|
||||
mitem_import = Gtk.ImageMenuItem("Import Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.MENU)
|
||||
mitem_import.set_image(icon)
|
||||
mitem_import.connect("activate", parent.logbook.import_log)
|
||||
subm_logbook.append(mitem_import)
|
||||
self.items["IMPORT_LOG"] = mitem_import
|
||||
self.items["IMPORT_LOG"] = self.builder.get_object("mitem_import_log")
|
||||
self.items["IMPORT_LOG"].connect("activate", parent.logbook.import_log)
|
||||
|
||||
# Export the current log
|
||||
mitem_export = Gtk.ImageMenuItem("Export Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU)
|
||||
mitem_export.set_image(icon)
|
||||
mitem_export.connect("activate", parent.logbook.export_log)
|
||||
subm_logbook.append(mitem_export)
|
||||
self.items["EXPORT_LOG"] = mitem_export
|
||||
|
||||
subm_logbook.append(Gtk.SeparatorMenuItem())
|
||||
self.items["EXPORT_LOG"] = self.builder.get_object("mitem_export_log")
|
||||
self.items["EXPORT_LOG"].connect("activate", parent.logbook.export_log)
|
||||
|
||||
# Print log
|
||||
mitem_print = Gtk.ImageMenuItem("Print Log")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_PRINT, Gtk.IconSize.MENU)
|
||||
mitem_print.set_image(icon)
|
||||
mitem_print.connect("activate", parent.logbook.print_log)
|
||||
key, mod = Gtk.accelerator_parse("<Control>P")
|
||||
mitem_print.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_logbook.append(mitem_print)
|
||||
self.items["PRINT_LOG"] = mitem_print
|
||||
|
||||
subm_logbook.append(Gtk.SeparatorMenuItem())
|
||||
self.items["PRINT_LOG"] = self.builder.get_object("mitem_print_log")
|
||||
self.items["PRINT_LOG"].connect("activate", parent.logbook.print_log)
|
||||
|
||||
# Quit
|
||||
mitem_quit = Gtk.ImageMenuItem("Quit")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_QUIT, Gtk.IconSize.MENU)
|
||||
mitem_quit.set_image(icon)
|
||||
mitem_quit.connect("activate", Gtk.main_quit)
|
||||
key, mod = Gtk.accelerator_parse("<Control>Q")
|
||||
mitem_quit.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_logbook.append(mitem_quit)
|
||||
self.items["QUIT"] = mitem_quit
|
||||
self.items["QUIT"] = self.builder.get_object("mitem_quit")
|
||||
self.items["QUIT"].connect("activate", Gtk.main_quit)
|
||||
|
||||
# RECORDS ######
|
||||
mitem_records = Gtk.MenuItem("Records")
|
||||
self.append(mitem_records)
|
||||
subm_records = Gtk.Menu()
|
||||
mitem_records.set_submenu(subm_records)
|
||||
# Add record
|
||||
self.items["ADD_RECORD"] = self.builder.get_object("mitem_add_record")
|
||||
self.items["ADD_RECORD"].connect("activate", parent.logbook.add_record_callback)
|
||||
|
||||
mitem_addrecord = Gtk.ImageMenuItem("Add Record...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.MENU)
|
||||
mitem_addrecord.set_image(icon)
|
||||
mitem_addrecord.connect("activate", parent.logbook.add_record_callback)
|
||||
key, mod = Gtk.accelerator_parse("<Control>R")
|
||||
mitem_addrecord.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_records.append(mitem_addrecord)
|
||||
self.items["ADD_RECORD"] = mitem_addrecord
|
||||
# Edit selected record
|
||||
self.items["EDIT_RECORD"] = self.builder.get_object("mitem_edit_record")
|
||||
self.items["EDIT_RECORD"].connect("activate", parent.logbook.edit_record_callback)
|
||||
|
||||
mitem_editrecord = Gtk.ImageMenuItem("Edit Selected Record...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.MENU)
|
||||
mitem_editrecord.set_image(icon)
|
||||
mitem_editrecord.connect("activate", parent.logbook.edit_record_callback, None, None)
|
||||
key, mod = Gtk.accelerator_parse("<Control>E")
|
||||
mitem_editrecord.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_records.append(mitem_editrecord)
|
||||
self.items["EDIT_RECORD"] = mitem_editrecord
|
||||
# Delete selected record
|
||||
self.items["DELETE_RECORD"] = self.builder.get_object("mitem_delete_record")
|
||||
self.items["DELETE_RECORD"].connect("activate", parent.logbook.delete_record_callback)
|
||||
|
||||
mitem_deleterecord = Gtk.ImageMenuItem("Delete Selected Record...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.MENU)
|
||||
mitem_deleterecord.set_image(icon)
|
||||
mitem_deleterecord.connect("activate", parent.logbook.delete_record_callback)
|
||||
key, mod = Gtk.accelerator_parse("Delete")
|
||||
mitem_deleterecord.add_accelerator("activate", agrp, key, mod, Gtk.AccelFlags.VISIBLE)
|
||||
subm_records.append(mitem_deleterecord)
|
||||
self.items["DELETE_RECORD"] = mitem_deleterecord
|
||||
# Remove duplicates
|
||||
self.items["REMOVE_DUPLICATES"] = self.builder.get_object("mitem_remove_duplicates")
|
||||
self.items["REMOVE_DUPLICATES"].connect("activate", parent.logbook.remove_duplicates_callback)
|
||||
|
||||
mitem_removeduplicates = Gtk.ImageMenuItem("Remove Duplicate Records")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_FIND_AND_REPLACE, Gtk.IconSize.MENU)
|
||||
mitem_removeduplicates.set_image(icon)
|
||||
mitem_removeduplicates.connect("activate", parent.logbook.remove_duplicates_callback)
|
||||
subm_records.append(mitem_removeduplicates)
|
||||
self.items["REMOVE_DUPLICATES"] = mitem_removeduplicates
|
||||
|
||||
# VIEW ######
|
||||
mitem_view = Gtk.MenuItem("View")
|
||||
self.append(mitem_view)
|
||||
subm_view = Gtk.Menu()
|
||||
mitem_view.set_submenu(subm_view)
|
||||
|
||||
mitem_toolbox = Gtk.CheckMenuItem("Toolbox")
|
||||
# View toolbox
|
||||
self.items["TOOLBOX"] = self.builder.get_object("mitem_toolbox")
|
||||
config = configparser.ConfigParser()
|
||||
have_config = (config.read(os.path.expanduser('~/.config/pyqso/preferences.ini')) != [])
|
||||
(section, option) = ("general", "show_toolbox")
|
||||
if(have_config and config.has_option(section, option)):
|
||||
mitem_toolbox.set_active(config.get(section, option) == "True")
|
||||
self.items["TOOLBOX"].set_active(config.get(section, option) == "True")
|
||||
else:
|
||||
mitem_toolbox.set_active(False) # Don't show the toolbox by default
|
||||
mitem_toolbox.connect("activate", parent.toolbox.toggle_visible_callback)
|
||||
subm_view.append(mitem_toolbox)
|
||||
self.items["TOOLBOX"] = mitem_toolbox
|
||||
self.items["TOOLBOX"].set_active(False) # Don't show the toolbox by default
|
||||
self.items["TOOLBOX"].connect("activate", parent.toolbox.toggle_visible_callback)
|
||||
|
||||
mitem_preferences = Gtk.ImageMenuItem("Preferences...")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU)
|
||||
mitem_preferences.set_image(icon)
|
||||
mitem_preferences.connect("activate", parent.show_preferences)
|
||||
subm_view.append(mitem_preferences)
|
||||
self.items["PREFERENCES"] = mitem_preferences
|
||||
|
||||
# HELP ######
|
||||
mitem_help = Gtk.MenuItem("Help")
|
||||
self.append(mitem_help)
|
||||
subm_help = Gtk.Menu()
|
||||
mitem_help.set_submenu(subm_help)
|
||||
# Preferences
|
||||
self.items["PREFERENCES"] = self.builder.get_object("mitem_preferences")
|
||||
self.items["PREFERENCES"].connect("activate", parent.show_preferences)
|
||||
|
||||
# About
|
||||
mitem_about = Gtk.ImageMenuItem("About PyQSO")
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_ABOUT, Gtk.IconSize.MENU)
|
||||
mitem_about.set_image(icon)
|
||||
mitem_about.connect("activate", parent.show_about)
|
||||
subm_help.append(mitem_about)
|
||||
self.items["ABOUT"] = self.builder.get_object("mitem_about")
|
||||
self.items["ABOUT"].connect("activate", parent.show_about)
|
||||
|
||||
self.set_logbook_item_sensitive(True)
|
||||
self.set_log_items_sensitive(False)
|
||||
|
|
|
@ -54,11 +54,11 @@ class Toolbox:
|
|||
|
||||
def toggle_visible_callback(self, widget=None):
|
||||
""" Show/hide the toolbox. """
|
||||
self.set_visible(not self.get_visible())
|
||||
self.tools.set_visible(not self.tools.get_visible())
|
||||
return
|
||||
|
||||
def _on_switch_page(self, widget, label, new_page):
|
||||
""" Re-draw the Grey Line if the user switches to the grey line tab. """
|
||||
if(isinstance(label, GreyLine)):
|
||||
if(label.get_text() == "Grey Line"):
|
||||
label.draw() # Note that 'label' is actually a GreyLine object.
|
||||
return
|
||||
|
|
Ładowanie…
Reference in New Issue