2015-10-12 00:23:37 +00:00
|
|
|
#!/usr/bin/env python3
|
2013-03-24 15:14:10 +00:00
|
|
|
|
2017-03-20 13:06:01 +00:00
|
|
|
# Copyright (C) 2013-2017 Christian Thomas Jacobs.
|
2013-03-24 15:14:10 +00:00
|
|
|
|
|
|
|
# This file is part of PyQSO.
|
|
|
|
|
|
|
|
# PyQSO is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# PyQSO is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with PyQSO. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-04-26 09:10:05 +00:00
|
|
|
|
2017-02-21 18:48:50 +00:00
|
|
|
class Toolbar:
|
2013-09-14 19:15:12 +00:00
|
|
|
|
2016-01-27 16:23:09 +00:00
|
|
|
""" The toolbar underneath the menu bar. """
|
|
|
|
|
2017-03-31 09:06:11 +00:00
|
|
|
def __init__(self, application):
|
|
|
|
""" Set up the various buttons in the toolbar, and connect to their corresponding functions.
|
|
|
|
|
|
|
|
:arg application: The PyQSO application containing the main Gtk window, etc.
|
|
|
|
"""
|
2016-01-27 16:23:09 +00:00
|
|
|
|
2017-03-31 09:06:11 +00:00
|
|
|
self.application = application
|
|
|
|
self.builder = self.application.builder
|
2017-02-21 19:16:13 +00:00
|
|
|
|
2016-01-27 16:23:09 +00:00
|
|
|
self.buttons = {}
|
|
|
|
|
|
|
|
# Create logbook
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["NEW_LOGBOOK"] = self.builder.get_object("toolbar_new_logbook")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.buttons["NEW_LOGBOOK"].connect("clicked", self.application.logbook.new)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Open logbook
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["OPEN_LOGBOOK"] = self.builder.get_object("toolbar_open_logbook")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.buttons["OPEN_LOGBOOK"].connect("clicked", self.application.logbook.open)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Close logbook
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["CLOSE_LOGBOOK"] = self.builder.get_object("toolbar_close_logbook")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.buttons["CLOSE_LOGBOOK"].connect("clicked", self.application.logbook.close)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Add record
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["ADD_RECORD"] = self.builder.get_object("toolbar_add_record")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.buttons["ADD_RECORD"].connect("clicked", self.application.logbook.add_record_callback)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Edit record
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["EDIT_RECORD"] = self.builder.get_object("toolbar_edit_record")
|
2017-06-27 19:05:28 +00:00
|
|
|
self.buttons["EDIT_RECORD"].connect("clicked", self.application.logbook.edit_record_callback)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Delete record
|
2017-02-21 19:16:13 +00:00
|
|
|
self.buttons["DELETE_RECORD"] = self.builder.get_object("toolbar_delete_record")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.buttons["DELETE_RECORD"].connect("clicked", self.application.logbook.delete_record_callback)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
|
|
|
# Filter log
|
2017-02-21 19:16:13 +00:00
|
|
|
self.filter_source = self.builder.get_object("filter_source")
|
2017-03-31 09:06:11 +00:00
|
|
|
self.filter_source.connect_after("changed", self.application.logbook.filter_logs)
|
2016-01-27 16:23:09 +00:00
|
|
|
|
2017-02-21 19:38:49 +00:00
|
|
|
# Set sensitivities.
|
2016-01-27 16:23:09 +00:00
|
|
|
self.set_logbook_button_sensitive(True)
|
|
|
|
self.set_record_buttons_sensitive(False)
|
|
|
|
self.filter_source.set_sensitive(False)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def set_logbook_button_sensitive(self, sensitive):
|
|
|
|
""" Enable/disable logbook-related toolbar items.
|
|
|
|
|
|
|
|
:arg bool sensitive: If True, enable the 'new logbook' and 'open logbook' toolbar items. If False, disable them.
|
|
|
|
"""
|
|
|
|
self.buttons["NEW_LOGBOOK"].set_sensitive(sensitive)
|
|
|
|
self.buttons["OPEN_LOGBOOK"].set_sensitive(sensitive)
|
|
|
|
self.buttons["CLOSE_LOGBOOK"].set_sensitive(not sensitive)
|
|
|
|
return
|
|
|
|
|
|
|
|
def set_record_buttons_sensitive(self, sensitive):
|
|
|
|
""" Enable/disable record-related toolbar items.
|
|
|
|
|
|
|
|
:arg bool sensitive: If True, enable all the record-related toolbar items. If False, disable them all.
|
|
|
|
"""
|
|
|
|
for button_name in ["ADD_RECORD", "EDIT_RECORD", "DELETE_RECORD"]:
|
|
|
|
self.buttons[button_name].set_sensitive(sensitive)
|
|
|
|
return
|