More moving of toolbar over to Glade.

pull/54/head
Christian T. Jacobs 2017-02-21 19:16:13 +00:00
rodzic fdc3a5f051
commit f266e6def8
3 zmienionych plików z 31 dodań i 66 usunięć

Wyświetl plik

@ -96,7 +96,7 @@ class PyQSO:
# Set up menu and tool bars. These classes depend on the Logbook and Toolbox class.
self.menu = Menu(self, self.builder)
#self.toolbar = Toolbar(self)
self.toolbar = Toolbar(self, self.builder)
self.window.show_all()

Wyświetl plik

@ -379,7 +379,7 @@
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkButton" id="toolbar_button_new_logbook">
<object class="GtkButton" id="toolbar_new_logbook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -400,7 +400,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="toolbar_button_open_logbook">
<object class="GtkButton" id="toolbar_open_logbook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -421,7 +421,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="toolbar_button_close_logbook">
<object class="GtkButton" id="toolbar_close_logbook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -454,7 +454,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="toolbar_button_add_record">
<object class="GtkButton" id="toolbar_add_record">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -475,7 +475,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="toolbar_button_edit_record">
<object class="GtkButton" id="toolbar_edit_record">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -496,7 +496,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="toolbar_button_delete_record">
<object class="GtkButton" id="toolbar_delete_record">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -529,7 +529,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label_filter">
<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>
@ -845,6 +845,9 @@
<property name="position">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>

Wyświetl plik

@ -25,84 +25,46 @@ class Toolbar:
""" The toolbar underneath the menu bar. """
def __init__(self, parent):
def __init__(self, parent, builder):
""" Set up the various buttons in the toolbar, and connect to their corresponding functions. """
logging.debug("Setting up the toolbar...")
self.parent = parent
self.builder = 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", parent.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", parent.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", parent.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", parent.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", parent.logbook.edit_record_callback, None, None)
# 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", parent.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.buttons["DELETE_RECORD"] = self.builder.get_object("toolbar_delete_record")
self.buttons["DELETE_RECORD"].connect("clicked", parent.logbook.delete_record_callback)
self.filter_source = self.builder.get_object("filter_source")
self.filter_source.connect_after("changed", parent.logbook.filter_logs)
self.pack_start(self.filter_source, False, False, 0)
self.set_logbook_button_sensitive(True)
self.set_record_buttons_sensitive(False)