# Path: fstimer/gui/util_classes.py
# class GtkStockButton(Gtk.Button):
#     
#     def __init__(self, icon_name, label_text):
#         #Init a regular Gtk.Button
#         Gtk.Button.__init__(self)
#         #Add the icon and the label.
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         btnIcon = Gtk.Image.new_from_file(fname)
#         btnLabel = Gtk.Label(label_text+' ')
#         #pack 'em into an HBox
#         btnHbox = Gtk.HBox(False, 0)
#         btnHbox.pack_start(btnIcon, False, False, 0)
#         btnHbox.pack_start(btnLabel, True, True, 0)
#         self.add(btnHbox)
#         return


import gi
import fstimer.gui
import os, json
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton
        btmhbox.pack_start(btnCANCEL, False, False, 8)
        btmalign = Gtk.Alignment.new(1, 0, 0, 0)
        btmalign.add(btmhbox)
        hbox = Gtk.HBox(False, 10)
        hbox.pack_start(btnFILE, False, False, 8)
        hbox.pack_start(self.pretimefilelabel, False, False, 8)
        hbox2 = Gtk.HBox(False, 10)
        hbox2.pack_start(self.entry1, False, False, 8)
        hbox2.pack_start(label2, False, False, 8)
        vbox = Gtk.VBox(False, 10)
        vbox.pack_start(hbox, False, False, 8)
        vbox.pack_start(hbox2, False, False, 8)
        vbox.pack_start(hbox3, False, False, 8)
        vbox.pack_start(btmalign, False, False, 8)
        self.add(vbox)
        self.show_all()

    def choose_timingdict(self, jnk_unused):
        '''Handles click on Choose file button
           Converts the selected file into a defaultdict'''
        chooser = Gtk.FileChooserDialog(title='Choose timing dictionary', parent=self, action=Gtk.FileChooserAction.OPEN, buttons=('Cancel', Gtk.ResponseType.CANCEL, 'OK', Gtk.ResponseType.OK))
        chooser.set_current_folder(self.path)
        ffilter = Gtk.FileFilter()
        ffilter.set_name('Timing dictionaries')
        ffilter.add_pattern('*_timing_dict.json')
        chooser.add_filter(ffilter)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            filename = chooser.get_filename()
            self.timing.clear() # reset

# Path: fstimer/gui/util_classes.py
# class GtkStockButton(Gtk.Button):
#     
#     def __init__(self, icon_name, label_text):
#         #Init a regular Gtk.Button
#         Gtk.Button.__init__(self)
#         #Add the icon and the label.
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         btnIcon = Gtk.Image.new_from_file(fname)
#         btnLabel = Gtk.Label(label_text+' ')
#         #pack 'em into an HBox
#         btnHbox = Gtk.HBox(False, 0)
#         btnHbox.pack_start(btnIcon, False, False, 0)
#         btnHbox.pack_start(btnLabel, True, True, 0)
#         self.add(btnHbox)
#         return


# Path: fstimer/gui/pretime.py
import gi
import fstimer.gui
import os, json
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton

        btmhbox.pack_start(btnCANCEL, False, False, 8)
        btmalign = Gtk.Alignment.new(1, 0, 0, 0)
        btmalign.add(btmhbox)
        hbox = Gtk.HBox(False, 10)
        hbox.pack_start(btnFILE, False, False, 8)
        hbox.pack_start(self.pretimefilelabel, False, False, 8)
        hbox2 = Gtk.HBox(False, 10)
        hbox2.pack_start(self.entry1, False, False, 8)
        hbox2.pack_start(label2, False, False, 8)
        vbox = Gtk.VBox(False, 10)
        vbox.pack_start(hbox, False, False, 8)
        vbox.pack_start(hbox2, False, False, 8)
        vbox.pack_start(hbox3, False, False, 8)
        vbox.pack_start(btmalign, False, False, 8)
        self.add(vbox)
        self.show_all()

    def choose_timingdict(self, jnk_unused):
        '''Handles click on Choose file button
           Converts the selected file into a defaultdict'''
        chooser = Gtk.FileChooserDialog(title='Choose timing dictionary', parent=self, action=Gtk.FileChooserAction.OPEN, buttons=('Cancel', Gtk.ResponseType.CANCEL, 'OK', Gtk.ResponseType.OK))
        chooser.set_current_folder(self.path)
        ffilter = Gtk.FileFilter()
        ffilter.set_name('Timing dictionaries')
        ffilter.add_pattern('*_timing_dict.json')
        chooser.add_filter(ffilter)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            filename = chooser.get_filename()
            self.timing.clear() # reset

            try: