[hamradio-commits] [pyqso] 01/04: New upstream version 1.0.0

Iain R. Learmonth irl at moszumanska.debian.org
Sun Aug 6 17:09:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

irl pushed a commit to branch master
in repository pyqso.

commit 6c9c422cd9f144df1112651c24676f83b341d039
Author: Iain R. Learmonth <irl at debian.org>
Date:   Sun Aug 6 17:25:33 2017 +0100

    New upstream version 1.0.0
---
 .gitignore                                      |    1 -
 .travis.yml                                     |    4 +-
 CHANGELOG.md                                    |   34 +-
 Makefile                                        |    8 +-
 README.md                                       |   35 +-
 bin/pyqso                                       |  145 +-
 docs/source/conf.py                             |   12 +-
 docs/source/getting_started.rst                 |   27 +-
 docs/source/images/awards.png                   |  Bin 11055 -> 10218 bytes
 docs/source/images/dx_cluster.png               |  Bin 39147 -> 62052 bytes
 docs/source/images/edit_record.png              |  Bin 47239 -> 46054 bytes
 docs/source/images/grey_line.png                |  Bin 65869 -> 63835 bytes
 docs/source/images/logbook.png                  |  Bin 125221 -> 99535 bytes
 docs/source/images/summary.png                  |  Bin 52682 -> 50916 bytes
 docs/source/introduction.rst                    |   24 +-
 docs/source/log_management.rst                  |   31 +-
 docs/source/preferences.rst                     |   44 +-
 docs/source/pyqso.rst                           |   56 +
 docs/source/record_management.rst               |    5 +-
 docs/source/shortcuts.rst                       |    2 +-
 docs/source/toolbox.rst                         |    8 +-
 pyqso/adif.py                                   |  270 +-
 pyqso/auxiliary_dialogs.py                      |   12 +-
 pyqso/awards.py                                 |   67 +-
 pyqso/blank.py                                  |   62 +
 pyqso/cabrillo.py                               |  105 +
 pyqso/cabrillo_export_dialog.py                 |   70 +
 pyqso/calendar_dialog.py                        |   60 +
 pyqso/callsign_lookup.py                        |  312 +-
 pyqso/compare.py                                |   73 +
 pyqso/dx_cluster.py                             |  256 +-
 pyqso/grey_line.py                              |   63 +-
 pyqso/log.py                                    |  376 +-
 pyqso/log_name_dialog.py                        |   43 +-
 pyqso/logbook.py                                | 1081 +++---
 pyqso/menu.py                                   |  275 +-
 pyqso/preferences_dialog.py                     |  645 ++--
 pyqso/printer.py                                |  132 +
 pyqso/record_dialog.py                          |  545 ++-
 {icons => pyqso/res}/log_1024x1024.xcf          |  Bin
 {icons => pyqso/res}/log_14x14.png              |  Bin
 {icons => pyqso/res}/log_192x192.png            |  Bin
 {icons => pyqso/res}/log_64x64.png              |  Bin
 pyqso/res/pyqso.glade                           | 4429 +++++++++++++++++++++++
 pyqso/summary.py                                |  238 ++
 pyqso/telnet_connection_dialog.py               |  125 +-
 pyqso/toolbar.py                                |   97 +-
 pyqso/toolbox.py                                |   50 +-
 setup.py                                        |   39 +-
 tests/res/ADIF.test_read.adi                    |    4 +
 tests/res/ADIF.test_read_alphabet.adi           |    2 +
 tests/res/ADIF.test_read_capitalisation.adi     |    2 +
 tests/res/ADIF.test_read_header_only.adi        |    1 +
 tests/res/ADIF.test_read_multiple.adi           |    9 +
 tests/res/ADIF.test_read_no_header.adi          |    1 +
 tests/res/invalid.db                            |    1 +
 {pyqso/unittest_resources => tests/res}/test.db |  Bin 3072 -> 4096 bytes
 tests/test_adif.py                              |  200 +
 tests/test_awards.py                            |   54 +
 tests/test_cabrillo.py                          |   61 +
 tests/test_calendar_dialog.py                   |   45 +
 tests/test_callsign_lookup.py                   |  141 +
 tests/test_compare.py                           |   85 +
 tests/test_dx_cluster.py                        |   49 +
 tests/test_log.py                               |  227 ++
 tests/test_logbook.py                           |  144 +
 tests/test_printer.py                           |   52 +
 tests/test_record_dialog.py                     |  111 +
 tests/test_summary.py                           |   72 +
 69 files changed, 8359 insertions(+), 2763 deletions(-)

diff --git a/.gitignore b/.gitignore
index e625f77..4296f83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,3 @@
 pyqso.debug
 build/
 docs/build
-ADIF.test*.adi
diff --git a/.travis.yml b/.travis.yml
index 86b71a8..437752e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 sudo: required
 dist: trusty
+group: deprecated-2017Q2
 
 language: python
 
@@ -11,7 +12,7 @@ virtualenv:
 
 before_install:
  - sudo apt-get update -qq
- - sudo apt-get install -yq xvfb gir1.2-gtk-3.0 python3-gi-cairo python-mpltoolkits.basemap python3-numpy python3-matplotlib python3-sphinx python-libhamlib2 python3-flake8
+ - sudo apt-get install -yq xvfb gir1.2-gtk-3.0 python3-gi-cairo python-mpltoolkits.basemap python3-numpy python3-matplotlib python3-sphinx python-libhamlib2 python3-flake8 python3-pip
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"
 
@@ -22,6 +23,7 @@ before_script:
   - export PYTHONPATH=`pwd`:$PYTHONPATH
   - echo $PYTHONPATH
   - flake8 pyqso
+  - flake8 tests
   - flake8 bin
   
 script:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0a0ff9..3b10744 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,35 @@
 # Change Log
 
+## [1.0.0] - 2017-08-02
+### Added
+- Pin-pointing of QTH on grey line map.
+- Default logbook.
+- Continued support for Python 2.x modules. Thanks to @gaionim (IU2HDS) for this patch.
+- Auto-filling of the Mode field using Hamlib.
+- Glade design of main window and dialogs.
+- Exporting of logs in the Cabrillo format.
+- More unit tests.
+- More tooltips.
+- The option to enter the frequency in Hz, kHz, MHz, or GHz in the Add/Edit Record dialog. Frequencies are still displayed in MHz in the logbook.
+- Record/QSO count feature.
+
+### Changed
+- Using username and port information (in addition to hostname) when creating an identifier for a DX cluster bookmark.
+- Pressing the Return key after entering a DX cluster command will send the command to the Telnet server.
+- Pressing the Return key after entering QSO information via the record dialog will add the QSO to the log.
+- Moved all unit tests to a dedicated tests directory.
+- Duplicate QSOs are now defined as having the same CALL, QSO_DATE and TIME_ON values. FREQ and MODE are no longer considered.
+- Improved the runtime performance of duplicate QSO removal.
+- Logs are now printed on a landscape page so that more QSO details can be included. The page layout has been improved.
+- Better handling of "\n" characters in the NOTES field.
+
+### Fixed
+- Any characters in the DX cluster server's reponse that cannot be decoded are now replaced with a replacement marker in the DX cluster frame.
+- Fixed the QSO index used in the Gtk.ListStore. Just before a QSO is added with add_record it was assumed that it's index would be max(rowid)+1, which is not always the case. This led to inconsistencies between the Gtk.ListStore and the database. Indices used in the Gtk.ListStore are now obtained directly from the database after insertion.
+- Direction of sorting.
+- IOTA data retrieval when looking up callsigns using hamqth.com.
+- Use percent-encoding when connecting to a callsign database.
+
 ## [0.3] - 2016-05-28
 ### Added
 - Support for callsign lookups using the HamQTH.com database.
@@ -25,7 +55,7 @@
 - Button to add the current date and time.
 - Option to specify default values for the power and mode fields.
 - Allow UTC time to be used when creating records.
-- Allow prefixes/suffixes to be removed when looking up a callsign (e.g. "MYCALL" would be extracted from "EA3/MYCALL/M").
+- Allow prefixes/suffixes to be removed when looking up a callsign (e.g. "MYCALL" would be extracted from "F/MYCALL/QRP").
 
 ### Changed
 - Migrated the documentation to a Sphinx-based setup.
@@ -65,7 +95,7 @@
 - QSO filtering and sorting.
 - Duplicate record removal.
 
-[Unreleased]: https://github.com/ctjacobs/pyqso/compare/v0.3...master
+[1.0.0]: https://github.com/ctjacobs/pyqso/compare/v0.3...v1.0.0
 [0.3]: https://github.com/ctjacobs/pyqso/compare/v0.2...v0.3
 [0.2]: https://github.com/ctjacobs/pyqso/compare/v0.1...v0.2
 [0.1]: https://github.com/ctjacobs/pyqso/compare/v0.1b...v0.1
diff --git a/Makefile b/Makefile
index 74a08ba..7fc68f5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -23,7 +23,7 @@ input: 	clean install docs
 
 install:
 	@echo "*** Installing PyQSO"
-	python3 setup.py install
+	pip3 install .
 
 docs:
 	@echo "*** Building the documentation"
@@ -31,12 +31,12 @@ docs:
 
 test:
 	@echo "*** Running the unit tests"
-	python3 -m unittest discover --start-directory=pyqso --pattern=*.py --verbose
+	python3 -m unittest discover --start-directory=tests --pattern=*.py --verbose
 
 clean:
 	@echo "*** Cleaning docs directory"
 	cd docs; make clean; cd ..
 	@echo "*** Cleaning pyqso directory"
-	rm -f ADIF.test_*.adi; cd pyqso; rm -f *.pyc ADIF.test_*.adi; cd ..
+	rm -f ADIF.test_*.adi Cabrillo.test_*.log Printer.test_*.pdf Logbook.test_*.db; cd pyqso; rm -f *.pyc ADIF.test_*.adi Cabrillo.test_*.log; cd ..
 	@echo "*** Removing build directory"
 	rm -rf build
diff --git a/README.md b/README.md
index 52ee443..988f69e 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-    Copyright (C) 2013-2016 Christian T. Jacobs.
+    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
     This file is part of PyQSO.
 
@@ -26,26 +26,24 @@ PyQSO is a contact logging tool for amateur radio operators.
 Installation and running
 ------------------------
 
-Assuming that the current working directory is PyQSO's base directory (the directory that the Makefile is in), PyQSO can be installed via the terminal with the following command:
+Assuming that the current working directory is PyQSO's base directory (the directory that the `Makefile` is in), PyQSO can be run without installation by issuing the following command in the terminal:
 
-   `make install`
+    python3 bin/pyqso
 
-Note: 'sudo' may be needed for this. Once installed, the following command will run PyQSO:
-   
-   `pyqso`
+If the `pip3` package manager is available on your system then PyQSO can be installed system-wide using:
 
-Alternatively, PyQSO can be run (without installing) with:
+    sudo make install
 
-   `python3 bin/pyqso`
+Once installed, the following command will run PyQSO:
 
-from PyQSO's base directory.
+    pyqso
 
 Documentation
 -------------
 
 The PyQSO documentation is stored in the `docs` directory. It can be built with the following command:
 
-   `make docs`
+    make docs
 
 which will produce an HTML version of the documentation in `docs/build/html` that can be opened in a web browser.
 
@@ -60,21 +58,32 @@ PyQSO depends on the following Debian packages:
 * python3
 * python3-gi-cairo (for log printing purposes)
 
-The following extra packages are necessary to enable the grey line tool and the plotting of logbook statistics:
+The following extra packages are necessary to fully enable the grey line tool and the plotting of logbook statistics:
 
 * python3-matplotlib (version 1.3.0 or later)
 * python3-mpltoolkits.basemap
 * python3-numpy
 * libxcb-render0-dev
 * python3-cairocffi
+* [geocoder](https://pypi.python.org/pypi/geocoder) (installable with `pip3` and used for QTH lookups)
 
 The following extra package is necessary to build the documentation:
 
 * python3-sphinx
 
-There currently does not exist a Python 3-compatible Debian package for [Hamlib](http://www.hamlib.org). This library must be built manually to enable Hamlib support.
+There currently does not exist a Python 3-compatible Debian package for [Hamlib](http://www.hamlib.org). This library must be built manually to enable Hamlib support. As per the instructions on the [Hamlib mailing list](https://sourceforge.net/p/hamlib/mailman/message/35692744/), run the following commands in the Hamlib root directory (you may need to run `sudo apt-get install build-essential autoconf automake libtool` beforehand):
+
+    export PYTHON=/usr/bin/python3
+    autoreconf --install
+    ./configure --with-python-binding
+    make
+    sudo make install
+
+You will also need to append the Hamlib `bindings` and `bindings/.libs` directories to the `PYTHONPATH`:
+
+    export PYTHONPATH=$PYTHONPATH:/path/to/hamlib/bindings:/path/to/hamlib/bindings/.libs
 
 Contact
 -------
 
-If you have any comments or questions about PyQSO, please send them via email to Christian Jacobs (2E0ICL) at <christian at christianjacobs.uk>.
+If you have any comments or questions about PyQSO please send them via email to Christian Jacobs, M0UOS, at <christian at christianjacobs.uk>.
diff --git a/bin/pyqso b/bin/pyqso
index 88d553a..6ea059a 100755
--- a/bin/pyqso
+++ b/bin/pyqso
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2012-2016 Christian T. Jacobs.
+#    Copyright (C) 2012-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,23 +17,30 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
+from gi import require_version
+require_version('Gtk', '3.0')
+require_version('PangoCairo', '1.0')
 from gi.repository import Gtk, GdkPixbuf
 import argparse
-import configparser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import os
 import os.path
 import sys
 import signal
+import pkg_resources
+
+import logging
+logging.basicConfig(level=logging.INFO)
+logging.info("PyQSO version 1.0.0")
 
 # This will help Python find the PyQSO modules that need to be imported below.
 pyqso_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir)
 sys.path.insert(0, pyqso_path)
 
-import logging
-logging.basicConfig(level=logging.INFO)
-logging.info("PyQSO version 0.3")
-
-# PyQSO modules
+# PyQSO modules.
 from pyqso.adif import *
 from pyqso.logbook import *
 from pyqso.menu import *
@@ -42,7 +49,7 @@ from pyqso.toolbox import *
 from pyqso.preferences_dialog import *
 
 
-class PyQSO(Gtk.Window):
+class PyQSO:
 
     """ The PyQSO application class. """
 
@@ -52,133 +59,111 @@ class PyQSO(Gtk.Window):
         :arg str logbook_path: An optional argument containing the path of the logbook file to open. If no value is provided, this defaults to None and no logbook is opened.
         """
 
-        # Call the constructor of the super class (Gtk.Window)
-        Gtk.Window.__init__(self, title="PyQSO")
+        # Get the PyQSO main window defined in the Glade file.
+        self.builder = Gtk.Builder()
+        glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade"))
+        self.builder.add_from_file(glade_file_path)
+        self.window = self.builder.get_object("pyqso")
 
         # Check that the directory for holding PyQSO configuration files exists. If it doesn't, create it now.
-        try:
-            os.makedirs(os.path.expanduser('~/.config/pyqso'), exist_ok=True)
-        except Exception as e:
-            logging.error("An error occurred whilst creating a directory for PyQSO configuration files. Try creating the directory '~/.config/pyqso' manually.")
-            logging.exception(e)
+        config_directory = os.path.expanduser('~/.config/pyqso')
+        if not os.path.exists(config_directory):
+            try:
+                os.makedirs(config_directory)
+            except Exception as e:
+                logging.error("An error occurred whilst creating a directory for PyQSO configuration files. Try creating the directory '~/.config/pyqso' manually.")
+                logging.exception(e)
 
-        # Get any application-specific preferences from the configuration file
+        # Get any application-specific preferences from the configuration file.
         config = configparser.ConfigParser()
 
         # Check that the configuration file actually exists (and is readable)
         # otherwise, we will resort to the defaults.
-        have_config = (config.read(os.path.expanduser("~/.config/pyqso/preferences.ini")) != [])
-
-        self.set_size_request(800, 600)  # Default to an 800 x 600 resolution.
-        self.set_position(Gtk.WindowPosition.CENTER)
-        possible_icon_paths = [os.path.join(pyqso_path, "icons", "log_64x64.png")]
-        for icon_path in possible_icon_paths:
-            try:
-                self.set_icon_from_file(icon_path)
-            except Exception as error:
-                print(error.message)
+        have_config = (config.read(config_directory + "/preferences.ini") != [])
 
         # Kills the application if the close button is clicked on the main window itself.
-        self.connect("delete-event", Gtk.main_quit)
-
-        vbox_outer = Gtk.VBox()
-        self.add(vbox_outer)
+        self.window.connect("delete-event", Gtk.main_quit)
 
-        self.statusbar = Gtk.Statusbar()
+        self.statusbar = self.builder.get_object("statusbar")
         context_id = self.statusbar.get_context_id("Status")
         self.statusbar.push(context_id, "No logbook is currently open.")
 
         # 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)
 
-        # 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.
+        # Set up menu and tool bars. These classes depend on the Logbook and Toolbox class.
         self.menu = Menu(self)
         self.toolbar = Toolbar(self)
 
-        vbox_outer.pack_start(self.menu, False, False, 0)
-        vbox_outer.pack_start(self.toolbar, False, False, 0)
-        vbox_outer.pack_start(self.logbook, True, True, 0)
-        vbox_outer.pack_start(self.toolbox, True, True, 0)
-        vbox_outer.pack_start(self.statusbar, False, False, 0)
-
-        self.show_all()
+        self.window.show_all()
 
         if(have_config):
-            if(config.get("general", "show_toolbox") == "False"):
+            if(not config.getboolean("general", "show_toolbox")):
                 self.toolbox.toggle_visible_callback()
         else:
-            # Hide the Toolbox by default
+            # Hide the Toolbox by default.
             self.toolbox.toggle_visible_callback()
 
-        if(logbook_path is not None):
-            self.logbook.open(widget=None, path=logbook_path)
+        if(logbook_path):
+            logging.info("Opening logbook: %s" % logbook_path)
+            self.logbook.open(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.getboolean(section, option)
+                (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(path=logbook_path)
 
         return
 
     def show_about(self, widget):
         """ Show the About dialog, which includes license information. """
-        about = Gtk.AboutDialog()
-        about.set_modal(True)
-        about.set_transient_for(parent=self)
-        about.set_program_name("PyQSO")
-        about.set_version("0.3")
-        about.set_authors(["Christian T. Jacobs (2E0ICL)"])
-        about.set_license("""This program 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.
-
-This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.""")
-        about.set_comments("PyQSO: A contact logging tool for amateur radio operators.")
-        possible_icon_paths = [os.path.join(pyqso_path, "icons", "log_64x64.png")]
-        for icon_path in possible_icon_paths:
-            try:
-                about.set_logo(GdkPixbuf.Pixbuf.new_from_file_at_scale(icon_path, 64, 64, False))
-            except Exception as error:
-                print(error.message)
+        glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade"))
+        self.builder.add_objects_from_file(glade_file_path, ("about_dialog",))
+        about = self.builder.get_object("about_dialog")
         about.run()
         about.destroy()
         return
 
     def show_preferences(self, widget):
-        """ Show the Preferences dialog. Any changes made by the user after clicking the 'Ok' button are saved in the .cfg file. """
+        """ Show the Preferences dialog. Any changes made by the user after clicking the 'Ok' button are saved in the configuration file. """
         preferences = PreferencesDialog(self)
-        response = preferences.run()
+        response = preferences.dialog.run()
         if(response == Gtk.ResponseType.OK):
             preferences.commit()
-        preferences.destroy()
+        preferences.dialog.destroy()
         return
 
 if(__name__ == "__main__"):
-    # Get any command line arguments
+    # Get any command line arguments.
     parser = argparse.ArgumentParser(prog="pyqso")
     parser.add_argument("-d", "--debug", action="store_true", default=False, help="Enable debugging. All debugging messages will be written to pyqso.debug.")
     parser.add_argument("-l", "--logbook", action="store", type=str, metavar="/path/to/my_logbook_file.db", default=None, help="Path to a Logbook file. If this file does not already exist, then it will be created.")
     args = parser.parse_args()
 
-    # Output debugging messages to a file
+    # Output debugging messages to a file.
     if(args.debug):
-        # Get the root logger
+        # Get the root logger.
         logger = logging.getLogger()
         logger.setLevel(logging.DEBUG)
-        # Add a file handler
+        # Add a file handler.
         handler = logging.FileHandler("pyqso.debug", mode="w")
         formatter = logging.Formatter(fmt="%(asctime)s %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
         handler.setFormatter(formatter)
         logger.addHandler(handler)
 
+    # Enforce an absolute logbook file path.
+    if(args.logbook):
+        args.logbook = os.path.abspath(args.logbook)
+
     signal.signal(signal.SIGINT, signal.SIG_DFL)  # Exit PyQSO if a SIGINT signal is captured.
-    application = PyQSO(args.logbook)  # Populate the main window and show it
+    application = PyQSO(args.logbook)  # Populate the main window and show it.
     Gtk.main()  # Start up the event loop!
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 1db6649..08d9da7 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -51,16 +51,16 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'PyQSO'
-copyright = u'2015-2016, Christian T. Jacobs (2E0ICL)'
+copyright = u'2015-2017, Christian Thomas Jacobs'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '0.3'
+version = '1.0.0'
 # The full version, including alpha/beta/rc tags.
-release = '0.3'
+release = '1.0.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -204,7 +204,7 @@ latex_elements = {
 #  author, documentclass [howto, manual, or own class]).
 latex_documents = [
     ('index', 'PyQSO.tex', u'PyQSO Documentation',
-     u'Christian T. Jacobs (2E0ICL)', 'manual'),
+     u'Christian Thomas Jacobs, M0UOS', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -234,7 +234,7 @@ latex_documents = [
 # (source start file, name, description, authors, manual section).
 man_pages = [
     ('index', 'pyqso', u'PyQSO Documentation',
-     [u'Christian T. Jacobs (2E0ICL)'], 1)
+     [u'Christian Thomas Jacobs, M0UOS'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -248,7 +248,7 @@ man_pages = [
 #  dir menu entry, description, category)
 texinfo_documents = [
     ('index', 'PyQSO', u'PyQSO Documentation',
-     u'Christian T. Jacobs (2E0ICL)', 'PyQSO', 'A contact logging tool for amateur radio operators.',
+     u'Christian Thomas Jacobs, M0UOS', 'PyQSO', 'A contact logging tool for amateur radio operators.',
      'Miscellaneous'),
 ]
 
diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst
index cc1c7ad..3ff528e 100644
--- a/docs/source/getting_started.rst
+++ b/docs/source/getting_started.rst
@@ -7,10 +7,10 @@ System requirements
 It is recommended that users run PyQSO on the Linux operating system,
 since all development and testing of PyQSO takes place there.
 
-As the name suggests, PyQSO is written primarily in the Python
-programming language. The graphical user interface has been built using
-the GTK+ library through the PyGObject bindings. PyQSO also uses an
-SQLite embedded database to manage all the contacts an amateur radio
+As the name suggests, PyQSO is written primarily in the `Python <https://www.python.org/>`_
+programming language (version 3.x). The graphical user interface has been built using
+the `GTK+ library <https://www.gtk.org/>`_ through the `PyGObject bindings <https://pygobject.readthedocs.io>`_. PyQSO also uses an
+`SQLite <https://www.sqlite.org/>`_ embedded database to manage all the contacts an amateur radio
 operator makes. Users must therefore make sure that the Python
 interpreter and any additional software dependencies are satisfied
 before PyQSO can be run successfully. The list of software packages that
@@ -19,28 +19,23 @@ PyQSO depends on is provided in the ``README.md`` file.
 Installation and running
 ------------------------
 
-Assuming that the current working directory is PyQSO's base directory
-(the directory that the Makefile is in), PyQSO can be installed via the
-terminal with the following command:
+Assuming that the current working directory is PyQSO's base directory (the directory that the ``Makefile`` is in), PyQSO can be run without installation by issuing the following command in the terminal:
 
 .. code-block:: bash
 
-   make install
+   python3 bin/pyqso
 
-Note: ``sudo`` may be needed for this. Once installed, the following
-command will run PyQSO:
+If the ``pip3`` package manager is available on your system then PyQSO can be installed system-wide using:
 
 .. code-block:: bash
 
-   pyqso
+   sudo make install
 
-Alternatively, PyQSO can be run (without installing) with:
+Once installed, the following command will run PyQSO:
 
 .. code-block:: bash
 
-   python3 bin/pyqso
-
-from PyQSO's base directory.
+   pyqso
 
 Command-line options
 ~~~~~~~~~~~~~~~~~~~~
@@ -87,7 +82,7 @@ Once the logbook has been opened, its name will appear in the status bar. All lo
    .. figure::  images/logbook.png
       :align:   center
       
-      The PyQSO main window, showing the records in a log called ``HF``, and the DX cluster tool in the toolbox below it.
+      The PyQSO main window, showing the records in a log called ``SO50`` (for contacts via the `amateur radio satellite <https://www.amsat.org/>`_ SO-50), and the DX cluster tool in the toolbox below it.
 
 Closing a logbook
 -----------------
diff --git a/docs/source/images/awards.png b/docs/source/images/awards.png
index 991e4ae..fdb62fd 100644
Binary files a/docs/source/images/awards.png and b/docs/source/images/awards.png differ
diff --git a/docs/source/images/dx_cluster.png b/docs/source/images/dx_cluster.png
index d3643f9..3661c63 100644
Binary files a/docs/source/images/dx_cluster.png and b/docs/source/images/dx_cluster.png differ
diff --git a/docs/source/images/edit_record.png b/docs/source/images/edit_record.png
index 068a2b5..599b562 100644
Binary files a/docs/source/images/edit_record.png and b/docs/source/images/edit_record.png differ
diff --git a/docs/source/images/grey_line.png b/docs/source/images/grey_line.png
index 36b7e28..a5d89d3 100644
Binary files a/docs/source/images/grey_line.png and b/docs/source/images/grey_line.png differ
diff --git a/docs/source/images/logbook.png b/docs/source/images/logbook.png
index 02a0cce..9d9e023 100644
Binary files a/docs/source/images/logbook.png and b/docs/source/images/logbook.png differ
diff --git a/docs/source/images/summary.png b/docs/source/images/summary.png
index 63128ef..3a1c46d 100644
Binary files a/docs/source/images/summary.png and b/docs/source/images/summary.png differ
diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst
index b90173c..b6deef7 100644
--- a/docs/source/introduction.rst
+++ b/docs/source/introduction.rst
@@ -10,12 +10,11 @@ about the contacts/QSOs they make with other operators on the air. All
 information is stored in a light-weight SQL database. Other key features
 include:
 
--  Customisable interface (e.g. only show callsign and frequency
-   information).
+-  Customisable interface (e.g. only show callsign and frequency information).
 
--  Import and export logs in ADIF format.
+-  Import logs in `ADIF <http://www.adif.org/>`_ format, and export logs in ADIF or `Cabrillo <http://wwrof.org/cabrillo/>`_ format.
 
--  Perform callsign lookups and auto-fill data fields using the qrz.com and hamqth.com online databases.
+-  Perform callsign lookups and auto-fill data fields using the `qrz.com <http://www.qrz.com/>`_ and `hamqth.com <http://www.hamqth.com/>`_ online databases.
 
 -  Sort the logs by individual fields.
 
@@ -23,18 +22,17 @@ include:
 
 -  Connect to Telnet-based DX clusters.
 
--  Progress tracker for the DXCC award.
+-  Progress tracker for the `DXCC <http://www.arrl.org/dxcc/>`_ award.
 
 -  Grey line plotter.
 
--  Filter out QSOs based on the callsign field (e.g. only display
-   contacts with callsigns beginning with "M6").
+-  Filter QSOs based on callsign (e.g. only display contacts with callsigns beginning with "M6").
 
 -  Remove duplicate QSOs.
 
--  Basic support for the Hamlib library.
+-  Basic support for the `Hamlib <http://hamlib.sourceforge.net/>`_ library.
 
-The source code for PyQSO, written in Python (version 3.x), is available for download from the `GitHub repository <https://github.com/ctjacobs/pyqso>`_.
+The source code for PyQSO, written in `Python <https://www.python.org/>`_ (version 3.x), is available for download from the `GitHub repository <https://github.com/ctjacobs/pyqso>`_.
 
 Data storage model
 ------------------
@@ -42,7 +40,7 @@ Data storage model
 Many amateur radio operators choose to store all the contacts they ever
 make in a single *logbook*, whereas others keep a separate logbook for
 each year, for example. Each logbook may be divided up to form multiple
-distinct *logs*, perhaps one for casual repeater contacts and another
+distinct *logs*, perhaps one for casual repeater contacts, another for satellite contacts, and another
 for DX'ing. Finally, each log can contain multiple *records*. PyQSO is
 based around this three-tier model for data storage, going from logbooks
 at the top to individual records at the bottom.
@@ -57,15 +55,15 @@ log.
 Licensing
 ---------
 
-PyQSO is free software, released under the `GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.en.html>`_. Please see the file called ``COPYING`` for more information. A copyright year range of the form YYYY-ZZZZ specifies every single year from YYYY to ZZZZ inclusive (for example, 2012-2016 means 2012, 2013, 2014, 2015, 2016).
+PyQSO is free software, released under the `GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.en.html>`_. Please see the file called ``COPYING`` for more information. A copyright year range of the form YYYY-ZZZZ specifies every single year from YYYY to ZZZZ inclusive (for example, 2012-2017 means 2012, 2013, 2014, 2015, 2016, 2017).
 
 Contact
 -------
 
-If you have any comments or questions about PyQSO, please send them via email to Christian Jacobs (2E0ICL) at christian at christianjacobs.uk. Bug reports and feature requests can be made via the `issue tracker <https://github.com/ctjacobs/pyqso/issues>`_.
+If you have any comments or questions about PyQSO, please send them via email to Christian Jacobs, M0UOS, at christian at christianjacobs.uk. Bug reports and feature requests can be made via the `issue tracker <https://github.com/ctjacobs/pyqso/issues>`_.
 
 Structure of this documentation
 -------------------------------
 
-The structure of this documentation is as follows. The section on `Getting Started <getting_started.html>`_ provides information on the PyQSO installation process through to creating a new logbook (or opening an existing one). The `Log Management <log_management.html>`_ section explains how to create a log in the logbook, as well as the basic operations that users can perform with existing logs, such as printing, importing from/exporting to ADIF format, and sorting. The `Record Managemen [...]
+The structure of this documentation is as follows. The section on `Getting Started <getting_started.html>`_ provides information on the PyQSO installation process through to creating a new logbook (or opening an existing one). The `Log Management <log_management.html>`_ section explains how to create a log in the logbook, as well as the basic operations that users can perform with existing logs, such as printing, importing/exporting logs, and sorting. The `Record Management <record_manag [...]
 
diff --git a/docs/source/log_management.rst b/docs/source/log_management.rst
index 5e3783c..16204cc 100644
--- a/docs/source/log_management.rst
+++ b/docs/source/log_management.rst
@@ -11,7 +11,7 @@ Creating a new log
 ------------------
 
 To create a new log, click ``New Log`` in the ``Logbook`` menu and enter
-the desired name of the log (e.g. repeater\_contacts, dx, mobile\_log).
+the desired name of the log in the dialog window that appears (e.g. repeater\_contacts, dx, mobile\_log).
 Alternatively, use the shortcut key combination ``Ctrl + N``.
 
 The log name must be unique (i.e. it cannot already exist in the
@@ -19,7 +19,7 @@ logbook). Furthermore, it can only be composed of alphanumeric
 characters and the underscore character, and the first character in the
 name must not be a number.
 
-Note: When logs are stored in the database file, field/column names from
+**Note:** When logs are stored in the database file, field/column names from
 the ADIF standard are used. However, please note that only the following
 subset of all the ADIF fields is considered: CALL, QSO\_DATE, TIME\_ON,
 FREQ, BAND, MODE, SUBMODE, TX\_PWR, RST\_SENT, RST\_RCVD, QSL\_SENT, QSL\_RCVD,
@@ -28,7 +28,7 @@ NOTES, NAME, ADDRESS, STATE, COUNTRY, DXCC, CQZ, ITUZ, IOTA. Visit the `ADIF web
 Renaming a log
 --------------
 
-To rename the currently selected log, click ``Rename Selected Log`` in
+To rename the currently selected log, click ``Rename Selected Log...`` in
 the ``Logbook`` menu. Remember that the log's new name cannot be the
 same as another log in the logbook.
 
@@ -39,26 +39,29 @@ To delete the currently selected log, click ``Delete Selected Log`` in
 the ``Logbook`` menu. As with all database operations in PyQSO, this is
 permanent and cannot be undone.
 
-Importing and exporting a log
------------------------------
+Exporting a log
+---------------
 
 While PyQSO stores logbooks in SQL format, it is possible to export
-individual logs in the well-known `ADIF <http://www.adif.org/>`_ format. Select the log to export,
-and click ``Export Log`` in the ``Logbook`` menu.
+individual logs in the well-known `ADIF <http://www.adif.org/>`_ and `Cabrillo <http://wwrof.org/cabrillo/>`_ formats. Select the log to export,
+and click ``Export Log as ADIF...`` or ``Export Log as Cabrillo...`` in the ``Logbook`` menu.
 
-Similarly, records can be imported from an ADIF file. Upon importing,
+**Note for contesters:** Cabrillo records typically require contest QSO information in the form ``CALL RST EXCH``, where ``EXCH`` denotes exchange information (e.g. a serial number or US state). No dedicated field exists in PyQSO to store exchange information so the RST fields should be used to store both the RST report *and* exchange information, separated by a space. The ``RST Sent`` field should therefore contain the RST and exchange information that you give to the other station (e.g [...]
+
+Importing a log
+---------------
+
+Records can be imported from an ADIF file. Upon importing,
 users can choose to store the records in a new log, or append them to an
-existing log in the logbook. To import, click ``Import Log`` in the
+existing log in the logbook. To import, click ``Import Log...`` in the
 ``Logbook`` menu.
 
-Note that all data must conform to the ADIF standard, otherwise it will
-be ignored.
+Note that each QSO record being imported must conform to the ADIF standard, otherwise the record will be ignored.
 
 Printing a log
 --------------
 
-Due to restrictions on the page width, only a selection of field names
-will be printed: callsign, date, time, frequency, and mode.
+The log that is currently selected can be printed out on paper or printed to a PDF file by clicking ``Print Log...`` in the ``Logbook`` menu. Each page uses a landscape orientation to maximise the amount of QSO information per line. The following data is included: Index, Callsign, Date, Time, Frequency, Mode, RST Sent, and RST Received.
 
 Filtering by callsign
 ---------------------
@@ -70,7 +73,7 @@ contain ``xyz``.
 Sorting by field
 ----------------
 
-To sort a log by a particular field name, left-click the column header
+To sort a log by a particular field name, click the column header
 that contains that field name. By default, it is the ``Index`` field
 that is sorted in ascending order.
 
diff --git a/docs/source/preferences.rst b/docs/source/preferences.rst
index fc5a253..880ebaa 100644
--- a/docs/source/preferences.rst
+++ b/docs/source/preferences.rst
@@ -9,46 +9,60 @@ General
 
 Under the ``General`` tab, the user can choose to:
 
--  always show the toolbox (see the `Toolbox <toolbox.html>`_ section) when PyQSO is started
+-  Always show the toolbox (see the `Toolbox <toolbox.html>`_ section) when PyQSO is started.
 
--  display yearly logbook statistics on the Summary page when a logbook is opened (see figure:summary_)
+-  Display yearly logbook statistics on the Summary page when a logbook is opened (see figure:summary_).
 
--  keep the ``Add Record`` dialog window open after a new QSO is added, in preparation for the next QSO
+-  Open a default logbook file.
+
+-  Keep the ``Add Record`` dialog window open after a new QSO is added, in preparation for the next QSO.
+
+-  Pin-point the user's QTH on the grey line map by specifying the latitude-longitude coordinates (or looking them up based on the QTH's name, e.g. city name).
 
    .. _figure:summary:
    .. figure::  images/summary.png
       :align:   center
       
       The Summary page which appears after a logbook is opened. This presents some basic logbook statistics.
-      
-View
-----
-
-Not all the available fields have to be displayed in the logbook. The user can choose to hide a subset of them by unchecking them in the ``View`` tab. PyQSO must be restarted in order for any changes to take effect.
 
-ADIF
+View
 ----
 
-PyQSO currently supports the ``NOTES`` field in the ADIF specification, but not the ``COMMENTS`` field. When a user imports a log in ADIF format, they can choose to merge any existing text in the ``COMMENTS`` field with the ``NOTES`` field by checking the 'merge' checkbox. This way, no information in the ``COMMENTS`` field is discarded during the import process.
+Not all the available fields have to be displayed in the logbook. The user can choose to hide a subset by unchecking them in the ``View`` tab. PyQSO must be restarted in order for any changes to take effect.
 
 Records
 -------
 
-The records tab allows users to choose if the UTC timezone is used when autocompleting the date and time fields, and whether the band should be automatically determined from the frequency field. Default values for the Power, Mode, and Submode fields can also be specified here.
+The records tab comprises options concerning the Add/Edit Record dialog window. It allows users to:
+
+-  Use the UTC timezone when autocompleting the date and time fields.
+
+-  Choose whether the band should be automatically determined from the frequency field.
+
+-  Specify default values for the Power, Mode, and Submode fields.
+
+-  Enter the QSO's frequency in a unit other than MHz (note that the frequency will always be presented in MHz in the main window, regardless of this preference).
+
+-  Specify the callsign lookup settings.
 
 Callsign lookup
 ~~~~~~~~~~~~~~~
 
 The user can enter their login details to access the `qrz.com <http://qrz.com/>`_ or `hamqth.com <http://hamqth.com/>`_ database and perform callsign lookups. Note that these details are currently stored in plain text (unencrypted) format.
 
-If the ``Ignore callsign prefixes and/or suffixes`` box is checked, then PyQSO will perform the callsign lookup whilst ignoring all prefixes (i.e. anything before a preceding "/" in the callsign) and the suffixes "P", "M", "A", "PM", "MM", "AM", and "QRP". For example, if the callsign to be looked up is EA3/MYCALL/P, only MYCALL will be looked up. If you get 'Callsign not found' errors, try enabling this option.
+If the ``Ignore callsign prefixes and/or suffixes`` box is checked, then PyQSO will perform the callsign lookup whilst ignoring all prefixes (i.e. anything before a preceding "/" in the callsign) and the suffixes "P", "M", "A", "PM", "MM", "AM", and "QRP". For example, if the callsign to be looked up is F/MYCALL/QRP, only MYCALL will be looked up. If you get 'Callsign not found' errors, try enabling this option.
+
+Import/Export
+-------------
+
+PyQSO currently supports the ``NOTES`` field in the ADIF specification, but not the ``COMMENTS`` field. When a user imports a log in ADIF format, they can choose to merge any existing text in the ``COMMENTS`` field with the ``NOTES`` field by checking the 'merge' checkbox. This way, no information in the ``COMMENTS`` field is discarded during the import process.
 
 Hamlib support
 --------------
 
-PyQSO features rudimentary support for the Hamlib library. The name and
+PyQSO features rudimentary support for the `Hamlib <http://hamlib.sourceforge.net/>`_ library. The name and
 path of the radio device connected to the user's computer can be
 specified in the ``Hamlib`` tab of the preferences dialog. Upon adding a
 new record to the log, PyQSO will use Hamlib to retrieve the current
-frequency that the radio device is set to and automatically fill in the
-Frequency field.
+frequency and mode that the radio device is set to and automatically fill in the
+Frequency and Mode fields.
diff --git a/docs/source/pyqso.rst b/docs/source/pyqso.rst
index 8336c24..ee2986b 100644
--- a/docs/source/pyqso.rst
+++ b/docs/source/pyqso.rst
@@ -28,6 +28,38 @@ pyqso.awards module
     :undoc-members:
     :show-inheritance:
 
+pyqso.blank module
+------------------
+
+.. automodule:: pyqso.blank
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+pyqso.cabrillo module
+---------------------
+
+.. automodule:: pyqso.cabrillo
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+pyqso.cabrillo_export_dialog module
+-----------------------------------
+
+.. automodule:: pyqso.cabrillo_export_dialog
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+pyqso.calendar_dialog module
+----------------------------
+
+.. automodule:: pyqso.calendar_dialog
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
 pyqso.callsign_lookup module
 ----------------------------
 
@@ -36,6 +68,14 @@ pyqso.callsign_lookup module
     :undoc-members:
     :show-inheritance:
 
+pyqso.compare module
+--------------------
+
+.. automodule:: pyqso.compare
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
 pyqso.dx_cluster module
 -----------------------
 
@@ -92,6 +132,14 @@ pyqso.preferences_dialog module
     :undoc-members:
     :show-inheritance:
 
+pyqso.printer module
+--------------------
+
+.. automodule:: pyqso.printer
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
 pyqso.record_dialog module
 --------------------------
 
@@ -100,6 +148,14 @@ pyqso.record_dialog module
     :undoc-members:
     :show-inheritance:
 
+pyqso.summary module
+--------------------
+
+.. automodule:: pyqso.summary
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
 pyqso.telnet_connection_dialog module
 -------------------------------------
 
diff --git a/docs/source/record_management.rst b/docs/source/record_management.rst
index 12f40d7..7b86e8c 100644
--- a/docs/source/record_management.rst
+++ b/docs/source/record_management.rst
@@ -17,7 +17,7 @@ A new QSO can be added by either:
 
 A dialog window will appear where details of the QSO can be entered (see
 figure:edit_record_). Note that the current date and time
-are filled in automatically. When ready, click ``OK`` to save the
+are filled in automatically. When ready, click ``OK`` or press the Enter key to save the
 changes.
 
    .. _figure:edit_record:
@@ -66,6 +66,5 @@ Removing duplicate records
 --------------------------
 
 PyQSO can find and delete duplicate records in a log. A record is a
-duplicate of another if its data in the Callsign, Date, Time, Frequency,
-and Mode fields are the same. Click ``Remove Duplicate Records`` in the
+duplicate of another if its data in the Callsign, Date, and Time fields are the same. Click ``Remove Duplicate Records`` in the
 ``Records`` menu.
diff --git a/docs/source/shortcuts.rst b/docs/source/shortcuts.rst
index 3bc856d..69bc22f 100644
--- a/docs/source/shortcuts.rst
+++ b/docs/source/shortcuts.rst
@@ -5,7 +5,7 @@ Keyboard shortcuts
 Description       Shortcut
 ==============    ===========
 Open logbook      Ctrl + O
-Close logbook     Ctrl + C
+Close logbook     Ctrl + W
 New log           Ctrl + N
 Print log         Ctrl + P
 Quit              Ctrl + Q
diff --git a/docs/source/toolbox.rst b/docs/source/toolbox.rst
index 29fcb84..c44f218 100644
--- a/docs/source/toolbox.rst
+++ b/docs/source/toolbox.rst
@@ -22,8 +22,8 @@ supplied. Frequently used servers can be bookmarked for next time; bookmarked se
 
 Once connected, the server output will appear in the DX
 cluster frame (see figure:dx_cluster_). A command can also
-be sent to the server by typing it into the entry box beneath the server output, and clicking the
-adjacent ``Send Command`` button.
+be sent to the server by typing it into the entry box beneath the server output and clicking the
+adjacent ``Send Command`` button (or pressing the Enter key).
 
    .. _figure:dx_cluster:
    .. figure::  images/dx_cluster.png
@@ -38,11 +38,13 @@ The grey line tool (see figure:grey_line_) can be used to
 check which parts of the world are in darkness. The position of the grey
 line is automatically updated every 30 minutes.
 
+The user's QTH can be pin-pointed on the map by specifying the QTH's location (e.g. city name) and latitude-longitude coordinates in the preferences. If the `geocoder <https://pypi.python.org/pypi/geocoder>`_ library is installed then these coordinates can be filled in for you by clicking the lookup button after entering the QTH's name, otherwise the coordinates will have to be entered manually.
+
    .. _figure:grey_line:
    .. figure::  images/grey_line.png
       :align:   center
       
-      The grey line tool.
+      The grey line tool with the user's QTH (e.g. Southampton) pin-pointed on the map.
 
 Awards
 ------
diff --git a/pyqso/adif.py b/pyqso/adif.py
index da139ab..a23d8e5 100644
--- a/pyqso/adif.py
+++ b/pyqso/adif.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2012-2016 Christian T. Jacobs.
+#    Copyright (C) 2012-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -19,10 +19,12 @@
 
 import re
 import logging
-import unittest
 from datetime import datetime
 import calendar
-import configparser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 from os.path import expanduser
 
 # ADIF field names and their associated data types available in PyQSO.
@@ -85,6 +87,7 @@ AVAILABLE_FIELD_NAMES_FRIENDLY = {"CALL": "Callsign",
 # M: Multi-line string
 # G: Multi-line international string
 # L: Location
+# E: Enumerated
 DATA_TYPES = ["A", "B", "N", "S", "I", "D", "T", "M", "G", "L", "E"]
 
 # All the valid modes listed in the ADIF specification. This is a dictionary with the key-value pairs holding the MODE and SUBMODE(s) respectively.
@@ -193,41 +196,35 @@ class ADIF:
 
     def __init__(self):
         """ Initialise class for I/O of files using the Amateur Data Interchange Format (ADIF). """
-        logging.debug("New ADIF instance created!")
+        return
 
     def read(self, path):
         """ Read an ADIF file and parse it.
 
         :arg str path: The path to the ADIF file to read.
-        :returns: A list of dictionaries (one dictionary per QSO), with each dictionary containing field-value pairs, e.g. {FREQ:145.500, BAND:2M, MODE:FM}.
+        :returns: A list of dictionaries (one dictionary per QSO), with each dictionary containing field-value pairs, e.g. {FREQ:145.500, BAND:2M, MODE:FM}. If the file cannot be read, the method returns None.
         :rtype: list
-        :raises IOError: if the ADIF file does not exist or cannot be read (e.g. due to lack of read permissions).
+        :raises IOError: If the ADIF file does not exist or cannot be read (e.g. due to lack of read permissions).
         """
         logging.debug("Reading in ADIF file with path: %s..." % path)
 
         text = ""
-        try:
-            f = open(path, mode='r', errors="replace")
+        with open(path, mode="r", errors="replace") as f:
             text = f.read()
-            f.close()  # Close the file, otherwise "bad things" might happen!
-        except IOError as e:
-            logging.error("I/O error %d: %s" % (e.errno, e.strerror))
-        except Exception as e:
-            logging.error("An error occurred when reading the ADIF file.")
-            logging.exception(e)
 
-        records = self._parse_adi(text)
+        records = self.parse_adi(text)
 
         if(records == []):
             logging.warning("No records found in the file. Empty file or wrong file type?")
 
+        logging.info("Read %d QSOs from %s in ADIF format." % (len(records), path))
         return records
 
-    def _parse_adi(self, text):
+    def parse_adi(self, text):
         """ Parse some raw text (defined in the 'text' argument) for ADIF field data.
 
         :arg str text: The raw text from the ADIF file to parse.
-        :returns: A list of dictionaries (one dictionary per QSO). Each dictionary contains the field-value pairs, e.g. {FREQ:145.500, BAND:2M, MODE:FM}.
+        :returns: A list of dictionaries (one dictionary per QSO). Each dictionary contains the field-value pairs, e.g. {"FREQ": "145.500", "BAND": "2M", "MODE": "FM"}.
         :rtype: list
         """
 
@@ -237,37 +234,34 @@ class ADIF:
 
         # ADIF-related configuration options
         config = configparser.ConfigParser()
-        have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
-        (section, option) = ("adif", "merge_comment")
-        if(have_config and config.has_option(section, option) and config.get(section, option) == "True"):
+        have_config = (config.read(expanduser("~/.config/pyqso/preferences.ini")) != [])
+        (section, option) = ("import_export", "merge_comment")
+        if(have_config and config.has_option(section, option) and config.getboolean(section, option)):
             merge_comment = True
         else:
             merge_comment = False
 
         # Separate the text at the <eor> or <eoh> markers.
-        tokens = re.split('(<eor>|<eoh>)', text, flags=re.IGNORECASE)
+        tokens = re.split("(<eor>|<eoh>)", text, flags=re.IGNORECASE)
         tokens.pop()  # Anything after the final <eor> marker should be ignored.
 
         # The header might tell us the number of records, but let's not assume
         # this and simply ignore it instead (if it exists).
-        if(re.search('<eoh>', text, flags=re.IGNORECASE) is not None):
+        if(re.search("<eoh>", text, flags=re.IGNORECASE) is not None):
             # There is a header present, so let's ignore everything
-            # up to and including the <eoh> marker. Note that
-            # re.search has been used here to handle any case sensitivity.
-            # Previously we were checking for <eoh>. <EOH> is also valid
-            # but wasn't being detected before.
+            # up to and including the <eoh> marker.
             while len(tokens) > 0:
                 t = tokens.pop(0)
-                if(re.match('<eoh>', t, flags=re.IGNORECASE) is not None):
+                if(re.match("<eoh>", t, flags=re.IGNORECASE) is not None):
                     break
 
         n_eor = 0
         n_record = 0
         records = []
-        pattern = re.compile('<(.*?):(\d*).*?>([^<\t\n\r\f\v]+)')
+        pattern = re.compile("<(.*?):(\d*).*?>([^<]+)")
 
         for t in tokens:
-            if(re.match('<eor>', t, flags=re.IGNORECASE) is not None):
+            if(re.match("<eor>", t, flags=re.IGNORECASE) is not None):
                 n_eor += 1
                 continue
             else:
@@ -284,6 +278,7 @@ class ADIF:
                     # This will help us later when comparing the field names
                     # against the available field names in the ADIF specification.
                     field_name = fd[0].upper()
+                    # Only read in the number of characters specified by the data length.
                     field_data = fd[2][:int(fd[1])]
 
                     # Combo boxes are used later on and these are case sensitive,
@@ -306,7 +301,7 @@ class ADIF:
                 if(merge_comment):
                     if("NOTES" in list(fields_and_data_dictionary.keys()) and comment):
                         logging.debug("Merging COMMENT field with NOTES field...")
-                        fields_and_data_dictionary["NOTES"] += "\\n" + comment
+                        fields_and_data_dictionary["NOTES"] += "\n" + comment
                         logging.debug("Merged fields.")
                     elif(comment):
                         # Create the NOTES entry, but only store the contents of the COMMENT field.
@@ -328,12 +323,12 @@ class ADIF:
         :arg list records: The list of QSO records to write.
         :arg str path: The desired path of the ADIF file to write to.
         :returns: None
-        :raises IOError: if the ADIF file cannot be written (e.g. due to lack of write permissions).
+        :raises IOError: If the ADIF file cannot be written (e.g. due to lack of write permissions).
         """
 
         logging.debug("Writing records to an ADIF file...")
-        try:
-            f = open(path, mode='w', errors="replace")  # Open file for writing
+
+        with open(path, mode="w", errors="replace") as f:  # Open file for writing
 
             # First write a header containing program version, number of records, etc.
             dt = datetime.now()
@@ -342,10 +337,10 @@ class ADIF:
 
 <adif_ver:%d>%s
 <programid:5>PyQSO
-<programversion:3>0.3
+<programversion:5>1.0.0
 <eoh>\n""" % (dt, len(records), len(str(ADIF_VERSION)), ADIF_VERSION))
 
-            # Then write each log to the file.
+            # Then write each record to the file.
             for r in records:
                 for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
                     if(not(field_name.lower() in list(r.keys()) or field_name.upper() in list(r.keys()))):
@@ -360,11 +355,7 @@ class ADIF:
             logging.debug("Finished writing records to the ADIF file.")
             f.close()
 
-        except IOError as e:
-            logging.error("I/O error %d: %s" % (e.errno, e.strerror))
-        except Exception as e:  # All other exceptions.
-            logging.error("An error occurred when writing the ADIF file.")
-            logging.exception(e)
+            logging.info("Wrote %d QSOs to %s in ADIF format." % (len(records), path))
 
         return
 
@@ -380,9 +371,9 @@ class ADIF:
 
         logging.debug("Validating the following data in field '%s': %s" % (field_name, data))
 
-        # Allow an empty string, in case the user doesn't want
+        # Allow an empty string or None, in case the user doesn't want
         # to fill in this field.
-        if(data == ""):
+        if(not data):
             return True
 
         if(data_type == "N"):
@@ -520,6 +511,9 @@ class ADIF:
             # Enumeration, AwardList.
             if(field_name == "MODE"):
                 return (data in list(MODES.keys()))
+            elif(field_name == "SUBMODE"):
+                submodes = [submode for mode in list(MODES.keys()) for submode in MODES[mode]]
+                return (data in submodes)
             elif(field_name == "BAND"):
                 return (data in BANDS)
             else:
@@ -527,195 +521,3 @@ class ADIF:
 
         else:
             return True
-
-
-class TestADIF(unittest.TestCase):
-
-    """ The unit tests for the ADIF module. """
-
-    def setUp(self):
-        """ Set up the ADIF object needed for the unit tests. """
-        self.adif = ADIF()
-
-    def test_adif_read(self):
-        """ Check that a single ADIF record can be read and parsed correctly. """
-        f = open("ADIF.test_read.adi", 'w')
-        f.write("""Some test ADI data.<eoh>
-
-<call:4>TEST<band:3>40m<mode:2>CW
-<qso_date:8:d>20130322<time_on:4>1955<eor>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read.adi")
-        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 1)
-        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
-        assert(records == expected_records)
-
-    def test_adif_read_multiple(self):
-        """ Check that multiple ADIF records can be read and parsed correctly. """
-        f = open("ADIF.test_read_multiple.adi", 'w')
-        f.write("""Some test ADI data.<eoh>
-
-<call:4>TEST<band:3>40m<mode:2>CW
-<qso_date:8:d>20130322<time_on:4>1955<eor>
-
-<call:8>TEST2ABC<band:3>20m<mode:3>SSB
-<qso_date:8>20150227<time_on:4>0820<eor>
-
-<call:5>HELLO<band:2>2m<mode:2>FM<qso_date:8:d>20150227<time_on:4>0832<eor>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read_multiple.adi")
-        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}, {'TIME_ON': '0820', 'BAND': '20m', 'CALL': 'TEST2ABC', 'MODE': 'SSB', 'QSO_DATE': '20150227'}, {'TIME_ON': '0832', 'BAND': '2m', 'CALL': 'HELLO', 'MODE': 'FM', 'QSO_DATE': '20150227'}]
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 3)
-        for i in range(len(expected_records)):
-            assert(len(list(records[i].keys())) == len(list(expected_records[i].keys())))
-        assert(records == expected_records)
-
-    def test_adif_read_alphabet(self):
-        """ Check that none of the letters of the alphabet are ignored during parsing. """
-        f = open("ADIF.test_read_alphabet.adi", 'w')
-        f.write("""Some test ADI data.<eoh>
-<call:64>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<eor>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read_alphabet.adi")
-        expected_records = [{'CALL': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'}]
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 1)
-        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
-        assert(records == expected_records)
-
-    def test_adif_read_capitalisation(self):
-        """ Check that the CALL field is capitalised correctly. """
-        f = open("ADIF.test_read_capitalisation.adi", 'w')
-        f.write("""Some test ADI data.<eoh>
-<call:4>test<eor>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read_capitalisation.adi")
-        expected_records = [{'CALL': 'TEST'}]
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 1)
-        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
-        assert(records == expected_records)
-
-    def test_adif_read_header_only(self):
-        """ Check that no records are read in if the ADIF file only contains header information. """
-        f = open("ADIF.test_read_header_only.adi", 'w')
-        f.write("""Some test ADI data.<eoh>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read_header_only.adi")
-        expected_records = []
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 0)
-        assert(records == expected_records)
-
-    def test_adif_read_no_header(self):
-        """ Check that an ADIF file can be parsed with no header information. """
-        f = open("ADIF.test_read_no_header.adi", 'w')
-        f.write("""<call:4>TEST<band:3>40m<mode:2>CW<qso_date:8:d>20130322<time_on:4>1955<eor>""")
-        f.close()
-
-        records = self.adif.read("ADIF.test_read_no_header.adi")
-        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
-        print("Imported records: ", records)
-        print("Expected records: ", expected_records)
-        assert(len(records) == 1)
-        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
-        assert(records == expected_records)
-
-    def test_adif_write(self):
-        """ Check that records can be written to an ADIF file correctly. """
-        records = [{"CALL": "TEST123", "QSO_DATE": "20120402", "TIME_ON": "1234", "FREQ": "145.500", "BAND": "2m", "MODE": "FM", "RST_SENT": "59", "RST_RCVD": "59"},
-                   {"CALL": "TEST123", "QSO_DATE": "20130312", "TIME_ON": "0101", "FREQ": "145.750", "BAND": "2m", "MODE": "FM"}]
-        self.adif.write(records, "ADIF.test_write.adi")
-
-        f = open("ADIF.test_write.adi", 'r')
-        text = f.read()
-        print("File 'ADIF.test_write.adi' contains the following text:", text)
-        assert("""
-<adif_ver:5>3.0.4
-<programid:5>PyQSO
-<programversion:3>0.3
-<eoh>
-<call:7>TEST123
-<qso_date:8>20120402
-<time_on:4>1234
-<freq:7>145.500
-<band:2>2m
-<mode:2>FM
-<rst_sent:2>59
-<rst_rcvd:2>59
-<eor>
-<call:7>TEST123
-<qso_date:8>20130312
-<time_on:4>0101
-<freq:7>145.750
-<band:2>2m
-<mode:2>FM
-<eor>
-""" in text)  # Ignore the header line here, since it contains the date and time the ADIF file was written, which will change each time 'make unittest' is run.
-        f.close()
-
-    def test_adif_write_sqlite3_Row(self):
-        """ Check that records can be written to an ADIF file from a test database file. """
-        import sqlite3
-        import os.path
-        self.connection = sqlite3.connect(os.path.dirname(os.path.realpath(__file__))+"/unittest_resources/test.db")
-        self.connection.row_factory = sqlite3.Row
-
-        c = self.connection.cursor()
-        c.execute("SELECT * FROM test")
-        records = c.fetchall()
-        print(records)
-
-        self.adif.write(records, "ADIF.test_write_sqlite3_Row.adi")
-
-        f = open("ADIF.test_write_sqlite3_Row.adi", 'r')
-        text = f.read()
-        print("File 'ADIF.test_write_sqlite3_Row.adi' contains the following text:", text)
-        assert("""
-<adif_ver:5>3.0.4
-<programid:5>PyQSO
-<programversion:3>0.3
-<eoh>
-<call:7>TEST123
-<qso_date:8>20120402
-<time_on:4>1234
-<freq:7>145.500
-<band:2>2m
-<mode:2>FM
-<rst_sent:2>59
-<rst_rcvd:2>59
-<eor>
-<call:7>TEST456
-<qso_date:8>20130312
-<time_on:4>0101
-<freq:7>145.750
-<band:2>2m
-<mode:2>FM
-<eor>
-""" in text)  # Ignore the header line here, since it contains the date and time the ADIF file was written, which will change each time 'make unittest' is run.
-        f.close()
-
-        self.connection.close()
-
-    def test_adif_is_valid(self):
-        """ Check that ADIF field validation is working correctly for different data types. """
-        assert(self.adif.is_valid("CALL", "TEST123", "S"))
-        assert(self.adif.is_valid("QSO_DATE", "20120402", "D"))
-        assert(self.adif.is_valid("TIME_ON", "1230", "T"))
-        assert(self.adif.is_valid("TX_PWR", "5", "N"))
-
-if(__name__ == '__main__'):
-    unittest.main()
diff --git a/pyqso/auxiliary_dialogs.py b/pyqso/auxiliary_dialogs.py
index 34554d1..752eab9 100644
--- a/pyqso/auxiliary_dialogs.py
+++ b/pyqso/auxiliary_dialogs.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -28,7 +28,7 @@ def error(parent, message):
     :arg str message: The message to display to the user.
     """
     logging.error(message)
-    _handle_gtk_dialog(parent, Gtk.MessageType.ERROR, message, "Error")
+    handle_gtk_dialog(parent, Gtk.MessageType.ERROR, message, "Error")
 
 
 def info(parent, message):
@@ -37,8 +37,8 @@ def info(parent, message):
     :arg parent: The Gtk parent window/dialog.
     :arg str message: The message to display to the user.
     """
-    logging.debug(message)
-    _handle_gtk_dialog(parent, Gtk.MessageType.INFO, message, "Information")
+    logging.info(message)
+    handle_gtk_dialog(parent, Gtk.MessageType.INFO, message, "Information")
 
 
 def question(parent, message):
@@ -49,10 +49,10 @@ def question(parent, message):
     :returns: The 'yes'/'no' response from the user.
     :rtype: Gtk.ResponseType
     """
-    return _handle_gtk_dialog(parent, Gtk.MessageType.QUESTION, message, "Question")
+    return handle_gtk_dialog(parent, Gtk.MessageType.QUESTION, message, "Question")
 
 
-def _handle_gtk_dialog(parent, msgtype, message, title):
+def handle_gtk_dialog(parent, msgtype, message, title):
     """
     Instantiate and present a dialog to the user.
 
diff --git a/pyqso/awards.py b/pyqso/awards.py
index 9656ef1..2d6be85 100644
--- a/pyqso/awards.py
+++ b/pyqso/awards.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -19,24 +19,24 @@
 
 from gi.repository import Gtk
 import logging
+import sqlite3 as sqlite
 
 
-class Awards(Gtk.VBox):
+class Awards:
 
     """ A tool for tracking progress towards an award. Currently this only supports the DXCC award.
     For more information visit http://www.arrl.org/dxcc """
 
-    def __init__(self, parent):
+    def __init__(self, application):
         """ Set up a table for progress tracking purposes.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
-        # TODO: This only considers the DXCC award for now.
-        logging.debug("New Awards instance created!")
+        # TODO: Add more awards. This only considers the DXCC award for now.
+        logging.debug("Setting up awards table...")
 
-        Gtk.VBox.__init__(self, spacing=2)
-
-        self.parent = parent
+        self.application = application
+        self.builder = self.application.builder
 
         self.bands = ["70cm", "2m", "6m", "10m", "12m", "15m", "17m", "20m", "30m", "40m", "80m", "160m"]
         self.modes = ["Phone", "CW", "Digital", "Mixed"]
@@ -44,9 +44,9 @@ class Awards(Gtk.VBox):
         data_types = [str] + [int]*len(self.bands)
         self.awards = Gtk.ListStore(*data_types)
 
-        # The main table for the awards
-        self.treeview = Gtk.TreeView(self.awards)
-        # A separate, empty column just for the mode names
+        # The main table for the awards.
+        self.treeview = Gtk.TreeView(model=self.awards)
+        # A separate, empty column just for the mode names.
         renderer = Gtk.CellRendererText()
         column = Gtk.TreeViewColumn("Modes", renderer, text=0)
         column.set_clickable(False)
@@ -60,34 +60,37 @@ class Awards(Gtk.VBox):
             column.set_clickable(False)
             self.treeview.append_column(column)
 
-        # Add a label to inform the user that this only considers the DXCC award for now.
-        label = Gtk.Label(halign=Gtk.Align.START)
-        label.set_markup("<span size=\"x-large\">%s</span>" % "DXCC Award")
-        self.pack_start(label, False, False, 4)
-        # Show the table in the Awards tab
-        self.add(self.treeview)
-        self.show_all()
+        # Show the table in the Awards tab.
+        self.builder.get_object("awards").add(self.treeview)
+        self.builder.get_object("awards").show_all()
 
         logging.debug("Awards table set up successfully.")
 
-        self.count()
+        self.count(self.application.logbook)
 
         return
 
-    def count(self):
-        """ Update the table for progress tracking. """
+    def count(self, logbook):
+        """ Update the table for progress tracking.
+
+        :arg logbook: The logbook containing logs which in turn contain QSOs.
+        :returns: A list of lists containing the QSO counts for different modes and bands.
+        :rtype: list
+        """
 
         logging.debug("Counting the band/mode combinations for the awards table...")
-        # Wipe everything and start again
+
+        # Wipe everything and start again.
         self.awards.clear()
+
         # For each mode, add a new list for holding the totals, and initialise the values to zero.
         count = []
         for i in range(0, len(self.bands)):
             count.append([0]*len(self.bands))
 
-        for log in self.parent.logbook.logs:
-            records = log.get_all_records()
-            if(records is not None):
+        for log in logbook.logs:
+            try:
+                records = log.records
                 for r in records:
                     if(r["BAND"] is not None and r["MODE"] is not None):
                         if(r["BAND"].lower() in self.bands and r["MODE"] != ""):
@@ -100,11 +103,15 @@ class Awards(Gtk.VBox):
                             else:
                                 # FIXME: This assumes that all the other modes in the ADIF list are digital modes. Is this the case?
                                 count[2][band] += 1
-                            count[3][band] += 1  # Keep the total of each column in the "Mixed" mode
-            else:
+                            count[3][band] += 1  # Keep the total of each column in the "Mixed" mode.
+
+            except sqlite.Error as e:
                 logging.error("Could not update the awards table for '%s' because of a database error." % log.name)
-        # Insert the rows containing the totals
+                logging.exception(e)
+
+        # Insert the rows containing the totals.
         for i in range(0, len(self.modes)):
             self.awards.append([self.modes[i]] + count[i])
+
         logging.debug("Awards table updated.")
-        return
+        return count
diff --git a/pyqso/blank.py b/pyqso/blank.py
new file mode 100644
index 0000000..dd696f5
--- /dev/null
+++ b/pyqso/blank.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+
+
+class Blank(object):
+
+    """ A blank page in the logbook for the "+" (New Log) tab. """
+
+    def __init__(self, application):
+        """ Create the blank page.
+
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
+
+        self.application = application
+
+        blank_treeview = Gtk.TreeView()
+
+        # Allow the (blank) page to be scrolled up/down
+        sw = Gtk.ScrolledWindow()
+        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
+        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+        sw.add(blank_treeview)
+        page = Gtk.VBox()
+        page.pack_start(sw, True, True, 0)
+
+        # Add a "+" button to the tab
+        tab = Gtk.HBox(homogeneous=False, spacing=0)
+        icon = Gtk.Image.new_from_icon_name(Gtk.STOCK_ADD, Gtk.IconSize.MENU)
+        button = Gtk.Button()
+        button.set_relief(Gtk.ReliefStyle.NONE)
+        button.set_focus_on_click(False)
+        button.connect("clicked", self.application.logbook.new_log)
+        button.add(icon)
+        button.set_tooltip_text('New Log')
+        tab.pack_start(button, False, False, 0)
+
+        tab.show_all()
+        page.show_all()
+
+        self.application.logbook.notebook.insert_page(page, tab, 1)
+        self.application.logbook.notebook.set_current_page(0)
+
+        return
diff --git a/pyqso/cabrillo.py b/pyqso/cabrillo.py
new file mode 100644
index 0000000..2debe9d
--- /dev/null
+++ b/pyqso/cabrillo.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import logging
+
+CABRILLO_VERSION = "3.0"
+
+CONTESTS = ["", "AP-SPRINT", "ARRL-10", "ARRL-160", "ARRL-222", "ARRL-DX-CW", "ARRL-DX-SSB", "ARRL-RR-PH", "ARRL-RR-DIG", "ARRL-RR-CW", "ARRL-SCR", "ARRL-SS-CW", "ARRL-SS-SSB", "ARRL-UHF-AUG", "ARRL-VHF-JAN", "ARRL-VHF-JUN", "ARRL-VHF-SEP", "ARRL-RTTY", "BARTG-RTTY", "CQ-160-CW", "CQ-160-SSB", "CQ-WPX-CW", "CQ-WPX-RTTY", "CQ-WPX-SSB", "CQ-VHF", "CQ-WW-CW", "CQ-WW-RTTY", "CQ-WW-SSB", "DARC-WAEDC-CW", "DARC-WAEDC-RTTY", "DARC-WAEDC-SSB", "DL-DX-RTTY", "DRCG-WW-RTTY", "FCG-FQP", "IARU-HF",  [...]
+
+
+class Cabrillo:
+
+    """ The Cabrillo class supplies methods for writing log files in the Cabrillo format (v3.0).
+    For more information, visit http://wwrof.org/cabrillo/ """
+
+    def __init__(self):
+        """ Initialise class for I/O of files using the Cabrillo format. """
+        return
+
+    def write(self, records, path, contest="", mycall=""):
+        """ Write a list of QSO records to a file in the Cabrillo format.
+
+        :arg list records: The list of QSO records to write.
+        :arg str path: The desired path of the Cabrillo file to write to.
+        :arg str contest: The name of the contest.
+        :arg str mycall: The callsign used during the contest.
+        :returns: None
+        :raises IOError: If the Cabrillo file cannot be written (e.g. due to lack of write permissions)."""
+
+        logging.debug("Writing records to a Cabrillo file...")
+
+        with open(path, mode='w', errors="replace") as f:  # Open file for writing
+
+            # Header
+            f.write("""START-OF-LOG: %s\n""" % (CABRILLO_VERSION))
+            f.write("""CREATED-BY: PyQSO v1.0.0\n""")
+            f.write("""CALLSIGN: %s\n""" % (mycall))
+            f.write("""CONTEST: %s\n""" % (contest))
+
+            # Write each record to the file.
+            for r in records:
+
+                # Frequency. Note that this must be in kHz. The frequency is stored in MHz in the database, so it's converted to kHz here.
+                try:
+                    freq = str(float(r["FREQ"])*1e3)
+                except ValueError:
+                    freq = ""
+
+                # Mode
+                if(r["MODE"] == "SSB"):
+                    mo = "PH"
+                elif(r["MODE"] == "CW"):
+                    mo = "CW"
+                elif(r["MODE"] == "FM"):
+                    mo = "FM"
+                else:
+                    # FIXME: This assumes that the mode is any other non-CW digital mode, which isn't always going to be the case (e.g. for AM).
+                    mo = "RY"
+
+                # Date in yyyy-mm-dd format.
+                date = r["QSO_DATE"][0:4] + "-" + r["QSO_DATE"][4:6] + "-" + r["QSO_DATE"][6:8]
+
+                # Time
+                time = r["TIME_ON"]
+
+                # The callsign that was used when operating the contest station.
+                call_sent = mycall
+
+                # Exchange (the part sent to the distant station)
+                exch_sent = r["RST_SENT"]
+
+                # Callsign
+                call_rcvd = r["CALL"]
+
+                # Exchange (the part received from the distant station)
+                exch_rcvd = r["RST_RCVD"]
+
+                # Transmitter ID (must be 0 or 1, if applicable).
+                # FIXME: For now this has been hard-coded to 0.
+                t = "0"
+
+                f.write("""QSO: %s %s %s %s %s %s %s %s %s\n""" % (freq, mo, date, time, call_sent, exch_sent, call_rcvd, exch_rcvd, t))
+
+            # Footer
+            f.write("END-OF-LOG:")
+
+            logging.info("Wrote %d QSOs to %s in Cabrillo format." % (len(records), path))
+
+        return
diff --git a/pyqso/cabrillo_export_dialog.py b/pyqso/cabrillo_export_dialog.py
new file mode 100644
index 0000000..38c0aac
--- /dev/null
+++ b/pyqso/cabrillo_export_dialog.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import os
+import logging
+from pyqso.cabrillo import CONTESTS
+
+
+class CabrilloExportDialog:
+
+    """ A handler for the Gtk.Dialog through which a user can specify Cabrillo log details. """
+
+    def __init__(self, application):
+        """ Create and show the Cabrillo export dialog to the user.
+
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
+
+        logging.debug("Building new Cabrillo export dialog...")
+
+        self.builder = application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("cabrillo_export_dialog",))
+        self.dialog = self.builder.get_object("cabrillo_export_dialog")
+
+        self.contest_combo = self.builder.get_object("cabrillo_export_contest_combo")
+        self.mycall_entry = self.builder.get_object("cabrillo_export_mycall_entry")
+        for contest in CONTESTS:
+            self.contest_combo.append_text(contest)
+
+        self.dialog.show_all()
+
+        logging.debug("Cabrillo export dialog built.")
+
+        return
+
+    @property
+    def contest(self):
+        """ Return the name of the contest.
+
+        :returns: The name of the contest.
+        :rtype: str
+        """
+        return self.contest_combo.get_active_text()
+
+    @property
+    def mycall(self):
+        """ Return the callsign used during the contest.
+
+        :returns: The callsign used during the contest.
+        :rtype: str
+        """
+        # Always show the callsigns in upper case.
+        return self.mycall_entry.get_text().upper()
diff --git a/pyqso/calendar_dialog.py b/pyqso/calendar_dialog.py
new file mode 100644
index 0000000..40159e7
--- /dev/null
+++ b/pyqso/calendar_dialog.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import logging
+import os.path
+
+
+class CalendarDialog:
+
+    """ Handler for a simple dialog containing a Gtk.Calendar widget. Using this ensures the date is in the correct YYYYMMDD format required by ADIF. """
+
+    def __init__(self, application):
+        """ Set up the calendar widget and show it to the user.
+
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
+
+        self.builder = application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("calendar_dialog",))
+        self.dialog = self.builder.get_object("calendar_dialog")
+        self.calendar = self.builder.get_object("calendar")
+        self.dialog.show_all()
+
+        return
+
+    @property
+    def date(self):
+        """ Return the date from the Gtk.Calendar widget in YYYYMMDD format.
+
+        :returns: The date from the calendar in YYYYMMDD format.
+        :rtype: str
+        """
+        logging.debug("Retrieving the date from the calendar...")
+        (year, month, day) = self.calendar.get_date()
+        # If necessary, add on leading zeros so the YYYYMMDD format is followed.
+        if(month + 1 < 10):
+            month = "0" + str(month + 1)  # Note: the months start from an index of 0 when retrieved from the calendar widget.
+        else:
+            month += 1
+        if(day < 10):
+            day = "0" + str(day)
+        date = str(year) + str(month) + str(day)
+        return date
diff --git a/pyqso/callsign_lookup.py b/pyqso/callsign_lookup.py
index 1c45983..a06fe1a 100644
--- a/pyqso/callsign_lookup.py
+++ b/pyqso/callsign_lookup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -18,15 +18,20 @@
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
 import logging
-import unittest
-import unittest.mock
-import http.client
+try:
+    import http.client as http_client
+except ImportError:
+    import httplib as http_client
 from xml.dom import minidom
+try:
+    from urllib.parse import quote
+except ImportError:
+    from urllib import quote
 
-from pyqso.auxiliary_dialogs import *
+from pyqso.auxiliary_dialogs import error
 
 
-class CallsignLookupQRZ():
+class CallsignLookupQRZ:
 
     """ Use qrz.com to lookup details about a particular callsign. """
 
@@ -49,30 +54,34 @@ class CallsignLookupQRZ():
         :rtype: bool
         """
         logging.debug("Connecting to the qrz.com server...")
+
+        # Connect to the server.
         try:
-            self.connection = http.client.HTTPConnection('xmldata.qrz.com')
-            request = '/xml/current/?username=%s;password=%s;agent=pyqso' % (username, password)
-            self.connection.request('GET', request)
+            self.connection = http_client.HTTPConnection("xmldata.qrz.com")
+            request = "/xml/current/?username=%s;password=%s;agent=pyqso" % (username, quote(password))  # Percent-escape the password in case there are reserved characters present.
+            self.connection.request("GET", request)
             response = self.connection.getresponse()
-        except:
+        except Exception as e:
+            logging.exception(e)
             error(parent=self.parent, message="Could not connect to the qrz.com server. Check connection to the internets?")
             return False
 
+        # Get the session key.
         xml_data = minidom.parseString(response.read())
-        session_node = xml_data.getElementsByTagName('Session')[0]  # There should only be one Session element
-        session_key_node = session_node.getElementsByTagName('Key')
-        if(len(session_key_node) > 0):
+        session_node = xml_data.getElementsByTagName("Session")[0]  # There should only be one Session element.
+        session_key_node = session_node.getElementsByTagName("Key")
+        if(session_key_node):
             self.session_key = session_key_node[0].firstChild.nodeValue
-            logging.debug("Successfully connected to the qrz.com server...")
+            logging.debug("Successfully connected to the qrz.com server. Session key is: %s." % self.session_key)
             connected = True
         else:
             connected = False
 
-        # If there are any errors or warnings, print them out
-        session_error_node = session_node.getElementsByTagName('Error')
-        if(len(session_error_node) > 0):
+        # If there are any errors or warnings, print them out.
+        session_error_node = session_node.getElementsByTagName("Error")
+        if(session_error_node):
             session_error = session_error_node[0].firstChild.nodeValue
-            error(parent=self.parent, message="qrz.com session error: "+session_error)
+            error(parent=self.parent, message="qrz.com session error: %s" % session_error)
 
         return connected
 
@@ -85,7 +94,7 @@ class CallsignLookupQRZ():
         :rtype: dict
         """
 
-        logging.debug("Looking up callsign. The full callsign (with a prefix and/or suffix) is %s" % full_callsign)
+        logging.debug("Looking up callsign. The full callsign (with a prefix and/or suffix) is %s." % full_callsign)
 
         # Remove any prefix or suffix from the callsign before performing the lookup.
         if(ignore_prefix_suffix):
@@ -96,66 +105,66 @@ class CallsignLookupQRZ():
         # Commence lookup.
         fields_and_data = {"NAME": "", "ADDRESS": "", "STATE": "", "COUNTRY": "", "DXCC": "", "CQZ": "", "ITUZ": "", "IOTA": ""}
         if(self.session_key):
-            request = '/xml/current/?s=%s;callsign=%s' % (self.session_key, callsign)
-            self.connection.request('GET', request)
+            request = "/xml/current/?s=%s;callsign=%s" % (self.session_key, callsign)
+            self.connection.request("GET", request)
             response = self.connection.getresponse()
 
             xml_data = minidom.parseString(response.read())
-            callsign_node = xml_data.getElementsByTagName('Callsign')
-            if(len(callsign_node) > 0):
-                callsign_node = callsign_node[0]  # There should only be a maximum of one Callsign element
+            callsign_node = xml_data.getElementsByTagName("Callsign")
+            if(callsign_node):
+                callsign_node = callsign_node[0]  # There should only be a maximum of one Callsign element.
 
-                callsign_fname_node = callsign_node.getElementsByTagName('fname')
-                callsign_name_node = callsign_node.getElementsByTagName('name')
-                if(len(callsign_fname_node) > 0):
+                callsign_fname_node = callsign_node.getElementsByTagName("fname")
+                callsign_name_node = callsign_node.getElementsByTagName("name")
+                if(callsign_fname_node):
                     fields_and_data["NAME"] = callsign_fname_node[0].firstChild.nodeValue
-                if(len(callsign_name_node) > 0):  # Add the surname, if present
+                if(callsign_name_node):  # Add the surname, if present.
                     fields_and_data["NAME"] = fields_and_data["NAME"] + " " + callsign_name_node[0].firstChild.nodeValue
 
-                callsign_addr1_node = callsign_node.getElementsByTagName('addr1')
-                callsign_addr2_node = callsign_node.getElementsByTagName('addr2')
-                if(len(callsign_addr1_node) > 0):
+                callsign_addr1_node = callsign_node.getElementsByTagName("addr1")
+                callsign_addr2_node = callsign_node.getElementsByTagName("addr2")
+                if(callsign_addr1_node):
                     fields_and_data["ADDRESS"] = callsign_addr1_node[0].firstChild.nodeValue
-                if(len(callsign_addr2_node) > 0):  # Add the second line of the address, if present
-                    fields_and_data["ADDRESS"] = (fields_and_data["ADDRESS"] + ", " if len(callsign_addr1_node) > 0 else "") + callsign_addr2_node[0].firstChild.nodeValue
+                if(callsign_addr2_node):  # Add the second line of the address, if present.
+                    fields_and_data["ADDRESS"] = (fields_and_data["ADDRESS"] + ", " if callsign_addr1_node else "") + callsign_addr2_node[0].firstChild.nodeValue
 
-                callsign_state_node = callsign_node.getElementsByTagName('state')
-                if(len(callsign_state_node) > 0):
+                callsign_state_node = callsign_node.getElementsByTagName("state")
+                if(callsign_state_node):
                     fields_and_data["STATE"] = callsign_state_node[0].firstChild.nodeValue
 
-                callsign_country_node = callsign_node.getElementsByTagName('country')
-                if(len(callsign_country_node) > 0):
+                callsign_country_node = callsign_node.getElementsByTagName("country")
+                if(callsign_country_node):
                     fields_and_data["COUNTRY"] = callsign_country_node[0].firstChild.nodeValue
 
-                callsign_ccode_node = callsign_node.getElementsByTagName('ccode')
-                if(len(callsign_ccode_node) > 0):
+                callsign_ccode_node = callsign_node.getElementsByTagName("ccode")
+                if(callsign_ccode_node):
                     fields_and_data["DXCC"] = callsign_ccode_node[0].firstChild.nodeValue
 
-                callsign_cqzone_node = callsign_node.getElementsByTagName('cqzone')
-                if(len(callsign_cqzone_node) > 0):
+                callsign_cqzone_node = callsign_node.getElementsByTagName("cqzone")
+                if(callsign_cqzone_node):
                     fields_and_data["CQZ"] = callsign_cqzone_node[0].firstChild.nodeValue
 
-                callsign_ituzone_node = callsign_node.getElementsByTagName('ituzone')
-                if(len(callsign_ituzone_node) > 0):
+                callsign_ituzone_node = callsign_node.getElementsByTagName("ituzone")
+                if(callsign_ituzone_node):
                     fields_and_data["ITUZ"] = callsign_ituzone_node[0].firstChild.nodeValue
 
-                callsign_iota_node = callsign_node.getElementsByTagName('iota')
-                if(len(callsign_iota_node) > 0):
+                callsign_iota_node = callsign_node.getElementsByTagName("iota")
+                if(callsign_iota_node):
                     fields_and_data["IOTA"] = callsign_iota_node[0].firstChild.nodeValue
             else:
-                # If there is no Callsign element, then print out the error message in the Session element
-                session_node = xml_data.getElementsByTagName('Session')
-                if(len(session_node) > 0):
-                    session_error_node = session_node[0].getElementsByTagName('Error')
-                    if(len(session_error_node) > 0):
+                # If there is no Callsign element, then print out the error message in the Session element.
+                session_node = xml_data.getElementsByTagName("Session")
+                if(session_node):
+                    session_error_node = session_node[0].getElementsByTagName("Error")
+                    if(session_error_node):
                         session_error = session_error_node[0].firstChild.nodeValue
                         error(parent=self.parent, message=session_error)
-                # Return empty strings for the field data
+                # Return empty strings for the field data.
             logging.debug("Callsign lookup complete. Returning data...")
         return fields_and_data
 
 
-class CallsignLookupHamQTH():
+class CallsignLookupHamQTH:
 
     """ Use hamqth.com to lookup details about a particular callsign. """
 
@@ -175,30 +184,34 @@ class CallsignLookupHamQTH():
         """
 
         logging.debug("Connecting to the hamqth.com server...")
+
+        # Connect to the server.
         try:
-            self.connection = http.client.HTTPConnection('www.hamqth.com')
-            request = '/xml.php?u=%s&p=%s' % (username, password)
-            self.connection.request('GET', request)
+            self.connection = http_client.HTTPSConnection("www.hamqth.com")
+            request = "/xml.php?u=%s&p=%s" % (username, quote(password))  # Percent-escape the password in case there are reserved characters present.
+            self.connection.request("GET", request)
             response = self.connection.getresponse()
-        except:
+        except Exception as e:
+            logging.exception(e)
             error(parent=self.parent, message="Could not connect to the hamqth.com server. Check connection to the internets?")
             return False
 
+        # Get the session ID.
         xml_data = minidom.parseString(response.read())
-        session_node = xml_data.getElementsByTagName('session')[0]  # There should only be one Session element
-        session_id_node = session_node.getElementsByTagName('session_id')
-        if(len(session_id_node) > 0):
+        session_node = xml_data.getElementsByTagName("session")[0]  # There should only be one Session element.
+        session_id_node = session_node.getElementsByTagName("session_id")
+        if(session_id_node):
             self.session_id = session_id_node[0].firstChild.nodeValue
-            logging.debug("Successfully connected to the hamqth.com server...")
+            logging.debug("Successfully connected to the hamqth.com server. Session ID is: %s." % self.session_id)
             connected = True
         else:
             connected = False
 
-        # If there are any errors or warnings, print them out
-        session_error_node = session_node.getElementsByTagName('error')
-        if(len(session_error_node) > 0):
+        # If there are any errors or warnings, print them out.
+        session_error_node = session_node.getElementsByTagName("error")
+        if(session_error_node):
             session_error = session_error_node[0].firstChild.nodeValue
-            error(parent=self.parent, message="hamqth.com session error: "+session_error)
+            error(parent=self.parent, message="hamqth.com session error: %s" % session_error)
 
         return connected
 
@@ -211,7 +224,7 @@ class CallsignLookupHamQTH():
         :rtype: dict
         """
 
-        logging.debug("Looking up callsign. The full callsign (with a prefix and/or suffix) is %s" % full_callsign)
+        logging.debug("Looking up callsign. The full callsign (with a prefix and/or suffix) is %s." % full_callsign)
 
         # Remove any prefix or suffix from the callsign before performing the lookup.
         if(ignore_prefix_suffix):
@@ -222,54 +235,55 @@ class CallsignLookupHamQTH():
         # Commence lookup.
         fields_and_data = {"NAME": "", "ADDRESS": "", "STATE": "", "COUNTRY": "", "DXCC": "", "CQZ": "", "ITUZ": "", "IOTA": ""}
         if(self.session_id):
-            request = '/xml.php?id=%s&callsign=%s&prg=pyqso' % (self.session_id, callsign)
-            self.connection.request('GET', request)
+            request = "/xml.php?id=%s&callsign=%s&prg=pyqso" % (self.session_id, callsign)
+            self.connection.request("GET", request)
             response = self.connection.getresponse()
 
             xml_data = minidom.parseString(response.read())
-            search_node = xml_data.getElementsByTagName('search')
-            if(len(search_node) > 0):
-                search_node = search_node[0]  # There should only be a maximum of one Callsign element
+            search_node = xml_data.getElementsByTagName("search")
+            if(search_node):
+                search_node = search_node[0]  # There should only be a maximum of one Callsign element.
 
-                search_name_node = search_node.getElementsByTagName('nick')
-                if(len(search_name_node) > 0):
+                search_name_node = search_node.getElementsByTagName("nick")
+                if(search_name_node):
                     fields_and_data["NAME"] = search_name_node[0].firstChild.nodeValue
 
-                search_addr1_node = search_node.getElementsByTagName('adr_street1')
-                search_addr2_node = search_node.getElementsByTagName('adr_street2')
-                if(len(search_addr1_node) > 0):
+                search_addr1_node = search_node.getElementsByTagName("adr_street1")
+                search_addr2_node = search_node.getElementsByTagName("adr_street2")
+                if(search_addr1_node):
                     fields_and_data["ADDRESS"] = search_addr1_node[0].firstChild.nodeValue
-                if(len(search_addr2_node) > 0):  # Add the second line of the address, if present
-                    fields_and_data["ADDRESS"] = (fields_and_data["ADDRESS"] + ", " if len(search_addr1_node) > 0 else "") + search_addr2_node[0].firstChild.nodeValue
+                if(search_addr2_node):  # Add the second line of the address, if present.
+                    fields_and_data["ADDRESS"] = (fields_and_data["ADDRESS"] + ", " if search_addr1_node else "") + search_addr2_node[0].firstChild.nodeValue
 
-                search_state_node = search_node.getElementsByTagName('us_state')
-                if(len(search_state_node) > 0):
+                search_state_node = search_node.getElementsByTagName("us_state")
+                if(search_state_node):
                     fields_and_data["STATE"] = search_state_node[0].firstChild.nodeValue
 
-                search_country_node = search_node.getElementsByTagName('country')
-                if(len(search_country_node) > 0):
+                search_country_node = search_node.getElementsByTagName("country")
+                if(search_country_node):
                     fields_and_data["COUNTRY"] = search_country_node[0].firstChild.nodeValue
 
-                search_cqzone_node = search_node.getElementsByTagName('cq')
-                if(len(search_cqzone_node) > 0):
+                search_cqzone_node = search_node.getElementsByTagName("cq")
+                if(search_cqzone_node):
                     fields_and_data["CQZ"] = search_cqzone_node[0].firstChild.nodeValue
 
-                search_ituzone_node = search_node.getElementsByTagName('itu')
-                if(len(search_ituzone_node) > 0):
+                search_ituzone_node = search_node.getElementsByTagName("itu")
+                if(search_ituzone_node):
                     fields_and_data["ITUZ"] = search_ituzone_node[0].firstChild.nodeValue
 
-                search_iota_node = search_node.getElementsByTagName('grid')
-                if(len(search_iota_node) > 0):
+                search_iota_node = search_node.getElementsByTagName("iota")
+                if(search_iota_node):
                     fields_and_data["IOTA"] = search_iota_node[0].firstChild.nodeValue
             else:
-                # If there is no Callsign element, then print out the error message in the Session element
-                session_node = xml_data.getElementsByTagName('session')
-                if(len(session_node) > 0):
-                    session_error_node = session_node[0].getElementsByTagName('error')
-                    if(len(session_error_node) > 0):
+                # If there is no Callsign element, then print out the error message in the Session element.
+                session_node = xml_data.getElementsByTagName("session")
+                if(session_node):
+                    session_error_node = session_node[0].getElementsByTagName("error")
+                    if(session_error_node):
                         session_error = session_error_node[0].firstChild.nodeValue
                         error(parent=self.parent, message=session_error)
-                # Return empty strings for the field data
+                # Return empty strings for the field data.
+
             logging.debug("Callsign lookup complete. Returning data...")
         return fields_and_data
 
@@ -293,125 +307,19 @@ def strip(full_callsign):
             if(components[1].upper() in suffixes or components[1].lower() in suffixes):
                 # If the last part of the full_callsign is a valid suffix, then use the part before that.
                 callsign = components[0]
-                logging.debug("Suffix %s found. Callsign to lookup is %s" % (components[1], callsign))
+                logging.debug("Suffix %s found. Callsign to lookup is %s." % (components[1], callsign))
             else:
                 # We have a prefix, so take the part after the first "/".
                 callsign = components[1]
-                logging.debug("Prefix %s found. Callsign to lookup is %s" % (components[0], callsign))
+                logging.debug("Prefix %s found. Callsign to lookup is %s." % (components[0], callsign))
 
         elif(len(components) == 1):
             # We have neither a prefix nor a suffix, so use the full_callsign.
             callsign = full_callsign
-            logging.debug("No prefix or suffix found. Callsign to lookup is %s" % callsign)
+            logging.debug("No prefix or suffix found. Callsign to lookup is %s." % callsign)
 
         else:
             raise ValueError
     except ValueError:
         callsign = full_callsign
     return callsign
-
-
-class TestCallsignLookup(unittest.TestCase):
-
-    """ The unit tests for the CallsignLookup class. """
-
-    def setUp(self):
-        """ Set up the objects needed for the unit tests. """
-        self.qrz = CallsignLookupQRZ(parent=None)
-        self.hamqth = CallsignLookupHamQTH(parent=None)
-
-    def tearDown(self):
-        """ Destroy any unit test resources. """
-        pass
-
-    def test_strip(self):
-        """ Check that a callsign with a prefix and a suffix is stripped correctly. """
-        callsign = "EA3/MYCALL/MM"
-        assert strip(callsign) == "MYCALL"
-
-    def test_strip_prefix_only(self):
-        """ Check that a callsign with only a prefix is stripped correctly. """
-        callsign = "EA3/MYCALL"
-        assert strip(callsign) == "MYCALL"
-
-    def test_strip_suffix_only(self):
-        """ Check that a callsign with only a suffix is stripped correctly. """
-        callsign = "MYCALL/M"
-        assert strip(callsign) == "MYCALL"
-
-    def test_strip_no_prefix_or_suffix(self):
-        """ Check that a callsign with no prefix or suffix remains unmodified. """
-        callsign = "MYCALL"
-        assert strip(callsign) == "MYCALL"
-
-    def test_qrz_connect(self):
-        """ Check the example response from the qrz.com server, and make sure the session key has been correctly extracted. """
-
-        http.client.HTTPConnection = unittest.mock.Mock(spec=http.client.HTTPConnection)
-        http.client.HTTPResponse = unittest.mock.Mock(spec=http.client.HTTPResponse)
-        connection = http.client.HTTPConnection()
-        response = http.client.HTTPResponse()
-
-        response.read.return_value = b'<?xml version="1.0" encoding="utf-8" ?>\n<QRZDatabase version="1.33" xmlns="http://xmldata.qrz.com">\n<Session>\n<Key>3b1fd1d3ba495189984f93ff67bd45b6</Key>\n<Count>61</Count>\n<SubExp>non-subscriber</SubExp>\n<GMTime>Sun Nov 22 21:25:34 2015</GMTime>\n<Remark>cpu: 0.147s</Remark>\n</Session>\n</QRZDatabase>\n'
-        connection.getresponse.return_value = response
-
-        result = self.qrz.connect("hello", "world")
-        assert(result)
-        assert(self.qrz.session_key == "3b1fd1d3ba495189984f93ff67bd45b6")
-
-    def test_qrz_lookup(self):
-        """ Check the example callsign lookup response from the qrz.com server, and make sure the callsign information has been correctly extracted. """
-
-        http.client.HTTPConnection = unittest.mock.Mock(spec=http.client.HTTPConnection)
-        http.client.HTTPResponse = unittest.mock.Mock(spec=http.client.HTTPResponse)
-        connection = http.client.HTTPConnection()
-        response = http.client.HTTPResponse()
-
-        response.read.return_value = b'<?xml version="1.0" encoding="utf-8" ?>\n<QRZDatabase version="1.33" xmlns="http://xmldata.qrz.com">\n<Callsign>\n<call>MYCALL</call>\n<fname>FIRSTNAME</fname>\n<name>LASTNAME</name>\n<addr2>ADDRESS2</addr2>\n<country>COUNTRY</country>\n</Callsign>\n<Session>\n<Key>3b1fd1d3ba495189984f93ff67bd45b6</Key>\n<Count>61</Count>\n<SubExp>non-subscriber</SubExp>\n<Message>A subscription is required to access the complete record.</Message>\n<GMTime>Sun Nov 2 [...]
-        connection.getresponse.return_value = response
-
-        self.qrz.connection = connection
-        self.qrz.session_key = "3b1fd1d3ba495189984f93ff67bd45b6"
-        fields_and_data = self.qrz.lookup("MYCALL")
-        assert(fields_and_data["NAME"] == "FIRSTNAME LASTNAME")
-        assert(fields_and_data["ADDRESS"] == "ADDRESS2")
-        assert(fields_and_data["COUNTRY"] == "COUNTRY")
-
-    def test_hamqth_connect(self):
-        """ Check the example response from the hamqth.com server, and make sure the session ID has been correctly extracted. """
-
-        http.client.HTTPConnection = unittest.mock.Mock(spec=http.client.HTTPConnection)
-        http.client.HTTPResponse = unittest.mock.Mock(spec=http.client.HTTPResponse)
-        connection = http.client.HTTPConnection()
-        response = http.client.HTTPResponse()
-
-        response.read.return_value = b'<?xml version="1.0"?>\n<HamQTH version="2.6" xmlns="https://www.hamqth.com">\n<session>\n<session_id>09b0ae90050be03c452ad235a1f2915ad684393c</session_id>\n</session>\n</HamQTH>\n'
-        connection.getresponse.return_value = response
-
-        result = self.hamqth.connect("hello", "world")
-        assert(result)
-        assert(self.hamqth.session_id == "09b0ae90050be03c452ad235a1f2915ad684393c")
-
-    def test_hamqth_lookup(self):
-        """ Check the example callsign lookup response from the hamqth.com server, and make sure the callsign information has been correctly extracted. """
-
-        http.client.HTTPConnection = unittest.mock.Mock(spec=http.client.HTTPConnection)
-        http.client.HTTPResponse = unittest.mock.Mock(spec=http.client.HTTPResponse)
-        connection = http.client.HTTPConnection()
-        response = http.client.HTTPResponse()
-
-        response.read.return_value = b'<?xml version="1.0"?>\n<HamQTH version="2.6" xmlns="https://www.hamqth.com">\n<search>\n<callsign>MYCALL</callsign>\n<nick>NAME</nick>\n<country>COUNTRY</country>\n<itu>ITU</itu>\n<cq>CQ</cq>\n<grid>GRID</grid>\n<adr_street1>ADDRESS</adr_street1>\n</search>\n</HamQTH>\n'
-        connection.getresponse.return_value = response
-
-        self.hamqth.connection = connection
-        self.hamqth.session_id = "09b0ae90050be03c452ad235a1f2915ad684393c"
-        fields_and_data = self.hamqth.lookup("MYCALL")
-        assert(fields_and_data["NAME"] == "NAME")
-        assert(fields_and_data["ADDRESS"] == "ADDRESS")
-        assert(fields_and_data["COUNTRY"] == "COUNTRY")
-        assert(fields_and_data["CQZ"] == "CQ")
-        assert(fields_and_data["ITUZ"] == "ITU")
-        assert(fields_and_data["IOTA"] == "GRID")
-
-if(__name__ == '__main__'):
-    unittest.main()
diff --git a/pyqso/compare.py b/pyqso/compare.py
new file mode 100644
index 0000000..8f532e1
--- /dev/null
+++ b/pyqso/compare.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+
+def compare_date_and_time(model, row1, row2, user_data):
+    """ Compare two rows (let's call them A and B) in a Gtk.ListStore, and sort by both date and time.
+
+    :arg Gtk.TreeModel model: The model used to sort the log data.
+    :arg Gtk.TreeIter row1: The pointer to row A.
+    :arg Gtk.TreeIter row2: The pointer to row B.
+    :arg user_data: The specific column from which to retrieve data for rows A and B.
+    :returns: -1 if Row B's date/time is more recent than Row A's; 0 if both dates and times are the same; 1 if Row A's date/time is more recent than Row B's.
+    :rtype: int
+    """
+    date1 = model.get_value(row1, user_data[0])
+    date2 = model.get_value(row2, user_data[0])
+    time1 = model.get_value(row1, user_data[1])
+    time2 = model.get_value(row2, user_data[1])
+    if(date1 < date2):
+        return -1
+    elif(date1 == date2):
+        # If the dates are the same, then let's also sort by time.
+        if(time1 > time2):
+            return 1
+        elif(time1 == time2):
+            return 0
+        else:
+            return -1
+    else:
+        return 1
+
+
+def compare_default(model, row1, row2, user_data):
+    """ The default sorting function for all Gtk.ListStore objects.
+
+    :arg Gtk.TreeModel model: The model used to sort the log data.
+    :arg Gtk.TreeIter row1: The pointer to row A.
+    :arg Gtk.TreeIter row2: The pointer to row B.
+    :arg user_data: The specific column from which to retrieve data for rows A and B.
+    :returns: -1 if the value of Row A's column value is less than Row B's column value; 0 if both values are the same; 1 if Row A's column value is greater than Row B's column value.
+    :rtype: int
+    """
+
+    # Let's try to deal with numerical values, if possible.
+    try:
+        value1 = float(model.get_value(row1, user_data))
+        value2 = float(model.get_value(row2, user_data))
+    except ValueError:
+        value1 = model.get_value(row1, user_data)
+        value2 = model.get_value(row2, user_data)
+
+    if(value1 < value2):
+        return -1
+    elif(value1 == value2):
+        return 0
+    else:
+        return 1
diff --git a/pyqso/dx_cluster.py b/pyqso/dx_cluster.py
index df14bc4..6e60717 100644
--- a/pyqso/dx_cluster.py
+++ b/pyqso/dx_cluster.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,136 +17,121 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk, GObject
+from gi.repository import Gtk, GObject, Gdk
 import logging
 import telnetlib
-import unittest
-import unittest.mock
-import configparser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import os.path
 
-from pyqso.telnet_connection_dialog import *
+from pyqso.telnet_connection_dialog import TelnetConnectionDialog
+from pyqso.auxiliary_dialogs import error
 
 BOOKMARKS_FILE = os.path.expanduser('~/.config/pyqso/bookmarks.ini')
 
 
-class DXCluster(Gtk.VBox):
+class DXCluster:
 
     """ A tool for connecting to a DX cluster (specifically Telnet-based DX clusters). """
 
-    def __init__(self, parent):
-        """ Set up the DX cluster's Gtk.VBox, and set up a timer so that PyQSO can retrieve new data from the Telnet server every few seconds.
+    def __init__(self, application):
+        """ Set up the DX cluster, and set up a timer so that PyQSO can retrieve new data from the Telnet server every few seconds.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
+
         logging.debug("Setting up the DX cluster...")
-        Gtk.VBox.__init__(self, spacing=2)
 
+        self.application = application
+        self.builder = self.application.builder
         self.connection = None
-        self.parent = parent
-
-        # Set up the menubar
-        self.menubar = Gtk.MenuBar()
 
-        self.items = {}
+        # Connect signals.
+        self.builder.get_object("mitem_new").connect("activate", self.new_server)
+        self.builder.get_object("mitem_disconnect").connect("activate", self.telnet_disconnect)
+        self.builder.get_object("send").connect("clicked", self.telnet_send_command)
+        self.builder.get_object("command").connect("key-press-event", self.on_command_key_press)
 
-        # CONNECTION ######
-        mitem_connection = Gtk.MenuItem(label="Connection")
-        self.menubar.append(mitem_connection)
-        subm_connection = Gtk.Menu()
-        mitem_connection.set_submenu(subm_connection)
-
-        # Connect
-        mitem_connect = Gtk.ImageMenuItem(label="Connect to Telnet Server")
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_CONNECT, Gtk.IconSize.MENU)
-        mitem_connect.set_image(icon)
-        subm_connection.append(mitem_connect)
-        self.items["CONNECT"] = mitem_connect
-
-        subm_connect = Gtk.Menu()
-
-        # New
-        mitem_new = Gtk.MenuItem(label="New...")
-        mitem_new.connect("activate", self.new_server)
-        subm_connect.append(mitem_new)
-
-        # From Bookmark
-        mitem_bookmark = Gtk.MenuItem(label="From Bookmark")
-        self.subm_bookmarks = Gtk.Menu()
-        mitem_bookmark.set_submenu(self.subm_bookmarks)
-        self._populate_bookmarks()
-        subm_connect.append(mitem_bookmark)
-
-        mitem_connect.set_submenu(subm_connect)
-
-        # Disconnect
-        mitem_disconnect = Gtk.ImageMenuItem(label="Disconnect from Telnet Server")
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_DISCONNECT, Gtk.IconSize.MENU)
-        mitem_disconnect.set_image(icon)
-        mitem_disconnect.connect("activate", self.telnet_disconnect)
-        subm_connection.append(mitem_disconnect)
-        self.items["DISCONNECT"] = mitem_disconnect
-
-        self.pack_start(self.menubar, False, False, 0)
-
-        # A TextView object to display the output from the Telnet server.
-        self.renderer = Gtk.TextView()
-        self.renderer.set_editable(False)
-        self.renderer.set_cursor_visible(False)
-        sw = Gtk.ScrolledWindow()
-        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
-        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
-        sw.add(self.renderer)
+        # Get the text renderer and its buffer.
+        self.renderer = self.builder.get_object("renderer")
         self.buffer = self.renderer.get_buffer()
-        self.pack_start(sw, True, True, 0)
-
-        # Set up the command box.
-        self.commandbox = Gtk.HBox(spacing=2)
-        self.command = Gtk.Entry()
-        self.commandbox.pack_start(self.command, True, True, 0)
-        self.send = Gtk.Button(label="Send Command")
-        self.send.connect("clicked", self.telnet_send_command)
-        self.commandbox.pack_start(self.send, False, False, 0)
-        self.pack_start(self.commandbox, False, False, 0)
 
+        # Items whose sensitivity may change.
+        self.items = {}
+        self.items["CONNECT"] = self.builder.get_object("mitem_connect")
+        self.items["DISCONNECT"] = self.builder.get_object("mitem_disconnect")
+        self.items["SEND"] = self.builder.get_object("send")
         self.set_items_sensitive(True)
 
-        self.show_all()
+        self.populate_bookmarks()
 
         logging.debug("DX cluster ready!")
 
         return
 
+    def on_command_key_press(self, widget, event, data=None):
+        """ If the Return key is pressed when the focus is on the command box, then send whatever command the user has entered. """
+        if(event.keyval == Gdk.KEY_Return):
+            self.telnet_send_command()
+        return
+
     def new_server(self, widget=None):
-        """ Get Telnet server host and login details specified in the Gtk.Entry boxes in the TelnetConnectionDialog and attempt a connection. """
-        dialog = TelnetConnectionDialog(self.parent)
-        response = dialog.run()
+        """ Get Telnet server host and login details specified in the Gtk.Entry boxes in the Telnet connection dialog and attempt a connection. """
 
+        # Get connection details.
+        tcd = TelnetConnectionDialog(self.application)
+        response = tcd.dialog.run()
         if(response == Gtk.ResponseType.OK):
-            connection_info = dialog.get_connection_info()
-            host = connection_info["HOST"].get_text()
-            port = connection_info["PORT"].get_text()
-            username = connection_info["USERNAME"].get_text()
-            password = connection_info["PASSWORD"].get_text()
+            host = tcd.host
+            port = tcd.port
+            username = tcd.username
+            password = tcd.password
+            bookmark = tcd.bookmark
+            tcd.dialog.destroy()
+
+            # Handle empty hostname.
+            if(not host):
+                logging.error("No hostname specified.")
+                return
+
+            # Handle empty port number.
+            if(not port):
+                logging.warning("No port specified. Assuming default port 23...")
+                port = 23
+            else:
+                try:
+                    # Cast port into an int.
+                    port = int(port)
+                except ValueError as e:
+                    logging.error("Could not cast the DX cluster's port information to an integer.")
+                    logging.exception(e)
+                    return
 
             # Save the server details in a new bookmark, if desired.
-            if(connection_info["BOOKMARK"].get_active()):
+            if(bookmark):
                 try:
                     config = configparser.ConfigParser()
                     config.read(BOOKMARKS_FILE)
 
                     # Use the host name as the bookmark's identifier.
+                    if(username):
+                        bookmark_identifier = "%s@%s:%d" % (username, host, port)
+                    else:
+                        bookmark_identifier = "%s:%d" % (host, port)
+                    logging.debug("Using %s as the bookmark identifier." % bookmark_identifier)
+
+                    # Add bookmark.
                     try:
-                        config.add_section(host)
+                        config.add_section(bookmark_identifier)
                     except configparser.DuplicateSectionError:
                         # If the hostname already exists, assume the user wants to update the port number, username and/or password.
-                        logging.warning("A server with hostname '%s' already exists. Over-writing existing details..." % (host))
-                    config.set(host, "host", host)
-                    config.set(host, "port", port)
-                    config.set(host, "username", username)
-                    config.set(host, "password", password)
+                        logging.warning("Bookmark '%s' already exists. Over-writing existing details..." % (bookmark_identifier))
+                    config.set(bookmark_identifier, "host", host)
+                    config.set(bookmark_identifier, "port", str(port))
+                    config.set(bookmark_identifier, "username", username)
+                    config.set(bookmark_identifier, "password", password)
 
                     # Write the bookmarks to file.
                     if not os.path.exists(os.path.expanduser('~/.config/pyqso')):
@@ -154,49 +139,45 @@ class DXCluster(Gtk.VBox):
                     with open(BOOKMARKS_FILE, 'w') as f:
                         config.write(f)
 
-                    self._populate_bookmarks()
+                    self.populate_bookmarks()
 
                 except IOError:
                     # Maybe the bookmarks file could not be written to?
                     logging.error("Bookmark could not be saved. Check bookmarks file permissions? Going ahead with the server connection anyway...")
 
-            dialog.destroy()
-
-            try:
-                # Convert port (currently of type str) into an int.
-                port = int(port)
-                # Attempt a connection with the server.
-                self.telnet_connect(host, port, username, password)
-            except ValueError as e:
-                logging.error("Could not convert the server's port information to an integer.")
-                logging.exception(e)
+            # Attempt a connection with the server.
+            self.telnet_connect(host, port, username, password)
 
         else:
-            dialog.destroy()
+            tcd.dialog.destroy()
         return
 
-    def _populate_bookmarks(self):
+    def populate_bookmarks(self):
         """ Populate the list of bookmarked Telnet servers in the menu. """
+
+        # Get the bookmarks submenu.
+        subm_bookmarks = self.builder.get_object("subm_bookmarks")
+
         config = configparser.ConfigParser()
         have_config = (config.read(BOOKMARKS_FILE) != [])
 
         if(have_config):
             try:
                 # Clear the menu of all current bookmarks.
-                for i in self.subm_bookmarks.get_children():
-                    self.subm_bookmarks.remove(i)
+                for i in subm_bookmarks.get_children():
+                    subm_bookmarks.remove(i)
 
                 # Add all bookmarks in the config file.
                 for bookmark in config.sections():
                     mitem = Gtk.MenuItem(label=bookmark)
                     mitem.connect("activate", self.bookmarked_server, bookmark)
-                    self.subm_bookmarks.append(mitem)
+                    subm_bookmarks.append(mitem)
 
             except Exception as e:
                 logging.error("An error occurred whilst populating the DX cluster bookmarks menu.")
                 logging.exception(e)
 
-            self.show_all()  # Need to do this to update the bookmarks list in the menu.
+            self.builder.get_object("dx_cluster").show_all()  # Need to do this to update the bookmarks list in the menu.
 
         return
 
@@ -224,7 +205,7 @@ class DXCluster(Gtk.VBox):
         except IOError as e:
             logging.exception(e)
         except Exception as e:
-            logging.error("Could not connect to Telnet server '%s'" % name)
+            logging.error("Could not connect to Telnet server '%s'." % name)
             logging.exception(e)
 
         return
@@ -238,14 +219,18 @@ class DXCluster(Gtk.VBox):
         :arg str password: The user's password. This is an optional argument.
         """
 
-        if(host == "" or host is None):
-            logging.error("No Telnet server specified.")
+        # Handle empty host/port string (or the case where host/port are None).
+        if(not host):
+            error(parent=self.application.window, message="Unable to connect to a DX cluster because no hostname was specified.")
             return
-        if(port == "" or port is None):
-            port = 23  # Use the default Telnet port
+        if(not port):
+            logging.warning("No port specified. Assuming default port 23...")
+            port = 23  # Use the default Telnet port.
 
         try:
+            logging.debug("Attempting connection to Telnet server %s:%d..." % (host, port))
             self.connection = telnetlib.Telnet(host, port)
+            assert(self.connection)
 
             if(username):
                 self.connection.read_until("login: ".encode())
@@ -254,14 +239,17 @@ class DXCluster(Gtk.VBox):
                 self.connection.read_until("password: ".encode())
                 self.connection.write((password + "\n").encode())
         except Exception as e:
-            logging.error("Could not create a connection to the Telnet server")
+            message = "Could not create a connection to the Telnet server %s:%d. Check connection to the internets? Check connection details?" % (host, port)
+            error(parent=self.application.window, message=message)
             logging.exception(e)
             self.connection = None
             return
 
+        logging.debug("Connection to %s:%d established." % (host, port))
+
         self.set_items_sensitive(False)
 
-        self.check_io_event = GObject.timeout_add(1000, self._on_telnet_io)
+        self.check_io_event = GObject.timeout_add(1000, self.on_telnet_io)
 
         return
 
@@ -285,18 +273,20 @@ class DXCluster(Gtk.VBox):
     def telnet_send_command(self, widget=None):
         """ Send the user-specified command in the Gtk.Entry box to the Telnet server (if PyQSO is connected to one). """
         if(self.connection):
-            self.connection.write((self.command.get_text() + "\n").encode())
-            self.command.set_text("")
+            command = self.builder.get_object("command")
+            self.connection.write((command.get_text() + "\n").encode())
+            command.set_text("")
         return
 
-    def _on_telnet_io(self):
+    def on_telnet_io(self):
         """ Retrieve any new data from the Telnet server and print it out in the Gtk.TextView widget.
 
         :returns: Always returns True to satisfy the GObject timer.
         :rtype: bool
         """
         if(self.connection):
-            text = self.connection.read_very_eager().decode()
+            text = self.connection.read_very_eager()
+            text = text.decode("ascii", "replace")  # Replace any characters that cannot be decoded with a replacement marker.
             try:
                 text = text.replace("\u0007", "")  # Remove the BEL Unicode character from the end of the line
             except UnicodeDecodeError:
@@ -324,31 +314,5 @@ class DXCluster(Gtk.VBox):
         """
         self.items["CONNECT"].set_sensitive(sensitive)
         self.items["DISCONNECT"].set_sensitive(not sensitive)
-        self.send.set_sensitive(not sensitive)
+        self.items["SEND"].set_sensitive(not sensitive)
         return
-
-
-class TestDXCluster(unittest.TestCase):
-
-    """ The unit tests for the DXCluster class. """
-
-    def setUp(self):
-        """ Set up the objects needed for the unit tests. """
-        self.dxcluster = DXCluster(parent=None)
-
-    def tearDown(self):
-        """ Destroy any unit test resources. """
-        pass
-
-    def test_on_telnet_io(self):
-        """ Check that the response from the Telnet server can be correctly decoded. """
-
-        telnetlib.Telnet = unittest.mock.Mock(spec=telnetlib.Telnet)
-        connection = telnetlib.Telnet("hello", "world")
-        connection.read_very_eager.return_value = b"Test message from the Telnet server."
-        self.dxcluster.connection = connection
-        result = self.dxcluster._on_telnet_io()
-        assert(result)
-
-if(__name__ == '__main__'):
-    unittest.main()
diff --git a/pyqso/grey_line.py b/pyqso/grey_line.py
index 42edf28..9dd3d88 100644
--- a/pyqso/grey_line.py
+++ b/pyqso/grey_line.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,16 +17,19 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk, GObject
+from gi.repository import GObject
 import logging
 from datetime import datetime
+from os.path import expanduser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 try:
     import numpy
     logging.info("Using version %s of numpy." % (numpy.__version__))
     import matplotlib
     logging.info("Using version %s of matplotlib." % (matplotlib.__version__))
-    matplotlib.use('Agg')
-    matplotlib.rcParams['font.size'] = 10.0
     import mpl_toolkits.basemap
     logging.info("Using version %s of mpl_toolkits.basemap." % (mpl_toolkits.basemap.__version__))
     from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
@@ -37,26 +40,43 @@ except ImportError as e:
     have_necessary_modules = False
 
 
-class GreyLine(Gtk.VBox):
+class GreyLine:
 
     """ A tool for visualising the grey line. """
 
-    def __init__(self, parent):
+    def __init__(self, application):
         """ Set up the drawing canvas and the timer which will re-plot the grey line every 30 minutes.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
         logging.debug("Setting up the grey line...")
-        Gtk.VBox.__init__(self, spacing=2)
-        self.parent = parent
+
+        self.application = application
+        self.builder = self.application.builder
+
+        # Get the QTH coordinates, if available.
+        config = configparser.ConfigParser()
+        have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
+        (section, option) = ("general", "show_qth")
+        self.show_qth = False
+        if(have_config and config.has_option(section, option)):
+            if(config.getboolean(section, option)):
+                self.show_qth = True
+                try:
+                    self.qth_name = config.get("general", "qth_name")
+                    self.qth_latitude = float(config.get("general", "qth_latitude"))
+                    self.qth_longitude = float(config.get("general", "qth_longitude"))
+                except ValueError:
+                    logging.warning("Unable to get the QTH name, latitude and/or longitude. The QTH will not be pinpointed on the grey line map. Check preferences?")
+                    self.show_qth = False
 
         if(have_necessary_modules):
             self.fig = matplotlib.figure.Figure()
             self.canvas = FigureCanvas(self.fig)  # For embedding in the Gtk application
-            self.pack_start(self.canvas, True, True, 0)
+            self.builder.get_object("greyline").pack_start(self.canvas, True, True, 0)
             self.refresh_event = GObject.timeout_add(1800000, self.draw)  # Re-draw the grey line automatically after 30 minutes (if the grey line tool is visible).
 
-        self.show_all()
+        self.builder.get_object("greyline").show_all()
 
         logging.debug("Grey line ready!")
 
@@ -70,7 +90,9 @@ class GreyLine(Gtk.VBox):
         """
 
         if(have_necessary_modules):
-            if(self.parent.toolbox.tools.get_current_page() != 1 or not self.parent.toolbox.get_visible()):
+            toolbox = self.builder.get_object("toolbox")
+            tools = self.builder.get_object("tools")
+            if(tools.get_current_page() != 1 or not toolbox.get_visible()):
                 # Don't re-draw if the grey line is not visible.
                 return True  # We need to return True in case this is method was called by a timer event.
             else:
@@ -81,15 +103,22 @@ class GreyLine(Gtk.VBox):
 
                 # Draw the map of the world. This is based on the example from:
                 # http://matplotlib.org/basemap/users/examples.html
-                m = mpl_toolkits.basemap.Basemap(projection='mill', lon_0=0, ax=sub, resolution='c', fix_aspect=False)
-                m.drawcountries(linewidth=0.5)
-                m.drawcoastlines(linewidth=0.5)
+                m = mpl_toolkits.basemap.Basemap(projection="mill", lon_0=0, ax=sub, resolution="c", fix_aspect=False)
+                m.drawcountries(linewidth=0.4)
+                m.drawcoastlines(linewidth=0.4)
                 m.drawparallels(numpy.arange(-90, 90, 30), labels=[1, 0, 0, 0])
                 m.drawmeridians(numpy.arange(m.lonmin, m.lonmax+30, 60), labels=[0, 0, 0, 1])
-                m.drawmapboundary(fill_color='lightblue')
-                m.fillcontinents(color='darkgreen', lake_color='lightblue')
+                m.drawmapboundary(fill_color="skyblue")
+                m.fillcontinents(color="green", lake_color="skyblue")
                 m.nightshade(datetime.utcnow())  # Add in the grey line using UTC time. Note that this requires NetCDF.
                 logging.debug("Grey line drawn.")
+
+                # Pin-point QTH on the map.
+                if(self.show_qth):
+                    qth_x, qth_y = m(self.qth_longitude, self.qth_latitude)
+                    m.plot(qth_x, qth_y, "ro")
+                    sub.text(qth_x+0.015*qth_x, qth_y+0.015*qth_y, self.qth_name, color="white", size="medium", weight="bold")
+
                 return True
         else:
             return False  # Don't try to re-draw the canvas if the necessary modules to do so could not be imported.
diff --git a/pyqso/log.py b/pyqso/log.py
index 7125e47..712b368 100644
--- a/pyqso/log.py
+++ b/pyqso/log.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -20,33 +20,30 @@
 from gi.repository import Gtk
 import logging
 import sqlite3 as sqlite
-import unittest
 
 from pyqso.adif import AVAILABLE_FIELD_NAMES_ORDERED
-from pyqso.record_dialog import *
 
 
 class Log(Gtk.ListStore):
 
-    """ A single log inside of the whole logbook. A Log object can store multiple Record objects. """
+    """ A single log inside of the whole logbook. A Log object can store multiple records. This is """
 
     def __init__(self, connection, name):
         """ Set up a new Log object.
 
         :arg connection: An sqlite database connection.
-        :arg str name: The name of the log (i.e. the sqlite table name).
+        :arg str name: The name of the log (i.e. the database table name).
         """
 
         # The ListStore constructor needs to know the data types of the columns.
         # The index is always an integer. We will assume the fields are strings.
         data_types = [int] + [str]*len(AVAILABLE_FIELD_NAMES_ORDERED)
-        # Call the constructor of the super class (Gtk.ListStore)
+        # Call the constructor of the super class (Gtk.ListStore).
         Gtk.ListStore.__init__(self, *data_types)
 
         self.connection = connection
         self.name = name
 
-        logging.debug("New Log instance created!")
         return
 
     def populate(self):
@@ -55,8 +52,10 @@ class Log(Gtk.ListStore):
         logging.debug("Populating '%s'..." % self.name)
         self.add_missing_db_columns()
         self.clear()
-        records = self.get_all_records()
-        if(records is not None):
+
+        try:
+            records = self.records
+
             for r in records:
                 liststore_entry = [r["id"]]
                 for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
@@ -66,15 +65,18 @@ class Log(Gtk.ListStore):
                     liststore_entry.append(r[field_name])
                 self.append(liststore_entry)
             logging.debug("Finished populating '%s'." % self.name)
-        else:
+
+        except sqlite.Error as e:
             logging.error("Could not populate '%s' because of a database error." % self.name)
+            logging.exception(e)
+
         return
 
     def add_missing_db_columns(self):
         """ Check whether each field name in AVAILABLE_FIELD_NAMES_ORDERED is in the database table. If not, add it
         (with all entries being set to an empty string initially).
 
-        :raises sqlite.Error, IndexError: if the existing database column names could not be obtained, or missing column names could not be added.
+        :raises sqlite.Error, IndexError: If the existing database column names could not be obtained, or missing column names could not be added.
         """
         logging.debug("Adding any missing database columns...")
 
@@ -116,12 +118,14 @@ class Log(Gtk.ListStore):
             fields_and_data = [fields_and_data]
 
         with self.connection:
-            # Get all the column names in the current database table.
             c = self.connection.cursor()
+
+            # Get all the column names in the current database table.
             c.execute("PRAGMA table_info(%s)" % self.name)
             column_names = c.fetchall()
-            # Get the index of the last inserted record in the database.
-            c.execute('SELECT max(id) FROM %s' % self.name)
+
+            # Get the index/rowid of the last inserted record in the database.
+            c.execute("SELECT max(id) FROM %s" % self.name)
             last_index = c.fetchone()[0]
             if last_index is None:
                 # Assume no records are currently present.
@@ -132,7 +136,7 @@ class Log(Gtk.ListStore):
 
         # Construct the SQL query.
         query = "INSERT INTO %s VALUES (NULL" % self.name
-        for i in range(len(column_names)-1):  # -1 here because we don't want to count the database's 'id' field.
+        for i in range(len(column_names)-1):  # -1 here because we don't want to count the database's 'id' column, since this is autoincremented.
             query = query + ",?"
         query = query + ")"
 
@@ -146,28 +150,34 @@ class Log(Gtk.ListStore):
                 if((column_name.upper() in AVAILABLE_FIELD_NAMES_ORDERED) and (column_name.upper() in list(fields_and_data[r].keys()))):
                     database_entry.append(fields_and_data[r][column_name.upper()])
                 else:
-                    if(column_name != "id"):  # Ignore the row index field. This is a special case since it's not in AVAILABLE_FIELD_NAMES_ORDERED.
+                    if(column_name != "id"):  # Ignore the index/rowid field. This is a special case since it's not in AVAILABLE_FIELD_NAMES_ORDERED.
                         database_entry.append("")
             database_entries.append(database_entry)
 
-            # Add the data to the ListStore as well.
-            liststore_entry = []
-            field_names = AVAILABLE_FIELD_NAMES_ORDERED
-            for i in range(0, len(field_names)):
-                if(field_names[i] in list(fields_and_data[r].keys())):
-                    liststore_entry.append(fields_and_data[r][field_names[i]])
-                else:
-                    liststore_entry.append("")
-
-            # Add the record's index.
-            index = last_index + (r+1)  # +1 here because r begins at zero, and we don't want to count the already-present record with index last_index.
-            liststore_entry.insert(0, index)
-            self.append(liststore_entry)
-
-        # Execute the query.
+        # Insert records in the database.
         with self.connection:
+            c = self.connection.cursor()
             c.executemany(query, database_entries)
 
+            # Get the indices/rowids of the newly-inserted records.
+            query = "SELECT id FROM %s WHERE id > %s ORDER BY id ASC" % (self.name, last_index)
+            c.execute(query)
+            inserted = c.fetchall()
+
+            # Check that the number of records we wanted to insert is the same as the number of records successfully inserted.
+            assert(len(inserted) == len(database_entries))
+
+            # Add the records to the ListStore as well.
+            for r in range(len(fields_and_data)):
+                liststore_entry = [inserted[r]["id"]]  # Add the record's index.
+                field_names = AVAILABLE_FIELD_NAMES_ORDERED
+                for i in range(0, len(field_names)):
+                    if(field_names[i] in list(fields_and_data[r].keys())):
+                        liststore_entry.append(fields_and_data[r][field_names[i]])
+                    else:
+                        liststore_entry.append("")
+                self.append(liststore_entry)
+
         logging.debug("Successfully added the record(s) to the log.")
         return
 
@@ -175,22 +185,22 @@ class Log(Gtk.ListStore):
         """ Delete a specified record from the log. The corresponding record is also deleted from the Gtk.ListStore data structure.
 
         :arg int index: The index of the record in the SQL database.
-        :arg iter: iter should always be given. It is given a default value of None for unit testing purposes only.
-        :raises sqlite.Error, IndexError: if the record could not be deleted.
+        :arg iter: The iterator pointing to the record to be deleted in the Gtk.ListStore. If the default value of None is used, only the database entry is deleted and the corresponding Gtk.ListStore is left alone.
+        :raises sqlite.Error, IndexError: If the record could not be deleted.
         """
         logging.debug("Deleting record from log...")
-        # Get the selected row in the logbook
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                query = "DELETE FROM %s" % self.name
-                c.execute(query+" WHERE id=?", [index])
-            if(iter is not None):
-                self.remove(iter)
-            logging.debug("Successfully deleted the record from the log.")
-        except (sqlite.Error, IndexError) as e:
-            logging.exception(e)
-            logging.error("Could not delete the record from the log.")
+
+        # Delete the selected row in database.
+        with self.connection:
+            c = self.connection.cursor()
+            query = "DELETE FROM %s" % self.name
+            c.execute(query+" WHERE id=?", [index])
+
+        # Delete the selected row in the Gtk.ListStore.
+        if(iter is not None):
+            self.remove(iter)
+
+        logging.debug("Successfully deleted the record from the log.")
         return
 
     def edit_record(self, index, field_name, data, iter=None, column_index=None):
@@ -199,23 +209,19 @@ class Log(Gtk.ListStore):
         :arg int index: The index of the record in the SQL database.
         :arg str field_name: The name of the field whose data should be modified.
         :arg str data: The data that should replace the current data in the field.
-        :arg iter: Should always be given. A default value of None is used for unit testing purposes only.
-        :arg column_index: Should always be given. A default value of None is used for unit testing purposes only.
-        :raises sqlite.Error, IndexError: if the record could not be edited.
+        :arg iter: The iterator pointing to the record to be edited in the Gtk.ListStore. If the default value of None is used, only the database entry is edited and the corresponding Gtk.ListStore is left alone.
+        :arg column_index: The index of the column in the Gtk.ListStore to be edited. If the default value of None is used, only the database entry is edited and the corresponding Gtk.ListStore is left alone.
+        :raises sqlite.Error, IndexError: If the record could not be edited.
         """
         logging.debug("Editing field '%s' in record %d..." % (field_name, index))
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                query = "UPDATE %s SET %s" % (self.name, field_name)
-                query = query + "=? WHERE id=?"
-                c.execute(query, [data, index])  # First update the SQL database...
-            if(iter is not None and column_index is not None):
-                self.set(iter, column_index, data)  # ...and then the ListStore.
-            logging.debug("Successfully edited field '%s' in record %d in the log." % (field_name, index))
-        except (sqlite.Error, IndexError) as e:
-            logging.exception(e)
-            logging.error("Could not edit field %s in record %d in the log." % (field_name, index))
+        with self.connection:
+            c = self.connection.cursor()
+            query = "UPDATE %s SET %s" % (self.name, field_name)
+            query = query + "=? WHERE id=?"
+            c.execute(query, [data, index])  # First update the SQL database...
+        if(iter is not None and column_index is not None):
+            self.set(iter, column_index, data)  # ...and then the ListStore.
+        logging.debug("Successfully edited field '%s' in record %d in the log." % (field_name, index))
         return
 
     def remove_duplicates(self):
@@ -229,23 +235,45 @@ class Log(Gtk.ListStore):
             return (0, 0)  # Nothing to do here.
 
         removed = 0  # Count the number of records that are removed. Hopefully this will be the same as len(duplicates).
-        while removed != len(duplicates):  # Unfortunately, in certain cases, extra passes may be necessary to ensure that all duplicates are removed.
-            path = Gtk.TreePath(0)  # Start with the first row in the log.
-            iter = self.get_iter(path)
-            while iter is not None:
-                row_index = self.get_value(iter, 0)  # Get the index.
-                if(row_index in duplicates):  # Is this a duplicate row? If so, delete it.
-                    self.delete_record(row_index, iter)
-                    removed += 1
-                iter = self.iter_next(iter)  # Move on to the next row, until iter_next returns None.
-
-        assert(removed == len(duplicates))
+        iter = self.get_iter_first()  # Start with the first row in the log.
+        prev = iter  # Keep track of the previous iter (initially this will be the same as the first row in the log).
+        while iter is not None:
+            row_index = self.get_value(iter, 0)  # Get the index.
+            if(row_index in duplicates):  # Is this a duplicate row? If so, delete it.
+                self.delete_record(row_index, iter)
+                removed += 1
+                iter = prev  # Go back to the iter before the record that was just removed and continue from there.
+                continue
+            prev = iter
+            iter = self.iter_next(iter)  # Move on to the next row, until iter_next returns None.
+
         return (len(duplicates), removed)
 
+    def rename(self, new_name):
+        """ Rename the log.
+
+        :arg str new_name: The new name for the log.
+        :returns: True if the renaming process is successful. Otherwise returns False.
+        :rtype: bool
+        """
+        try:
+            with self.connection:
+                # First try to alter the table name in the database.
+                c = self.connection.cursor()
+                query = "ALTER TABLE %s RENAME TO %s" % (self.name, new_name)
+                c.execute(query)
+            # If the table name change was successful, then change the name attribute of the Log object too.
+            self.name = new_name
+            success = True
+        except sqlite.Error as e:
+            logging.exception(e)
+            success = False
+        return success
+
     def get_duplicates(self):
-        """ Find the duplicates in the log, based on the CALL, QSO_DATE, TIME_ON, FREQ and MODE fields.
+        """ Find the duplicates in the log, based on the CALL, QSO_DATE, and TIME_ON fields.
 
-        :returns: A list of row IDs corresponding to the duplicate records.
+        :returns: A list of indices/ids corresponding to the duplicate records.
         :rtype: list
         """
         duplicates = []
@@ -253,13 +281,14 @@ class Log(Gtk.ListStore):
             with self.connection:
                 c = self.connection.cursor()
                 c.execute(
-                    """SELECT rowid FROM %s WHERE rowid NOT IN
+                    """SELECT id FROM %s WHERE id NOT IN
    (
-   SELECT MIN(rowid) FROM %s GROUP BY call, qso_date, time_on, freq, mode
+   SELECT MIN(id) FROM %s GROUP BY call, qso_date, time_on
    )""" % (self.name, self.name))
                 result = c.fetchall()
-            for rowid in result:
-                duplicates.append(rowid[0])  # Get the integer from inside the tuple.
+            for index in result:
+                duplicates.append(index[0])  # Get the integer from inside the tuple.
+            duplicates.sort()  # These indices should monotonically increasing, but let's sort the list just in case.
         except (sqlite.Error, IndexError) as e:
             logging.exception(e)
         return duplicates
@@ -270,189 +299,36 @@ class Log(Gtk.ListStore):
         :arg int index: The index of the record in the SQL database.
         :returns: The desired record, represented by a dictionary of field-value pairs.
         :rtype: dict
+        :raises sqlite.Error: If the record could not be retrieved from the database.
         """
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                query = "SELECT * FROM %s WHERE id=?" % self.name
-                c.execute(query, [index])
-                return c.fetchone()
-        except sqlite.Error as e:
-            logging.exception(e)
-            return None
+        with self.connection:
+            c = self.connection.cursor()
+            query = "SELECT * FROM %s WHERE id=?" % self.name
+            c.execute(query, [index])
+            return c.fetchone()
 
-    def get_all_records(self):
+    @property
+    def records(self):
         """ Return a list of all the records in the log.
 
         :returns: A list of all the records in the log. Each record is represented by a dictionary.
         :rtype: dict
+        :raises sqlite.Error: If the records could not be retrieved from the database.
         """
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                c.execute("SELECT * FROM %s" % self.name)
-                return c.fetchall()
-        except sqlite.Error as e:
-            logging.exception(e)
-            return None
+        with self.connection:
+            c = self.connection.cursor()
+            c.execute("SELECT * FROM %s" % self.name)
+            return c.fetchall()
 
-    def get_number_of_records(self):
+    @property
+    def record_count(self):
         """ Return the total number of records in the log.
 
         :returns: The total number of records in the log.
         :rtype: int
+        :raises sqlite.Error: If the record count could not be determined due to a database error.
         """
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                c.execute("SELECT Count(*) FROM %s" % self.name)
-                return c.fetchone()[0]
-        except (sqlite.Error, IndexError) as e:
-            logging.exception(e)
-            return None
-
-
-class TestLog(unittest.TestCase):
-
-    def setUp(self):
-        self.connection = sqlite.connect(":memory:")
-        self.connection.row_factory = sqlite.Row
-
-        self.field_names = ["CALL", "QSO_DATE", "TIME_ON", "FREQ", "BAND", "MODE", "RST_SENT", "RST_RCVD"]
-        self.fields_and_data = {"CALL": "TEST123", "QSO_DATE": "20130312", "TIME_ON": "1234", "FREQ": "145.500", "BAND": "2m", "MODE": "FM", "RST_SENT": "59", "RST_RCVD": "59"}
-
-        c = self.connection.cursor()
-        query = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT"
-        for field_name in self.field_names:
-            s = ", %s TEXT" % field_name.lower()
-            query = query + s
-        query = query + ")"
-        c.execute(query)
-
-        self.log = Log(self.connection, "test")
-
-    def tearDown(self):
-        self.connection.close()
-
-    def test_log_add_missing_db_columns(self):
-
-        column_names_before = []
-        column_names_after = []
-
-        c = self.connection.cursor()
-        c.execute("PRAGMA table_info(test)")
-        result = c.fetchall()
-        for t in result:
-            column_names_before.append(t[1].upper())
-
-        self.log.add_missing_db_columns()
-
-        c.execute("PRAGMA table_info(test)")
-        result = c.fetchall()
-        for t in result:
-            column_names_after.append(t[1].upper())
-
-        print("Column names before: ", column_names_before)
-        print("Column names after: ", column_names_after)
-
-        assert(len(column_names_before) == len(self.field_names) + 1)  # Added 1 here because of the "ID" column in all database tables.
-        assert(len(column_names_after) == len(AVAILABLE_FIELD_NAMES_ORDERED) + 1)
-        for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
-            assert(field_name in column_names_after)
-
-    def test_log_add_record(self):
-        self.log.add_record(self.fields_and_data)
-        c = self.connection.cursor()
-        c.execute("SELECT * FROM test")
-        records = c.fetchall()
-
-        assert len(records) == 1
-
-        for field_name in self.field_names:
-            print(self.fields_and_data[field_name], records[0][field_name])
-            assert self.fields_and_data[field_name] == records[0][field_name]
-
-    def test_log_delete_record(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-
-        c.execute("SELECT * FROM test")
-        records_before = c.fetchall()
-
-        self.log.delete_record(1)
-
-        c.execute("SELECT * FROM test")
-        records_after = c.fetchall()
-
-        assert(len(records_before) == 1)
-        assert(len(records_after) == 0)
-
-    def test_log_edit_record(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-
-        c.execute("SELECT * FROM test")
-        record_before = c.fetchall()[0]
-
-        self.log.edit_record(1, "CALL", "TEST456")
-        self.log.edit_record(1, "FREQ", "145.450")
-
-        c.execute("SELECT * FROM test")
-        record_after = c.fetchall()[0]
-
-        assert(record_before["CALL"] == "TEST123")
-        assert(record_after["CALL"] == "TEST456")
-        assert(record_before["FREQ"] == "145.500")
-        assert(record_after["FREQ"] == "145.450")
-
-    def test_log_get_record_by_index(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-
-        record = self.log.get_record_by_index(1)
-        print("Contents of retrieved record: ", record)
-        for field_name in list(record.keys()):
-            if(field_name.upper() == "ID"):
-                continue
-            else:
-                assert(record[field_name.upper()] == self.fields_and_data[field_name.upper()])
-        assert(len(record) == len(self.fields_and_data) + 1)
-
-    def test_log_get_all_records(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        # Add the same record twice
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-
-        records = self.log.get_all_records()
-        print("Contents of all retrieved records: ", records)
-        assert(len(records) == 2)  # There should be 2 records
-        for field_name in self.field_names:
-            assert(records[0][field_name] == self.fields_and_data[field_name])
-            assert(records[1][field_name] == self.fields_and_data[field_name])
-
-    def test_log_get_number_of_records(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        # Add the same record twice
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-
-        number_of_records = self.log.get_number_of_records()
-        print("Number of records in the log: ", number_of_records)
-        assert(number_of_records == 2)  # There should be 2 records
-
-    def test_log_get_duplicates(self):
-        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
-        c = self.connection.cursor()
-        n = 5  # The total number of records to insert.
-        for i in range(0, n):
-            c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
-        assert len(self.log.get_duplicates()) == n-1  # Expecting n-1 duplicates.
-
-if(__name__ == '__main__'):
-    unittest.main()
+        with self.connection:
+            c = self.connection.cursor()
+            c.execute("SELECT Count(*) FROM %s" % self.name)
+            return c.fetchone()[0]
diff --git a/pyqso/log_name_dialog.py b/pyqso/log_name_dialog.py
index df46436..dbd00eb 100644
--- a/pyqso/log_name_dialog.py
+++ b/pyqso/log_name_dialog.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,50 +17,49 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk
 import logging
+import os.path
 
 
-class LogNameDialog(Gtk.Dialog):
+class LogNameDialog:
 
-    """ A Gtk.Dialog where a user can specify the name of a Log object. """
+    """ A handler for the Gtk.Dialog through which a user can specify the name of a Log object. """
 
-    def __init__(self, parent, title=None, name=None):
+    def __init__(self, application, title=None, name=None):
         """ Create and show the log name dialog to the user.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         :arg title: The title of the dialog. If this is None, it is assumed that a new log is going to be created.
         :arg name: The existing name of the Log object. Defaults to None if not specified (because the Log does not yet exist).
         """
 
+        logging.debug("Building new log name dialog...")
+
+        self.builder = application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("log_name_dialog",))
+        self.dialog = self.builder.get_object("log_name_dialog")
+
         if(title is None):
-            title = "New Log"
+            self.dialog.set_title("New Log")
         else:
-            title = title
-        Gtk.Dialog.__init__(self, title=title, parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Log Name:")
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 6)
-        self.entry = Gtk.Entry()
+            self.dialog.set_title(title)
+
+        self.entry = self.builder.get_object("log_name_entry")
         if(name is not None):
             self.entry.set_text(name)
-        hbox_temp.pack_start(self.entry, False, False, 6)
-        self.vbox.pack_start(hbox_temp, False, False, 6)
 
-        self.show_all()
+        self.dialog.show_all()
 
-        logging.debug("New LogNameDialog instance created!")
+        logging.debug("Log name dialog built.")
 
         return
 
-    def get_log_name(self):
+    @property
+    def name(self):
         """ Return the log name specified in the Gtk.Entry box by the user.
 
         :returns: The log's name.
         :rtype: str
         """
-
-        logging.debug("Retrieving the log name from the LogNameDialog...")
         return self.entry.get_text()
diff --git a/pyqso/logbook.py b/pyqso/logbook.py
index d3f22dd..5bc725c 100644
--- a/pyqso/logbook.py
+++ b/pyqso/logbook.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2012-2016 Christian T. Jacobs.
+#    Copyright (C) 2012-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,57 +17,59 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk, Pango, PangoCairo
+from gi.repository import Gtk
 import logging
 import sqlite3 as sqlite
-from os.path import basename, getmtime, expanduser
-from datetime import datetime, date
-import configparser
-
+from os.path import expanduser
 try:
-    from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
-    from matplotlib.figure import Figure
-    from matplotlib.dates import DateFormatter, MonthLocator
-    have_matplotlib = True
-except ImportError as e:
-    logging.warning(e)
-    logging.warning("Could not import matplotlib, so you will not be able to plot annual logbook statistics. Check that all the PyQSO dependencies are satisfied.")
-    have_matplotlib = False
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 
 from pyqso.adif import *
+from pyqso.cabrillo import *
 from pyqso.log import *
-from pyqso.log_name_dialog import *
 from pyqso.auxiliary_dialogs import *
+from pyqso.log_name_dialog import LogNameDialog
+from pyqso.record_dialog import RecordDialog
+from pyqso.cabrillo_export_dialog import CabrilloExportDialog
+from pyqso.summary import Summary
+from pyqso.blank import Blank
+from pyqso.printer import Printer
+from pyqso.compare import compare_date_and_time, compare_default
 
 
-class Logbook(Gtk.Notebook):
+class Logbook:
 
     """ A Logbook object can store multiple Log objects. """
 
-    def __init__(self, parent):
+    def __init__(self, application):
         """ Create a new Logbook object and initialise the list of Logs.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
 
-        Gtk.Notebook.__init__(self)
-
-        self.parent = parent
+        self.application = application
+        self.builder = self.application.builder
+        self.notebook = self.builder.get_object("logbook")
         self.connection = None
-        self.summary = {}
         self.logs = []
-        logging.debug("New Logbook instance created!")
+
         return
 
     def new(self, widget=None):
-        """ Create a new logbook, and open it. """
+        """ Create a new logbook, and open it.
+
+        :returns: True if the new logbook is successfully opened, and False otherwise.
+        :rtype: bool
+        """
 
         # Get the new file's path from a dialog.
         dialog = Gtk.FileChooserDialog("Create a New SQLite Database File",
-                                       self.parent,
+                                       self.application.window,
                                        Gtk.FileChooserAction.SAVE,
-                                      (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
-                                       Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
+                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
         dialog.set_do_overwrite_confirmation(True)
 
         response = dialog.run()
@@ -77,115 +79,119 @@ class Logbook(Gtk.Notebook):
             path = None
         dialog.destroy()
 
-        if(path is None):  # If the Cancel button has been clicked, path will still be None
+        if(path is None):  # If the Cancel button has been clicked, path will still be None.
             logging.debug("No file path specified.")
             return
         else:
             # Clear the contents of the file, in case the file exists already.
             open(path, 'w').close()
             # Open the new logbook, ready for use.
-            self.open(path=path)
-        return
+            opened = self.open(path=path)
+        return opened
 
     def open(self, widget=None, path=None):
         """ Open a logbook, and render all the logs within it.
 
         :arg str path: An optional argument containing the database file location, if already known. If this is None, a file selection dialog will appear.
+        :returns: True if the logbook is successfully opened, and False otherwise.
+        :rtype: bool
         """
 
         if(path is None):
             # If no path has been provided, get one from a "File Open" dialog.
             dialog = Gtk.FileChooserDialog("Open SQLite Database File",
-                                           self.parent,
+                                           self.application.window,
                                            Gtk.FileChooserAction.OPEN,
-                                          (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
-                                           Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
+                                           (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                                            Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
 
             response = dialog.run()
             if(response == Gtk.ResponseType.OK):
                 path = dialog.get_filename()
             dialog.destroy()
 
-            if(path is None):  # If the Cancel button has been clicked, path will still be None
+            if(path is None):  # If the Cancel button has been clicked, path will still be None.
                 logging.debug("No file path specified.")
-                return
+                return False
 
         connected = self.db_connect(path)
         if(connected):
-            # If the connection setup was successful, then open all the logs in the database
+            # If the connection setup was successful, then open all the logs in the database.
 
             self.path = path
 
-            logging.debug("Trying to retrieve all the logs in the logbook...")
-            self.logs = []  # A fresh stack of Log objects
+            logging.debug("Retrieving all the logs in the logbook...")
             try:
-                with self.connection:
-                    c = self.connection.cursor()
-                    c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name NOT GLOB 'sqlite_*'")
-                    for name in c:
-                        l = Log(self.connection, name[0])
-                        l.populate()
-                        self.logs.append(l)
+                self.logs = self.get_logs()
             except (sqlite.Error, IndexError) as e:
                 logging.exception(e)
-                error(parent=self.parent, message="Oops! Something went wrong when trying to retrieve the logs from the logbook. Perhaps the logbook file is encrypted, corrupted, or in the wrong format?")
-                return
+                error(parent=self.application.window, message="Could not open logbook. Something went wrong when trying to retrieve the logs. Perhaps the logbook file is encrypted, corrupted, or in the wrong format?")
+                return False
+
+            logging.debug("All logs retrieved successfully.")
 
-            logging.debug("All logs retrieved successfully. Now attempting to render them all in the Gtk.Notebook...")
+            logging.debug("Rendering logs...")
             # For rendering the logs. One treeview and one treeselection per Log.
             self.treeview = []
             self.treeselection = []
             self.sorter = []
             self.filter = []
-            self._create_summary_page()
-            self._create_dummy_page()
+            self.summary = Summary(self.application)
+            self.blank = Blank(self.application)
 
             # FIXME: This is an unfortunate work-around. If the area around the "+/New Log" button
             # is clicked, PyQSO will change to an empty page. This signal is used to stop this from happening.
-            self.connect("switch-page", self._on_switch_page)
+            self.notebook.connect("switch-page", self.on_switch_page)
 
             for i in range(len(self.logs)):
-                self._render_log(i)
+                self.render_log(i)
             logging.debug("All logs rendered successfully.")
 
-            self.update_summary()
-            self.parent.toolbox.awards.count()
+            self.summary.update()
+            self.application.toolbox.awards.count(self)
 
-            context_id = self.parent.statusbar.get_context_id("Status")
-            self.parent.statusbar.push(context_id, "Logbook: %s" % self.path)
-            self.parent.toolbar.set_logbook_button_sensitive(False)
-            self.parent.menu.set_logbook_item_sensitive(False)
-            self.parent.menu.set_log_items_sensitive(True)
-            self.parent.toolbar.filter_source.set_sensitive(True)
+            context_id = self.application.statusbar.get_context_id("Status")
+            self.application.statusbar.push(context_id, "Logbook: %s" % self.path)
+            self.application.toolbar.set_logbook_button_sensitive(False)
+            self.application.menu.set_logbook_item_sensitive(False)
+            self.application.menu.set_log_items_sensitive(True)
+            self.application.toolbar.filter_source.set_sensitive(True)
 
-            self.show_all()
+            self.notebook.show_all()
 
         else:
             logging.debug("Not connected to a logbook. No logs were opened.")
+            return False
 
-        return
+        return True
 
     def close(self, widget=None):
-        """ Close the logbook that is currently open. """
+        """ Close the logbook that is currently open.
+
+        :returns: True if the logbook is successfully closed, and False otherwise.
+        :rtype: bool
+        """
 
         disconnected = self.db_disconnect()
         if(disconnected):
             logging.debug("Closing all logs in the logbook...")
-            while(self.get_n_pages() > 0):
+            while(self.notebook.get_n_pages() > 0):
                 # Once a page is removed, the other pages get re-numbered,
                 # so a 'for' loop isn't the best option here.
-                self.remove_page(0)
+                self.notebook.remove_page(0)
             logging.debug("All logs now closed.")
 
-            context_id = self.parent.statusbar.get_context_id("Status")
-            self.parent.statusbar.push(context_id, "No logbook is currently open.")
-            self.parent.toolbar.set_logbook_button_sensitive(True)
-            self.parent.menu.set_logbook_item_sensitive(True)
-            self.parent.menu.set_log_items_sensitive(False)
-            self.parent.toolbar.filter_source.set_sensitive(False)
+            context_id = self.application.statusbar.get_context_id("Status")
+            self.application.statusbar.push(context_id, "No logbook is currently open.")
+            self.application.toolbar.set_logbook_button_sensitive(True)
+            self.application.menu.set_logbook_item_sensitive(True)
+            self.application.menu.set_log_items_sensitive(False)
+            self.application.toolbar.filter_source.set_sensitive(False)
         else:
             logging.debug("Unable to disconnect from the database. No logs were closed.")
-        return
+            return False
+
+        return True
 
     def db_connect(self, path):
         """ Create an SQL database connection to the Logbook's data source.
@@ -194,15 +200,15 @@ class Logbook(Gtk.Notebook):
         """
 
         logging.debug("Attempting to connect to the logbook database...")
-        # Try setting up the SQL database connection
+        # Try setting up the SQL database connection.
         try:
             self.db_disconnect()  # Destroy any existing connections first.
             self.connection = sqlite.connect(path)
             self.connection.row_factory = sqlite.Row
         except sqlite.Error as e:
-            # PyQSO can't connect to the database.
+            # Cannot connect to the database.
             logging.exception(e)
-            error(parent=self.parent, message="PyQSO cannot connect to the database. Check file permissions?")
+            error(parent=self.application.window, message="Cannot connect to the database. Check file permissions?")
             return False
 
         logging.debug("Database connection created successfully!")
@@ -226,246 +232,19 @@ class Logbook(Gtk.Notebook):
             logging.debug("Already disconnected. Nothing to do here.")
         return True
 
-    def _create_dummy_page(self):
-        """ Create a blank page in the Gtk.Notebook for the "+" (New Log) tab. """
-
-        blank_treeview = Gtk.TreeView()
-        # Allow the Log to be scrolled up/down
-        sw = Gtk.ScrolledWindow()
-        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
-        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
-        sw.add(blank_treeview)
-        vbox = Gtk.VBox()
-        vbox.pack_start(sw, True, True, 0)
-
-        # Add a "+" button to the tab
-        hbox = Gtk.HBox(False, 0)
-        icon = Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.MENU)
-        button = Gtk.Button()
-        button.set_relief(Gtk.ReliefStyle.NONE)
-        button.set_focus_on_click(False)
-        button.connect("clicked", self.new_log)
-        button.add(icon)
-        button.set_tooltip_text('New Log')
-        hbox.pack_start(button, False, False, 0)
-        hbox.show_all()
-        vbox.show_all()
-
-        self.insert_page(vbox, hbox, 1)
-        self.show_all()
-        self.set_current_page(0)
-        return
-
-    def _create_summary_page(self):
-        """ Create a summary page containing the number of logs in the logbook, and the logbook's modification date. """
-
-        vbox = Gtk.VBox()
-
-        # Database name in large font at the top of the summary page
-        hbox = Gtk.HBox()
-        label = Gtk.Label(halign=Gtk.Align.START)
-        label.set_markup("<span size=\"x-large\">%s</span>" % basename(self.path))
-        hbox.pack_start(label, False, False, 6)
-        vbox.pack_start(hbox, False, False, 4)
-
-        hbox = Gtk.HBox()
-        label = Gtk.Label("Number of logs: ", halign=Gtk.Align.START)
-        hbox.pack_start(label, False, False, 6)
-        self.summary["LOG_COUNT"] = Gtk.Label("0")
-        hbox.pack_start(self.summary["LOG_COUNT"], False, False, 4)
-        vbox.pack_start(hbox, False, False, 4)
-
-        hbox = Gtk.HBox()
-        label = Gtk.Label("Total number of QSOs: ", halign=Gtk.Align.START)
-        hbox.pack_start(label, False, False, 6)
-        self.summary["QSO_COUNT"] = Gtk.Label("0")
-        hbox.pack_start(self.summary["QSO_COUNT"], False, False, 4)
-        vbox.pack_start(hbox, False, False, 4)
-
-        hbox = Gtk.HBox()
-        label = Gtk.Label("Date modified: ", halign=Gtk.Align.START)
-        hbox.pack_start(label, False, False, 6)
-        self.summary["DATE_MODIFIED"] = Gtk.Label("0")
-        hbox.pack_start(self.summary["DATE_MODIFIED"], False, False, 4)
-        vbox.pack_start(hbox, False, False, 4)
-
-        hseparator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
-        vbox.pack_start(hseparator, False, False, 4)
-
-        # Yearly statistics
-        config = configparser.ConfigParser()
-        have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
-        (section, option) = ("general", "show_yearly_statistics")
-        if(have_config and config.has_option(section, option)):
-            if(config.get("general", "show_yearly_statistics") == "True" and have_matplotlib):
-                hbox = Gtk.HBox()
-                label = Gtk.Label("Display statistics for year: ", halign=Gtk.Align.START)
-                hbox.pack_start(label, False, False, 6)
-                self.summary["YEAR_SELECT"] = Gtk.ComboBoxText()
-                min_year, max_year = self._find_year_bounds()
-                if min_year and max_year:
-                    for year in range(max_year, min_year-1, -1):
-                        self.summary["YEAR_SELECT"].append_text(str(year))
-                self.summary["YEAR_SELECT"].append_text("")
-                self.summary["YEAR_SELECT"].connect("changed", self._on_year_changed)
-                hbox.pack_start(self.summary["YEAR_SELECT"], False, False, 6)
-                vbox.pack_start(hbox, False, False, 4)
-
-                self.summary["YEARLY_STATISTICS"] = Figure()
-                canvas = FigureCanvas(self.summary["YEARLY_STATISTICS"])
-                canvas.set_size_request(800, 250)
-                canvas.show()
-                vbox.pack_start(canvas, True, True, 4)
-
-        # Summary tab label and icon.
-        hbox = Gtk.HBox(False, 0)
-        label = Gtk.Label("Summary  ")
-        icon = Gtk.Image.new_from_stock(Gtk.STOCK_INDEX, Gtk.IconSize.MENU)
-        hbox.pack_start(label, False, False, 0)
-        hbox.pack_start(icon, False, False, 0)
-        hbox.show_all()
-
-        self.insert_page(vbox, hbox, 0)  # Append as a new tab
-        self.show_all()
-
-        return
-
-    def _on_year_changed(self, combo):
-        """ Re-plot the statistics for the year selected by the user. """
-
-        # Clear figure
-        self.summary["YEARLY_STATISTICS"].clf()
-        self.summary["YEARLY_STATISTICS"].canvas.draw()
-
-        # Get year to show statistics for.
-        year = combo.get_active_text()
-        try:
-            year = int(year)
-        except ValueError:
-            # Empty year string.
-            return
-
-        # Number of contacts made each month
-        contact_count_plot = self.summary["YEARLY_STATISTICS"].add_subplot(121)
-        contact_count = self._get_annual_contact_count(year)
-
-        # x-axis formatting based on the date
-        contact_count_plot.bar(list(contact_count.keys()), list(contact_count.values()), color="k", width=15, align="center")
-        formatter = DateFormatter("%b")
-        contact_count_plot.xaxis.set_major_formatter(formatter)
-        month_locator = MonthLocator()
-        contact_count_plot.xaxis.set_major_locator(month_locator)
-        contact_count_plot.set_ylabel("Number of QSOs")
-
-        # Set x-axis upper limit based on the current month.
-        contact_count_plot.xaxis_date()
-        contact_count_plot.set_xlim([date(year-1, 12, 16), date(year, 12, 15)])  # Make a bit of space either side of January and December of the selected year.
-
-        # Pie chart of all the modes used.
-        mode_count_plot = self.summary["YEARLY_STATISTICS"].add_subplot(122)
-        mode_count = self._get_annual_mode_count(year)
-        (patches, texts, autotexts) = mode_count_plot.pie(list(mode_count.values()), labels=mode_count.keys(), autopct='%1.1f%%', shadow=False)
-        for p in patches:
-            # Make the patches partially transparent.
-            p.set_alpha(0.75)
-        mode_count_plot.set_title("Modes used")
-
-        self.summary["YEARLY_STATISTICS"].canvas.draw()
-
-        return
-
-    def _find_year_bounds(self):
-        """ Find the years of the oldest and newest QSOs across all logs in the logbook. """
-
-        c = self.connection.cursor()
-        max_years = []
-        min_years = []
-        for log in self.logs:
-            query = "SELECT min(QSO_DATE), max(QSO_DATE) FROM %s" % (log.name)
-            c.execute(query)
-            years = c.fetchone()
-            if years[0] and years[1]:
-                min_years.append(int(years[0][:4]))
-                max_years.append(int(years[1][:4]))
-
-        if len(min_years) == 0 or max_years == 0:
-            return None, None
-        else:
-            # Return the min and max across all logs.
-            return min(min_years), max(max_years)
-
-    def _get_annual_contact_count(self, year):
-        """ Find the total number of contacts made in each month in the specified year. """
-
-        contact_count = {}
-        c = self.connection.cursor()
-
-        for log in self.logs:
-            query = "SELECT QSO_DATE, count(QSO_DATE) FROM %s WHERE QSO_DATE >= %d0101 AND QSO_DATE < %d0101 GROUP by QSO_DATE" % (log.name, year, year+1)
-            c.execute(query)
-            xy = c.fetchall()
-
-            for i in range(len(xy)):
-                date_str = xy[i][0]
-                y = int(date_str[0:4])
-                m = int(date_str[4:6])
-                date = datetime(y, m, 1)  # Collect all contacts together by month.
-                if date in contact_count.keys():
-                    contact_count[date] += xy[i][1]
-                else:
-                    contact_count[date] = xy[i][1]
-
-        return contact_count
-
-    def _get_annual_mode_count(self, year):
-        """ Find the total number of contacts made with each mode in a specified year. """
-
-        mode_count = {}
-
-        for log in self.logs:
-            query = "SELECT MODE, count(MODE) FROM %s WHERE QSO_DATE >= %d0101 AND QSO_DATE < %d0101 GROUP by MODE" % (log.name, year, year+1)
-            c = self.connection.cursor()
-            c.execute(query)
-            xy = c.fetchall()
-
-            for i in range(len(xy)):
-                mode = xy[i][0]
-                if mode == "":
-                    mode = "Unspecified"
-
-                # Add to running total
-                if mode in mode_count.keys():
-                    mode_count[mode] += xy[i][1]
-                else:
-                    mode_count[mode] = xy[i][1]
-
-        return mode_count
-
-    def update_summary(self):
-        """ Update the information presented on the summary page. """
-
-        self.summary["LOG_COUNT"].set_label(str(self.get_number_of_logs()))
-        self.summary["QSO_COUNT"].set_label(str(self.get_number_of_qsos()))
-        try:
-            t = datetime.fromtimestamp(getmtime(self.path)).strftime("%d %B %Y @ %H:%M")
-            self.summary["DATE_MODIFIED"].set_label(str(t))
-        except (IOError, OSError) as e:
-            logging.exception(e)
-        return
-
-    def _on_switch_page(self, widget, label, new_page):
+    def on_switch_page(self, widget, label, new_page):
         """ Handle a tab/page change, and enable/disable the relevant Record-related buttons. """
 
-        if(new_page == self.get_n_pages()-1):  # The last (right-most) tab is the "New Log" tab.
-            self.stop_emission("switch-page")
+        if(new_page == self.notebook.get_n_pages()-1):  # The last (right-most) tab is the "New Log" tab.
+            self.notebook.stop_emission("switch-page")
 
         # Disable the record buttons if a log page is not selected.
         if(new_page == 0):
-            self.parent.toolbar.set_record_buttons_sensitive(False)
-            self.parent.menu.set_record_items_sensitive(False)
+            self.application.toolbar.set_record_buttons_sensitive(False)
+            self.application.menu.set_record_items_sensitive(False)
         else:
-            self.parent.toolbar.set_record_buttons_sensitive(True)
-            self.parent.menu.set_record_items_sensitive(True)
+            self.application.toolbar.set_record_buttons_sensitive(True)
+            self.application.menu.set_record_items_sensitive(True)
         return
 
     def new_log(self, widget=None):
@@ -474,14 +253,15 @@ class Logbook(Gtk.Notebook):
         if(self.connection is None):
             return
         exists = True
-        dialog = LogNameDialog(self.parent)
+        ln = LogNameDialog(self.application)
         while(exists):
-            response = dialog.run()
+            response = ln.dialog.run()
             if(response == Gtk.ResponseType.OK):
-                log_name = dialog.get_log_name()
+                log_name = ln.name
                 try:
                     with self.connection:
                         c = self.connection.cursor()
+                        # NOTE: "id" is simply an alias for the "rowid" column here.
                         query = "CREATE TABLE %s (id INTEGER PRIMARY KEY AUTOINCREMENT" % log_name
                         for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
                             s = ", %s TEXT" % field_name.lower()
@@ -492,22 +272,23 @@ class Logbook(Gtk.Notebook):
                 except sqlite.Error as e:
                     logging.exception(e)
                     # Data is not valid - inform the user.
-                    error(parent=self.parent, message="Database error. Try another log name.")
+                    error(parent=ln.dialog, message="Database error. Try another log name.")
                     exists = True
             else:
-                dialog.destroy()
+                ln.dialog.destroy()
                 return
 
-        dialog.destroy()
+        ln.dialog.destroy()
 
-        l = Log(self.connection, log_name)  # Empty log
+        # Instantiate and populate a new Log object.
+        l = Log(self.connection, log_name)
         l.populate()
 
         self.logs.append(l)
-        self._render_log(self.get_number_of_logs()-1)
-        self.update_summary()
+        self.render_log(self.log_count-1)
+        self.summary.update()
 
-        self.set_current_page(self.get_number_of_logs())
+        self.notebook.set_current_page(self.log_count)
         return
 
     def delete_log(self, widget, page=None):
@@ -519,25 +300,25 @@ class Logbook(Gtk.Notebook):
             return
 
         if(page is None):
-            page_index = self.get_current_page()  # Gets the index of the selected tab in the logbook
+            page_index = self.notebook.get_current_page()  # Get the index of the selected tab in the logbook.
             if(page_index == 0):  # If we are on the Summary page...
                 logging.debug("No log currently selected!")
                 return
             else:
-                page = self.get_nth_page(page_index)  # Gets the Gtk.VBox of the selected tab in the logbook
+                page = self.notebook.get_nth_page(page_index)  # Get the Gtk.VBox of the selected tab in the logbook.
 
-        log_index = self._get_log_index(name=page.get_name())
+        log_index = self.get_log_index(name=page.get_name())
         log = self.logs[log_index]
 
         # We also need the page's index in order to remove it using remove_page below.
-        # This may not be the same as what self.get_current_page() returns.
-        page_index = self.page_num(page)
+        # This may not be the same as what get_current_page() returns.
+        page_index = self.notebook.page_num(page)
 
-        if(page_index == 0 or page_index == self.get_n_pages()-1):  # Only the "New Log" tab is present (i.e. no actual logs in the logbook)
+        if(page_index == 0 or page_index == self.notebook.get_n_pages()-1):  # Only the "New Log" tab is present (i.e. no actual logs in the logbook).
             logging.debug("No logs to delete!")
             return
 
-        response = question(parent=self.parent, message="Are you sure you want to delete log %s?" % log.name)
+        response = question(parent=self.application.window, message="Are you sure you want to delete log %s?" % log.name)
         if(response == Gtk.ResponseType.YES):
             try:
                 with self.connection:
@@ -545,20 +326,20 @@ class Logbook(Gtk.Notebook):
                     c.execute("DROP TABLE %s" % log.name)
             except sqlite.Error as e:
                 logging.exception(e)
-                error(parent=self.parent, message="Database error. Could not delete the log.")
+                error(parent=self.application.window, message="Database error. Could not delete the log.")
                 return
 
             self.logs.pop(log_index)
-            # Remove the log from the renderers too
+            # Remove the log from the renderers too.
             self.treeview.pop(log_index)
             self.treeselection.pop(log_index)
             self.sorter.pop(log_index)
             self.filter.pop(log_index)
-            # And finally remove the tab in the Logbook
-            self.remove_page(page_index)
+            # And finally remove the tab in the Logbook.
+            self.notebook.remove_page(page_index)
 
-        self.update_summary()
-        self.parent.toolbox.awards.count()
+        self.summary.update()
+        self.application.toolbox.awards.count(self)
         return
 
     def filter_logs(self, widget=None):
@@ -567,7 +348,7 @@ class Logbook(Gtk.Notebook):
             self.filter[i].refilter()
         return
 
-    def _filter_by_callsign(self, model, iter, data):
+    def filter_by_callsign(self, model, iter, data):
         """ Filter all the logs in the logbook by the callsign field, based on a user-defined expression.
 
         :arg Gtk.TreeModel model: The model used to filter the log data.
@@ -577,7 +358,7 @@ class Logbook(Gtk.Notebook):
         :rtype: bool
         """
         value = model.get_value(iter, 1)
-        callsign = self.parent.toolbar.filter_source.get_text()
+        callsign = self.application.toolbar.filter_source.get_text()
 
         if(callsign is None or callsign == ""):
             # If there is nothing to filter with, then show all the records!
@@ -587,23 +368,23 @@ class Logbook(Gtk.Notebook):
             # Also, we could use value[:][0:len(callsign))] if we wanted to match from the very start of each callsign.
             return callsign.upper() in value or callsign.lower() in value
 
-    def _render_log(self, index):
+    def render_log(self, index):
         """ Render a Log in the Gtk.Notebook.
 
         :arg int index: The index of the Log (in the list of Logs) to render.
         """
         self.filter.append(self.logs[index].filter_new(root=None))
-        # Set the callsign column as the column we want to filter by
-        self.filter[index].set_visible_func(self._filter_by_callsign, data=None)
+        # Set the callsign column as the column we want to filter by.
+        self.filter[index].set_visible_func(self.filter_by_callsign, data=None)
         self.sorter.append(Gtk.TreeModelSort(model=self.filter[index]))
         self.sorter[index].set_sort_column_id(0, Gtk.SortType.ASCENDING)
 
-        self.treeview.append(Gtk.TreeView(self.sorter[index]))
+        self.treeview.append(Gtk.TreeView(model=self.sorter[index]))
         self.treeview[index].set_grid_lines(Gtk.TreeViewGridLines.BOTH)
         self.treeview[index].connect("row-activated", self.edit_record_callback)
         self.treeselection.append(self.treeview[index].get_selection())
         self.treeselection[index].set_mode(Gtk.SelectionMode.SINGLE)
-        # Allow the Log to be scrolled up/down
+        # Allow the Log to be scrolled up/down.
         sw = Gtk.ScrolledWindow()
         sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
         sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
@@ -613,12 +394,12 @@ class Logbook(Gtk.Notebook):
         vbox.pack_start(sw, True, True, 0)
 
         # Add a close button to the tab
-        hbox = Gtk.HBox(False, 0)
-        label = Gtk.Label(self.logs[index].name)
+        hbox = Gtk.HBox(homogeneous=False, spacing=0)
+        label = Gtk.Label(label=self.logs[index].name)
         hbox.pack_start(label, False, False, 0)
         hbox.show_all()
 
-        self.insert_page(vbox, hbox, index+1)  # Append the new log as a new tab
+        self.notebook.insert_page(vbox, hbox, index+1)  # Append the new log as a new tab.
 
         # The first column of the logbook will always be the unique record index.
         # Let's append this separately to the field names.
@@ -636,6 +417,10 @@ class Logbook(Gtk.Notebook):
         field_names = AVAILABLE_FIELD_NAMES_ORDERED
         for i in range(0, len(field_names)):
             renderer = Gtk.CellRendererText()
+
+            # Keep each row to a single line.
+            renderer.set_property("single-paragraph-mode", True)
+
             column = Gtk.TreeViewColumn(AVAILABLE_FIELD_NAMES_FRIENDLY[field_names[i]], renderer, text=i+1)
             column.set_resizable(True)
             column.set_min_width(50)
@@ -643,9 +428,11 @@ class Logbook(Gtk.Notebook):
 
             # Special cases
             if(field_names[i] == "NOTES"):
-                # Give the 'Notes' column some extra space, since this is likely to contain some long sentences...
+                # Give the 'Notes' column some extra space, since this is likely to contain some long sentences ...
                 column.set_min_width(300)
-                # ... but don't let it automatically re-size itself.
+                # ... but not too much extra space ...
+                column.set_max_width(600)
+                # ... and don't let the column automatically re-size itself.
                 column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
 
             column.connect("clicked", self.sort_log, i+1)
@@ -654,74 +441,28 @@ class Logbook(Gtk.Notebook):
             have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
             (section, option) = ("view", AVAILABLE_FIELD_NAMES_ORDERED[i].lower())
             if(have_config and config.has_option(section, option)):
-                column.set_visible(config.get(section, option) == "True")
+                column.set_visible(config.getboolean(section, option))
             self.treeview[index].append_column(column)
 
-        self.show_all()
+        self.notebook.show_all()
         return
 
-    def _compare_date_and_time(self, model, row1, row2, user_data):
-        """ Compare two rows (let's call them A and B) in a Gtk.ListStore, and sort by both date and time.
-
-        :arg Gtk.TreeModel model: The model used to sort the log data.
-        :arg Gtk.TreeIter row1: The pointer to row A.
-        :arg Gtk.TreeIter row2: The pointer to row B.
-        :arg user_data: The specific column from which to retrieve data for rows A and B.
-        :returns: 1 if Row B's date/time is more recent than Row A's; 0 if both dates and times are the same; -1 if Row A's date/time is more recent than Row B's.
-        :rtype: int
-        """
-        date1 = model.get_value(row1, user_data[0])
-        date2 = model.get_value(row2, user_data[0])
-        time1 = model.get_value(row1, user_data[1])
-        time2 = model.get_value(row2, user_data[1])
-        if(date1 < date2):
-            return 1
-        elif(date1 == date2):
-            # If the dates are the same, then let's also sort by time.
-            if(time1 > time2):
-                return -1
-            elif(time1 == time2):
-                return 0
-            else:
-                return 1
-        else:
-            return -1
-
-    def _compare_default(self, model, row1, row2, user_data):
-        """ The default sorting function for all Gtk.ListStore objects.
-
-        :arg Gtk.TreeModel model: The model used to sort the log data.
-        :arg Gtk.TreeIter row1: The pointer to row A.
-        :arg Gtk.TreeIter row2: The pointer to row B.
-        :arg user_data: The specific column from which to retrieve data for rows A and B.
-        :returns: 1 if the value of Row A's column value is less than Row B's column value; 0 if both values are the same; -1 if Row A's column value is greater than Row B's column value.
-        :rtype: int
-        """
-        value1 = model.get_value(row1, user_data)
-        value2 = model.get_value(row2, user_data)
-        if(value1 < value2):
-            return 1
-        elif(value1 == value2):
-            return 0
-        else:
-            return -1
-
     def sort_log(self, widget, column_index):
         """ Sort the log (that is currently selected) with respect to a given field.
 
         :arg int column_index: The index of the column to sort by.
         """
 
-        log_index = self._get_log_index()
+        log_index = self.get_log_index()
         column = self.treeview[log_index].get_column(column_index)
 
         if(AVAILABLE_FIELD_NAMES_ORDERED[column_index-1] == "QSO_DATE"):
             # If the field being sorted is the QSO_DATE, then also sort by the TIME_ON field so we get the
             # correct chronological order.
             # Note: This assumes that the TIME_ON field is always immediately to the right of the QSO_DATE field.
-            self.sorter[log_index].set_sort_func(column_index, self._compare_date_and_time, user_data=[column_index, column_index+1])
+            self.sorter[log_index].set_sort_func(column_index, compare_date_and_time, user_data=[column_index, column_index+1])
         else:
-            self.sorter[log_index].set_sort_func(column_index, self._compare_default, user_data=column_index)
+            self.sorter[log_index].set_sort_func(column_index, compare_default, user_data=column_index)
 
         # If we are operating on the currently-sorted column...
         if(self.sorter[log_index].get_sort_column_id()[0] == column_index):
@@ -754,61 +495,53 @@ class Logbook(Gtk.Notebook):
         """ Rename the log that is currently selected. """
         if(self.connection is None):
             return
-        page_index = self.get_current_page()
+        page_index = self.notebook.get_current_page()
         if(page_index == 0):  # If we are on the Summary page...
             logging.debug("No log currently selected!")
             return
-        page = self.get_nth_page(page_index)  # Gets the Gtk.VBox of the selected tab in the logbook
+        page = self.notebook.get_nth_page(page_index)  # Get the Gtk.VBox of the selected tab in the logbook.
         old_log_name = page.get_name()
 
-        log_index = self._get_log_index(name=old_log_name)
+        log_index = self.get_log_index(name=old_log_name)
 
-        exists = True
-        dialog = LogNameDialog(self.parent, title="Rename Log", name=old_log_name)
-        while(exists):
-            response = dialog.run()
+        success = False
+        ln = LogNameDialog(self.application, title="Rename Log", name=old_log_name)
+        while(not success):
+            response = ln.dialog.run()
             if(response == Gtk.ResponseType.OK):
-                new_log_name = dialog.get_log_name()
-                try:
-                    with self.connection:
-                        c = self.connection.cursor()
-                        query = "ALTER TABLE %s RENAME TO %s" % (old_log_name, new_log_name)
-                        c.execute(query)
-                        exists = False
-                except sqlite.Error as e:
-                    logging.exception(e)
-                    # Data is not valid - inform the user.
-                    error(parent=self.parent, message="Database error. Try another log name.")
-                    exists = True
+                new_log_name = ln.name
+                success = self.logs[log_index].rename(new_log_name)
+                if(success):
+                    ln.dialog.destroy()
+                else:
+                    # Unsuccessful rename attempt. Inform the user.
+                    error(parent=ln.dialog, message="Database error. Try another log name.")
             else:
-                dialog.destroy()
+                ln.dialog.destroy()
                 return
 
-        dialog.destroy()
-
-        # Remember to change the Log object's name...
-        self.logs[log_index].name = new_log_name
+        # Remember to change the page's name ...
+        page.set_name(new_log_name)
 
-        # ...and the page's name
-        page.set_name(self.logs[log_index].name)
-
-        # ...and update the tab's label
-        hbox = Gtk.HBox(False, 0)
-        label = Gtk.Label(new_log_name)
+        # ... and update the tab's label.
+        hbox = Gtk.HBox(homogeneous=False, spacing=0)
+        label = Gtk.Label(label=new_log_name)
         hbox.pack_start(label, False, False, 0)
         hbox.show_all()
-        self.set_tab_label(page, hbox)
+        self.notebook.set_tab_label(page, hbox)
 
         # The number of logs will obviously stay the same, but
         # we want to update the logbook's modification date.
-        self.update_summary()
+        self.summary.update()
 
         return
 
     def import_log(self, widget=None):
         """ Import a log from an ADIF file. """
+
+        # Get the path to the ADIF file.
         dialog = Gtk.FileChooserDialog("Import ADIF Log File",
-                                       self.parent,
+                                       self.application.window,
                                        Gtk.FileChooserAction.OPEN,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
@@ -834,26 +567,43 @@ class Logbook(Gtk.Notebook):
             logging.debug("No file path specified.")
             return
 
-        dialog = LogNameDialog(self.parent, title="Import Log")
+        # Read the records.
+        adif = ADIF()
+        try:
+            records = adif.read(path)
+        except IOError as e:
+            error(parent=self.application.window, message="Could not import the log. I/O error %d: %s" % (e.errno, e.strerror))
+            return
+        except Exception as e:
+            error(parent=self.application.window, message="Could not import the log.")
+            logging.exception(e)
+            return
+
+        # Get the new log's name (or the name of the existing log the user wants to import into).
+        ln = LogNameDialog(self.application, title="Import Log")
         while(True):
-            response = dialog.run()
+            response = ln.dialog.run()
             if(response == Gtk.ResponseType.OK):
-                log_name = dialog.get_log_name()
-                if(self.log_name_exists(log_name)):
-                    # Import into existing log
-                    exists = True
-                    l = self.logs[self._get_log_index(name=log_name)]
-                    response = question(parent=self.parent, message="Are you sure you want to import into an existing log?")
-                    if(response == Gtk.ResponseType.YES):
-                        break
-                elif(self.log_name_exists(log_name) is None):
+                log_name = ln.name
+
+                # Check if the log name exists.
+                try:
+                    exists = self.log_name_exists(log_name)
+                except (sqlite.Error, IndexError) as e:
                     # Could not determine if the log name exists. It's safer to stop here than to try to add a new log.
-                    error(parent=self.parent, message="Database error. Could not check if the log name exists.")
-                    dialog.destroy()
+                    logging.exception(e)
+                    error(parent=ln.dialog, message="Database error. Could not check if the log name exists.")
+                    ln.dialog.destroy()
                     return
+
+                if(exists):
+                    # Import into existing log.
+                    l = self.logs[self.get_log_index(name=log_name)]
+                    response = question(parent=ln.dialog, message="Are you sure you want to import into an existing log?")
+                    if(response == Gtk.ResponseType.YES):
+                        break
                 else:
-                    # Create a new log with the name the user supplies
-                    exists = False
+                    # Create a new log with the name the user supplies.
                     try:
                         with self.connection:
                             c = self.connection.cursor()
@@ -868,39 +618,41 @@ class Logbook(Gtk.Notebook):
                     except sqlite.Error as e:
                         logging.exception(e)
                         # Data is not valid - inform the user.
-                        error(parent=self.parent, message="Database error. Try another log name.")
+                        error(parent=ln.dialog, message="Database error. Try another log name.")
             else:
-                dialog.destroy()
+                ln.dialog.destroy()
                 return
 
-        dialog.destroy()
+        ln.dialog.destroy()
 
-        adif = ADIF()
-        logging.debug("Importing records from the ADIF file with path: %s" % path)
-        records = adif.read(path)
+        # Update new or existing Log object.
         l.add_record(records)
         l.populate()
 
         if(not exists):
             self.logs.append(l)
-            self._render_log(self.get_number_of_logs()-1)
-        self.update_summary()
-        self.parent.toolbox.awards.count()
+            self.render_log(self.log_count-1)
+
+        # Update statistics, etc.
+        self.summary.update()
+        self.application.toolbox.awards.count(self)
+
+        info(parent=self.application.window, message="Imported %d QSOs into log '%s'." % (len(records), l.name))
 
         return
 
-    def export_log(self, widget=None):
+    def export_log_adif(self, widget=None):
         """ Export the log (that is currently selected) to an ADIF file. """
-        page_index = self.get_current_page()  # Gets the index of the selected tab in the logbook
+        page_index = self.notebook.get_current_page()  # Get the index of the selected tab in the logbook.
         if(page_index == 0):  # If we are on the Summary page...
             logging.debug("No log currently selected!")
             return
 
-        log_index = self._get_log_index()
+        log_index = self.get_log_index()
         log = self.logs[log_index]
 
-        dialog = Gtk.FileChooserDialog("Export Log to File",
-                                       self.parent,
+        dialog = Gtk.FileChooserDialog("Export Log as ADIF",
+                                       self.application.window,
                                        Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
@@ -927,102 +679,132 @@ class Logbook(Gtk.Notebook):
         if(path is None):
             logging.debug("No file path specified.")
         else:
+
+            # Retrieve the log's records from the database.
+            try:
+                records = log.records
+            except sqlite.Error as e:
+                logging.exception(e)
+                error(parent=self.application.window, message="Could not retrieve the records from the SQL database. No records have been exported.")
+                return
+
+            # Write the records.
             adif = ADIF()
-            records = log.get_all_records()
-            if(records is not None):
+            try:
                 adif.write(records, path)
-            else:
-                error(self.parent, "Could not retrieve the records from the SQL database. No records have been exported.")
+                info(parent=self.application.window, message="Exported %d QSOs to %s in ADIF format." % (len(records), path))
+            except IOError as e:
+                error(parent=self.application.window, message="Could not export the records. I/O error %d: %s" % (e.errno, e.strerror))
+            except Exception as e:  # All other exceptions.
+                logging.exception(e)
+                error(parent=self.application.window, message="Could not export the records.")
+
         return
 
-    def print_log(self, widget=None):
-        """ Print all the records in the log (that is currently selected).
-        Note that only a few important fields are printed because of the restricted width of the page. """
-        page_index = self.get_current_page()  # Gets the index of the selected tab in the logbook
+    def export_log_cabrillo(self, widget=None):
+        """ Export the log (that is currently selected) to a Cabrillo file. """
+        page_index = self.notebook.get_current_page()  # Get the index of the selected tab in the logbook.
         if(page_index == 0):  # If we are on the Summary page...
             logging.debug("No log currently selected!")
             return
-        log_index = self._get_log_index()
+
+        log_index = self.get_log_index()
         log = self.logs[log_index]
 
-        self.text_to_print = "Callsign\t---\tDate\t---\tTime\t---\tFrequency\t---\tMode\n"
-        records = log.get_all_records()
-        if(records is not None):
-            for r in records:
-                self.text_to_print += str(r["CALL"]) + "\t---\t" + str(r["QSO_DATE"]) + "\t---\t" + str(r["TIME_ON"]) + "\t---\t" + str(r["FREQ"]) + "\t---\t" + str(r["MODE"]) + "\n"
+        dialog = Gtk.FileChooserDialog("Export Log as Cabrillo",
+                                       self.application.window,
+                                       Gtk.FileChooserAction.SAVE,
+                                      (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                                       Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
+        dialog.set_do_overwrite_confirmation(True)
+
+        filter = Gtk.FileFilter()
+        filter.set_name("All Cabrillo files (*.log, *.LOG)")
+        filter.add_pattern("*.log")
+        filter.add_pattern("*.LOG")
+        dialog.add_filter(filter)
+
+        filter = Gtk.FileFilter()
+        filter.set_name("All files")
+        filter.add_pattern("*")
+        dialog.add_filter(filter)
 
-            action = Gtk.PrintOperationAction.PRINT_DIALOG
-            operation = Gtk.PrintOperation()
-            operation.set_default_page_setup(Gtk.PageSetup())
-            operation.set_unit(Gtk.Unit.MM)
+        response = dialog.run()
+        if(response == Gtk.ResponseType.OK):
+            path = dialog.get_filename()
+        else:
+            path = None
+        dialog.destroy()
 
-            operation.connect("begin_print", self._begin_print)
-            operation.connect("draw_page", self._draw_page)
-            operation.run(action, parent=self.parent)
+        if(path is None):
+            logging.debug("No file path specified.")
         else:
-            error(self.parent, "Could not retrieve the records from the SQL database. No records have been printed.")
-        return
+            # Get Cabrillo-specific fields, such as the callsign used during a contest and the contest's name.
+            ced = CabrilloExportDialog(self.application)
+            response = ced.dialog.run()
+            if(response == Gtk.ResponseType.OK):
+                contest = ced.contest
+                mycall = ced.mycall
+            else:
+                ced.dialog.destroy()
+                return
+            ced.dialog.destroy()
 
-    def _begin_print(self, operation, context):
-        """ Specify the layout/position/font of the text on the pages to be printed.
+            # Retrieve the log's records from the database.
+            try:
+                records = log.records
+            except sqlite.Error as e:
+                logging.exception(e)
+                error(parent=self.application.window, message="Could not retrieve the records from the SQL database. No records have been exported.")
+                return
+
+            # Write the records.
+            cabrillo = Cabrillo()
+            try:
+                cabrillo.write(records, path, contest=contest, mycall=mycall)
+                info(parent=self.application.window, message="Exported %d QSOs to %s in Cabrillo format." % (len(records), path))
+            except IOError as e:
+                error(parent=self.application.window, message="Could not export the records. I/O error %d: %s" % (e.errno, e.strerror))
+            except Exception as e:  # All other exceptions.
+                logging.exception(e)
+                error(parent=self.application.window, message="Could not export the records.")
 
-        :arg Gtk.PrintOperation operation: The printing API.
-        :arg Gtk.PrintContext context: Used to draw/render the pages to print.
-        """
-        width = context.get_width()
-        height = context.get_height()
-        layout = context.create_pango_layout()
-        layout.set_font_description(Pango.FontDescription("normal 10"))
-        layout.set_width(int(width*Pango.SCALE))
-        layout.set_text(self.text_to_print, -1)
-
-        number_of_pages = 0
-        page_height = 0
-        for line in range(0, layout.get_line_count()):
-            layout_line = layout.get_line(line)
-            ink_rectangle, logical_rectangle = layout_line.get_extents()
-            self.line_height = logical_rectangle.height/1024.0 + 3
-            page_height += self.line_height
-            if(page_height + self.line_height > height):
-                number_of_pages += 1
-                page_height = self.line_height
-        operation.set_n_pages(number_of_pages + 1)
-        self.text_to_print = self.text_to_print.split("\n")
         return
 
-    def _draw_page(self, operation, context, page_number):
-        """ Render the QSO details on the page.
+    def print_log(self, widget=None):
+        """ Print all the records in the log (that is currently selected).
+        Note that only a few important fields are printed because of the restricted width of the page. """
+
+        page_index = self.notebook.get_current_page()  # Get the index of the selected tab in the logbook.
+        if(page_index == 0):  # If we are on the Summary page...
+            logging.debug("No log currently selected!")
+            return
+        log_index = self.get_log_index()
+        log = self.logs[log_index]
+
+        # Retrieve the records.
+        try:
+            records = log.records
+        except sqlite.Error as e:
+            logging.exception(e)
+            error(parent=self.application.window, message="Could not retrieve the records from the SQL database. No records have been printed.")
+            return
+
+        # Print the records.
+        printer = Printer(self.application)
+        printer.print_records(records, title="Log: %s" % log.name)
 
-        :arg Gtk.PrintOperation operation: The printing API.
-        :arg Gtk.PrintContext context: Used to draw/render the pages to print.
-        :arg int page_number: The current page number.
-        """
-        cr = context.get_cairo_context()
-        cr.set_source_rgb(0, 0, 0)
-        layout = context.create_pango_layout()
-
-        current_line_number = 0
-        for line in self.text_to_print:
-            layout.set_text(line, -1)
-            cr.move_to(5, current_line_number*self.line_height)
-            PangoCairo.update_layout(cr, layout)
-            PangoCairo.show_layout(cr, layout)
-            current_line_number += 1
-            if(current_line_number*self.line_height > context.get_height()):
-                for j in range(0, current_line_number):
-                    self.text_to_print.pop(0)  # Remove what has been printed already before draw_page is called again
-                break
         return
 
     def add_record_callback(self, widget):
         """ A callback function used to add a particular record/QSO. """
-        # Get the log index
+        # Get the log index.
         try:
-            log_index = self._get_log_index()
+            log_index = self.get_log_index()
             if(log_index is None):
-                raise ValueError("The log index could not be determined. Perhaps you tried adding a record when the Summary page was selected?")
+                raise ValueError("The log index could not be determined. Perhaps the Summary page is selected?")
         except ValueError as e:
-            error(self.parent, e)
+            error(parent=self.application.window, message=e)
             return
         log = self.logs[log_index]
 
@@ -1031,14 +813,15 @@ class Logbook(Gtk.Notebook):
         have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
         (section, option) = ("general", "keep_open")
         if(have_config and config.has_option(section, option)):
-            keep_open = config.get("general", "keep_open") == "True"
+            keep_open = config.getboolean("general", "keep_open")
         else:
             keep_open = False
+
         adif = ADIF()
 
         exit = False
         while not exit:
-            dialog = RecordDialog(parent=self.parent, log=log, index=None)
+            rd = RecordDialog(application=self.application, log=log, index=None)
 
             all_valid = False  # Are all the field entries valid?
 
@@ -1053,44 +836,55 @@ class Logbook(Gtk.Notebook):
                 # The add/edit record window will stay open until the user gives valid data,
                 # or until the Cancel button is clicked.
                 all_valid = True
-                response = dialog.run()
+                response = rd.dialog.run()
                 if(response == Gtk.ResponseType.OK):
                     fields_and_data = {}
                     field_names = AVAILABLE_FIELD_NAMES_ORDERED
                     for i in range(0, len(field_names)):
                         # Validate user input.
-                        fields_and_data[field_names[i]] = dialog.get_data(field_names[i])
+                        fields_and_data[field_names[i]] = rd.get_data(field_names[i])
                         if(not(adif.is_valid(field_names[i], fields_and_data[field_names[i]], AVAILABLE_FIELD_NAMES_TYPES[field_names[i]]))):
                             # Data is not valid - inform the user.
-                            error(parent=self.parent, message="The data in field \"%s\" is not valid!" % field_names[i])
+                            error(parent=rd.dialog, message="The data in field \"%s\" is not valid!" % field_names[i])
                             all_valid = False
                             break  # Don't check the other data until the user has fixed the current one.
 
                     if(all_valid):
                         # All data has been validated, so we can go ahead and add the new record.
-                        log.add_record(fields_and_data)
-                        self.update_summary()
-                        self.parent.toolbox.awards.count()
-                        # Select the new Record's row in the treeview.
-                        number_of_records = log.get_number_of_records()
-                        if(number_of_records is not None):
-                            self.treeselection[log_index].select_path(number_of_records)
+                        try:
+                            log.add_record(fields_and_data)
+                        except (sqlite.Error, IndexError) as e:
+                            logging.exception(e)
+                            error(parent=self.application.window, message="Could not add the record to the log.")
+
+                        # Scroll to the new record's row in the treeview (but don't select it).
+                        try:
+                            record_count = log.record_count
+                            treepath = Gtk.TreePath(record_count-1)
+                            self.treeview[log_index].scroll_to_cell(treepath)
+                        except (sqlite.Error, IndexError) as e:
+                            logging.exception(e)
+
+                        # Update summary, etc.
+                        self.summary.update()
+                        self.application.toolbox.awards.count(self)
+
                 else:
                     exit = True
                     break
-            dialog.destroy()
+            rd.dialog.destroy()
         return
 
     def delete_record_callback(self, widget):
         """ A callback function used to delete a particular record/QSO. """
 
-        # Get the log index
+        # Get the log index.
         try:
-            log_index = self._get_log_index()
+            log_index = self.get_log_index()
             if(log_index is None):
-                raise ValueError("The log index could not be determined. Perhaps you tried deleting a record when the Summary page was selected?")
+                raise ValueError("The log index could not be determined. Perhaps the Summary page is selected?")
         except ValueError as e:
-            error(self.parent, e)
+            error(parent=self.application.window, message=e)
             return
         log = self.logs[log_index]
 
@@ -1105,32 +899,39 @@ class Logbook(Gtk.Notebook):
             logging.debug("Trying to delete a record, but there are no records in the log!")
             return
 
-        response = question(parent=self.parent, message="Are you sure you want to delete record %d?" % row_index)
+        response = question(parent=self.application.window, message="Are you sure you want to delete record %d?" % row_index)
         if(response == Gtk.ResponseType.YES):
             # Deletes the record with index 'row_index' from the Records list.
             # 'iter' is needed to remove the record from the ListStore itself.
-            log.delete_record(row_index, iter=child_iter)
-            self.update_summary()
-            self.parent.toolbox.awards.count()
+            try:
+                log.delete_record(row_index, iter=child_iter)
+            except (sqlite.Error, IndexError) as e:
+                logging.exception(e)
+                error(parent=self.application.window, message="Could not delete the record from the log.")
+
+            # Update summary, etc.
+            self.summary.update()
+            self.application.toolbox.awards.count(self)
+
         return
 
-    def edit_record_callback(self, widget, path, view_column):
+    def edit_record_callback(self, widget, path=None, view_column=None):
         """ A callback function used to edit a particular record/QSO.
         Note that the widget, path and view_column arguments are not used,
-        but need to be passed in since they associated with the row-activated signal
+        but need to be passed in since they are associated with the row-activated signal
         which is generated when the user double-clicks on a record. """
 
-        # Get the log index
+        # Get the log index.
         try:
-            log_index = self._get_log_index()
+            log_index = self.get_log_index()
             if(log_index is None):
-                raise ValueError("The log index could not be determined. Perhaps you tried editing a record when the Summary page was selected?")
+                raise ValueError("The log index could not be determined. Perhaps the Summary page is selected?")
         except ValueError as e:
-            error(self.parent, e)
+            error(parent=self.application.window, message=e)
             return
         log = self.logs[log_index]
 
-        (sort_model, path) = self.treeselection[log_index].get_selected_rows()  # Get the selected row in the log
+        (sort_model, path) = self.treeselection[log_index].get_selected_rows()  # Get the selected row in the log.
         try:
             sort_iter = sort_model.get_iter(path[0])
             filter_iter = self.sorter[log_index].convert_iter_to_child_iter(sort_iter)
@@ -1141,7 +942,7 @@ class Logbook(Gtk.Notebook):
             logging.debug("Could not find the selected row's index!")
             return
 
-        dialog = RecordDialog(parent=self.parent, log=self.logs[log_index], index=row_index)
+        rd = RecordDialog(application=self.application, log=self.logs[log_index], index=row_index)
         all_valid = False  # Are all the field entries valid?
 
         adif = ADIF()
@@ -1150,52 +951,91 @@ class Logbook(Gtk.Notebook):
             # The add/edit record window will stay open until the user gives valid data,
             # or until the Cancel button is clicked.
             all_valid = True
-            response = dialog.run()
+            response = rd.dialog.run()
             if(response == Gtk.ResponseType.OK):
                 fields_and_data = {}
                 field_names = AVAILABLE_FIELD_NAMES_ORDERED
                 for i in range(0, len(field_names)):
                     # Validate user input.
-                    fields_and_data[field_names[i]] = dialog.get_data(field_names[i])
+                    fields_and_data[field_names[i]] = rd.get_data(field_names[i])
                     if(not(adif.is_valid(field_names[i], fields_and_data[field_names[i]], AVAILABLE_FIELD_NAMES_TYPES[field_names[i]]))):
                         # Data is not valid - inform the user.
-                        error(parent=self.parent, message="The data in field \"%s\" is not valid!" % field_names[i])
+                        error(parent=rd.dialog, message="The data in field \"%s\" is not valid!" % field_names[i])
                         all_valid = False
                         break  # Don't check the other fields until the user has fixed the current field's data.
 
                 if(all_valid):
-                    # All data has been validated, so we can go ahead and update the record.
-                    record = log.get_record_by_index(row_index)
-                    if(record is None):
-                        message = "Could not retrieve record with row_index %d from the SQL database. The record has not been edited." % row_index
-                        logging.error(message)
-                        error(parent=self.parent, message=message)
-                    else:
+                    try:
+                        # Get the record in its current state from the database.
+                        record = log.get_record_by_index(row_index)
+                        # Iterate over all fields and check whether the data has actually changed. Database updates can be expensive.
                         for i in range(0, len(field_names)):
-                            # Check whether the data has actually changed. Database updates can be expensive.
                             if(record[field_names[i].lower()] != fields_and_data[field_names[i]]):
                                 # Update the record in the database and then in the ListStore.
                                 # We add 1 onto the column_index here because we don't want to consider the index column.
                                 log.edit_record(row_index, field_names[i], fields_and_data[field_names[i]], iter=child_iter, column_index=i+1)
-                        self.update_summary()
-                        self.parent.toolbox.awards.count()
+                    except(sqlite.Error, IndexError) as e:
+                        logging.exception(e)
+                        error(parent=rd.dialog, message="Could not edit record %d." % row_index)
 
-        dialog.destroy()
+                    # Update summary, etc.
+                    self.summary.update()
+                    self.application.toolbox.awards.count(self)
+
+        rd.dialog.destroy()
         return
 
     def remove_duplicates_callback(self, widget=None):
-        """ Remove duplicate records in a log.
-        Detecting duplicate records is done based on the CALL, QSO_DATE, TIME_ON, FREQ, and MODE fields. """
+        """ A callback function used to remove duplicate records in a log.
+        Detecting duplicate records is done based on the CALL, QSO_DATE, and TIME_ON fields. """
         logging.debug("Removing duplicate records...")
 
-        log_index = self._get_log_index()
+        # Get the log index.
+        try:
+            log_index = self.get_log_index()
+            if(log_index is None):
+                raise ValueError("The log index could not be determined. Perhaps the Summary page is selected?")
+        except ValueError as e:
+            error(parent=self.application.window, message=e)
+            return
+
         log = self.logs[log_index]
 
         (number_of_duplicates, number_of_duplicates_removed) = log.remove_duplicates()
-        info(self.parent, "Found %d duplicate(s). Successfully removed %d duplicate(s)." % (number_of_duplicates, number_of_duplicates_removed))
+        info(parent=self.application.window, message="Found %d duplicate(s). Successfully removed %d duplicate(s)." % (number_of_duplicates, number_of_duplicates_removed))
+
+        if(number_of_duplicates_removed > 0):
+            # Update statistics.
+            self.summary.update()
+            self.application.toolbox.awards.count(self)
+
         return
 
-    def get_number_of_logs(self):
+    def record_count_callback(self, widget=None):
+        """ A callback function used to show the record count for the selected log. """
+
+        # Get the log index.
+        try:
+            log_index = self.get_log_index()
+            if(log_index is None):
+                raise ValueError("The log index could not be determined. Perhaps the Summary page is selected?")
+        except ValueError as e:
+            error(parent=self.application.window, message=e)
+            return
+
+        # Get the number of records.
+        log = self.logs[log_index]
+        try:
+            record_count = log.record_count
+            info(parent=self.application.window, message="Log '%s' contains %d records." % (log.name, record_count))
+        except sqlite.Error as e:
+            logging.exception(e)
+            error(parent=self.application.window, message="Could not get the record count for '%s' because of a database error." % log.name)
+
+        return
+
+    @property
+    def log_count(self):
         """ Return the total number of logs in the logbook.
 
         :returns: The total number of logs in the logbook.
@@ -1203,82 +1043,71 @@ class Logbook(Gtk.Notebook):
         """
         return len(self.logs)
 
-    def get_number_of_qsos(self):
+    @property
+    def record_count(self):
         """ Return the total number of QSOs/records in the whole logbook.
 
         :returns: The total number of QSOs/records in the whole logbook.
         :rtype: int
         """
-        total = 0
-        for log in self.logs:
-            total += log.get_number_of_records()
-        return total
+        return sum([log.record_count for log in self.logs])
 
     def log_name_exists(self, table_name):
         """ Determine whether a Log object with a given name exists in the SQL database.
 
         :arg str table_name: The name of the log (i.e. the name of the table in the SQL database).
-        :returns: True if the log name already exists in the logbook; False if it does not already exist; None if there is a database error.
-        :rtype: bool or None
+        :returns: True if the log name already exists in the logbook; False if it does not already exist.
+        :rtype: bool
+        :raises sqlite.Error: If a database error occurs.
         """
-        try:
-            with self.connection:
-                c = self.connection.cursor()
-                c.execute("SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE name=?)", [table_name])
-                exists = c.fetchone()
-            if(exists[0] == 1):
-                return True
-            else:
-                return False
-        except (sqlite.Error, IndexError) as e:
-            logging.exception(e)  # Database error. PyQSO could not check if the log name exists.
-            return None
 
-    def _get_log_index(self, name=None):
+        with self.connection:
+            c = self.connection.cursor()
+            c.execute("SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE name=?)", [table_name])
+            exists = c.fetchone()
+        if(exists[0] == 1):
+            return True
+        else:
+            return False
+
+    def get_log_index(self, name=None):
         """ Given the name of a log, return its index in the list of Log objects.
 
         :arg str name: The name of the log. If None, use the name of the currently-selected log.
-        :returns: The index of the named log in the list of Log objects.
+        :returns: The index of the named log in the list of Log objects. Returns None is the log cannot be found.
         :rtype: int
         """
         if(name is None):
-            # If no page name is supplied, then just use the currently selected page
-            page_index = self.get_current_page()  # Gets the index of the selected tab in the logbook
-            if(page_index == 0 or page_index == self.get_n_pages()-1):
-                # We either have the Summary page, or the "+" (add log) dummy page.
+            # If no page name is supplied, then just use the currently selected page.
+            page_index = self.notebook.get_current_page()  # Get the index of the selected tab in the logbook.
+            if(page_index == 0 or page_index == self.notebook.get_n_pages()-1):
+                # We either have the Summary page, or the "+" (add log) blank/dummy page.
                 logging.debug("No log currently selected!")
                 return None
-            name = self.get_nth_page(page_index).get_name()
+            name = self.notebook.get_nth_page(page_index).get_name()
         # If a page of the logbook (and therefore a Log object) gets deleted,
         # then the page_index may not correspond to the index of the log in the self.logs list.
         # Therefore, we have to search for the tab with the same name as the log.
+        log_index = None
         for i in range(0, len(self.logs)):
             if(self.logs[i].name == name):
                 log_index = i
                 break
         return log_index
 
+    def get_logs(self):
+        """ Retrieve all the logs in the logbook file, and create Log objects that represent them.
 
-class TestLogbook(unittest.TestCase):
-
-    """ The unit tests for the Logbook class. """
-
-    def setUp(self):
-        """ Set up the Logbook object and connection to the test database needed for the unit tests. """
-        import os
-        self.logbook = Logbook(parent=None)
-        success = self.logbook.db_connect(os.path.dirname(os.path.realpath(__file__))+"/unittest_resources/test.db")
-        assert success
-
-    def tearDown(self):
-        """ Disconnect from the test database. """
-        success = self.logbook.db_disconnect()
-        assert success
-
-    def test_log_name_exists(self):
-        """ Check that only the log called 'test' exists. """
-        assert self.logbook.log_name_exists("test")  # Log 'test' exists.
-        assert not self.logbook.log_name_exists("hello")  # Log 'hello' should not exist.
-
-if(__name__ == '__main__'):
-    unittest.main()
+        :returns: A list containing all the logs in the logbook.
+        :rtype: list
+        :raises sqlite.Error: If the log names could not be determined from the sqlite_master table in the database.
+        """
+        logs = []
+        with self.connection:
+            c = self.connection.cursor()
+            c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name NOT GLOB 'sqlite_*'")
+            for name in c:
+                l = Log(self.connection, name[0])
+                l.populate()
+                logs.append(l)
+        return logs
diff --git a/pyqso/menu.py b/pyqso/menu.py
index 4c8b078..fceeb83 100644
--- a/pyqso/menu.py
+++ b/pyqso/menu.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2012-2016 Christian T. Jacobs.
+#    Copyright (C) 2012-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -18,236 +18,116 @@
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
 from gi.repository import Gtk
-import logging
-import configparser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import os.path
 
 
-class Menu(Gtk.MenuBar):
+class Menu:
 
-    """ The PyQSO menu bar along the top of the main window. """
+    """ The menu bar along the top of the main window. """
 
-    def __init__(self, parent):
+    def __init__(self, application):
         """ Set up all menu items and connect to the various functions.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
 
-        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.application = application
+        self.builder = self.application.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", self.application.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", self.application.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", self.application.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", self.application.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", self.application.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", self.application.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
-
-        # 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["IMPORT_LOG"] = self.builder.get_object("mitem_import_log")
+        self.items["IMPORT_LOG"].connect("activate", self.application.logbook.import_log)
+
+        # Export the current log as ADIF
+        self.items["EXPORT_LOG_ADIF"] = self.builder.get_object("mitem_export_log_adif")
+        self.items["EXPORT_LOG_ADIF"].connect("activate", self.application.logbook.export_log_adif)
+
+        # Export the current log as Cabrillo
+        self.items["EXPORT_LOG_CABRILLO"] = self.builder.get_object("mitem_export_log_cabrillo")
+        self.items["EXPORT_LOG_CABRILLO"].connect("activate", self.application.logbook.export_log_cabrillo)
 
         # 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", self.application.logbook.print_log)
+
+        # Preferences
+        self.items["PREFERENCES"] = self.builder.get_object("mitem_preferences")
+        self.items["PREFERENCES"].connect("activate", self.application.show_preferences)
 
         # 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
-
-        # RECORDS ######
-        mitem_records = Gtk.MenuItem("Records")
-        self.append(mitem_records)
-        subm_records = Gtk.Menu()
-        mitem_records.set_submenu(subm_records)
-
-        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
-
-        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
-
-        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
-
-        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")
+        self.items["QUIT"] = self.builder.get_object("mitem_quit")
+        self.items["QUIT"].connect("activate", Gtk.main_quit)
+
+        # Add record
+        self.items["ADD_RECORD"] = self.builder.get_object("mitem_add_record")
+        self.items["ADD_RECORD"].connect("activate", self.application.logbook.add_record_callback)
+
+        # Edit selected record
+        self.items["EDIT_RECORD"] = self.builder.get_object("mitem_edit_record")
+        self.items["EDIT_RECORD"].connect("activate", self.application.logbook.edit_record_callback)
+
+        # Delete selected record
+        self.items["DELETE_RECORD"] = self.builder.get_object("mitem_delete_record")
+        self.items["DELETE_RECORD"].connect("activate", self.application.logbook.delete_record_callback)
+
+        # Remove duplicates
+        self.items["REMOVE_DUPLICATES"] = self.builder.get_object("mitem_remove_duplicates")
+        self.items["REMOVE_DUPLICATES"].connect("activate", self.application.logbook.remove_duplicates_callback)
+
+        # Record count
+        self.items["RECORD_COUNT"] = self.builder.get_object("mitem_record_count")
+        self.items["RECORD_COUNT"].connect("activate", self.application.logbook.record_count_callback)
+
+        # 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.getboolean(section, option))
         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
-
-        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)
+            self.items["TOOLBOX"].set_active(False)  # Don't show the toolbox by default
+        self.items["TOOLBOX"].connect("activate", self.application.toolbox.toggle_visible_callback)
 
         # 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", self.application.show_about)
 
         self.set_logbook_item_sensitive(True)
         self.set_log_items_sensitive(False)
         self.set_record_items_sensitive(False)
 
-        logging.debug("Menu bar ready!")
-
         return
 
     def set_logbook_item_sensitive(self, sensitive):
@@ -255,11 +135,10 @@ class Menu(Gtk.MenuBar):
 
         :arg bool sensitive: If True, enable the 'new logbook' and 'open logbook' menu items. If False, disable them.
         """
-        logging.debug("Setting the 'Create/Open Logbook' menu item's sensitivity to: %s..." % sensitive)
+
         self.items["NEW_LOGBOOK"].set_sensitive(sensitive)
         self.items["OPEN_LOGBOOK"].set_sensitive(sensitive)
         self.items["CLOSE_LOGBOOK"].set_sensitive(not sensitive)
-        logging.debug("Set the 'Create/Open Logbook' menu item's sensitivity to: %s." % sensitive)
         return
 
     def set_log_items_sensitive(self, sensitive):
@@ -267,10 +146,9 @@ class Menu(Gtk.MenuBar):
 
         :arg bool sensitive: If True, enable all the log-related menu items. If False, disable them all.
         """
-        logging.debug("Setting log-related menu item sensitivity to: %s..." % sensitive)
-        for item_name in ["NEW_LOG", "DELETE_LOG", "RENAME_LOG", "IMPORT_LOG", "EXPORT_LOG", "PRINT_LOG"]:
+
+        for item_name in ["NEW_LOG", "DELETE_LOG", "RENAME_LOG", "IMPORT_LOG", "EXPORT_LOG_ADIF", "EXPORT_LOG_CABRILLO", "PRINT_LOG"]:
             self.items[item_name].set_sensitive(sensitive)
-        logging.debug("Set log-related menu item sensitivity to: %s." % sensitive)
         return
 
     def set_record_items_sensitive(self, sensitive):
@@ -278,8 +156,7 @@ class Menu(Gtk.MenuBar):
 
         :arg bool sensitive: If True, enable all the record-related menu items. If False, disable them all.
         """
-        logging.debug("Setting record-related menu item sensitivity to: %s..." % sensitive)
-        for item_name in ["ADD_RECORD", "EDIT_RECORD", "DELETE_RECORD", "REMOVE_DUPLICATES"]:
+
+        for item_name in ["ADD_RECORD", "EDIT_RECORD", "DELETE_RECORD", "REMOVE_DUPLICATES", "RECORD_COUNT"]:
             self.items[item_name].set_sensitive(sensitive)
-        logging.debug("Set record-related menu item sensitivity to: %s." % sensitive)
         return
diff --git a/pyqso/preferences_dialog.py b/pyqso/preferences_dialog.py
index 60c4b13..e93df1a 100644
--- a/pyqso/preferences_dialog.py
+++ b/pyqso/preferences_dialog.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -19,7 +19,10 @@
 
 from gi.repository import Gtk
 import logging
-import configparser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import os.path
 import base64
 try:
@@ -28,42 +31,44 @@ try:
 except ImportError:
     logging.warning("Could not import the Hamlib module!")
     have_hamlib = False
+try:
+    import geocoder
+    have_geocoder = True
+except ImportError:
+    logging.warning("Could not import the geocoder module!")
+    have_geocoder = False
 
-from pyqso.adif import *
+from pyqso.adif import AVAILABLE_FIELD_NAMES_ORDERED, MODES
+from pyqso.auxiliary_dialogs import error
 
 PREFERENCES_FILE = os.path.expanduser("~/.config/pyqso/preferences.ini")
 
 
-class PreferencesDialog(Gtk.Dialog):
+class PreferencesDialog:
 
     """ A dialog to specify the PyQSO preferences. """
 
-    def __init__(self, parent):
-        """ Set up the various pages of the preferences dialog. """
-
-        logging.debug("Setting up the preferences dialog...")
+    def __init__(self, application):
+        """ Set up the various pages of the preferences dialog.
 
-        Gtk.Dialog.__init__(self, title="Preferences", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
 
-        self.preferences = Gtk.Notebook()
-
-        self.general = GeneralPage()
-        self.preferences.insert_page(self.general, Gtk.Label("General"), 0)
-
-        self.view = ViewPage()
-        self.preferences.insert_page(self.view, Gtk.Label("View"), 1)
-
-        self.hamlib = HamlibPage()
-        self.preferences.insert_page(self.hamlib, Gtk.Label("Hamlib"), 2)
+        logging.debug("Setting up the preferences dialog...")
 
-        self.records = RecordsPage()
-        self.preferences.insert_page(self.records, Gtk.Label("Records"), 2)
+        self.application = application
+        self.builder = self.application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("preferences_dialog",))
+        self.dialog = self.builder.get_object("preferences_dialog")
 
-        self.adif = ADIFPage()
-        self.preferences.insert_page(self.adif, Gtk.Label("ADIF"), 2)
+        self.general = GeneralPage(self.dialog, self.builder)
+        self.view = ViewPage(self.dialog, self.builder)
+        self.records = RecordsPage(self.dialog, self.builder)
+        self.import_export = ImportExportPage(self.dialog, self.builder)
+        self.hamlib = HamlibPage(self.dialog, self.builder)
 
-        self.vbox.pack_start(self.preferences, True, True, 2)
-        self.show_all()
+        self.dialog.show_all()
 
         logging.debug("Preferences dialog ready!")
 
@@ -73,38 +78,33 @@ class PreferencesDialog(Gtk.Dialog):
         """ Commit the user preferences to the configuration file. """
 
         logging.debug("Committing the user preferences to the configuration file...")
-        general_data = self.general.get_data()
-        view_data = self.view.get_data()
-        hamlib_data = self.hamlib.get_data()
-        records_data = self.records.get_data()
-        adif_data = self.adif.get_data()
 
         config = configparser.ConfigParser()
 
         # General
         config.add_section("general")
-        for key in list(general_data.keys()):
-            config.set("general", key.lower(), str(general_data[key]))
+        for key in list(self.general.data.keys()):
+            config.set("general", key.lower(), str(self.general.data[key]))
 
         # View
         config.add_section("view")
-        for key in list(view_data.keys()):
-            config.set("view", key.lower(), str(view_data[key]))
+        for key in list(self.view.data.keys()):
+            config.set("view", key.lower(), str(self.view.data[key]))
 
-        # ADIF
-        config.add_section("adif")
-        for key in list(adif_data.keys()):
-            config.set("adif", key.lower(), str(adif_data[key]))
+        # Records
+        config.add_section("records")
+        for key in list(self.records.data.keys()):
+            config.set("records", key.lower(), str(self.records.data[key]))
+
+        # Import/Export
+        config.add_section("import_export")
+        for key in list(self.import_export.data.keys()):
+            config.set("import_export", key.lower(), str(self.import_export.data[key]))
 
         # Hamlib
         config.add_section("hamlib")
-        for key in list(hamlib_data.keys()):
-            config.set("hamlib", key.lower(), str(hamlib_data[key]))
-
-        # Records
-        config.add_section("records")
-        for key in list(records_data.keys()):
-            config.set("records", key.lower(), str(records_data[key]))
+        for key in list(self.hamlib.data.keys()):
+            config.set("hamlib", key.lower(), str(self.hamlib.data[key]))
 
         # Write the preferences to file.
         with open(os.path.expanduser(PREFERENCES_FILE), 'w') as f:
@@ -113,275 +113,253 @@ class PreferencesDialog(Gtk.Dialog):
         return
 
 
-class GeneralPage(Gtk.VBox):
+class GeneralPage:
 
     """ The section of the preferences dialog containing general preferences. """
 
-    def __init__(self):
-        logging.debug("Setting up the General page of the preferences dialog...")
+    def __init__(self, parent, builder):
+        """ Set up the General page of the Preferences dialog. """
 
-        Gtk.VBox.__init__(self, spacing=2)
+        self.parent = parent
+        self.builder = builder
+        self.sources = {}
 
         # Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
         # because a configuration file may have been created after launching the application. Let's check to see if one exists again...
         config = configparser.ConfigParser()
         have_config = (config.read(PREFERENCES_FILE) != [])
 
-        self.sources = {}
-
-        # Startup
-        frame = Gtk.Frame()
-        frame.set_label("Startup")
-
-        vbox = Gtk.VBox()
-
-        # Show toolbox
-        hbox = Gtk.HBox()
-        self.sources["SHOW_TOOLBOX"] = Gtk.CheckButton("Show toolbox by default")
+        # Show toolbox.
+        self.sources["SHOW_TOOLBOX"] = self.builder.get_object("general_show_toolbox_checkbutton")
         (section, option) = ("general", "show_toolbox")
         if(have_config and config.has_option(section, option)):
-            self.sources["SHOW_TOOLBOX"].set_active(config.get(section, option) == "True")
+            self.sources["SHOW_TOOLBOX"].set_active(config.getboolean(section, option))
         else:
             self.sources["SHOW_TOOLBOX"].set_active(False)
-        hbox.pack_start(self.sources["SHOW_TOOLBOX"], False, False, 2)
-        vbox.pack_start(hbox, False, False, 2)
 
-        # Show statistics
-        hbox = Gtk.HBox()
-        self.sources["SHOW_YEARLY_STATISTICS"] = Gtk.CheckButton("Show yearly logbook statistics on the Summary page")
+        # Show statistics.
+        self.sources["SHOW_YEARLY_STATISTICS"] = self.builder.get_object("general_show_yearly_statistics_checkbutton")
         (section, option) = ("general", "show_yearly_statistics")
         if(have_config and config.has_option(section, option)):
-            self.sources["SHOW_YEARLY_STATISTICS"].set_active(config.get(section, option) == "True")
+            self.sources["SHOW_YEARLY_STATISTICS"].set_active(config.getboolean(section, option))
         else:
             self.sources["SHOW_YEARLY_STATISTICS"].set_active(False)
-        hbox.pack_start(self.sources["SHOW_YEARLY_STATISTICS"], False, False, 2)
-        vbox.pack_start(hbox, False, False, 2)
 
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
+        # Default logbook.
+        self.sources["DEFAULT_LOGBOOK"] = self.builder.get_object("general_default_logbook_checkbutton")
+        (section, option) = ("general", "default_logbook")
+        if(have_config and config.has_option(section, option)):
+            self.sources["DEFAULT_LOGBOOK"].set_active(config.getboolean(section, option))
+        else:
+            self.sources["DEFAULT_LOGBOOK"].set_active(False)
+        self.sources["DEFAULT_LOGBOOK"].connect("toggled", self.on_default_logbook_toggled)
 
-        # Dialogs
-        frame = Gtk.Frame()
-        frame.set_label("Dialogs")
+        self.sources["DEFAULT_LOGBOOK_PATH"] = self.builder.get_object("general_default_logbook_entry")
+        (section, option) = ("general", "default_logbook")
+        # Disable the text entry box if the default logbook checkbox is not checked.
+        if(have_config and config.has_option(section, option)):
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_sensitive(self.sources["DEFAULT_LOGBOOK"].get_active())
+            self.builder.get_object("general_default_logbook_button").set_sensitive(self.sources["DEFAULT_LOGBOOK"].get_active())
+        else:
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_sensitive(False)
+            self.builder.get_object("general_default_logbook_button").set_sensitive(False)
+        (section, option) = ("general", "default_logbook_path")
+        if(have_config and config.has_option(section, option)):
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_text(config.get(section, option))
 
-        vbox = Gtk.VBox()
+        self.builder.get_object("general_default_logbook_button").connect("clicked", self.on_default_logbook_clicked)
 
-        # Keep 'Add Record' dialog open
-        hbox = Gtk.HBox()
-        self.sources["KEEP_OPEN"] = Gtk.CheckButton("Keep the Add Record dialog open after a QSO is added")
+        # Keep 'Add Record' dialog open.
+        self.sources["KEEP_OPEN"] = self.builder.get_object("general_keep_open_checkbutton")
         (section, option) = ("general", "keep_open")
         if(have_config and config.has_option(section, option)):
-            self.sources["KEEP_OPEN"].set_active(config.get(section, option) == "True")
+            self.sources["KEEP_OPEN"].set_active(config.getboolean(section, option))
         else:
             self.sources["KEEP_OPEN"].set_active(False)
-        hbox.pack_start(self.sources["KEEP_OPEN"], False, False, 2)
-        vbox.pack_start(hbox, False, False, 2)
 
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
+        # Pin-point QTH on grey line map.
+        self.sources["SHOW_QTH"] = self.builder.get_object("general_show_qth_checkbutton")
+        (section, option) = ("general", "show_qth")
+        if(have_config and config.has_option(section, option)):
+            self.sources["SHOW_QTH"].set_active(config.getboolean(section, option))
+        else:
+            self.sources["SHOW_QTH"].set_active(False)
+
+        self.sources["QTH_NAME"] = self.builder.get_object("general_qth_name_entry")
+        button = self.builder.get_object("general_qth_lookup")
+        button.connect("clicked", self.lookup_callback)  # Uses geocoding to find the latitude-longitude coordinates.
+
+        self.sources["QTH_LATITUDE"] = self.builder.get_object("general_qth_coordinates_latitude_entry")
+        self.sources["QTH_LONGITUDE"] = self.builder.get_object("general_qth_coordinates_longitude_entry")
+
+        (section, option) = ("general", "show_qth")
+        # Disable the text entry boxes if the SHOW_QTH checkbox is not checked.
+        if(have_config and config.has_option(section, option)):
+            self.sources["QTH_NAME"].set_sensitive(self.sources["SHOW_QTH"].get_active())
+            self.sources["QTH_LATITUDE"].set_sensitive(self.sources["SHOW_QTH"].get_active())
+            self.sources["QTH_LONGITUDE"].set_sensitive(self.sources["SHOW_QTH"].get_active())
+            button.set_sensitive(self.sources["SHOW_QTH"].get_active())
+        else:
+            self.sources["QTH_NAME"].set_sensitive(False)
+            self.sources["QTH_LATITUDE"].set_sensitive(False)
+            self.sources["QTH_LONGITUDE"].set_sensitive(False)
+            button.set_sensitive(False)
+        (section, option) = ("general", "qth_name")
+        if(have_config and config.has_option(section, option)):
+            self.sources["QTH_NAME"].set_text(config.get(section, option))
+        (section, option) = ("general", "qth_latitude")
+        if(have_config and config.has_option(section, option)):
+            self.sources["QTH_LATITUDE"].set_text(config.get(section, option))
+        (section, option) = ("general", "qth_longitude")
+        if(have_config and config.has_option(section, option)):
+            self.sources["QTH_LONGITUDE"].set_text(config.get(section, option))
+        self.sources["SHOW_QTH"].connect("toggled", self.on_show_qth_toggled)
 
-        logging.debug("General page of the preferences dialog ready!")
         return
 
-    def get_data(self):
-        logging.debug("Retrieving data from the General page of the preferences dialog...")
+    @property
+    def data(self):
+        """ User preferences regarding General settings. """
         data = {}
         data["SHOW_TOOLBOX"] = self.sources["SHOW_TOOLBOX"].get_active()
         data["SHOW_YEARLY_STATISTICS"] = self.sources["SHOW_YEARLY_STATISTICS"].get_active()
+        data["DEFAULT_LOGBOOK"] = self.sources["DEFAULT_LOGBOOK"].get_active()
+        data["DEFAULT_LOGBOOK_PATH"] = os.path.expanduser(self.sources["DEFAULT_LOGBOOK_PATH"].get_text())
         data["KEEP_OPEN"] = self.sources["KEEP_OPEN"].get_active()
+        data["SHOW_QTH"] = self.sources["SHOW_QTH"].get_active()
+        data["QTH_NAME"] = self.sources["QTH_NAME"].get_text()
+        data["QTH_LATITUDE"] = self.sources["QTH_LATITUDE"].get_text()
+        data["QTH_LONGITUDE"] = self.sources["QTH_LONGITUDE"].get_text()
         return data
 
+    def on_default_logbook_toggled(self, widget, data=None):
+        if(widget.get_active()):
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_sensitive(True)
+            self.builder.get_object("general_default_logbook_button").set_sensitive(True)
+        else:
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_sensitive(False)
+            self.builder.get_object("general_default_logbook_button").set_sensitive(False)
+        return
 
-class ViewPage(Gtk.VBox):
-
-    """ The section of the preferences dialog containing view-related preferences. """
-
-    def __init__(self):
-        logging.debug("Setting up the View page of the preferences dialog...")
-
-        Gtk.VBox.__init__(self, spacing=2)
-
-        config = configparser.ConfigParser()
-        have_config = (config.read(PREFERENCES_FILE) != [])
-
-        self.sources = {}
+    def on_default_logbook_clicked(self, widget):
+        """ Let the user select the default logbook file via a file chooser dialog,
+        and set the path in the adjacent entry box. """
+
+        dialog = Gtk.FileChooserDialog("Select SQLite Database File",
+                                       self.parent,
+                                       Gtk.FileChooserAction.OPEN,
+                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                                        Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
+        response = dialog.run()
+        if(response == Gtk.ResponseType.OK):
+            path = dialog.get_filename()
+            self.sources["DEFAULT_LOGBOOK_PATH"].set_text(path)
+        dialog.destroy()
+        return
 
-        # Visible fields frame
-        frame = Gtk.Frame()
-        frame.set_label("Visible fields")
-
-        # Divide the list of available field names up into multiple columns (of maximum length 'max_buttons_per_column')
-        # so we don't make the Preferences dialog too long.
-        hbox = Gtk.HBox(spacing=2)
-        max_buttons_per_column = 6
-        number_of_columns = int(len(AVAILABLE_FIELD_NAMES_ORDERED)/max_buttons_per_column) + 1  # Number of check buttons per column
-        for i in range(0, number_of_columns):
-            vbox = Gtk.VBox(spacing=2)
-            for j in range(0, max_buttons_per_column):
-                if(i*max_buttons_per_column + j >= len(AVAILABLE_FIELD_NAMES_ORDERED)):
-                    break
-                field_name = AVAILABLE_FIELD_NAMES_ORDERED[i*max_buttons_per_column + j]
-                button = Gtk.CheckButton(AVAILABLE_FIELD_NAMES_FRIENDLY[field_name])
-                if(have_config and config.has_option("view", field_name.lower())):
-                    button.set_active(config.get("view", field_name.lower()) == "True")
-                else:
-                    button.set_active(True)
-                self.sources[field_name] = button
-                vbox.pack_start(button, False, False, 2)
-            hbox.pack_start(vbox, False, False, 2)
-        frame.add(hbox)
-        self.pack_start(frame, False, False, 2)
-
-        self.label = Gtk.Label("Note: View-related changes will not take effect\nuntil PyQSO is restarted.")
-        self.pack_start(self.label, False, False, 2)
-
-        logging.debug("View page of the preferences dialog ready!")
+    def on_show_qth_toggled(self, widget, data=None):
+        if(widget.get_active()):
+            self.sources["QTH_NAME"].set_sensitive(True)
+            self.sources["QTH_LATITUDE"].set_sensitive(True)
+            self.sources["QTH_LONGITUDE"].set_sensitive(True)
+            self.builder.get_object("general_qth_lookup").set_sensitive(True)
+        else:
+            self.sources["QTH_NAME"].set_sensitive(False)
+            self.sources["QTH_LATITUDE"].set_sensitive(False)
+            self.sources["QTH_LONGITUDE"].set_sensitive(False)
+            self.builder.get_object("general_qth_lookup").set_sensitive(False)
         return
 
-    def get_data(self):
-        logging.debug("Retrieving data from the View page of the preferences dialog...")
-        data = {}
-        for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
-            data[field_name] = self.sources[field_name].get_active()
-        return data
+    def lookup_callback(self, widget=None):
+        """ Perform geocoding of the QTH location to obtain latitude-longitude coordinates. """
+        if(not have_geocoder):
+            error(parent=self.parent, message="Geocoder module could not be imported. Geocoding aborted.")
+            return
+        logging.debug("Geocoding QTH location...")
+        name = self.sources["QTH_NAME"].get_text()
+        try:
+            g = geocoder.google(name)
+            latitude, longitude = g.latlng
+            self.sources["QTH_LATITUDE"].set_text(str(latitude))
+            self.sources["QTH_LONGITUDE"].set_text(str(longitude))
+            logging.debug("QTH coordinates found: (%s, %s)", str(latitude), str(longitude))
+        except ValueError as e:
+            error(parent=self.parent, message="Unable to lookup QTH coordinates. Is the QTH name correct?")
+            logging.exception(e)
+        except Exception as e:
+            error(parent=self.parent, message="Unable to lookup QTH coordinates. Check connection to the internets?")
+            logging.exception(e)
+        return
 
 
-class HamlibPage(Gtk.VBox):
+class ViewPage:
 
-    """ The section of the preferences dialog containing Hamlib-related preferences. """
+    """ The section of the preferences dialog containing view-related preferences. """
 
-    def __init__(self):
-        logging.debug("Setting up the Hamlib page of the preferences dialog...")
+    def __init__(self, parent, builder):
+        """ Set up the View page of the Preferences dialog. """
 
-        Gtk.VBox.__init__(self, spacing=2)
+        self.parent = parent
+        self.builder = builder
+        self.sources = {}
 
         config = configparser.ConfigParser()
         have_config = (config.read(PREFERENCES_FILE) != [])
 
-        self.sources = {}
-
-        frame = Gtk.Frame()
-        frame.set_label("Hamlib support")
-
-        vbox_inner = Gtk.VBox(spacing=2)
-
-        self.sources["AUTOFILL"] = Gtk.CheckButton("Auto-fill Frequency field")
-        (section, option) = ("hamlib", "autofill")
-        if(have_config and config.has_option(section, option)):
-            self.sources["AUTOFILL"].set_active(config.get(section, option) == "True")
-        else:
-            self.sources["AUTOFILL"].set_active(False)
-        vbox_inner.pack_start(self.sources["AUTOFILL"], False, False, 2)
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Model: ")
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(17)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        # Get the list of rig models
-        models = ["RIG_MODEL_NONE"]
-        if(have_hamlib):
-            try:
-                for item in dir(Hamlib):
-                    if(item.startswith("RIG_MODEL_")):
-                        models.append(item)
-            except:
-                logging.error("Could not obtain rig models list via Hamlib!")
-        else:
-            logging.debug("Hamlib module not present. Could not obtain a list of rig models.")
-
-        self.sources["RIG_MODEL"] = Gtk.ComboBoxText()
-        for model in models:
-            self.sources["RIG_MODEL"].append_text(model)
-        (section, option) = ("hamlib", "rig_model")
-        if(have_config and config.has_option("hamlib", "rig_model")):
-            self.sources["RIG_MODEL"].set_active(models.index(config.get("hamlib", "rig_model")))
-        else:
-            self.sources["RIG_MODEL"].set_active(models.index("RIG_MODEL_NONE"))  # Set to RIG_MODEL_NONE as the default option.
-        hbox_temp.pack_start(self.sources["RIG_MODEL"], True, True, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
-
-        # Path to rig
-        hbox_temp = Gtk.HBox()
-        label = Gtk.Label("Path to radio device: ")
-        label.set_width_chars(17)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["RIG_PATHNAME"] = Gtk.Entry()
-        (section, option) = ("hamlib", "rig_pathname")
-        if(have_config and config.has_option(section, option)):
-            self.sources["RIG_PATHNAME"].set_text(config.get(section, option))
-        hbox_temp.pack_start(self.sources["RIG_PATHNAME"], True, True, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
-
-        frame.add(vbox_inner)
-        self.pack_start(frame, True, True, 2)
+        # Visible fields
+        for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
+            self.sources[field_name] = self.builder.get_object("visible_fields_%s" % (field_name.lower()))
+            if(have_config and config.has_option("view", field_name.lower())):
+                self.sources[field_name].set_active(config.getboolean("view", field_name.lower()))
+            else:
+                self.sources[field_name].set_active(True)
 
-        logging.debug("Hamlib page of the preferences dialog ready!")
         return
 
-    def get_data(self):
-        logging.debug("Retrieving data from the Hamlib page of the preferences dialog...")
+    @property
+    def data(self):
+        """ User preferences regarding View settings. """
         data = {}
-        data["AUTOFILL"] = self.sources["AUTOFILL"].get_active()
-        data["RIG_PATHNAME"] = self.sources["RIG_PATHNAME"].get_text()
-        data["RIG_MODEL"] = self.sources["RIG_MODEL"].get_active_text()
+        for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
+            data[field_name] = self.sources[field_name].get_active()
         return data
 
 
-class RecordsPage(Gtk.VBox):
+class RecordsPage:
 
     """ The section of the preferences dialog containing record-related preferences. """
 
-    def __init__(self):
-        logging.debug("Setting up the Records page of the preferences dialog...")
+    def __init__(self, parent, builder):
+        """ Set up the Record page of the Preferences dialog. """
 
-        Gtk.VBox.__init__(self, spacing=2)
+        self.parent = parent
+        self.builder = builder
+        self.sources = {}
 
         # Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
         # because a configuration file may have been created after launching the application. Let's check to see if one exists again...
         config = configparser.ConfigParser()
         have_config = (config.read(PREFERENCES_FILE) != [])
 
-        self.sources = {}
-
-        # Autocomplete frame
-        frame = Gtk.Frame()
-        frame.set_label("Autocomplete")
-        vbox = Gtk.VBox()
-        self.sources["AUTOCOMPLETE_BAND"] = Gtk.CheckButton("Autocomplete the Band field")
+        # Autocomplete
+        self.sources["AUTOCOMPLETE_BAND"] = self.builder.get_object("records_autocomplete_band_checkbutton")
         (section, option) = ("records", "autocomplete_band")
         if(have_config and config.has_option(section, option)):
-            self.sources["AUTOCOMPLETE_BAND"].set_active(config.get(section, option) == "True")
+            self.sources["AUTOCOMPLETE_BAND"].set_active(config.getboolean(section, option))
         else:
             self.sources["AUTOCOMPLETE_BAND"].set_active(True)
-        vbox.pack_start(self.sources["AUTOCOMPLETE_BAND"], False, False, 2)
 
-        self.sources["USE_UTC"] = Gtk.CheckButton("Use UTC when autocompleting the Date and Time")
+        self.sources["USE_UTC"] = self.builder.get_object("records_autocomplete_utc_checkbutton")
         (section, option) = ("records", "use_utc")
         if(have_config and config.has_option(section, option)):
-            self.sources["USE_UTC"].set_active(config.get(section, option) == "True")
+            self.sources["USE_UTC"].set_active(config.getboolean(section, option))
         else:
             self.sources["USE_UTC"].set_active(True)
-        vbox.pack_start(self.sources["USE_UTC"], False, False, 2)
 
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
-
-        # Default values frame
-        frame = Gtk.Frame()
-        frame.set_label("Default values")
-        vbox = Gtk.VBox()
+        # Default values
 
         # Mode
-        hbox_temp = Gtk.HBox()
-        label = Gtk.Label("Mode: ")
-        label.set_width_chars(17)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["DEFAULT_MODE"] = Gtk.ComboBoxText()
+        self.sources["DEFAULT_MODE"] = self.builder.get_object("default_values_mode_combo")
         for mode in sorted(MODES.keys()):
             self.sources["DEFAULT_MODE"].append_text(mode)
         (section, option) = ("records", "default_mode")
@@ -390,18 +368,10 @@ class RecordsPage(Gtk.VBox):
         else:
             mode = ""
         self.sources["DEFAULT_MODE"].set_active(sorted(MODES.keys()).index(mode))
-        self.sources["DEFAULT_MODE"].connect("changed", self._on_mode_changed)
-        hbox_temp.pack_start(self.sources["DEFAULT_MODE"], False, False, 2)
-        vbox.pack_start(hbox_temp, False, False, 2)
+        self.sources["DEFAULT_MODE"].connect("changed", self.on_mode_changed)
 
         # Submode
-        hbox_temp = Gtk.HBox()
-        label = Gtk.Label("Submode: ")
-        label.set_width_chars(17)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["DEFAULT_SUBMODE"] = Gtk.ComboBoxText()
+        self.sources["DEFAULT_SUBMODE"] = self.builder.get_object("default_values_submode_combo")
         for submode in MODES[mode]:
             self.sources["DEFAULT_SUBMODE"].append_text(submode)
         (section, option) = ("records", "default_submode")
@@ -410,41 +380,28 @@ class RecordsPage(Gtk.VBox):
         else:
             submode = ""
         self.sources["DEFAULT_SUBMODE"].set_active(MODES[mode].index(submode))
-        hbox_temp.pack_start(self.sources["DEFAULT_SUBMODE"], False, False, 2)
-        vbox.pack_start(hbox_temp, False, False, 2)
 
         # Power
-        hbox_temp = Gtk.HBox()
-        label = Gtk.Label("TX Power (W): ")
-        label.set_width_chars(17)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["DEFAULT_POWER"] = Gtk.Entry()
+        self.sources["DEFAULT_POWER"] = self.builder.get_object("default_values_tx_power_entry")
         (section, option) = ("records", "default_power")
         if(have_config and config.has_option(section, option)):
             self.sources["DEFAULT_POWER"].set_text(config.get(section, option))
         else:
             self.sources["DEFAULT_POWER"].set_text("")
-        hbox_temp.pack_start(self.sources["DEFAULT_POWER"], False, False, 2)
-        vbox.pack_start(hbox_temp, False, False, 2)
-
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
 
-        # Callsign lookup frame
-        frame = Gtk.Frame()
-        frame.set_label("Callsign lookup")
-        vbox = Gtk.VBox()
-
-        # Callsign database
-        hbox_temp = Gtk.HBox()
-        label = Gtk.Label("Database: ")
-        label.set_width_chars(17)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
+        # Frequency unit
+        self.sources["DEFAULT_FREQUENCY_UNIT"] = self.builder.get_object("default_values_frequency_unit_combo")
+        units = ["Hz", "kHz", "MHz", "GHz"]
+        for unit in units:
+            self.sources["DEFAULT_FREQUENCY_UNIT"].append_text(unit)
+        (section, option) = ("records", "default_frequency_unit")
+        if(have_config and config.has_option(section, option)):
+            self.sources["DEFAULT_FREQUENCY_UNIT"].set_active(units.index(config.get(section, option)))
+        else:
+            self.sources["DEFAULT_FREQUENCY_UNIT"].set_active(units.index("MHz"))
 
-        self.sources["CALLSIGN_DATABASE"] = Gtk.ComboBoxText()
+        # Callsign lookup
+        self.sources["CALLSIGN_DATABASE"] = self.builder.get_object("callsign_lookup_database_combo")
         callsign_database = ["", "qrz.com", "hamqth.com"]
         for database in callsign_database:
             self.sources["CALLSIGN_DATABASE"].append_text(database)
@@ -453,62 +410,31 @@ class RecordsPage(Gtk.VBox):
             self.sources["CALLSIGN_DATABASE"].set_active(callsign_database.index(config.get(section, option)))
         else:
             self.sources["CALLSIGN_DATABASE"].set_active(callsign_database.index(""))
-        hbox_temp.pack_start(self.sources["CALLSIGN_DATABASE"], False, False, 2)
-        vbox.pack_start(hbox_temp, False, False, 2)
 
         # Login details
-        subframe = Gtk.Frame()
-        subframe.set_label("Login details")
-        inner_vbox = Gtk.VBox()
-
-        hbox = Gtk.HBox()
-        label = Gtk.Label("Username: ")
-        label.set_width_chars(9)
-        label.set_alignment(0, 0.5)
-        hbox.pack_start(label, False, False, 2)
-        self.sources["CALLSIGN_DATABASE_USERNAME"] = Gtk.Entry()
+        self.sources["CALLSIGN_DATABASE_USERNAME"] = self.builder.get_object("callsign_lookup_login_details_username_entry")
         (section, option) = ("records", "callsign_database_username")
         if(have_config and config.has_option(section, option)):
             self.sources["CALLSIGN_DATABASE_USERNAME"].set_text(config.get(section, option))
-        hbox.pack_start(self.sources["CALLSIGN_DATABASE_USERNAME"], False, False, 2)
-        inner_vbox.pack_start(hbox, False, False, 2)
-
-        hbox = Gtk.HBox()
-        label = Gtk.Label("Password: ")
-        label.set_width_chars(9)
-        label.set_alignment(0, 0.5)
-        hbox.pack_start(label, False, False, 2)
-        self.sources["CALLSIGN_DATABASE_PASSWORD"] = Gtk.Entry()
-        self.sources["CALLSIGN_DATABASE_PASSWORD"].set_visibility(False)  # Mask the password with the "*" character.
+
+        self.sources["CALLSIGN_DATABASE_PASSWORD"] = self.builder.get_object("callsign_lookup_login_details_password_entry")
         (section, option) = ("records", "callsign_database_password")
         if(have_config and config.has_option(section, option)):
             password = base64.b64decode(config.get(section, option)).decode("utf-8")
             self.sources["CALLSIGN_DATABASE_PASSWORD"].set_text(password)
-        hbox.pack_start(self.sources["CALLSIGN_DATABASE_PASSWORD"], False, False, 2)
-        inner_vbox.pack_start(hbox, False, False, 2)
-
-        label = Gtk.Label("Warning: Login details are currently stored as\nBase64-encoded plain text in the configuration file.")
-        inner_vbox.pack_start(label, False, False, 2)
 
-        subframe.add(inner_vbox)
-        vbox.pack_start(subframe, False, False, 2)
-
-        self.sources["IGNORE_PREFIX_SUFFIX"] = Gtk.CheckButton("Ignore callsign prefixes and/or suffixes")
+        self.sources["IGNORE_PREFIX_SUFFIX"] = self.builder.get_object("callsign_lookup_ignore_prefix_suffix_checkbutton")
         (section, option) = ("records", "ignore_prefix_suffix")
         if(have_config and config.has_option(section, option)):
-            self.sources["IGNORE_PREFIX_SUFFIX"].set_active(config.get(section, option) == "True")
+            self.sources["IGNORE_PREFIX_SUFFIX"].set_active(config.getboolean(section, option))
         else:
             self.sources["IGNORE_PREFIX_SUFFIX"].set_active(True)
-        vbox.pack_start(self.sources["IGNORE_PREFIX_SUFFIX"], False, False, 2)
-
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
 
-        logging.debug("Records page of the preferences dialog ready!")
         return
 
-    def get_data(self):
-        logging.debug("Retrieving data from the Records page of the preferences dialog...")
+    @property
+    def data(self):
+        """ User preferences regarding Records settings. """
         data = {}
         data["AUTOCOMPLETE_BAND"] = self.sources["AUTOCOMPLETE_BAND"].get_active()
         data["USE_UTC"] = self.sources["USE_UTC"].get_active()
@@ -516,58 +442,113 @@ class RecordsPage(Gtk.VBox):
         data["DEFAULT_MODE"] = self.sources["DEFAULT_MODE"].get_active_text()
         data["DEFAULT_SUBMODE"] = self.sources["DEFAULT_SUBMODE"].get_active_text()
         data["DEFAULT_POWER"] = self.sources["DEFAULT_POWER"].get_text()
+        data["DEFAULT_FREQUENCY_UNIT"] = self.sources["DEFAULT_FREQUENCY_UNIT"].get_active_text()
 
         data["CALLSIGN_DATABASE"] = self.sources["CALLSIGN_DATABASE"].get_active_text()
         data["CALLSIGN_DATABASE_USERNAME"] = self.sources["CALLSIGN_DATABASE_USERNAME"].get_text()
-        data["CALLSIGN_DATABASE_PASSWORD"] = base64.b64encode(self.sources["CALLSIGN_DATABASE_PASSWORD"].get_text().encode("utf-8")).decode('utf-8')  # Need to convert from bytes to str here.
+        data["CALLSIGN_DATABASE_PASSWORD"] = base64.b64encode(self.sources["CALLSIGN_DATABASE_PASSWORD"].get_text().encode("utf-8")).decode("utf-8")  # Need to convert from bytes to str here.
         data["IGNORE_PREFIX_SUFFIX"] = self.sources["IGNORE_PREFIX_SUFFIX"].get_active()
         return data
 
-    def _on_mode_changed(self, combo):
+    def on_mode_changed(self, combo):
         """ If the MODE field has changed its value, then fill the SUBMODE field with all the available SUBMODE options for that new MODE. """
         self.sources["DEFAULT_SUBMODE"].get_model().clear()
         mode = combo.get_active_text()
         for submode in MODES[mode]:
             self.sources["DEFAULT_SUBMODE"].append_text(submode)
+        self.sources["DEFAULT_SUBMODE"].set_active(MODES[mode].index(""))
         return
 
 
-class ADIFPage(Gtk.VBox):
+class ImportExportPage:
 
-    """ The section of the preferences dialog containing ADIF-related preferences. """
+    """ The section of the preferences dialog containing import/export-related preferences. """
 
-    def __init__(self):
-        logging.debug("Setting up the ADIF page of the preferences dialog...")
+    def __init__(self, parent, builder):
+        """ Set up the Import/Export page of the Preferences dialog. """
 
-        Gtk.VBox.__init__(self, spacing=2)
+        self.parent = parent
+        self.builder = builder
+        self.sources = {}
 
         # Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
         # because a configuration file may have been created after launching the application. Let's check to see if one exists again...
         config = configparser.ConfigParser()
         have_config = (config.read(PREFERENCES_FILE) != [])
 
+        # Import
+        self.sources["MERGE_COMMENT"] = self.builder.get_object("adif_import_merge_comment_checkbutton")
+        (section, option) = ("import_export", "merge_comment")
+        if(have_config and config.has_option(section, option)):
+            self.sources["MERGE_COMMENT"].set_active(config.getboolean(section, option))
+        else:
+            self.sources["MERGE_COMMENT"].set_active(False)
+
+        return
+
+    @property
+    def data(self):
+        """ User preferences regarding Import/Export settings. """
+        data = {}
+        data["MERGE_COMMENT"] = self.sources["MERGE_COMMENT"].get_active()
+        return data
+
+
+class HamlibPage:
+
+    """ The section of the preferences dialog containing Hamlib-related preferences. """
+
+    def __init__(self, parent, builder):
+        """ Set up the Hamlib page of the Preferences dialog. """
+
+        self.parent = parent
+        self.builder = builder
         self.sources = {}
 
-        # Import frame
-        frame = Gtk.Frame()
-        frame.set_label("Import")
-        vbox = Gtk.VBox()
-        self.sources["MERGE_COMMENT"] = Gtk.CheckButton("Merge any text in the COMMENT field with the NOTES field.")
-        (section, option) = ("adif", "merge_comment")
+        config = configparser.ConfigParser()
+        have_config = (config.read(PREFERENCES_FILE) != [])
+
+        self.sources["AUTOFILL"] = self.builder.get_object("hamlib_support_checkbutton")
+        (section, option) = ("hamlib", "autofill")
         if(have_config and config.has_option(section, option)):
-            self.sources["MERGE_COMMENT"].set_active(config.get(section, option) == "True")
+            self.sources["AUTOFILL"].set_active(config.getboolean(section, option))
         else:
-            self.sources["MERGE_COMMENT"].set_active(False)
-        vbox.pack_start(self.sources["MERGE_COMMENT"], False, False, 2)
+            self.sources["AUTOFILL"].set_active(False)
+
+        # Get the list of rig models
+        models = ["RIG_MODEL_NONE"]
+        if(have_hamlib):
+            try:
+                for item in dir(Hamlib):
+                    if(item.startswith("RIG_MODEL_")):
+                        models.append(item)
+            except:
+                logging.error("Could not obtain rig models list via Hamlib!")
+        else:
+            logging.debug("Hamlib module not present. Could not obtain a list of rig models.")
+
+        self.sources["RIG_MODEL"] = self.builder.get_object("hamlib_support_model_combo")
+        for model in models:
+            self.sources["RIG_MODEL"].append_text(model)
+        (section, option) = ("hamlib", "rig_model")
+        if(have_config and config.has_option("hamlib", "rig_model")):
+            self.sources["RIG_MODEL"].set_active(models.index(config.get("hamlib", "rig_model")))
+        else:
+            self.sources["RIG_MODEL"].set_active(models.index("RIG_MODEL_NONE"))  # Set to RIG_MODEL_NONE as the default option.
 
-        frame.add(vbox)
-        self.pack_start(frame, False, False, 2)
+        # Path to rig
+        self.sources["RIG_PATHNAME"] = self.builder.get_object("hamlib_support_path_entry")
+        (section, option) = ("hamlib", "rig_pathname")
+        if(have_config and config.has_option(section, option)):
+            self.sources["RIG_PATHNAME"].set_text(config.get(section, option))
 
-        logging.debug("ADIF page of the preferences dialog ready!")
         return
 
-    def get_data(self):
-        logging.debug("Retrieving data from the ADIF page of the preferences dialog...")
+    @property
+    def data(self):
+        """ User preferences regarding Hamlib settings. """
         data = {}
-        data["MERGE_COMMENT"] = self.sources["MERGE_COMMENT"].get_active()
+        data["AUTOFILL"] = self.sources["AUTOFILL"].get_active()
+        data["RIG_PATHNAME"] = self.sources["RIG_PATHNAME"].get_text()
+        data["RIG_MODEL"] = self.sources["RIG_MODEL"].get_active_text()
         return data
diff --git a/pyqso/printer.py b/pyqso/printer.py
new file mode 100644
index 0000000..117a693
--- /dev/null
+++ b/pyqso/printer.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk, Pango, PangoCairo
+import logging
+
+from pyqso.auxiliary_dialogs import error
+
+
+class Printer(object):
+
+    """ Handles the printing of one or more records to file or paper. """
+
+    def __init__(self, application):
+        """ Initialise the record printer.
+
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
+
+        self.application = application
+
+        self.action = Gtk.PrintOperationAction.PRINT_DIALOG
+        self.operation = Gtk.PrintOperation()
+        ps = Gtk.PageSetup()
+        ps.set_orientation(Gtk.PageOrientation.LANDSCAPE)
+        self.operation.set_default_page_setup(ps)
+        self.operation.set_unit(Gtk.Unit.MM)
+
+        self.operation.connect("begin_print", self.begin_print)
+        self.operation.connect("draw_page", self.draw_page)
+
+        return
+
+    def print_records(self, records, title=None):
+        """ Perform the print operation.
+
+        :arg dict records: The records to be printed.
+        :arg str title: Optional title for the document. Default is None.
+        :returns: The result of the print operation.
+        :rtype: Gtk.PrintOperationResult
+        """
+
+        # Add the title, if given.
+        if(title):
+            self.text_to_print = title + "\n\n"
+        else:
+            self.text_to_print = ""
+
+        # Assemble the header and records into one string.
+        line_format = "%-5s\t%-15s\t%-8s\t%-6s\t%-15s\t%-12s\t%-8s\t%-8s\n"
+        self.text_to_print += line_format % ("Index", "Callsign", "Date", "Time", "Frequency", "Mode", "RST Sent", "RST Rcvd")
+        self.text_to_print += line_format % ("-----", "--------", "----", "----", "---------", "----", "--------", "--------")
+        for r in records:
+            self.text_to_print += line_format % (str(r["id"]), str(r["CALL"]), str(r["QSO_DATE"]), str(r["TIME_ON"]), str(r["FREQ"]), str(r["MODE"]), str(r["RST_SENT"]), str(r["RST_RCVD"]))
+
+        result = self.operation.run(self.action, parent=self.application.window)
+        if(result == Gtk.PrintOperationResult.ERROR):
+            error(parent=self.application.window, message="Unable to print the log.")
+
+        return result
+
+    def begin_print(self, operation, context):
+        """ Specify the layout/position/font of the text on the pages to be printed.
+
+        :arg Gtk.PrintOperation operation: The printing API.
+        :arg Gtk.PrintContext context: Used to draw/render the pages to print.
+        """
+        width = context.get_width()  # Measured in pixels.
+        height = context.get_height()  # Measured in pixels.
+        layout = context.create_pango_layout()
+        layout.set_font_description(Pango.FontDescription("monospace expanded 10"))
+        layout.set_width(int(width*Pango.SCALE))
+        layout.set_text(self.text_to_print, -1)
+
+        number_of_pages = 1
+        page_height = 0
+        for line in range(0, layout.get_line_count()):
+            layout_line = layout.get_line(line)
+            ink_rectangle, logical_rectangle = layout_line.get_pixel_extents()
+            self.line_height = logical_rectangle.height + 3.0
+            page_height += self.line_height
+            if((page_height + 2*self.line_height) >= height):
+                # Go on to the next page.
+                number_of_pages += 1
+                page_height = 0.0
+        operation.set_n_pages(number_of_pages)
+        logging.debug("Printing %d pages..." % number_of_pages)
+        self.text_to_print = self.text_to_print.split("\n")
+        return
+
+    def draw_page(self, operation, context, page_number):
+        """ Render the QSO details on the page.
+
+        :arg Gtk.PrintOperation operation: The printing API.
+        :arg Gtk.PrintContext context: Used to draw/render the pages to print.
+        :arg int page_number: The current page number.
+        """
+        cr = context.get_cairo_context()
+        cr.set_source_rgb(0, 0, 0)
+        layout = context.create_pango_layout()
+        layout.set_font_description(Pango.FontDescription("monospace expanded 10"))
+        layout.set_width(int(context.get_width()*Pango.SCALE))
+
+        current_line_number = 1
+        for line in self.text_to_print:
+            layout.set_text(line, -1)
+            cr.move_to(5, current_line_number*self.line_height)
+            PangoCairo.update_layout(cr, layout)
+            PangoCairo.show_layout(cr, layout)
+            current_line_number += 1
+            if((current_line_number+1)*self.line_height >= context.get_height()):
+                for j in range(0, current_line_number-1):
+                    self.text_to_print.pop(0)  # Remove what has been printed already before draw_page is called again.
+                break
+
+        return
diff --git a/pyqso/record_dialog.py b/pyqso/record_dialog.py
index 4b934a3..4c9d383 100644
--- a/pyqso/record_dialog.py
+++ b/pyqso/record_dialog.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,9 +17,13 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk
+from gi.repository import Gtk, Gdk
 import logging
-import configparser
+import os
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 from datetime import datetime
 from os.path import expanduser
 import base64
@@ -33,337 +37,135 @@ except ImportError:
 from pyqso.adif import *
 from pyqso.callsign_lookup import *
 from pyqso.auxiliary_dialogs import *
+from pyqso.calendar_dialog import CalendarDialog
 
 
-class RecordDialog(Gtk.Dialog):
+class RecordDialog:
 
     """ A dialog through which users can enter information about a QSO/record. """
 
-    def __init__(self, parent, log, index=None):
+    def __init__(self, application, log, index=None):
         """ Set up the layout of the record dialog, populate the various fields with the QSO details (if the record already exists), and show the dialog to the user.
 
-        :arg parent: The parent Gtk window.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         :arg log: The log to which the record belongs (or will belong).
         :arg int index: If specified, then the dialog turns into 'edit record mode' and fills the data sources (e.g. the Gtk.Entry boxes) with the existing data in the log. If not specified (i.e. index is None), then the dialog starts off with nothing in the data sources.
         """
 
         logging.debug("Setting up the record dialog...")
 
+        self.application = application
+        self.builder = self.application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("record_dialog",))
+        self.dialog = self.builder.get_object("record_dialog")
+        self.builder.get_object("record_dialog").connect("key-press-event", self.on_key_press)
+
+        # Set dialog title
         if(index is not None):
-            title = "Edit Record %d" % index
+            self.dialog.set_title("Edit Record %d" % index)
         else:
-            title = "Add Record"
-        Gtk.Dialog.__init__(self, title=title, parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
+            self.dialog.set_title("Add Record")
 
         # Check if a configuration file is present, since we might need it to set up the rest of the dialog.
         config = configparser.ConfigParser()
         have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
 
-        # QSO DATA FRAME
-        qso_frame = Gtk.Frame()
-        qso_frame.set_label("QSO Information")
-        self.vbox.add(qso_frame)
-
-        hbox_inner = Gtk.HBox(spacing=2)
-
-        vbox_inner = Gtk.VBox(spacing=2)
-        hbox_inner.pack_start(vbox_inner, True, True, 2)
-
         # Create label:entry pairs and store them in a dictionary
         self.sources = {}
 
+        # QSO INFORMATION
+
         # CALL
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["CALL"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["CALL"] = Gtk.Entry()
-        self.sources["CALL"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["CALL"], False, False, 2)
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.MENU)
-        button = Gtk.Button()
-        button.add(icon)
-        button.connect("clicked", self.lookup_callback)  # Looks up the callsign using an online database, for callsign and station information.
-        button.set_tooltip_text("Callsign lookup")
-        hbox_temp.pack_start(button, True, True, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["CALL"] = self.builder.get_object("qso_call_entry")
+        self.builder.get_object("callsign_lookup").connect("clicked", self.callsign_lookup_callback)
 
         # DATE
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["QSO_DATE"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["QSO_DATE"] = Gtk.Entry()
-        self.sources["QSO_DATE"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["QSO_DATE"], False, False, 2)
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU)
-        button = Gtk.Button()
-        button.add(icon)
-        button.connect("clicked", self.calendar_callback)
-        button.set_tooltip_text("Select date from calendar")
-        hbox_temp.pack_start(button, True, True, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["QSO_DATE"] = self.builder.get_object("qso_date_entry")
+        self.builder.get_object("select_date").connect("clicked", self.calendar_callback)
 
         # TIME
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["TIME_ON"], halign=Gtk.Align.START)
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["TIME_ON"] = Gtk.Entry()
-        self.sources["TIME_ON"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["TIME_ON"], False, False, 2)
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.MENU)
-        button = Gtk.Button()
-        button.add(icon)
-        button.connect("clicked", self.set_current_datetime_callback)
-        button.set_tooltip_text("Use the current time and date")
-        hbox_temp.pack_start(button, True, True, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["TIME_ON"] = self.builder.get_object("qso_time_entry")
+        self.builder.get_object("current_datetime").connect("clicked", self.set_current_datetime_callback)
 
         # FREQ
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["FREQ"], halign=Gtk.Align.START)
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["FREQ"] = Gtk.Entry()
-        self.sources["FREQ"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["FREQ"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["FREQ"] = self.builder.get_object("qso_frequency_entry")
+        (section, option) = ("records", "default_frequency_unit")
+        if(have_config and config.has_option(section, option)):
+            self.frequency_unit = config.get(section, option)
+            self.builder.get_object("qso_frequency_label").set_label("Frequency (%s)" % self.frequency_unit)
+        else:
+            self.frequency_unit = "MHz"
 
         # BAND
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["BAND"], halign=Gtk.Align.START)
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["BAND"] = Gtk.ComboBoxText()
+        self.sources["BAND"] = self.builder.get_object("qso_band_combo")
         for band in BANDS:
             self.sources["BAND"].append_text(band)
         self.sources["BAND"].set_active(0)  # Set an empty string as the default option.
-        hbox_temp.pack_start(self.sources["BAND"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
 
         # MODE
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["MODE"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["MODE"] = Gtk.ComboBoxText()
+        self.sources["MODE"] = self.builder.get_object("qso_mode_combo")
         for mode in sorted(MODES.keys()):
             self.sources["MODE"].append_text(mode)
         self.sources["MODE"].set_active(0)  # Set an empty string as the default option.
-        self.sources["MODE"].connect("changed", self._on_mode_changed)
-        hbox_temp.pack_start(self.sources["MODE"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["MODE"].connect("changed", self.on_mode_changed)
 
         # SUBMODE
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["SUBMODE"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-
-        self.sources["SUBMODE"] = Gtk.ComboBoxText()
+        self.sources["SUBMODE"] = self.builder.get_object("qso_submode_combo")
         self.sources["SUBMODE"].append_text("")
         self.sources["SUBMODE"].set_active(0)  # Set an empty string initially. As soon as the user selects a particular MODE, the available SUBMODES will appear.
-        hbox_temp.pack_start(self.sources["SUBMODE"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
 
         # POWER
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["TX_PWR"], halign=Gtk.Align.START)
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["TX_PWR"] = Gtk.Entry()
-        self.sources["TX_PWR"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["TX_PWR"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
-
-        vbox_inner = Gtk.VBox(spacing=2)
-        hbox_inner.pack_start(Gtk.SeparatorToolItem(), False, False, 0)
-        hbox_inner.pack_start(vbox_inner, True, True, 2)
+        self.sources["TX_PWR"] = self.builder.get_object("qso_power_entry")
 
         # RST_SENT
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["RST_SENT"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["RST_SENT"] = Gtk.Entry()
-        self.sources["RST_SENT"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["RST_SENT"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["RST_SENT"] = self.builder.get_object("qso_rst_sent_entry")
 
         # RST_RCVD
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["RST_RCVD"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["RST_RCVD"] = Gtk.Entry()
-        self.sources["RST_RCVD"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["RST_RCVD"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["RST_RCVD"] = self.builder.get_object("qso_rst_received_entry")
 
         # QSL_SENT
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["QSL_SENT"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        qsl_options = ["", "Y", "N", "R", "I"]
-        self.sources["QSL_SENT"] = Gtk.ComboBoxText()
-        for option in qsl_options:
+        self.sources["QSL_SENT"] = self.builder.get_object("qso_qsl_sent_combo")
+        qsl_sent_options = ["", "Y", "N", "R", "Q", "I"]
+        for option in qsl_sent_options:
             self.sources["QSL_SENT"].append_text(option)
         self.sources["QSL_SENT"].set_active(0)  # Set an empty string as the default option.
-        hbox_temp.pack_start(self.sources["QSL_SENT"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
 
         # QSL_RCVD
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["QSL_RCVD"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        qsl_options = ["", "Y", "N", "R", "I"]
-        self.sources["QSL_RCVD"] = Gtk.ComboBoxText()
-        for option in qsl_options:
+        self.sources["QSL_RCVD"] = self.builder.get_object("qso_qsl_received_combo")
+        qsl_rcvd_options = ["", "Y", "N", "R", "I", "V"]
+        for option in qsl_rcvd_options:
             self.sources["QSL_RCVD"].append_text(option)
         self.sources["QSL_RCVD"].set_active(0)  # Set an empty string as the default option.
-        hbox_temp.pack_start(self.sources["QSL_RCVD"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
 
         # NOTES
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["NOTES"])
-        label.set_alignment(0, 0.5)
-        label.set_width_chars(15)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.textview = Gtk.TextView()
-        sw = Gtk.ScrolledWindow()
-        sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
-        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
-        sw.add(self.textview)
-        self.sources["NOTES"] = self.textview.get_buffer()
-        hbox_temp.pack_start(sw, True, True, 2)
-        vbox_inner.pack_start(hbox_temp, True, True, 2)
-
-        qso_frame.add(hbox_inner)
-
-        # STATION INFORMATION FRAME
-        station_frame = Gtk.Frame()
-        station_frame.set_label("Station Information")
-        self.vbox.add(station_frame)
-
-        hbox_inner = Gtk.HBox(spacing=2)
-
-        vbox_inner = Gtk.VBox(spacing=2)
-        hbox_inner.pack_start(vbox_inner, True, True, 2)
+        self.sources["NOTES"] = self.builder.get_object("qso_notes_textview").get_buffer()
+
+        # STATION INFORMATION
 
         # NAME
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["NAME"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["NAME"] = Gtk.Entry()
-        self.sources["NAME"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["NAME"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["NAME"] = self.builder.get_object("station_name_entry")
 
         # ADDRESS
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["ADDRESS"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["ADDRESS"] = Gtk.Entry()
-        self.sources["ADDRESS"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["ADDRESS"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["ADDRESS"] = self.builder.get_object("station_address_entry")
 
         # STATE
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["STATE"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["STATE"] = Gtk.Entry()
-        self.sources["STATE"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["STATE"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["STATE"] = self.builder.get_object("station_state_entry")
 
         # COUNTRY
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["COUNTRY"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["COUNTRY"] = Gtk.Entry()
-        self.sources["COUNTRY"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["COUNTRY"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
-
-        vbox_inner = Gtk.VBox(spacing=2)
-        hbox_inner.pack_start(Gtk.SeparatorToolItem(), False, False, 0)
-        hbox_inner.pack_start(vbox_inner, True, True, 2)
+        self.sources["COUNTRY"] = self.builder.get_object("station_country_entry")
 
         # DXCC
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["DXCC"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["DXCC"] = Gtk.Entry()
-        self.sources["DXCC"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["DXCC"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["DXCC"] = self.builder.get_object("station_dxcc_entry")
 
         # CQZ
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["CQZ"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["CQZ"] = Gtk.Entry()
-        self.sources["CQZ"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["CQZ"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["CQZ"] = self.builder.get_object("station_cq_entry")
 
         # ITUZ
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["ITUZ"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["ITUZ"] = Gtk.Entry()
-        self.sources["ITUZ"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["ITUZ"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
+        self.sources["ITUZ"] = self.builder.get_object("station_itu_entry")
 
         # IOTA
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label(AVAILABLE_FIELD_NAMES_FRIENDLY["IOTA"], halign=Gtk.Align.START)
-        label.set_width_chars(15)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 2)
-        self.sources["IOTA"] = Gtk.Entry()
-        self.sources["IOTA"].set_width_chars(15)
-        hbox_temp.pack_start(self.sources["IOTA"], False, False, 2)
-        vbox_inner.pack_start(hbox_temp, False, False, 2)
-
-        station_frame.add(hbox_inner)
+        self.sources["IOTA"] = self.builder.get_object("station_iota_entry")
 
         # Populate various fields, if possible.
         if(index is not None):
@@ -376,21 +178,23 @@ class RecordDialog(Gtk.Dialog):
                     data = ""
                 if(field_names[i] == "BAND"):
                     self.sources[field_names[i]].set_active(BANDS.index(data))
+                elif(field_names[i] == "FREQ" and self.frequency_unit != "MHz"):
+                    converted = self.convert_frequency(data, from_unit="MHz", to_unit=self.frequency_unit)
+                    self.sources[field_names[i]].set_text(str(converted))
                 elif(field_names[i] == "MODE"):
                     self.sources[field_names[i]].set_active(sorted(MODES.keys()).index(data))
-
+                    # Handle SUBMODE at the same time.
                     submode_data = record["submode"]
                     if(submode_data is None):
                         submode_data = ""
                     self.sources["SUBMODE"].set_active(MODES[data].index(submode_data))
                 elif(field_names[i] == "SUBMODE"):
+                    # Skip, because this has been (or will be) handled when populating the MODE field.
                     continue
-                elif(field_names[i] == "QSL_SENT" or field_names[i] == "QSL_RCVD"):
-                    self.sources[field_names[i]].set_active(qsl_options.index(data))
-                elif(field_names[i] == "NOTES"):
-                    # Remember to put the new line escape characters back in when displaying the data in a Gtk.TextView
-                    text = data.replace("\\n", "\n")
-                    self.sources[field_names[i]].set_text(text)
+                elif(field_names[i] == "QSL_SENT"):
+                    self.sources[field_names[i]].set_active(qsl_sent_options.index(data))
+                elif(field_names[i] == "QSL_RCVD"):
+                    self.sources[field_names[i]].set_active(qsl_rcvd_options.index(data))
                 else:
                     self.sources[field_names[i]].set_text(data)
         else:
@@ -422,36 +226,26 @@ class RecordDialog(Gtk.Dialog):
                 power = ""
             self.sources["TX_PWR"].set_text(power)
 
+            # If the Hamlib module is present, then use it to fill in various fields if desired.
             if(have_hamlib):
-                # If the Hamlib module is present, then use it to fill in the Frequency field if desired.
                 if(have_config and config.has_option("hamlib", "autofill") and config.has_option("hamlib", "rig_model") and config.has_option("hamlib", "rig_pathname")):
-                    autofill = (config.get("hamlib", "autofill") == "True")
+                    autofill = (config.getboolean("hamlib", "autofill"))
                     rig_model = config.get("hamlib", "rig_model")
                     rig_pathname = config.get("hamlib", "rig_pathname")
                     if(autofill):
-                        # Use Hamlib (if available) to get the frequency
-                        try:
-                            Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
-                            rig = Hamlib.Rig(Hamlib.__dict__[rig_model])  # Look up the model's numerical index in Hamlib's symbol dictionary
-                            rig.set_conf("rig_pathname", rig_pathname)
-                            rig.open()
-                            frequency = "%.6f" % (rig.get_freq()/1.0e6)  # Converting to MHz here
-                            self.sources["FREQ"].set_text(frequency)
-                            rig.close()
-                        except:
-                            logging.error("Could not obtain Frequency data via Hamlib!")
+                        self.hamlib_autofill(rig_model, rig_pathname)
 
         # Do we want PyQSO to autocomplete the Band field based on the Frequency field?
         (section, option) = ("records", "autocomplete_band")
-        if(have_config and config.get(section, option)):
-            autocomplete_band = (config.get(section, option) == "True")
+        if(have_config and config.has_option(section, option)):
+            autocomplete_band = (config.getboolean(section, option))
             if(autocomplete_band):
-                self.sources["FREQ"].connect("changed", self._autocomplete_band)
+                self.sources["FREQ"].connect("changed", self.autocomplete_band)
         else:
             # If no configuration file exists, autocomplete the Band field by default.
-            self.sources["FREQ"].connect("changed", self._autocomplete_band)
+            self.sources["FREQ"].connect("changed", self.autocomplete_band)
 
-        self.show_all()
+        self.dialog.show_all()
 
         logging.debug("Record dialog ready!")
 
@@ -468,6 +262,9 @@ class RecordDialog(Gtk.Dialog):
         if(field_name == "CALL"):
             # Always show the callsigns in upper case.
             return self.sources[field_name].get_text().upper()
+        elif(field_name == "FREQ" and self.frequency_unit != "MHz"):
+            converted = self.convert_frequency(self.sources[field_name].get_text(), from_unit=self.frequency_unit, to_unit="MHz")
+            return str(converted)
         elif(field_name == "MODE"):
             return self.sources["MODE"].get_active_text()
         elif(field_name == "SUBMODE"):
@@ -477,25 +274,31 @@ class RecordDialog(Gtk.Dialog):
         elif(field_name == "NOTES"):
             (start, end) = self.sources[field_name].get_bounds()
             text = self.sources[field_name].get_text(start, end, True)
-            # Replace the escape characters with a slightly different new line marker.
-            # If we don't do this, the rows in the Gtk.TreeView expand based on the number of new lines.
-            text = text.replace("\n", "\\n")
             return text
         else:
             return self.sources[field_name].get_text()
 
-    def _on_mode_changed(self, combo):
+    def on_mode_changed(self, combo):
         """ If the MODE field has changed its value, then fill the SUBMODE field with all the available SUBMODE options for that new MODE. """
         self.sources["SUBMODE"].get_model().clear()
-        text = combo.get_active_text()
-        for submode in MODES[text]:
+        mode = combo.get_active_text()
+        for submode in MODES[mode]:
             self.sources["SUBMODE"].append_text(submode)
+        self.sources["SUBMODE"].set_active(MODES[mode].index(""))  # Set the submode to an empty string.
         return
 
-    def _autocomplete_band(self, widget=None):
+    def on_key_press(self, widget, event):
+        """ If the Return key is pressed, emit the "OK" response to record the QSO. """
+        child = widget.get_focus()
+        if(not(isinstance(child, Gtk.ToggleButton) or isinstance(child, Gtk.Button) or isinstance(child, Gtk.TextView)) and event.keyval == Gdk.KEY_Return):
+            self.dialog.emit('response', Gtk.ResponseType.OK)
+        return
+
+    def autocomplete_band(self, widget=None):
         """ If a value for the Frequency is entered, this function autocompletes the Band field. """
 
         frequency = self.sources["FREQ"].get_text()
+
         # Check whether we actually have a (valid) value to use. If not, set the BAND field to an empty string ("").
         try:
             frequency = float(frequency)
@@ -503,6 +306,10 @@ class RecordDialog(Gtk.Dialog):
             self.sources["BAND"].set_active(0)
             return
 
+        # Convert to MHz if necessary.
+        if(self.frequency_unit != "MHz"):
+            frequency = self.convert_frequency(frequency, from_unit=self.frequency_unit, to_unit="MHz")
+
         # Find which band the frequency lies in.
         for i in range(1, len(BANDS)):
             if(frequency >= BANDS_RANGES[i][0] and frequency <= BANDS_RANGES[i][1]):
@@ -512,7 +319,57 @@ class RecordDialog(Gtk.Dialog):
         self.sources["BAND"].set_active(0)  # If we've reached this, then the frequency does not lie in any of the specified bands.
         return
 
-    def lookup_callback(self, widget=None):
+    def hamlib_autofill(self, rig_model, rig_pathname):
+        """ Set the various fields using data from the radio via Hamlib.
+
+        :arg str rig_model: The model of the radio/rig.
+        :arg str rig_pathname: The path to the rig (or rig control device).
+        """
+
+        # Open a communication channel to the radio.
+        try:
+            Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
+            rig = Hamlib.Rig(Hamlib.__dict__[rig_model])  # Look up the model's numerical index in Hamlib's symbol dictionary.
+            rig.set_conf("rig_pathname", rig_pathname)
+            rig.open()
+        except:
+            logging.error("Could not open a communication channel to the rig via Hamlib!")
+            return
+
+        # Frequency
+        try:
+            frequency = "%.6f" % (rig.get_freq()/1.0e6)  # Converting to MHz here.
+            # Convert to the desired unit, if necessary.
+            if(self.frequency_unit != "MHz"):
+                frequency = str(self.convert_frequency(frequency, from_unit="MHz", to_unit=self.frequency_unit))
+            self.sources["FREQ"].set_text(frequency)
+        except:
+            logging.error("Could not obtain the current frequency via Hamlib!")
+
+        # Mode
+        try:
+            (mode, width) = rig.get_mode()
+            mode = Hamlib.rig_strrmode(mode).upper()
+            # Handle USB and LSB as special cases.
+            if(mode == "USB" or mode == "LSB"):
+                submode = mode
+                mode = "SSB"
+                self.sources["MODE"].set_active(sorted(MODES.keys()).index(mode))
+                self.sources["SUBMODE"].set_active(MODES[mode].index(submode))
+            else:
+                self.sources["MODE"].set_active(sorted(MODES.keys()).index(mode))
+        except:
+            logging.error("Could not obtain the current mode (e.g. FM, AM, CW) via Hamlib!")
+
+        # Close communication channel.
+        try:
+            rig.close()
+        except:
+            logging.error("Could not close the communication channel to the rig via Hamlib!")
+
+        return
+
+    def callsign_lookup_callback(self, widget=None):
         """ Get the callsign-related data from an online database and store it in the relevant Gtk.Entry boxes, but return None. """
 
         # Get the database name.
@@ -526,48 +383,55 @@ class RecordDialog(Gtk.Dialog):
             else:
                 raise ValueError
         except ValueError:
-            error(parent=self, message="To perform a callsign lookup, please specify the name of the callsign database in the Preferences.")
+            error(parent=self.dialog, message="To perform a callsign lookup, please specify the name of the callsign database in the Preferences.")
             return
 
         try:
             if(database == "qrz.com"):
                 # QRZ.com
-                callsign_lookup = CallsignLookupQRZ(parent=self)
+                callsign_lookup = CallsignLookupQRZ(parent=self.dialog)
             elif(database == "hamqth.com"):
-                # HamQTH
-                callsign_lookup = CallsignLookupHamQTH(parent=self)
+                # HamQTH.com
+                callsign_lookup = CallsignLookupHamQTH(parent=self.dialog)
             else:
                 raise ValueError("Unknown callsign database: %s" % database)
         except ValueError as e:
             logging.exception(e)
-            error(e)
+            error(parent=self.dialog, message=e)
             return
 
-        # Get username and password from configuration file
+        # Get username and password from configuration file.
         if(have_config and config.has_option("records", "callsign_database_username") and config.has_option("records", "callsign_database_password")):
             username = config.get("records", "callsign_database_username")
             password = base64.b64decode(config.get("records", "callsign_database_password")).decode("utf-8")
-            if(username == "" or password == ""):
+            if(not username or not password):
                 details_given = False
             else:
                 details_given = True
         else:
             details_given = False
         if(not details_given):
-            error(parent=self, message="To perform a callsign lookup, please specify your username and password in the Preferences.")
+            error(parent=self.dialog, message="To perform a callsign lookup, please specify your username and password in the Preferences.")
             return
 
-        # Connect and look up
+        # Get the callsign from the CALL field.
+        full_callsign = self.sources["CALL"].get_text()
+        if(not full_callsign):
+            # Empty callsign field.
+            error(parent=self.dialog, message="Please enter a callsign to lookup.")
+            return
+
+        # Connect to the database.
         connected = callsign_lookup.connect(username, password)
         if(connected):
-            full_callsign = self.sources["CALL"].get_text()
             # Check whether we want to ignore any prefixes (e.g. "IA/") or suffixes "(e.g. "/M") in the callsign
             # before performing the lookup.
             if(have_config and config.has_option("records", "ignore_prefix_suffix")):
-                ignore_prefix_suffix = (config.get("records", "ignore_prefix_suffix") == "True")
+                ignore_prefix_suffix = (config.getboolean("records", "ignore_prefix_suffix"))
             else:
                 ignore_prefix_suffix = True
 
+            # Perform the lookup.
             fields_and_data = callsign_lookup.lookup(full_callsign, ignore_prefix_suffix=ignore_prefix_suffix)
             for field_name in list(fields_and_data.keys()):
                 self.sources[field_name].set_text(fields_and_data[field_name])
@@ -575,12 +439,11 @@ class RecordDialog(Gtk.Dialog):
 
     def calendar_callback(self, widget):
         """ Open up a calendar widget for easy QSO_DATE selection. Return None after the user destroys the dialog. """
-        calendar = CalendarDialog(parent=self)
-        response = calendar.run()
+        c = CalendarDialog(self.application)
+        response = c.dialog.run()
         if(response == Gtk.ResponseType.OK):
-            date = calendar.get_date()
-            self.sources["QSO_DATE"].set_text(date)
-        calendar.destroy()
+            self.sources["QSO_DATE"].set_text(c.date)
+        c.dialog.destroy()
         return
 
     def set_current_datetime_callback(self, widget=None):
@@ -593,7 +456,7 @@ class RecordDialog(Gtk.Dialog):
         # Do we want to use UTC or the computer's local time?
         (section, option) = ("records", "use_utc")
         if(have_config and config.has_option(section, option)):
-            use_utc = (config.get(section, option) == "True")
+            use_utc = (config.getboolean(section, option))
             if(use_utc):
                 dt = datetime.utcnow()
             else:
@@ -606,38 +469,38 @@ class RecordDialog(Gtk.Dialog):
 
         return
 
+    def convert_frequency(self, frequency, from_unit, to_unit):
+        """ Convert a frequency from one unit to another.
 
-class CalendarDialog(Gtk.Dialog):
-
-    """ A simple dialog containing a Gtk.Calendar widget. Using this ensures the date is in the correct YYYYMMDD format required by ADIF. """
-
-    def __init__(self, parent):
-        """ Set up the calendar widget and show it to the user.
-
-        :arg parent: The parent Gtk window/dialog.
-        """
-        logging.debug("Setting up a calendar dialog...")
-        Gtk.Dialog.__init__(self, title="Select Date", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
-        self.calendar = Gtk.Calendar()
-        self.vbox.add(self.calendar)
-        self.show_all()
-        logging.debug("Calendar dialog ready!")
-        return
-
-    def get_date(self):
-        """ Return the date from the Gtk.Calendar widget in YYYYMMDD format.
-
-        :returns: The date from the calendar in YYYYMMDD format.
-        :rtype: str
+        :arg float frequency: The frequency to convert.
+        :arg str from_unit: The current unit of the frequency.
+        :arg str to_unit: The desired unit of the frequency.
+        :rtype: float
+        :returns: The frequency in the to_unit.
         """
-        logging.debug("Retrieving the date from the calendar widget...")
-        (year, month, day) = self.calendar.get_date()
-        # If necessary, add on leading zeros so the YYYYMMDD format is followed.
-        if(month + 1 < 10):
-            month = "0" + str(month + 1)  # Note: the months start from an index of 0 when retrieved from the calendar widget.
-        else:
-            month += 1
-        if(day < 10):
-            day = "0" + str(day)
-        date = str(year) + str(month) + str(day)
-        return date
+        scaling = {"Hz": 1, "kHz": 1e3, "MHz": 1e6, "GHz": 1e9}
+        # Check that the from/to frequency units are valid.
+        try:
+            if(from_unit not in scaling.keys()):
+                raise ValueError("Unknown frequency unit '%s' in from_unit" % from_unit)
+            if(to_unit not in scaling.keys()):
+                raise ValueError("Unknown frequency unit '%s' in to_unit" % to_unit)
+        except ValueError as e:
+            logging.exception(e)
+            return frequency
+        # Cast to float before scaling.
+        if(not isinstance(frequency, float)):
+            try:
+                if(frequency == "" or frequency is None):
+                    return frequency
+                else:
+                    frequency = float(frequency)
+            except(ValueError, TypeError):
+                logging.exception("Could not convert frequency to a floating-point value.")
+                return frequency
+        # Do not bother scaling if the units are the same.
+        if(from_unit == to_unit):
+            return frequency
+
+        coefficient = scaling[from_unit]/scaling[to_unit]
+        return float("%.6f" % (coefficient*frequency))
diff --git a/icons/log_1024x1024.xcf b/pyqso/res/log_1024x1024.xcf
similarity index 100%
rename from icons/log_1024x1024.xcf
rename to pyqso/res/log_1024x1024.xcf
diff --git a/icons/log_14x14.png b/pyqso/res/log_14x14.png
similarity index 100%
rename from icons/log_14x14.png
rename to pyqso/res/log_14x14.png
diff --git a/icons/log_192x192.png b/pyqso/res/log_192x192.png
similarity index 100%
rename from icons/log_192x192.png
rename to pyqso/res/log_192x192.png
diff --git a/icons/log_64x64.png b/pyqso/res/log_64x64.png
similarity index 100%
rename from icons/log_64x64.png
rename to pyqso/res/log_64x64.png
diff --git a/pyqso/res/pyqso.glade b/pyqso/res/pyqso.glade
new file mode 100644
index 0000000..8e809fc
--- /dev/null
+++ b/pyqso/res/pyqso.glade
@@ -0,0 +1,4429 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkImage" id="image1">
+    <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="image29">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-go-back</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="image30">
+    <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="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>
+    <property name="title" translatable="yes">PyQSO</property>
+    <property name="window_position">center</property>
+    <property name="default_width">800</property>
+    <property name="default_height">600</property>
+    <property name="icon">log_64x64.png</property>
+    <child>
+      <object class="GtkBox" id="vbox_outer">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkMenuBar" id="menu">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkMenuItem" id="mitem_logbook">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Logbook</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="subm_logbook">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mitem_new_logbook">
+                        <property name="label" translatable="yes">Create a New Logbook...</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="image">image3</property>
+                        <property name="use_stock">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mitem_open_logbook">
+                        <property name="label" translatable="yes">Open an Existing Logbook...</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="image">image2</property>
+                        <property name="use_stock">False</property>
+                        <accelerator key="o" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mitem_close_logbook">
+                        <property name="label" translatable="yes">Close Logbook</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="image">image1</property>
+                        <property name="use_stock">False</property>
+                        <accelerator key="w" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mitem_new_log">
+                        <property name="label" translatable="yes">New Log...</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="image">image30</property>
+                        <property name="use_stock">False</property>
+                        <accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+                      </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="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="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_adif">
+                        <property name="label" translatable="yes">Export Log as ADIF...</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="GtkImageMenuItem" id="mitem_export_log_cabrillo">
+                        <property name="label" translatable="yes">Export Log as Cabrillo...</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="image">image29</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_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>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem6">
+                        <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>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mitem_records">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Records</property>
+                <child type="submenu">
+                  <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>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkMenuItem" id="mitem_record_count">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Record Count</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mitem_view">
+                <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>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mitem_help">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Help</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="subm_help">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <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="image">image13</property>
+                        <property name="use_stock">False</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="toolbar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">2</property>
+            <child>
+              <object class="GtkButton" id="toolbar_new_logbook">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Create a New Logbook</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image19">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-new</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="toolbar_open_logbook">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Open an Existing Logbook</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image20">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-open</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="toolbar_close_logbook">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Close Logbook</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image21">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-close</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="toolbar_add_record">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Add Record</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image22">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-add</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="toolbar_edit_record">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Edit Record</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image23">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-edit</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="toolbar_delete_record">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Delete Record</property>
+                <property name="always_show_image">True</property>
+                <child>
+                  <object class="GtkImage" id="image24">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-delete</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">6</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">5</property>
+                <property name="position">7</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="filter_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Filter by callsign: </property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">8</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="filter_source">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Only show QSOs with a given callsign. For example, if XYZ is entered, only the QSOs whose callsign contains XYZ will be displayed in the logbook.</property>
+                <property name="width_chars">11</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">9</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkPaned" id="paned">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkNotebook" id="logbook">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="scrollable">True</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">True</property>
+                <property name="shrink">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="toolbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <child>
+                  <object class="GtkAlignment" id="toolbox_alignment">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkNotebook" id="tools">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <child>
+                          <object class="GtkBox" id="dx_cluster">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkMenuBar" id="dx_cluster_menu">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkMenuItem" id="mitem_connection">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Connection</property>
+                                    <child type="submenu">
+                                      <object class="GtkMenu" id="connection_menu">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkImageMenuItem" id="mitem_connect">
+                                            <property name="label" translatable="yes">Connect to Telnet Server</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="image">image5</property>
+                                            <property name="use_stock">False</property>
+                                            <child type="submenu">
+                                              <object class="GtkMenu" id="subm_connect">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <child>
+                                                  <object class="GtkMenuItem" id="mitem_new">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="label" translatable="yes">New...</property>
+                                                  </object>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkMenuItem" id="mitem_bookmark ">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="label" translatable="yes">From Bookmark</property>
+                                                    <child type="submenu">
+                                                      <object class="GtkMenu" id="subm_bookmarks">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </object>
+                                                    </child>
+                                                  </object>
+                                                </child>
+                                              </object>
+                                            </child>
+                                          </object>
+                                        </child>
+                                        <child>
+                                          <object class="GtkImageMenuItem" id="mitem_disconnect">
+                                            <property name="label" translatable="yes">Disconnect from Telnet Server</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="image">image6</property>
+                                            <property name="use_stock">False</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkScrolledWindow" id="sw">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="shadow_type">etched-in</property>
+                                <child>
+                                  <object class="GtkTextView" id="renderer">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="editable">False</property>
+                                    <property name="cursor_visible">False</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="commandbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkEntry" id="command">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="tooltip_text" translatable="yes">The command to send to the DX cluster. For example, HELP or SHOW/DX.</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="send">
+                                    <property name="label" translatable="yes">Send Command</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                        <child type="tab">
+                          <object class="GtkLabel" id="dxcluster_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">DX Cluster</property>
+                          </object>
+                          <packing>
+                            <property name="tab_fill">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="greyline">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child type="tab">
+                          <object class="GtkLabel" id="greyline_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Grey Line</property>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                            <property name="tab_fill">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="awards">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkLabel" id="dxcc_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="margin_left">4</property>
+                                <property name="label" translatable="yes"><span size="x-large">DXCC Award</span></property>
+                                <property name="use_markup">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="padding">4</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child type="tab">
+                          <object class="GtkLabel" id="awards_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Awards</property>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                            <property name="tab_fill">False</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="toolbox_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Toolbox</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">True</property>
+                <property name="shrink">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkStatusbar" id="statusbar">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">10</property>
+            <property name="margin_right">10</property>
+            <property name="margin_top">6</property>
+            <property name="margin_bottom">6</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">2</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkAboutDialog" id="about_dialog">
+    <property name="can_focus">False</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <property name="program_name">PyQSO</property>
+    <property name="version">1.0.0</property>
+    <property name="copyright" translatable="yes">Copyright (C) 2012-2017 Christian Thomas Jacobs</property>
+    <property name="comments" translatable="yes">A contact logging tool for amateur radio operators.</property>
+    <property name="website">http://christianjacobs.uk/pyqso</property>
+    <property name="license" translatable="yes">This program 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.
+
+This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.</property>
+    <property name="authors">Christian Thomas Jacobs, M0UOS</property>
+    <property name="logo">log_64x64.png</property>
+    <property name="license_type">custom</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="about_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="about_dialog_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkDialog" id="cabrillo_export_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Cabrillo Export</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="cabrillo_export_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="cabrillo_export_dialog_action_area">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cabrillo_export_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cabrillo_export_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="cabrillo_export_contest_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="cabrillo_export_contest_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Contest</property>
+                <property name="width_chars">12</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBoxText" id="cabrillo_export_contest_combo">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="has_entry">True</property>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="cabrillo_export_contest_combo_entry">
+                    <property name="can_focus">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="cabrillo_export_mycall_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="cabrillo_export_mycall_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">My Callsign</property>
+                <property name="width_chars">12</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="cabrillo_export_mycall_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cabrillo_export_cancel_button</action-widget>
+      <action-widget response="-5">cabrillo_export_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="log_name_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">New Log</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="log_name_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="log_name_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="log_name_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="log_name_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="log_name_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="log_name_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Log Name</property>
+                <property name="width_chars">12</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">2</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="log_name_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">log_name_cancel_button</action-widget>
+      <action-widget response="-5">log_name_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="preferences_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Preferences</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="preferences_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="preferences_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="preferences_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="preferences_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkNotebook" id="preferences">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <child>
+              <object class="GtkBox" id="preferences_general_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">2</property>
+                <child>
+                  <object class="GtkFrame" id="preferences_general_startup">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_general_startup_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_general_startup_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkCheckButton" id="general_show_toolbox_checkbutton">
+                                <property name="label" translatable="yes">Show toolbox by default</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="general_show_yearly_statistics_checkbutton">
+                                <property name="label" translatable="yes">Show yearly logbook statistics on the Summary page</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="general_default_logbook_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">3</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="general_default_logbook_checkbutton">
+                                    <property name="label" translatable="yes">Open a default logbook</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="general_default_logbook_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="tooltip_text" translatable="yes">The absolute path to the logbook database file.</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="general_default_logbook_button">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="tooltip_text" translatable="yes">Choose the default logbook file</property>
+                                    <property name="always_show_image">True</property>
+                                    <child>
+                                      <object class="GtkImage" id="image31">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-open</property>
+                                        <property name="icon_size">1</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_general_startup_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Startup</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="preferences_general_dialogs">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_general_dialogs_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_general_dialogs_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkBox" id="general_keep_open_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="general_keep_open_checkbutton">
+                                    <property name="label" translatable="yes">Keep the Add Record dialog open after a QSO is added</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="tooltip_text" translatable="yes">Allows multiple QSOs to be entered in quick succession. Especially useful for contest stations or special event stations where pileups may be expected.</property>
+                                    <property name="xalign">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_general_dialogs_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Dialogs</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="preferences_general_qth">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_general_qth_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_general_qth_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkCheckButton" id="general_show_qth_checkbutton">
+                                <property name="label" translatable="yes">Pin-point QTH on grey line map</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="general_qth_name_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkLabel" id="general_qth_name_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Name</property>
+                                    <property name="width_chars">10</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="general_qth_name_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="tooltip_text" translatable="yes">This might be the name of the city or road in which your radio station is located.</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="general_qth_lookup">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="tooltip_text" translatable="yes">Lookup the latitude-longitude coordinates for the QTH based on the QTH's name</property>
+                                    <property name="always_show_image">True</property>
+                                    <child>
+                                      <object class="GtkImage" id="image25">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-info</property>
+                                        <property name="icon_size">1</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="general_qth_coordinates_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkLabel" id="general_qth_coordinates_latitude_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Latitude</property>
+                                    <property name="width_chars">10</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="general_qth_coordinates_latitude_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="general_qth_coordinates_longitude_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Longitude</property>
+                                    <property name="width_chars">10</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="general_qth_coordinates_longitude_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_general_qth_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">QTH</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="preferences_general_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">General</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="preferences_view_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">2</property>
+                <child>
+                  <object class="GtkFrame" id="preferences_view_visible_fields">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_view_visible_fields_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_view_visible_fields_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">2</property>
+                            <property name="homogeneous">True</property>
+                            <child>
+                              <object class="GtkBox" id="preferences_view_visible_fields_vbox1">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="orientation">vertical</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_call">
+                                    <property name="label" translatable="yes">Callsign</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_qso_date">
+                                    <property name="label" translatable="yes">Date</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_time_on">
+                                    <property name="label" translatable="yes">Time</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_freq">
+                                    <property name="label" translatable="yes">Frequency (MHz)</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_band">
+                                    <property name="label" translatable="yes">Band</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_mode">
+                                    <property name="label" translatable="yes">Mode</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">5</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="preferences_view_visible_fields_vbox2">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="orientation">vertical</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_submode">
+                                    <property name="label" translatable="yes">Submode</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_tx_pwr">
+                                    <property name="label" translatable="yes">TX Power (W)</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_rst_sent">
+                                    <property name="label" translatable="yes">RST Sent</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_rst_rcvd">
+                                    <property name="label" translatable="yes">RST Received</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_qsl_sent">
+                                    <property name="label" translatable="yes">QSL Sent</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_qsl_rcvd">
+                                    <property name="label" translatable="yes">QSL Received</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">5</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="preferences_view_visible_fields_vbox3">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="orientation">vertical</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_notes">
+                                    <property name="label" translatable="yes">Notes</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_name">
+                                    <property name="label" translatable="yes">Name</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_address">
+                                    <property name="label" translatable="yes">Address</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_state">
+                                    <property name="label" translatable="yes">State</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_country">
+                                    <property name="label" translatable="yes">Country</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_dxcc">
+                                    <property name="label" translatable="yes">DXCC</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">5</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="preferences_view_visible_fields_vbox4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="orientation">vertical</property>
+                                <property name="spacing">2</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_cqz">
+                                    <property name="label" translatable="yes">CQ Zone</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_ituz">
+                                    <property name="label" translatable="yes">ITU Zone</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="visible_fields_iota">
+                                    <property name="label" translatable="yes">IOTA Designator</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_view_visible_fields_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Visible fields</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="preferences_view_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">View</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="preferences_records_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">2</property>
+                <child>
+                  <object class="GtkFrame" id="preferences_records_autocomplete">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_records_autocomplete_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_records_autocomplete_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkCheckButton" id="records_autocomplete_band_checkbutton">
+                                <property name="label" translatable="yes">Autocomplete the Band field</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Given a frequency, automatically determine the band.</property>
+                                <property name="xalign">0</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="records_autocomplete_utc_checkbutton">
+                                <property name="label" translatable="yes">Use UTC when autocompleting the Date and Time</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Use Coordinated Universal Time (UTC) if the date and time of a QSO are automatically filled in.</property>
+                                <property name="xalign">0</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_records_autocomplete_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Autocomplete</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="preferences_records_default_values">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_records_default_values_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_records_default_values_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkBox" id="default_values_mode_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="default_values_mode_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Mode</property>
+                                    <property name="width_chars">15</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxText" id="default_values_mode_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="default_values_submode_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="default_values_submode_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Submode</property>
+                                    <property name="width_chars">15</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxText" id="default_values_submode_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="default_values_tx_power_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="default_values_tx_power_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">TX Power (W)</property>
+                                    <property name="width_chars">15</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="default_values_tx_power_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="width_chars">15</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="default_values_frequency_unit_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="default_values_frequency_unit_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Frequency unit</property>
+                                    <property name="width_chars">15</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxText" id="default_values_frequency_unit_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="tooltip_text" translatable="yes">The unit of the frequency that will be entered into the Frequency entry box in the Add/Edit Record dialog (e.g. by selecting kHz, a value of 7140 can be entered instead of 7.140 MHz). However, the frequency will still be shown in MHz in the logbook.</property>
+                                    <property name="active">2</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_records_default_values_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Default values</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="preferences_records_callsign_lookup">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_records_callsign_lookup_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_records_callsign_lookup_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkBox" id="callsign_lookup_database_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="callsign_lookup_database_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Database</property>
+                                    <property name="width_chars">15</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxText" id="callsign_lookup_database_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkFrame" id="callsign_lookup_login_details">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label_xalign">0</property>
+                                <child>
+                                  <object class="GtkAlignment" id="callsign_lookup_login_details_alignment">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <child>
+                                      <object class="GtkBox" id="callsign_lookup_login_details_vbox">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="orientation">vertical</property>
+                                        <property name="spacing">2</property>
+                                        <child>
+                                          <object class="GtkBox" id="callsign_lookup_login_details_username_hbox">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <child>
+                                              <object class="GtkLabel" id="callsign_lookup_login_details_username_label">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="label" translatable="yes">Username</property>
+                                                <property name="width_chars">15</property>
+                                                <property name="xalign">0</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">True</property>
+                                                <property name="padding">2</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkEntry" id="callsign_lookup_login_details_username_entry">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="width_chars">15</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">True</property>
+                                                <property name="padding">2</property>
+                                                <property name="position">1</property>
+                                              </packing>
+                                            </child>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">True</property>
+                                            <property name="padding">2</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkBox" id="callsign_lookup_login_details_password_hbox">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <child>
+                                              <object class="GtkLabel" id="callsign_lookup_login_details_password_label">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="label" translatable="yes">Password</property>
+                                                <property name="width_chars">15</property>
+                                                <property name="xalign">0</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">True</property>
+                                                <property name="padding">2</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkEntry" id="callsign_lookup_login_details_password_entry">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="visibility">False</property>
+                                                <property name="invisible_char">*</property>
+                                                <property name="width_chars">15</property>
+                                                <property name="input_purpose">password</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">True</property>
+                                                <property name="padding">2</property>
+                                                <property name="position">1</property>
+                                              </packing>
+                                            </child>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">True</property>
+                                            <property name="padding">2</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="callsign_lookup_login_details_warning_label">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label" translatable="yes">Warning: Login details are currently stored as
+Base64-encoded plain text in the configuration file.</property>
+                                            <property name="justify">center</property>
+                                            <attributes>
+                                              <attribute name="weight" value="bold"/>
+                                            </attributes>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">2</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child type="label">
+                                  <object class="GtkLabel" id="callsign_lookup_database_login_details_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Login details</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="callsign_lookup_ignore_prefix_suffix_checkbutton">
+                                <property name="label" translatable="yes">Ignore callsign prefixes and/or suffixes</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Ignore prefixes (such as F/ in F/MYCALL) and suffixes (such as /MM in MYCALL/MM) when performing callsign lookups.</property>
+                                <property name="xalign">0</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_records_callsign_lookup_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Callsign lookup</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="preferences_records_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Records</property>
+              </object>
+              <packing>
+                <property name="position">2</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="preferences_import_export_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">2</property>
+                <child>
+                  <object class="GtkFrame" id="preferences_adif_import">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_adif_import_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_adif_import_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkCheckButton" id="adif_import_merge_comment_checkbutton">
+                                <property name="label" translatable="yes">Merge any text in the COMMENT field with the NOTES field</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_adif_import_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">ADIF Import</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="preferences_import_export_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Import/Export</property>
+              </object>
+              <packing>
+                <property name="position">3</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="preferences_hamlib_vbox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">2</property>
+                <child>
+                  <object class="GtkFrame" id="preferences_hamlib_support">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkAlignment" id="preferences_hamlib_support_alignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="left_padding">2</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkBox" id="preferences_hamlib_support_vbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkCheckButton" id="hamlib_support_checkbutton">
+                                <property name="label" translatable="yes">Auto-fill Frequency and Mode fields</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="xalign">0</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="hamlib_support_model_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="hamlib_support_model_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Model</property>
+                                    <property name="width_chars">18</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxText" id="hamlib_support_model_combo">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="hamlib_support_path_hbox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel" id="hamlib_support_path_label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Path to radio device</property>
+                                    <property name="width_chars">18</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="hamlib_support_path_entry">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="width_chars">15</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="padding">2</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="preferences_hamlib_support_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Hamlib support</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="preferences_hamlib_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Hamlib</property>
+              </object>
+              <packing>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">preferences_cancel_button</action-widget>
+      <action-widget response="-5">preferences_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="record_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Add Record</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="record_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="record_dialog_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="record_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="record_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="qso_frame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <child>
+              <object class="GtkAlignment" id="qso_frame_alignment">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkBox" id="qso_hbox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">2</property>
+                    <property name="homogeneous">True</property>
+                    <child>
+                      <object class="GtkBox" id="qso_vbox_left">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkBox" id="qso_call_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_call_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Callsign</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_call_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="callsign_lookup">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="tooltip_text" translatable="yes">Callsign lookup</property>
+                                <property name="always_show_image">True</property>
+                                <child>
+                                  <object class="GtkImage" id="image26">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-info</property>
+                                    <property name="icon_size">1</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_date_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_date_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Date</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_date_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="select_date">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="tooltip_text" translatable="yes">Select date from calendar</property>
+                                <property name="always_show_image">True</property>
+                                <child>
+                                  <object class="GtkImage" id="image27">
+                                    <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>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_time_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_time_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Time</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_time_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="current_datetime">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="tooltip_text" translatable="yes">Use the current time and date</property>
+                                <property name="always_show_image">True</property>
+                                <child>
+                                  <object class="GtkImage" id="image28">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-media-play</property>
+                                    <property name="icon_size">1</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_frequency_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_frequency_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Frequency (MHz)</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_frequency_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_band_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_band_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Band</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBoxText" id="qso_band_combo">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_mode_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_mode_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Mode</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBoxText" id="qso_mode_combo">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_submode_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_submode_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Submode</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBoxText" id="qso_submode_combo">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">6</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_power_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_power_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">TX Power (W)</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_power_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">7</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="padding">2</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="qso_vbox_right">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkBox" id="qso_rst_sent_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_rst_sent_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">RST Sent</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_rst_sent_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_rst_received_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_rst_received_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">RST Received</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="qso_rst_received_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_qsl_sent_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_qsl_sent_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">QSL Sent</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBoxText" id="qso_qsl_sent_combo">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_qsl_received_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_qsl_received_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">QSL Received</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBoxText" id="qso_qsl_received_combo">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="qso_notes_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="qso_notes_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Notes</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkScrolledWindow" id="qso_notes_sw">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="shadow_type">etched-in</property>
+                                <child>
+                                  <object class="GtkTextView" id="qso_notes_textview">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="wrap_mode">word-char</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="padding">2</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="qso_frame_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">QSO Information</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="padding">2</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="station_frame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <child>
+              <object class="GtkAlignment" id="station_frame_alignment">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkBox" id="station_hbox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">2</property>
+                    <property name="homogeneous">True</property>
+                    <child>
+                      <object class="GtkBox" id="station_vbox_left">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkBox" id="station_name_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_name_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Name</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_name_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_address_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_address_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Address</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_address_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_state_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_state_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">State</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_state_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_country_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_country_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Country</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_country_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="padding">2</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="station_vbox_right">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkBox" id="station_dxcc_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_dxcc_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">DXCC</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_dxcc_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_cq_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_cq_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">CQ Zone</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_cq_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_itu_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_itu_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">ITU Zone</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_itu_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="station_iota_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <object class="GtkLabel" id="station_iota_label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">IOTA Designator</property>
+                                <property name="width_chars">15</property>
+                                <property name="xalign">0</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkEntry" id="station_iota_entry">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="width_chars">15</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="padding">2</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="padding">2</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="padding">2</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="station_frame_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Station Information</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">record_cancel_button</action-widget>
+      <action-widget response="-5">record_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="calendar_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Select Date</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">record_dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="calendar_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="calendar_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="calendar_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="calendar_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkCalendar" id="calendar">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">calendar_cancel_button</action-widget>
+      <action-widget response="-5">calendar_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="telnet_connection_dialog">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">New Telnet Connection</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="transient_for">pyqso</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="telnet_connection_dialog_vbox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="telnet_connection_buttons">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="telnet_connection_cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="telnet_connection_ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="always_show_image">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">5</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="host_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="host_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Host</property>
+                <property name="width_chars">10</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">6</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="host_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="port_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="port_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Port</property>
+                <property name="width_chars">10</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">6</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="port_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="input_purpose">number</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="username_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="username_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Username</property>
+                <property name="width_chars">10</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">6</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="username_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="password_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="password_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Password</property>
+                <property name="width_chars">10</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">6</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="password_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="visibility">False</property>
+                <property name="invisible_char">*</property>
+                <property name="input_purpose">password</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="bookmark_hbox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkCheckButton" id="bookmark_checkbox">
+                <property name="label" translatable="yes">Bookmark server details</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="padding">6</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">6</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">telnet_connection_cancel_button</action-widget>
+      <action-widget response="-5">telnet_connection_ok_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkBox" id="summary_page">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkBox" id="database_name_hbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="database_name">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="margin_left">4</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">2</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="padding">4</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="log_count_hbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="log_count_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Number of logs:</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="log_count">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">0</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="padding">4</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="qso_count_hbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="qso_count_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Total number of QSOs:</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="qso_count">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">0</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="padding">4</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="date_modified_hbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="date_modified_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Date modified:</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="date_modified">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">0</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="padding">6</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="padding">4</property>
+        <property name="position">3</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkSeparator" id="summary_page_separator">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="padding">4</property>
+        <property name="position">4</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/pyqso/summary.py b/pyqso/summary.py
new file mode 100644
index 0000000..a87b7a3
--- /dev/null
+++ b/pyqso/summary.py
@@ -0,0 +1,238 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+import logging
+from os.path import basename, getmtime, expanduser, dirname, join, realpath
+from datetime import datetime, date
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
+try:
+    import matplotlib
+    matplotlib.use('Agg')
+    matplotlib.rcParams['font.size'] = 10.0
+    from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
+    from matplotlib.figure import Figure
+    from matplotlib.dates import DateFormatter, MonthLocator
+    have_matplotlib = True
+except ImportError as e:
+    logging.warning(e)
+    logging.warning("Could not import matplotlib, so you will not be able to plot annual logbook statistics. Check that all the PyQSO dependencies are satisfied.")
+    have_matplotlib = False
+
+
+class Summary(object):
+
+    def __init__(self, application):
+        """ Create a summary page containing various statistics such as the number of logs in the logbook, the logbook's modification date, etc.
+
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
+
+        self.application = application
+        self.logbook = self.application.logbook
+        self.builder = self.application.builder
+        glade_file_path = join(realpath(dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("summary_page",))
+        self.summary_page = self.builder.get_object("summary_page")
+
+        self.items = {}
+
+        # Database name in large font at the top of the summary page
+        self.builder.get_object("database_name").set_markup("<span size=\"x-large\">%s</span>" % basename(self.logbook.path))
+        self.items["LOG_COUNT"] = self.builder.get_object("log_count")
+        self.items["QSO_COUNT"] = self.builder.get_object("qso_count")
+        self.items["DATE_MODIFIED"] = self.builder.get_object("date_modified")
+
+        # Yearly statistics
+        config = configparser.ConfigParser()
+        have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
+        (section, option) = ("general", "show_yearly_statistics")
+        if(have_config and config.has_option(section, option)):
+            if(config.getboolean("general", "show_yearly_statistics") and have_matplotlib):
+                hbox = Gtk.HBox()
+                label = Gtk.Label(label="Display statistics for year: ", halign=Gtk.Align.START)
+                hbox.pack_start(label, False, False, 6)
+                year_select = Gtk.ComboBoxText()
+                min_year, max_year = self.get_year_bounds()
+                if min_year and max_year:
+                    for year in range(max_year, min_year-1, -1):
+                        year_select.append_text(str(year))
+                year_select.append_text("")
+                year_select.connect("changed", self.on_year_changed)
+                hbox.pack_start(year_select, False, False, 6)
+                self.summary_page.pack_start(hbox, False, False, 4)
+
+                self.items["YEARLY_STATISTICS"] = Figure()
+                canvas = FigureCanvas(self.items["YEARLY_STATISTICS"])
+                canvas.set_size_request(800, 175)
+                canvas.show()
+                self.summary_page.pack_start(canvas, True, True, 0)
+
+        # Summary tab label and icon.
+        tab = Gtk.HBox(homogeneous=False, spacing=0)
+        label = Gtk.Label(label="Summary  ")
+        icon = Gtk.Image.new_from_icon_name(Gtk.STOCK_INDEX, Gtk.IconSize.MENU)
+        tab.pack_start(label, False, False, 0)
+        tab.pack_start(icon, False, False, 0)
+        tab.show_all()
+
+        self.logbook.notebook.insert_page(self.summary_page, tab, 0)  # Append as a new tab
+        self.logbook.notebook.show_all()
+
+        return
+
+    def on_year_changed(self, combo):
+        """ Re-plot the statistics for the year selected by the user. """
+
+        # Clear figure
+        self.items["YEARLY_STATISTICS"].clf()
+        self.items["YEARLY_STATISTICS"].canvas.draw()
+
+        # Get year to show statistics for.
+        year = combo.get_active_text()
+        try:
+            year = int(year)
+        except ValueError:
+            # Empty year string.
+            return
+
+        # Number of contacts made each month
+        contact_count_plot = self.items["YEARLY_STATISTICS"].add_subplot(121)
+        contact_count = self.get_annual_contact_count(year)
+
+        # x-axis formatting based on the date
+        contact_count_plot.bar(list(contact_count.keys()), list(contact_count.values()), color="k", width=15, align="center")
+        formatter = DateFormatter("%b")
+        contact_count_plot.xaxis.set_major_formatter(formatter)
+        month_locator = MonthLocator()
+        contact_count_plot.xaxis.set_major_locator(month_locator)
+        contact_count_plot.set_ylabel("Number of QSOs")
+
+        # Set x-axis upper limit based on the current month.
+        contact_count_plot.xaxis_date()
+        contact_count_plot.set_xlim([date(year-1, 12, 16), date(year, 12, 15)])  # Make a bit of space either side of January and December of the selected year.
+
+        # Pie chart of all the modes used.
+        mode_count_plot = self.items["YEARLY_STATISTICS"].add_subplot(122)
+        mode_count = self.get_annual_mode_count(year)
+        (patches, texts, autotexts) = mode_count_plot.pie(list(mode_count.values()), labels=mode_count.keys(), autopct='%1.1f%%', shadow=False)
+        for p in patches:
+            # Make the patches partially transparent.
+            p.set_alpha(0.75)
+        mode_count_plot.set_title("Modes used")
+
+        self.items["YEARLY_STATISTICS"].canvas.draw()
+
+        return
+
+    def get_year_bounds(self):
+        """ Find the years of the oldest and newest QSOs across all logs in the logbook.
+
+        :returns: The years of the oldest and newest QSOs. The tuple (None, None) is returned if no QSOs have been made or no QSO dates have been specified.
+        :rtype: tuple
+        """
+
+        c = self.logbook.connection.cursor()
+        max_years = []
+        min_years = []
+        for log in self.logbook.logs:
+            query = "SELECT min(QSO_DATE), max(QSO_DATE) FROM %s" % (log.name)
+            c.execute(query)
+            years = c.fetchone()
+            if years[0] and years[1]:
+                min_years.append(int(years[0][:4]))
+                max_years.append(int(years[1][:4]))
+
+        if len(min_years) == 0 or len(max_years) == 0:
+            return None, None
+        else:
+            # Return the min and max across all logs.
+            return min(min_years), max(max_years)
+
+    def get_annual_contact_count(self, year):
+        """ Find the total number of contacts made in each month in the specified year.
+
+        :arg int year: The year of interest.
+        :returns: The total number of contacts made in each month of a given year.
+        :rtype: dict
+        """
+
+        contact_count = {}
+        c = self.logbook.connection.cursor()
+
+        for log in self.logbook.logs:
+            query = "SELECT QSO_DATE, count(QSO_DATE) FROM %s WHERE QSO_DATE >= %d0101 AND QSO_DATE < %d0101 GROUP by QSO_DATE" % (log.name, year, year+1)
+            c.execute(query)
+            xy = c.fetchall()
+
+            for i in range(len(xy)):
+                date_str = xy[i][0]
+                y = int(date_str[0:4])
+                m = int(date_str[4:6])
+                date = datetime(y, m, 1)  # Collect all contacts together by month.
+                if date in contact_count.keys():
+                    contact_count[date] += xy[i][1]
+                else:
+                    contact_count[date] = xy[i][1]
+
+        return contact_count
+
+    def get_annual_mode_count(self, year):
+        """ Find the total number of contacts made with each mode in a specified year.
+
+        :arg int year: The year of interest.
+        :returns: The total number of contacts made with each mode in a given year.
+        :rtype: dict
+        """
+
+        mode_count = {}
+
+        for log in self.logbook.logs:
+            query = "SELECT MODE, count(MODE) FROM %s WHERE QSO_DATE >= %d0101 AND QSO_DATE < %d0101 GROUP by MODE" % (log.name, year, year+1)
+            c = self.logbook.connection.cursor()
+            c.execute(query)
+            xy = c.fetchall()
+
+            for i in range(len(xy)):
+                mode = xy[i][0]
+                if mode == "":
+                    mode = "Unspecified"
+
+                # Add to running total
+                if mode in mode_count.keys():
+                    mode_count[mode] += xy[i][1]
+                else:
+                    mode_count[mode] = xy[i][1]
+
+        return mode_count
+
+    def update(self):
+        """ Update the information presented on the summary page. """
+
+        self.items["LOG_COUNT"].set_label(str(self.logbook.log_count))
+        self.items["QSO_COUNT"].set_label(str(self.logbook.record_count))
+        try:
+            t = datetime.fromtimestamp(getmtime(self.logbook.path)).strftime("%d %B %Y @ %H:%M")
+            self.items["DATE_MODIFIED"].set_label(str(t))
+        except (IOError, OSError) as e:
+            logging.exception(e)
+        return
diff --git a/pyqso/telnet_connection_dialog.py b/pyqso/telnet_connection_dialog.py
index 347c697..4105dec 100644
--- a/pyqso/telnet_connection_dialog.py
+++ b/pyqso/telnet_connection_dialog.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,77 +17,74 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk
-import logging
+import os
 
 
-class TelnetConnectionDialog(Gtk.Dialog):
+class TelnetConnectionDialog:
 
-    """ A simple dialog through which users can specify host and login information for a Telnet server.
-    This can be used to connect to DX clusters. """
+    """ A handler for the Gtk.Dialog through which a user can specify Telnet connection details. """
 
-    def __init__(self, parent):
-        """ Set up and show the Telnet connection dialog to the user.
+    def __init__(self, application):
+        """ Create and show the Telnet connection dialog to the user.
 
-        :arg parent: The parent Gtk window/dialog.
+        :arg application: The PyQSO application containing the main Gtk window, etc.
         """
 
-        logging.debug("Setting up the Telnet connection dialog...")
-
-        Gtk.Dialog.__init__(self, title="New Telnet Connection", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
-
-        self.sources = {}
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Host: ", halign=Gtk.Align.START)
-        label.set_width_chars(12)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 6)
-        self.sources["HOST"] = Gtk.Entry()
-        hbox_temp.pack_start(self.sources["HOST"], True, True, 6)
-        self.vbox.pack_start(hbox_temp, False, False, 6)
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Port: ", halign=Gtk.Align.START)
-        label.set_width_chars(12)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 6)
-        self.sources["PORT"] = Gtk.Entry()
-        hbox_temp.pack_start(self.sources["PORT"], True, True, 6)
-        self.vbox.pack_start(hbox_temp, False, False, 6)
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Username: ", halign=Gtk.Align.START)
-        label.set_width_chars(12)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 6)
-        self.sources["USERNAME"] = Gtk.Entry()
-        hbox_temp.pack_start(self.sources["USERNAME"], True, True, 6)
-        self.vbox.pack_start(hbox_temp, False, False, 6)
-
-        hbox_temp = Gtk.HBox(spacing=0)
-        label = Gtk.Label("Password: ", halign=Gtk.Align.START)
-        label.set_width_chars(12)
-        label.set_alignment(0, 0.5)
-        hbox_temp.pack_start(label, False, False, 6)
-        self.sources["PASSWORD"] = Gtk.Entry()
-        self.sources["PASSWORD"].set_visibility(False)  # Mask the password with the "*" character.
-        hbox_temp.pack_start(self.sources["PASSWORD"], True, True, 6)
-        self.vbox.pack_start(hbox_temp, False, False, 6)
-
-        self.sources["BOOKMARK"] = Gtk.CheckButton("Bookmark server details for next time")
-        self.vbox.pack_start(self.sources["BOOKMARK"], False, False, 6)
-
-        logging.debug("Telnet connection dialog ready!")
-
-        self.show_all()
+        self.builder = application.builder
+        glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
+        self.builder.add_objects_from_file(glade_file_path, ("telnet_connection_dialog",))
+        self.dialog = self.builder.get_object("telnet_connection_dialog")
+        self.sources = {"HOST": self.builder.get_object("host_entry"),
+                        "PORT": self.builder.get_object("port_entry"),
+                        "USERNAME": self.builder.get_object("username_entry"),
+                        "PASSWORD": self.builder.get_object("password_entry"),
+                        "BOOKMARK": self.builder.get_object("bookmark_checkbox")}
+
+        self.dialog.show_all()
+
         return
 
-    def get_connection_info(self):
-        """ Return the host and login information stored in the Gtk.Entry boxes.
+    @property
+    def host(self):
+        """ Return the Telnet server's host name.
+
+        :returns: The server's host name.
+        :rtype: str
+        """
+        return self.sources["HOST"].get_text()
+
+    @property
+    def port(self):
+        """ Return the Telnet server's port number (as a string).
+
+        :returns: The server's port number (as a string).
+        :rtype: str
+        """
+        return self.sources["PORT"].get_text()
+
+    @property
+    def username(self):
+        """ Return the user's username.
+
+        :returns: The user's username.
+        :rtype: str
+        """
+        return self.sources["USERNAME"].get_text()
+
+    @property
+    def password(self):
+        """ Return the user's password.
+
+        :returns: The user's password.
+        :rtype: str
+        """
+        return self.sources["PASSWORD"].get_text()
+
+    @property
+    def bookmark(self):
+        """ Return True if a new bookmark should be created, otherwise return False.
 
-        :returns: A dictionary of Telnet connection-related information (username, password, port, host).
-        :rtype: dict
+        :returns: True if a new bookmark should be created, otherwise False.
+        :rtype: bool
         """
-        logging.debug("Returning Telnet connection information...")
-        return self.sources
+        return self.sources["BOOKMARK"].get_active()
diff --git a/pyqso/toolbar.py b/pyqso/toolbar.py
index 61df885..9785ec5 100644
--- a/pyqso/toolbar.py
+++ b/pyqso/toolbar.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,102 +17,55 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk
-import logging
 
-
-class Toolbar(Gtk.HBox):
+class Toolbar:
 
     """ The toolbar underneath the menu bar. """
 
-    def __init__(self, parent):
-        """ Set up the various buttons in the toolbar, and connect to their corresponding functions. """
+    def __init__(self, application):
+        """ Set up the various buttons in the toolbar, and connect to their corresponding functions.
 
-        logging.debug("Setting up the toolbar...")
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
 
-        Gtk.HBox.__init__(self, spacing=2)
+        self.application = application
+        self.builder = self.application.builder
 
         self.buttons = {}
 
         # Create logbook
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Create a New Logbook')
-        button.connect("clicked", parent.logbook.new)
-        self.pack_start(button, False, False, 0)
-        self.buttons["NEW_LOGBOOK"] = button
+        self.buttons["NEW_LOGBOOK"] = self.builder.get_object("toolbar_new_logbook")
+        self.buttons["NEW_LOGBOOK"].connect("clicked", self.application.logbook.new)
 
         # Open logbook
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Open an Existing Logbook')
-        button.connect("clicked", parent.logbook.open)
-        self.pack_start(button, False, False, 0)
-        self.buttons["OPEN_LOGBOOK"] = button
+        self.buttons["OPEN_LOGBOOK"] = self.builder.get_object("toolbar_open_logbook")
+        self.buttons["OPEN_LOGBOOK"].connect("clicked", self.application.logbook.open)
 
         # Close logbook
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Close Logbook')
-        button.connect("clicked", parent.logbook.close)
-        self.pack_start(button, False, False, 0)
-        self.buttons["CLOSE_LOGBOOK"] = button
-
-        self.pack_start(Gtk.SeparatorToolItem(), False, False, 0)
+        self.buttons["CLOSE_LOGBOOK"] = self.builder.get_object("toolbar_close_logbook")
+        self.buttons["CLOSE_LOGBOOK"].connect("clicked", self.application.logbook.close)
 
         # Add record
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Add Record')
-        button.connect("clicked", parent.logbook.add_record_callback)
-        self.pack_start(button, False, False, 0)
-        self.buttons["ADD_RECORD"] = button
+        self.buttons["ADD_RECORD"] = self.builder.get_object("toolbar_add_record")
+        self.buttons["ADD_RECORD"].connect("clicked", self.application.logbook.add_record_callback)
 
         # Edit record
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Edit Record')
-        button.connect("clicked", parent.logbook.edit_record_callback, None, None)
-        self.pack_start(button, False, False, 0)
-        self.buttons["EDIT_RECORD"] = button
+        self.buttons["EDIT_RECORD"] = self.builder.get_object("toolbar_edit_record")
+        self.buttons["EDIT_RECORD"].connect("clicked", self.application.logbook.edit_record_callback)
 
         # Delete record
-        icon = Gtk.Image()
-        icon.set_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON)
-        button = Gtk.Button()
-        button.add(icon)
-        button.set_tooltip_text('Delete Record')
-        button.connect("clicked", parent.logbook.delete_record_callback)
-        self.pack_start(button, False, False, 0)
-        self.buttons["DELETE_RECORD"] = button
-
-        self.pack_start(Gtk.SeparatorToolItem(), False, False, 0)
+        self.buttons["DELETE_RECORD"] = self.builder.get_object("toolbar_delete_record")
+        self.buttons["DELETE_RECORD"].connect("clicked", self.application.logbook.delete_record_callback)
 
         # Filter log
-        label = Gtk.Label("Filter by callsign: ")
-        self.pack_start(label, False, False, 0)
-        self.filter_source = Gtk.Entry()
-        self.filter_source.set_width_chars(11)
-        self.filter_source.connect_after("changed", parent.logbook.filter_logs)
-        self.pack_start(self.filter_source, False, False, 0)
+        self.filter_source = self.builder.get_object("filter_source")
+        self.filter_source.connect_after("changed", self.application.logbook.filter_logs)
 
+        # Set sensitivities.
         self.set_logbook_button_sensitive(True)
         self.set_record_buttons_sensitive(False)
-
         self.filter_source.set_sensitive(False)
 
-        logging.debug("Toolbar ready!")
-
         return
 
     def set_logbook_button_sensitive(self, sensitive):
@@ -120,11 +73,9 @@ class Toolbar(Gtk.HBox):
 
         :arg bool sensitive: If True, enable the 'new logbook' and 'open logbook' toolbar items. If False, disable them.
         """
-        logging.debug("Setting logbook-related toolbar item sensitivity to: %s..." % sensitive)
         self.buttons["NEW_LOGBOOK"].set_sensitive(sensitive)
         self.buttons["OPEN_LOGBOOK"].set_sensitive(sensitive)
         self.buttons["CLOSE_LOGBOOK"].set_sensitive(not sensitive)
-        logging.debug("Set logbook-related toolbar item sensitivity to: %s." % sensitive)
         return
 
     def set_record_buttons_sensitive(self, sensitive):
@@ -132,8 +83,6 @@ class Toolbar(Gtk.HBox):
 
         :arg bool sensitive: If True, enable all the record-related toolbar items. If False, disable them all.
         """
-        logging.debug("Setting record-related toolbar item sensitivity to: %s..." % sensitive)
         for button_name in ["ADD_RECORD", "EDIT_RECORD", "DELETE_RECORD"]:
             self.buttons[button_name].set_sensitive(sensitive)
-        logging.debug("Set record-related toolbar item sensitivity to: %s." % sensitive)
         return
diff --git a/pyqso/toolbox.py b/pyqso/toolbox.py
index f28bc9c..dc0fc9b 100644
--- a/pyqso/toolbox.py
+++ b/pyqso/toolbox.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,50 +17,42 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from gi.repository import Gtk
-import logging
+from pyqso.dx_cluster import DXCluster
+from pyqso.grey_line import GreyLine
+from pyqso.awards import Awards
 
-from pyqso.dx_cluster import *
-from pyqso.grey_line import *
-from pyqso.awards import *
 
-
-class Toolbox(Gtk.Frame):
+class Toolbox:
 
     """ Contains a Gtk.Notebook full of amateur radio-related tools. """
 
-    def __init__(self, parent):
-        """ Instantiate and insert the various tools into the toolbox. """
-
-        logging.debug("Setting up the toolbox...")
+    def __init__(self, application):
+        """ Instantiate and insert the various tools into the toolbox.
 
-        Gtk.Frame.__init__(self)
-        self.set_label("Toolbox")
-        self.parent = parent
+        :arg application: The PyQSO application containing the main Gtk window, etc.
+        """
 
-        self.tools = Gtk.Notebook()
+        self.application = application
+        self.builder = self.application.builder
 
-        self.dx_cluster = DXCluster(self.parent)
-        self.tools.insert_page(self.dx_cluster, Gtk.Label("DX Cluster"), 0)
-        self.grey_line = GreyLine(self.parent)
-        self.tools.insert_page(self.grey_line, Gtk.Label("Grey Line"), 1)
-        self.awards = Awards(self.parent)
-        self.tools.insert_page(self.awards, Gtk.Label("Awards"), 2)
+        self.tools = self.builder.get_object("tools")
 
-        self.add(self.tools)
-        self.tools.connect_after("switch-page", self._on_switch_page)
+        self.dx_cluster = DXCluster(self.application)
+        self.grey_line = GreyLine(self.application)
+        self.awards = Awards(self.application)
 
-        logging.debug("Toolbox ready!")
+        self.tools.connect_after("switch-page", self.on_switch_page)
 
         return
 
     def toggle_visible_callback(self, widget=None):
         """ Show/hide the toolbox. """
-        self.set_visible(not self.get_visible())
+        toolbox_frame = self.builder.get_object("toolbox")
+        toolbox_frame.set_visible(not toolbox_frame.get_visible())
         return
 
-    def _on_switch_page(self, widget, label, new_page):
+    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)):
-            label.draw()  # Note that 'label' is actually a GreyLine object.
+        if(widget.get_tab_label(label).get_text() == "Grey Line"):
+            self.grey_line.draw()
         return
diff --git a/setup.py b/setup.py
index 74ff52a..c373e55 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-#    Copyright (C) 2013-2016 Christian T. Jacobs.
+#    Copyright (C) 2013-2017 Christian Thomas Jacobs.
 
 #    This file is part of PyQSO.
 
@@ -17,24 +17,25 @@
 #    You should have received a copy of the GNU General Public License
 #    along with PyQSO.  If not, see <http://www.gnu.org/licenses/>.
 
-from distutils.core import setup
+from setuptools import setup
 
-setup(name='PyQSO',
-      version='0.3',
-      description='A contact logging tool for amateur radio operators.',
-      author='Christian T. Jacobs (2E0ICL)',
-      author_email='christian at christianjacobs.uk',
-      url='https://github.com/ctjacobs/pyqso',
-      packages=['pyqso'],
-      package_dir={'pyqso': 'pyqso'},
-      scripts=["bin/pyqso"],
-      data_files=[("icons", ["icons/log_64x64.png"])],
+setup(name="PyQSO",
+      version="1.0.0",
+      description="A contact logging tool for amateur radio operators.",
+      author="Christian Thomas Jacobs",
+      author_email="christian at christianjacobs.uk",
+      url="https://github.com/ctjacobs/pyqso",
       classifiers=[
-          'Development Status :: 5 - Production/Stable',
-          'Intended Audience :: End Users/Desktop',
-          'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
-          'Natural Language :: English',
-          'Programming Language :: Python :: 3',
-          'Topic :: Communications :: Ham Radio',
-      ]
+          "Development Status :: 5 - Production/Stable",
+          "Intended Audience :: End Users/Desktop",
+          "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
+          "Natural Language :: English",
+          "Programming Language :: Python :: 3",
+          "Topic :: Communications :: Ham Radio",
+      ],
+      packages=["pyqso"],
+      package_dir={"pyqso": "pyqso"},
+      package_data={"pyqso": ["res/pyqso.glade", "res/log_64x64.png"]},
+      scripts=["bin/pyqso"],
+      zip_safe=False
       )
diff --git a/tests/res/ADIF.test_read.adi b/tests/res/ADIF.test_read.adi
new file mode 100644
index 0000000..cdf6044
--- /dev/null
+++ b/tests/res/ADIF.test_read.adi
@@ -0,0 +1,4 @@
+Some test ADI data.<eoh>
+
+<call:4>TEST<band:3>40m<mode:2>CW
+<qso_date:8:d>20130322<time_on:4>1955<eor>
diff --git a/tests/res/ADIF.test_read_alphabet.adi b/tests/res/ADIF.test_read_alphabet.adi
new file mode 100644
index 0000000..e2f3337
--- /dev/null
+++ b/tests/res/ADIF.test_read_alphabet.adi
@@ -0,0 +1,2 @@
+Some test ADI data.<eoh>
+<call:64>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<eor>
diff --git a/tests/res/ADIF.test_read_capitalisation.adi b/tests/res/ADIF.test_read_capitalisation.adi
new file mode 100644
index 0000000..0380016
--- /dev/null
+++ b/tests/res/ADIF.test_read_capitalisation.adi
@@ -0,0 +1,2 @@
+Some test ADI data.<eoh>
+<call:4>test<eor>
diff --git a/tests/res/ADIF.test_read_header_only.adi b/tests/res/ADIF.test_read_header_only.adi
new file mode 100644
index 0000000..59b1a09
--- /dev/null
+++ b/tests/res/ADIF.test_read_header_only.adi
@@ -0,0 +1 @@
+Some test ADI data.<eoh>
diff --git a/tests/res/ADIF.test_read_multiple.adi b/tests/res/ADIF.test_read_multiple.adi
new file mode 100644
index 0000000..a5de8a1
--- /dev/null
+++ b/tests/res/ADIF.test_read_multiple.adi
@@ -0,0 +1,9 @@
+Some test ADI data.<eoh>
+
+<call:4>TEST<band:3>40m<mode:2>CW
+<qso_date:8:d>20130322<time_on:4>1955<eor>
+
+<call:8>TEST2ABC<band:3>20m<mode:3>SSB
+<qso_date:8>20150227<time_on:4>0820<eor>
+
+<call:5>HELLO<band:2>2m<mode:2>FM<qso_date:8:d>20150227<time_on:4>0832<eor>
diff --git a/tests/res/ADIF.test_read_no_header.adi b/tests/res/ADIF.test_read_no_header.adi
new file mode 100644
index 0000000..a7f70b2
--- /dev/null
+++ b/tests/res/ADIF.test_read_no_header.adi
@@ -0,0 +1 @@
+<call:4>TEST<band:3>40m<mode:2>CW<qso_date:8:d>20130322<time_on:4>1955<eor>
diff --git a/tests/res/invalid.db b/tests/res/invalid.db
new file mode 100644
index 0000000..030847a
--- /dev/null
+++ b/tests/res/invalid.db
@@ -0,0 +1 @@
+This is a plain text file used for testing PyQSO. Trying to open this file in PyQSO should case an error, since it is not a valid database file.
diff --git a/pyqso/unittest_resources/test.db b/tests/res/test.db
similarity index 54%
rename from pyqso/unittest_resources/test.db
rename to tests/res/test.db
index fedcb4b..51e7fe4 100644
Binary files a/pyqso/unittest_resources/test.db and b/tests/res/test.db differ
diff --git a/tests/test_adif.py b/tests/test_adif.py
new file mode 100644
index 0000000..4432a0b
--- /dev/null
+++ b/tests/test_adif.py
@@ -0,0 +1,200 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+import os
+from pyqso.adif import *
+
+
+class TestADIF(unittest.TestCase):
+
+    """ The unit tests for the ADIF class. """
+
+    def setUp(self):
+        """ Set up the ADIF object needed for the unit tests. """
+        self.adif = ADIF()
+
+    def test_read(self):
+        """ Check that a single ADIF record can be read and parsed correctly. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read.adi")
+        records = self.adif.read(path)
+        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 1)
+        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
+        assert(records == expected_records)
+
+    def test_read_multiple(self):
+        """ Check that multiple ADIF records can be read and parsed correctly. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read_multiple.adi")
+        records = self.adif.read(path)
+        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}, {'TIME_ON': '0820', 'BAND': '20m', 'CALL': 'TEST2ABC', 'MODE': 'SSB', 'QSO_DATE': '20150227'}, {'TIME_ON': '0832', 'BAND': '2m', 'CALL': 'HELLO', 'MODE': 'FM', 'QSO_DATE': '20150227'}]
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 3)
+        for i in range(len(expected_records)):
+            assert(len(list(records[i].keys())) == len(list(expected_records[i].keys())))
+        assert(records == expected_records)
+
+    def test_read_alphabet(self):
+        """ Check that none of the letters of the alphabet are ignored during parsing. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read_alphabet.adi")
+        records = self.adif.read(path)
+        expected_records = [{'CALL': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'}]
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 1)
+        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
+        assert(records == expected_records)
+
+    def test_read_capitalisation(self):
+        """ Check that the CALL field is capitalised correctly. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read_capitalisation.adi")
+        records = self.adif.read(path)
+        expected_records = [{'CALL': 'TEST'}]
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 1)
+        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
+        assert(records == expected_records)
+
+    def test_read_header_only(self):
+        """ Check that no records are read in if the ADIF file only contains header information. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read_header_only.adi")
+        records = self.adif.read(path)
+        expected_records = []
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 0)
+        assert(records == expected_records)
+
+    def test_read_no_header(self):
+        """ Check that an ADIF file can be parsed with no header information. """
+        path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "ADIF.test_read_no_header.adi")
+        records = self.adif.read(path)
+        expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
+        print("Imported records: ", records)
+        print("Expected records: ", expected_records)
+        assert(len(records) == 1)
+        assert(len(list(records[0].keys())) == len(list(expected_records[0].keys())))
+        assert(records == expected_records)
+
+    def test_write(self):
+        """ Check that records can be written to an ADIF file correctly. """
+        records = [{"CALL": "TEST123", "QSO_DATE": "20120402", "TIME_ON": "1234", "FREQ": "145.500", "BAND": "2m", "MODE": "FM", "RST_SENT": "59", "RST_RCVD": "59"},
+                   {"CALL": "TEST123", "QSO_DATE": "20130312", "TIME_ON": "0101", "FREQ": "145.750", "BAND": "2m", "MODE": "FM"}]
+        self.adif.write(records, "ADIF.test_write.adi")
+
+        f = open("ADIF.test_write.adi", 'r')
+        text = f.read()
+        print("File 'ADIF.test_write.adi' contains the following text:", text)
+        assert("""
+<adif_ver:5>3.0.4
+<programid:5>PyQSO
+<programversion:5>1.0.0
+<eoh>
+<call:7>TEST123
+<qso_date:8>20120402
+<time_on:4>1234
+<freq:7>145.500
+<band:2>2m
+<mode:2>FM
+<rst_sent:2>59
+<rst_rcvd:2>59
+<eor>
+<call:7>TEST123
+<qso_date:8>20130312
+<time_on:4>0101
+<freq:7>145.750
+<band:2>2m
+<mode:2>FM
+<eor>
+""" in text)  # Ignore the header line here, since it contains the date and time the ADIF file was written, which will change each time 'make unittest' is run.
+        f.close()
+
+    def test_write_sqlite3_Row(self):
+        """ Check that records can be written to an ADIF file from a test database file. """
+        import sqlite3
+        import os.path
+        path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
+        self.connection = sqlite3.connect(path_to_test_database)
+        self.connection.row_factory = sqlite3.Row
+
+        c = self.connection.cursor()
+        c.execute("SELECT * FROM test")
+        records = c.fetchall()
+        print(records)
+
+        self.adif.write(records, "ADIF.test_write_sqlite3_Row.adi")
+
+        f = open("ADIF.test_write_sqlite3_Row.adi", 'r')
+        text = f.read()
+        print("File 'ADIF.test_write_sqlite3_Row.adi' contains the following text:", text)
+        assert("""
+<adif_ver:5>3.0.4
+<programid:5>PyQSO
+<programversion:5>1.0.0
+<eoh>
+<call:7>TEST123
+<qso_date:8>20120402
+<time_on:4>1234
+<freq:7>145.500
+<band:2>2m
+<mode:2>FM
+<rst_sent:2>59
+<rst_rcvd:2>59
+<eor>
+<call:7>TEST456
+<qso_date:8>20130312
+<time_on:4>0101
+<freq:7>145.750
+<band:2>2m
+<mode:2>FM
+<eor>
+""" in text)  # Ignore the header line here, since it contains the date and time the ADIF file was written, which will change each time 'make unittest' is run.
+        f.close()
+
+        self.connection.close()
+
+    def test_is_valid(self):
+        """ Check that ADIF field validation is working correctly for different data types. """
+
+        assert(self.adif.is_valid("CALL", "TEST123", "S"))
+        assert(self.adif.is_valid("CALL", "F/MYCALL123MYCALL", "S"))
+
+        assert(self.adif.is_valid("QSO_DATE", "20120402", "D"))
+        assert(not self.adif.is_valid("QSO_DATE", "19000101", "D"))
+
+        assert(self.adif.is_valid("TIME_ON", "0000", "T"))
+        assert(self.adif.is_valid("TIME_ON", "235959", "T"))
+        assert(self.adif.is_valid("TIME_ON", "1230", "T"))
+        assert(self.adif.is_valid("TIME_ON", "155329", "T"))
+        assert(not self.adif.is_valid("TIME_ON", "2500", "T"))
+
+        assert(self.adif.is_valid("TX_PWR", "5", "N"))
+        assert(self.adif.is_valid("FREQ", "145.550", "N"))
+
+        assert(self.adif.is_valid("NOTES", "TEST123\nHELLO_WORLD", "M"))
+
+        assert(self.adif.is_valid("MODE", "FM", "E"))
+        assert(self.adif.is_valid("SUBMODE", "LSB", "E"))
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_awards.py b/tests/test_awards.py
new file mode 100644
index 0000000..0ff3e07
--- /dev/null
+++ b/tests/test_awards.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import os
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.awards import *
+from pyqso.logbook import Logbook
+
+
+class TestAwards(unittest.TestCase):
+
+    """ The unit tests for the Awards class. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+        PyQSO = mock.MagicMock()
+        self.awards = Awards(application=PyQSO())
+        self.logbook = Logbook(application=PyQSO())
+        path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
+        success = self.logbook.db_connect(path_to_test_database)
+        assert(success)
+        self.logbook.logs = self.logbook.get_logs()
+        assert(self.logbook.logs is not None)
+
+    def test_count(self):
+        """ Check that there are 3 FM/AM/SSB/SSTV QSOs and 1 CW QSO. Note that the BAND must be specified in order to be counted. """
+        count = self.awards.count(self.logbook)
+        assert(sum(count[0]) == 3)  # FM/AM/SSB/SSTV
+        assert(sum(count[1]) == 1)  # CW
+        assert(sum(count[2]) == 1)  # Other modes
+        assert(sum(count[3]) == 5)  # Mixed
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_cabrillo.py b/tests/test_cabrillo.py
new file mode 100644
index 0000000..c632709
--- /dev/null
+++ b/tests/test_cabrillo.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+from pyqso.cabrillo import *
+
+
+class TestCabrillo(unittest.TestCase):
+
+    """ The unit tests for the Cabrillo class. """
+
+    def setUp(self):
+        """ Set up the Cabrillo object needed for the unit tests. """
+        self.cabrillo = Cabrillo()
+        return
+
+    def test_write(self):
+        """ Check that QSOs are written correctly in Cabrillo format. """
+        records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'FREQ': "145.550", 'MODE': 'FM', 'QSO_DATE': '20130322', 'RST_SENT': '59 001', 'RST_RCVD': '59 002'}, {'TIME_ON': '0820', 'BAND': '20m', 'CALL': 'TEST2ABC', 'FREQ': "144.330", 'MODE': 'SSB', 'QSO_DATE': '20150227', 'RST_SENT': '55 020', 'RST_RCVD': '57 003'}, {'TIME_ON': '0832', 'BAND': '2m', 'CALL': 'HELLO', 'FREQ': "145.550", 'MODE': 'FM', 'QSO_DATE': '20150227', 'RST_SENT': '59 001', 'RST_RCVD': '59 002'}]
+
+        expected = """START-OF-LOG: 3.0
+CREATED-BY: PyQSO v1.0.0
+CALLSIGN: MYCALL
+CONTEST: MYCONTEST
+QSO: 145550.0 FM 2013-03-22 1955 MYCALL 59 001 TEST 59 002 0
+QSO: 144330.0 PH 2015-02-27 0820 MYCALL 55 020 TEST2ABC 57 003 0
+QSO: 145550.0 FM 2015-02-27 0832 MYCALL 59 001 HELLO 59 002 0
+END-OF-LOG:"""
+        print("Expected Cabrillo file contents: ", expected)
+
+        mycall = "MYCALL"
+        mycontest = "MYCONTEST"
+        path = "Cabrillo.test_write.log"
+        self.cabrillo.write(records, path, contest=mycontest, mycall=mycall)
+
+        actual = ""
+        f = open(path, "r")
+        for line in f:
+            actual += line
+        f.close()
+        print("Actual Cabrillo file contents: ", actual)
+        assert(expected == actual)
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_calendar_dialog.py b/tests/test_calendar_dialog.py
new file mode 100644
index 0000000..dc59523
--- /dev/null
+++ b/tests/test_calendar_dialog.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.calendar_dialog import *
+
+
+class TestCalendarDialog(unittest.TestCase):
+
+    """ The unit tests for the CalendarDialog class. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+        self.cd = CalendarDialog(application=mock.MagicMock())
+        self.cd.calendar = Gtk.Calendar()
+        self.cd.calendar.select_month(3, 2017)  # Note: Months start from 0 when using the Calendar widget. So "3" represents April here.
+        self.cd.calendar.select_day(2)
+
+    def test_date(self):
+        """ Check that the date obtained from the Calendar is in the correct format. """
+        assert(self.cd.date == "20170402")
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_callsign_lookup.py b/tests/test_callsign_lookup.py
new file mode 100644
index 0000000..ed89e03
--- /dev/null
+++ b/tests/test_callsign_lookup.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.callsign_lookup import *
+
+
+class TestCallsignLookup(unittest.TestCase):
+
+    """ The unit tests for the callsign lookup functionality. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+        self.qrz = CallsignLookupQRZ(parent=None)
+        self.hamqth = CallsignLookupHamQTH(parent=None)
+
+    def test_strip(self):
+        """ Check that a callsign with a prefix and a suffix is stripped correctly. """
+        assert strip("F/MYCALL/MM") == "MYCALL"
+        assert strip("F/MYCALL/M") == "MYCALL"
+        assert strip("HB9/MYCALL/P") == "MYCALL"
+        assert strip("HB9/MYCALL/QRP") == "MYCALL"
+        assert strip("HB9/MYCALL/A") == "MYCALL"
+        assert strip("HB9/MYCALL/AM") == "MYCALL"
+        assert strip("HB9/MYCALL/PM") == "MYCALL"
+
+    def test_strip_prefix_only(self):
+        """ Check that a callsign with only a prefix is stripped correctly. """
+        assert strip("F/MYCALL") == "MYCALL"
+
+    def test_strip_suffix_only(self):
+        """ Check that a callsign with only a suffix is stripped correctly. """
+        assert strip("MYCALL/M") == "MYCALL"
+        assert strip("MYCALL/P") == "MYCALL"
+        assert strip("MYCALL/A") == "MYCALL"
+        assert strip("MYCALL/MM") == "MYCALL"
+        assert strip("MYCALL/PM") == "MYCALL"
+        assert strip("MYCALL/AM") == "MYCALL"
+        assert strip("MYCALL/QRP") == "MYCALL"
+
+    def test_strip_no_prefix_or_suffix(self):
+        """ Check that a callsign with no prefix or suffix remains unmodified. """
+        callsign = "MYCALL"
+        assert strip(callsign) == "MYCALL"
+
+    def test_strip_too_many_components(self):
+        """ Check that a callsign with too many prefix/suffix components remains unmodified. """
+        callsign = "F/HB9/MYCALL/MM"
+        assert strip(callsign) == "F/HB9/MYCALL/MM"
+
+    def test_qrz_connect(self):
+        """ Check the example response from the qrz.com server, and make sure the session key has been correctly extracted. """
+
+        http_client.HTTPConnection = mock.Mock(spec=http_client.HTTPConnection)
+        http_client.HTTPResponse = mock.Mock(spec=http_client.HTTPResponse)
+        connection = http_client.HTTPConnection()
+        response = http_client.HTTPResponse()
+
+        response.read.return_value = b'<?xml version="1.0" encoding="utf-8" ?>\n<QRZDatabase version="1.33" xmlns="http://xmldata.qrz.com">\n<Session>\n<Key>3b1fd1d3ba495189984f93ff67bd45b6</Key>\n<Count>61</Count>\n<SubExp>non-subscriber</SubExp>\n<GMTime>Sun Nov 22 21:25:34 2015</GMTime>\n<Remark>cpu: 0.147s</Remark>\n</Session>\n</QRZDatabase>\n'
+        connection.getresponse.return_value = response
+
+        result = self.qrz.connect("hello", "world")
+        assert(result)
+        assert(self.qrz.session_key == "3b1fd1d3ba495189984f93ff67bd45b6")
+
+    def test_qrz_lookup(self):
+        """ Check the example callsign lookup response from the qrz.com server, and make sure the callsign information has been correctly extracted. """
+
+        http_client.HTTPConnection = mock.Mock(spec=http_client.HTTPConnection)
+        http_client.HTTPResponse = mock.Mock(spec=http_client.HTTPResponse)
+        connection = http_client.HTTPConnection()
+        response = http_client.HTTPResponse()
+
+        response.read.return_value = b'<?xml version="1.0" encoding="utf-8" ?>\n<QRZDatabase version="1.33" xmlns="http://xmldata.qrz.com">\n<Callsign>\n<call>MYCALL</call>\n<fname>FIRSTNAME</fname>\n<name>LASTNAME</name>\n<addr2>ADDRESS2</addr2>\n<country>COUNTRY</country>\n</Callsign>\n<Session>\n<Key>3b1fd1d3ba495189984f93ff67bd45b6</Key>\n<Count>61</Count>\n<SubExp>non-subscriber</SubExp>\n<Message>A subscription is required to access the complete record.</Message>\n<GMTime>Sun Nov 2 [...]
+        connection.getresponse.return_value = response
+
+        self.qrz.connection = connection
+        self.qrz.session_key = "3b1fd1d3ba495189984f93ff67bd45b6"
+        fields_and_data = self.qrz.lookup("MYCALL")
+        assert(fields_and_data["NAME"] == "FIRSTNAME LASTNAME")
+        assert(fields_and_data["ADDRESS"] == "ADDRESS2")
+        assert(fields_and_data["COUNTRY"] == "COUNTRY")
+
+    def test_hamqth_connect(self):
+        """ Check the example response from the hamqth.com server, and make sure the session ID has been correctly extracted. """
+
+        http_client.HTTPSConnection = mock.Mock(spec=http_client.HTTPSConnection)
+        http_client.HTTPResponse = mock.Mock(spec=http_client.HTTPResponse)
+        connection = http_client.HTTPSConnection()
+        response = http_client.HTTPResponse()
+
+        response.read.return_value = b'<?xml version="1.0"?>\n<HamQTH version="2.6" xmlns="https://www.hamqth.com">\n<session>\n<session_id>09b0ae90050be03c452ad235a1f2915ad684393c</session_id>\n</session>\n</HamQTH>\n'
+        connection.getresponse.return_value = response
+
+        result = self.hamqth.connect("hello", "world")
+        assert(result)
+        assert(self.hamqth.session_id == "09b0ae90050be03c452ad235a1f2915ad684393c")
+
+    def test_hamqth_lookup(self):
+        """ Check the example callsign lookup response from the hamqth.com server, and make sure the callsign information has been correctly extracted. """
+
+        http_client.HTTPSConnection = mock.Mock(spec=http_client.HTTPSConnection)
+        http_client.HTTPResponse = mock.Mock(spec=http_client.HTTPResponse)
+        connection = http_client.HTTPSConnection()
+        response = http_client.HTTPResponse()
+
+        response.read.return_value = b'<?xml version="1.0"?>\n<HamQTH version="2.6" xmlns="https://www.hamqth.com">\n<search>\n<callsign>MYCALL</callsign>\n<nick>NAME</nick>\n<country>COUNTRY</country>\n<itu>ITU</itu>\n<cq>CQ</cq>\n<iota>IOTA</iota>\n<adr_street1>ADDRESS</adr_street1>\n</search>\n</HamQTH>\n'
+        connection.getresponse.return_value = response
+
+        self.hamqth.connection = connection
+        self.hamqth.session_id = "09b0ae90050be03c452ad235a1f2915ad684393c"
+        fields_and_data = self.hamqth.lookup("MYCALL")
+        assert(fields_and_data["NAME"] == "NAME")
+        assert(fields_and_data["ADDRESS"] == "ADDRESS")
+        assert(fields_and_data["COUNTRY"] == "COUNTRY")
+        assert(fields_and_data["CQZ"] == "CQ")
+        assert(fields_and_data["ITUZ"] == "ITU")
+        assert(fields_and_data["IOTA"] == "IOTA")
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_compare.py b/tests/test_compare.py
new file mode 100644
index 0000000..76acfde
--- /dev/null
+++ b/tests/test_compare.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+import unittest
+from pyqso.compare import *
+
+
+class TestCompare(unittest.TestCase):
+
+    """ The unit tests for the comparison schemes. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+
+        data_types = [int] + [str]*3
+        self.model = Gtk.ListStore(*data_types)
+        row1 = [0, "100", "20150323", "1433"]
+        self.model.append(row1)
+        row2 = [1, "5000", "20160423", "1432"]
+        self.model.append(row2)
+        row3 = [2, "5000", "20160423", "1433"]
+        self.model.append(row3)
+        row4 = [3, "25", "20160423", "1433"]
+        self.model.append(row4)
+        return
+
+    def test_compare_default(self):
+        """ Check the correctness of the default comparison scheme. """
+
+        # Get the row iterables.
+        path = Gtk.TreePath(0)
+        iter1 = self.model.get_iter(path)
+        iter2 = self.model.iter_next(iter1)
+        iter3 = self.model.iter_next(iter2)
+        iter4 = self.model.iter_next(iter3)
+
+        # Compare values in the second column.
+        column_index = 1
+        result = compare_default(self.model, iter1, iter2, column_index)
+        assert(result == -1)
+        result = compare_default(self.model, iter2, iter3, column_index)
+        assert(result == 0)
+        result = compare_default(self.model, iter3, iter4, column_index)
+        assert(result == 1)
+
+    def test_compare_date_and_time(self):
+        """ Check that dates in yyyymmdd format are compared correctly. """
+
+        # Get the row iterables.
+        path = Gtk.TreePath(0)
+        iter1 = self.model.get_iter(path)
+        iter2 = self.model.iter_next(iter1)
+        iter3 = self.model.iter_next(iter2)
+        iter4 = self.model.iter_next(iter3)
+
+        # Compare values in the third (and fourth, if necessary) column.
+        column_index = 2
+        result = compare_date_and_time(self.model, iter1, iter2, [column_index, column_index+1])
+        assert(result == -1)
+        result = compare_date_and_time(self.model, iter2, iter3, [column_index, column_index+1])
+        assert(result == -1)
+        result = compare_date_and_time(self.model, iter3, iter4, [column_index, column_index+1])
+        assert(result == 0)
+        result = compare_date_and_time(self.model, iter4, iter1, [column_index, column_index+1])
+        assert(result == 1)
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_dx_cluster.py b/tests/test_dx_cluster.py
new file mode 100644
index 0000000..12a8f04
--- /dev/null
+++ b/tests/test_dx_cluster.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.dx_cluster import *
+
+
+class TestDXCluster(unittest.TestCase):
+
+    """ The unit tests for the DXCluster class. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+
+        PyQSO = mock.MagicMock()
+        self.dxcluster = DXCluster(application=PyQSO())
+
+    def test_on_telnet_io(self):
+        """ Check that the response from the Telnet server can be correctly decoded. """
+
+        telnetlib.Telnet = mock.Mock(spec=telnetlib.Telnet)
+        connection = telnetlib.Telnet("hello", "world")
+        connection.read_very_eager.return_value = b"Test message from the Telnet server."
+        self.dxcluster.connection = connection
+        result = self.dxcluster.on_telnet_io()
+        assert(result)
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_log.py b/tests/test_log.py
new file mode 100644
index 0000000..d63adfa
--- /dev/null
+++ b/tests/test_log.py
@@ -0,0 +1,227 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+from pyqso.log import *
+
+
+class TestLog(unittest.TestCase):
+
+    """ The unit tests for the Log class. """
+
+    def setUp(self):
+        """ Create a connection to a temporary database and set up the objects needed for the unit tests. """
+        self.connection = sqlite.connect(":memory:")
+        self.connection.row_factory = sqlite.Row
+
+        self.field_names = ["CALL", "QSO_DATE", "TIME_ON", "FREQ", "BAND", "MODE", "RST_SENT", "RST_RCVD"]
+        self.fields_and_data = {"CALL": "TEST123", "QSO_DATE": "20130312", "TIME_ON": "1234", "FREQ": "145.500", "BAND": "2m", "MODE": "FM", "RST_SENT": "59", "RST_RCVD": "59"}
+
+        c = self.connection.cursor()
+        query = "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT"
+        for field_name in self.field_names:
+            s = ", %s TEXT" % field_name.lower()
+            query = query + s
+        query = query + ")"
+        c.execute(query)
+
+        self.log = Log(self.connection, "test")
+
+    def tearDown(self):
+        """ Destroy the connection to the temporary database. """
+        self.connection.close()
+
+    def test_add_missing_db_columns(self):
+        """ Check that any missing columns in the database are added successfully. """
+
+        c = self.connection.cursor()
+
+        # 'Before' state.
+        column_names_before = []
+        c.execute("PRAGMA table_info(test)")
+        result = c.fetchall()
+        for t in result:
+            column_names_before.append(t[1].upper())
+
+        # Add missing columns.
+        self.log.add_missing_db_columns()
+
+        # 'After' state.
+        column_names_after = []
+        c.execute("PRAGMA table_info(test)")
+        result = c.fetchall()
+        for t in result:
+            column_names_after.append(t[1].upper())
+
+        print("Column names before: ", column_names_before)
+        print("Column names after: ", column_names_after)
+
+        assert(len(column_names_before) == len(self.field_names) + 1)  # Added 1 here because of the "id" column in all database tables.
+        assert(len(column_names_after) == len(AVAILABLE_FIELD_NAMES_ORDERED) + 1)
+        for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
+            assert(field_name in column_names_after)
+
+    def test_add_record(self):
+        """ Check that a single record can be successfully added. """
+
+        self.log.add_record(self.fields_and_data)
+
+        c = self.connection.cursor()
+        c.execute("SELECT * FROM test")
+        records = c.fetchall()
+        assert len(records) == 1
+
+        # Check that all the data has been added to all the fields.
+        for field_name in self.field_names:
+            print(self.fields_and_data[field_name], records[0][field_name])
+            assert self.fields_and_data[field_name] == records[0][field_name]
+
+        # Check consistency of index between Gtk.ListStore and the database.
+        assert(records[0]["id"] == 1)
+        iter = self.log.get_iter_first()
+        row_index = self.log.get_value(iter, 0)
+        assert(records[0]["id"] == row_index)
+
+    def test_add_record_multiple(self):
+        """ Check that multiple records can be successfully added in one go. """
+        self.log.add_record([self.fields_and_data]*5)
+
+        c = self.connection.cursor()
+        c.execute("SELECT * FROM test")
+        records = c.fetchall()
+        assert len(records) == 5
+
+    def test_delete_record(self):
+        """ Check that a record can be successfully deleted. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+
+        c.execute("SELECT * FROM test")
+        records_before = c.fetchall()
+
+        self.log.delete_record(1)
+
+        c.execute("SELECT * FROM test")
+        records_after = c.fetchall()
+
+        assert(len(records_before) == 1)
+        assert(len(records_after) == 0)
+
+    def test_edit_record(self):
+        """ Check that a record's fields can be successfully edited. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+
+        c.execute("SELECT * FROM test")
+        record_before = c.fetchall()[0]
+
+        self.log.edit_record(1, "CALL", "TEST456")
+        self.log.edit_record(1, "FREQ", "145.450")
+
+        c.execute("SELECT * FROM test")
+        record_after = c.fetchall()[0]
+
+        assert(record_before["CALL"] == "TEST123")
+        assert(record_after["CALL"] == "TEST456")
+        assert(record_before["FREQ"] == "145.500")
+        assert(record_after["FREQ"] == "145.450")
+
+    def test_get_record_by_index(self):
+        """ Check that a record can be retrieved using its index. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+
+        record = self.log.get_record_by_index(1)
+        print("Contents of retrieved record: ", record)
+        for field_name in list(record.keys()):
+            if(field_name.upper() == "ID"):
+                continue
+            else:
+                assert(record[field_name.upper()] == self.fields_and_data[field_name.upper()])
+        assert(len(record) == len(self.fields_and_data) + 1)
+
+    def test_records(self):
+        """ Check that all records in a log can be successfully retrieved. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        # Add the same record twice
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+
+        records = self.log.records
+        print("Contents of all retrieved records: ", records)
+        assert(len(records) == 2)  # There should be 2 records
+        for field_name in self.field_names:
+            assert(records[0][field_name] == self.fields_and_data[field_name])
+            assert(records[1][field_name] == self.fields_and_data[field_name])
+
+    def test_record_count(self):
+        """ Check that the total number of records in a log is calculated correctly. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        # Add the same record twice
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+        c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+
+        record_count = self.log.record_count
+        print("Number of records in the log: ", record_count)
+        assert(record_count == 2)  # There should be 2 records
+
+    def test_get_duplicates(self):
+        """ Insert n records, n-1 of which are duplicates, and check that the duplicates are successfully identified. """
+        query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
+        c = self.connection.cursor()
+        n = 5  # The total number of records to insert.
+        for i in range(0, n):
+            c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
+        assert(len(self.log.get_duplicates()) == n-1)  # Expecting n-1 duplicates.
+
+    def test_remove_duplicates(self):
+        """ Insert n records, n-1 of which are duplicates, and check that the duplicates are successfully removed. """
+        n = 5  # The total number of records to insert.
+        for i in range(0, n):
+            self.log.add_record(self.fields_and_data)
+        (number_of_duplicates, number_of_duplicates_removed) = self.log.remove_duplicates()
+        print("Number of duplicates: %d" % number_of_duplicates)
+        print("Number of duplicates removed: %d" % number_of_duplicates_removed)
+        assert(number_of_duplicates == number_of_duplicates_removed)
+        assert(number_of_duplicates == 4)
+        assert(self.log.record_count == 1)
+
+    def test_rename(self):
+        """ Check that a log can be successfully renamed. """
+        old_name = "test"
+        new_name = "hello"
+        success = self.log.rename(new_name)
+        assert(success)
+        with self.connection:
+            c = self.connection.cursor()
+            c.execute("SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE name=?)", [old_name])
+            exists = c.fetchone()
+            assert(exists[0] == 0)  # Old log name should no longer exist.
+            c.execute("SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE name=?)", [new_name])
+            exists = c.fetchone()
+            assert(exists[0] == 1)  # New log name should now exist.
+        assert(self.log.name == new_name)
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_logbook.py b/tests/test_logbook.py
new file mode 100644
index 0000000..14091d8
--- /dev/null
+++ b/tests/test_logbook.py
@@ -0,0 +1,144 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+import os
+from shutil import copyfile
+from pyqso.logbook import *
+
+
+class TestLogbook(unittest.TestCase):
+
+    """ The unit tests for the Logbook class. """
+
+    @mock.patch('pyqso.logbook.Logbook.filter_by_callsign')
+    def setUp(self, mock_filter_by_callsign):
+        """ Set up the Logbook object and connection to the test database needed for the unit tests. """
+
+        self.logbook = Logbook(application=mock.MagicMock())
+
+        # Open the test database file.
+        path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
+        opened = self.logbook.open(path=path_to_test_database)
+        assert(opened)
+        assert(self.logbook.connection is not None)
+
+        # Check that the logs have been retrieved.
+        assert(len(self.logbook.logs) == 2)
+        assert(self.logbook.logs[0].name == "test")
+        assert(self.logbook.logs[1].name == "test2")
+
+    def tearDown(self):
+        """ Close the logbook and disconnect from the test database. """
+        self.logbook.notebook.get_n_pages.return_value = 0
+        closed = self.logbook.close()
+        assert(closed)
+
+    def test_db_disconnect(self):
+        """ Check that the logbook can disconnect from the database. """
+        disconnected = self.logbook.db_disconnect()
+        assert(disconnected)
+        # Attempt to disconnect again. This shouldn't do anything.
+        disconnected = self.logbook.db_disconnect()
+        assert(disconnected)
+
+    @mock.patch('pyqso.auxiliary_dialogs.handle_gtk_dialog')
+    @mock.patch('gi.repository.Gtk.FileChooserDialog')
+    def test_new(self, mock_FileChooserDialog, mock_handle_gtk_dialog):
+        """ Check that a new logbook can be created. """
+        mock_FileChooserDialog().run.return_value = Gtk.ResponseType.OK
+        mock_FileChooserDialog().get_filename.return_value = "Logbook.test_new.db"
+        self.logbook.new()
+        assert(os.path.isfile("Logbook.test_new.db"))
+
+    @mock.patch('pyqso.auxiliary_dialogs.handle_gtk_dialog')
+    def test_open_invalid_logbook(self, mock_handle_gtk_dialog):
+        """ Open an invalid database file (comprising only one line of plain text) and check that an error occurs. """
+        invalid_logbook = Logbook(application=mock.MagicMock())
+        path_to_invalid_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "invalid.db")
+        opened = invalid_logbook.open(path=path_to_invalid_database)
+        assert(not opened)
+        assert(not invalid_logbook.logs)
+
+    @mock.patch('pyqso.logbook.Logbook.render_log')
+    @mock.patch('pyqso.auxiliary_dialogs.handle_gtk_dialog')
+    @mock.patch('pyqso.logbook.LogNameDialog')
+    def test_new_log(self, mock_LogNameDialog, mock_handle_gtk_dialog, mock_render_log):
+        """ Create an empty logbook file, open it, and check that a new log can successfully be added. """
+        # Create a copy of the test database just for use in this particular test, since the contents will need to be modified.
+        path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
+        destination = "Logbook.test_new_log.db"
+        copyfile(path_to_test_database, destination)
+        opened = self.logbook.open(path=destination)
+        assert(opened)
+        mock_LogNameDialog().dialog.run.return_value = Gtk.ResponseType.OK
+        mock_LogNameDialog().name = "my_new_log"
+        self.logbook.new_log()
+        assert(len(self.logbook.logs) == 3)
+        assert(self.logbook.logs[-1].name == "my_new_log")
+
+    def test_log_name_exists(self):
+        """ Check that only the log called 'test' exists. """
+        assert(self.logbook.log_name_exists("test"))  # Log 'test' exists.
+        assert(not self.logbook.log_name_exists("hello"))  # Log 'hello' should not exist.
+
+    def test_log_count(self):
+        """ Check the log count. """
+        assert(self.logbook.log_count == 2)
+
+    def test_record_count(self):
+        """ Check the total number of records over all the logs in the logbook. """
+        assert(self.logbook.record_count == 7)
+
+    def test_filter_by_callsign(self):
+        """ Check that callsigns are filtered correctly. """
+
+        # Consider only the first record of the first log.
+        model = self.logbook.logs[0]
+        path = Gtk.TreePath(0)
+        iter = model.get_iter(path)
+
+        self.logbook.application.toolbar.filter_source.get_text.return_value = ""
+        present = self.logbook.filter_by_callsign(model, iter, data=None)
+        assert(present)  # Show all the callsigns.
+
+        self.logbook.application.toolbar.filter_source.get_text.return_value = "TEST123"
+        present = self.logbook.filter_by_callsign(model, iter, data=None)
+        assert(present)  # "TEST123" is present.
+
+        self.logbook.application.toolbar.filter_source.get_text.return_value = "TEST"
+        present = self.logbook.filter_by_callsign(model, iter, data=None)
+        assert(present)  # "TEST" is present in "TEST123"
+
+        self.logbook.application.toolbar.filter_source.get_text.return_value = "HELLOWORLD"
+        present = self.logbook.filter_by_callsign(model, iter, data=None)
+        assert(not present)  # "HELLOWORLD" is not present in "TEST123"
+
+    def test_get_log_index(self):
+        """ Check that a log's index can be resolved using the log's name. """
+        assert(self.logbook.get_log_index(name="test") == 0)
+        assert(self.logbook.get_log_index(name="test2") == 1)
+        assert(self.logbook.get_log_index(name="helloworld") is None)
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_printer.py b/tests/test_printer.py
new file mode 100644
index 0000000..68a09ef
--- /dev/null
+++ b/tests/test_printer.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+import os
+from pyqso.printer import *
+
+
+class TestPrinter(unittest.TestCase):
+
+    """ The unit tests for the Printer class. """
+
+    def setUp(self):
+        """ Set up the Printer object. """
+        PyQSO = mock.MagicMock()
+        self.printer = Printer(application=PyQSO())
+        self.printer.application.window = Gtk.Window()
+
+    def test_print_records(self):
+        """ Check that a list of records can be printed to a PDF file. """
+        self.printer.action = Gtk.PrintOperationAction.EXPORT
+        pdf = "Printer.test_print_records.pdf"
+        self.printer.operation.set_export_filename(pdf)
+        records = [{"id": 1, "CALL": "MYCALL", "QSO_DATE": "24062017", "TIME_ON": "1519", "FREQ": "145.550", "MODE": "FM", "RST_SENT": "59", "RST_RCVD": "57"}]
+        result = self.printer.print_records(records)
+        assert(result != Gtk.PrintOperationResult.ERROR)
+        assert(result == Gtk.PrintOperationResult.APPLY)
+        assert(os.path.exists(pdf))
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_record_dialog.py b/tests/test_record_dialog.py
new file mode 100644
index 0000000..8913398
--- /dev/null
+++ b/tests/test_record_dialog.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+from gi.repository import Gtk
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.record_dialog import *
+
+
+class TestRecordDialog(unittest.TestCase):
+
+    """ The unit tests for the RecordDialog class. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests. """
+        PyQSO = mock.MagicMock()
+        self.record_dialog = RecordDialog(application=PyQSO(), log=None)
+        self.record_dialog.frequency_unit = "MHz"
+
+        # Set up the necessary sources.
+        self.record_dialog.sources["FREQ"] = Gtk.Entry()
+
+        self.record_dialog.sources["BAND"] = Gtk.ComboBoxText()
+        for band in BANDS:
+            self.record_dialog.sources["BAND"].append_text(band)
+
+        self.record_dialog.sources["MODE"] = Gtk.ComboBoxText()
+        for mode in sorted(MODES.keys()):
+            self.record_dialog.sources["MODE"].append_text(mode)
+
+        self.record_dialog.sources["SUBMODE"] = Gtk.ComboBoxText()
+        self.record_dialog.sources["SUBMODE"].append_text("")
+        self.record_dialog.sources["SUBMODE"].set_active(0)
+
+        return
+
+    def test_autocomplete_band(self):
+        """ Given a frequency, check that the band field is automatically set to the correct value. """
+        self.record_dialog.sources["FREQ"].set_text("145.525")
+        self.record_dialog.autocomplete_band()
+        band = self.record_dialog.sources["BAND"].get_active_text()
+        assert(band == "2m")
+
+        self.record_dialog.sources["FREQ"].set_text("9001")
+        self.record_dialog.autocomplete_band()
+        band = self.record_dialog.sources["BAND"].get_active_text()
+        assert(band == "")  # Frequency does not lie in any of the specified bands.
+
+    def test_convert_frequency(self):
+        """ Check that a frequency can be successfully converted from one unit to another. """
+        frequency = "7.140"  # In MHz
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="AHz")  # Unknown to_unit. This should return the input unmodified (and give an error message).
+        assert(converted == frequency)
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="kHz")  # Convert from MHz to kHz.
+        assert(float(converted) == 1e3*float(frequency))
+        converted = self.record_dialog.convert_frequency(converted, from_unit="kHz", to_unit="MHz")  # Convert from kHz back to MHz. This should give the original frequency.
+        assert(float(converted) == float(frequency))
+
+        # Floating-point data type.
+        frequency = 7.140  # In MHz
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="kHz")
+        assert(converted == frequency*1e3)
+
+        # Floating-point data type.
+        frequency = 7.140  # In MHz
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="MHz")
+        assert(converted == frequency)
+
+        # Empty string.
+        frequency = ""
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="kHz")
+        assert(converted == frequency)
+
+        # Not a valid frequency.
+        frequency = "HelloWorld"
+        converted = self.record_dialog.convert_frequency(frequency, from_unit="MHz", to_unit="kHz")
+        assert(converted == frequency)
+
+    def test_hamlib_autofill(self):
+        """ Check that FREQ, MODE and SUBMODE information can be retrieved from Hamlib's dummy rig (if the Hamlib module exists). """
+        if(have_hamlib):
+            rig_model = "RIG_MODEL_DUMMY"
+            rig_pathname = "/dev/Rig"
+            self.record_dialog.hamlib_autofill(rig_model, rig_pathname)
+            assert(self.record_dialog.sources["FREQ"].get_text() == "145.000000")
+            assert(self.record_dialog.sources["MODE"].get_active_text() == "FM")
+            assert(self.record_dialog.sources["SUBMODE"].get_active_text() == "")
+        else:
+            pass
+
+if(__name__ == '__main__'):
+    unittest.main()
diff --git a/tests/test_summary.py b/tests/test_summary.py
new file mode 100644
index 0000000..ae640c9
--- /dev/null
+++ b/tests/test_summary.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+
+#    Copyright (C) 2017 Christian Thomas Jacobs.
+
+#    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/>.
+
+import os
+import unittest
+try:
+    import unittest.mock as mock
+except ImportError:
+    import mock
+from pyqso.summary import *
+from pyqso.logbook import Logbook
+
+
+class TestSummary(unittest.TestCase):
+
+    """ The unit tests for the Summary class. """
+
+    def setUp(self):
+        """ Set up the objects needed for the unit tests and create a connection to the test database. """
+        PyQSO = mock.MagicMock()
+        self.summary = Summary(application=PyQSO())
+        self.summary.logbook = Logbook(application=PyQSO())
+        path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
+        success = self.summary.logbook.db_connect(path_to_test_database)
+        assert(success)
+        self.summary.logbook.logs = self.summary.logbook.get_logs()
+        assert(self.summary.logbook.logs is not None)
+
+    def tearDown(self):
+        """ Destroy the connection to the test database. """
+        success = self.summary.logbook.db_disconnect()
+        assert(success)
+
+    def test_get_year_bounds(self):
+        """ Check that the years of the earliest and latest QSO are correct. """
+        year_min, year_max = self.summary.get_year_bounds()
+        assert(year_min == 2012)
+        assert(year_max == 2017)
+
+    def test_get_annual_contact_count(self):
+        """ Check that there are 3 QSOs in the year 2017. """
+        count = self.summary.get_annual_contact_count(2017)
+        april = datetime(2017, 4, 1)
+        april_count = count[april]
+        assert(april_count == 3)  # A total of 3 contacts made in April.
+        assert(sum(count.values()) == 4)  # A total of 4 contacts made that whole year.
+
+    def test_get_annual_mode_count(self):
+        """ Check that, in the year 2017, there was 1 QSO made using CW, 2 QSOs made using FM, and 1 QSO made using SSB. """
+        count = self.summary.get_annual_mode_count(2017)
+        assert(count["CW"] == 1)
+        assert(count["FM"] == 2)
+        assert(count["SSB"] == 1)
+
+if(__name__ == '__main__'):
+    unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/pyqso.git



More information about the pkg-hamradio-commits mailing list