kopia lustrzana https://github.com/ctjacobs/pyqso
Moved the blank/dummy page to blank.py
rodzic
68dfa0f9d6
commit
c53c7ab9a3
|
@ -0,0 +1,59 @@
|
|||
#!/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):
|
||||
def __init__(self, application):
|
||||
""" Create a blank page in the Gtk.Notebook for the "+" (New Log) tab.
|
||||
|
||||
:arg application: The PyQSO application containing the main Gtk window, etc.
|
||||
"""
|
||||
|
||||
self.application = application
|
||||
|
||||
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)
|
||||
page = Gtk.VBox()
|
||||
page.pack_start(sw, True, True, 0)
|
||||
|
||||
# Add a "+" button to the tab
|
||||
tab = 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.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
|
|
@ -39,6 +39,7 @@ 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
|
||||
|
||||
|
@ -140,7 +141,7 @@ class Logbook:
|
|||
self.sorter = []
|
||||
self.filter = []
|
||||
self.summary = Summary(self.application)
|
||||
self.create_dummy_page()
|
||||
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.
|
||||
|
@ -228,36 +229,6 @@ class Logbook:
|
|||
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.notebook.insert_page(vbox, hbox, 1)
|
||||
self.notebook.show_all()
|
||||
self.notebook.set_current_page(0)
|
||||
return
|
||||
|
||||
def on_switch_page(self, widget, label, new_page):
|
||||
""" Handle a tab/page change, and enable/disable the relevant Record-related buttons. """
|
||||
|
||||
|
@ -998,7 +969,7 @@ class Logbook:
|
|||
# If no page name is supplied, then just use the currently selected page
|
||||
page_index = self.notebook.get_current_page() # Gets 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) dummy page.
|
||||
# We either have the Summary page, or the "+" (add log) blank/dummy page.
|
||||
logging.debug("No log currently selected!")
|
||||
return None
|
||||
name = self.notebook.get_nth_page(page_index).get_name()
|
||||
|
|
Ładowanie…
Reference in New Issue