# 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
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#The author/copyright holder can be contacted at bletham@gmail.com
'''Handling of the window used for editing t0, the race start time'''

gi.require_version('Gtk', '3.0')

class EditT0Win(Gtk.Window):
    '''Handling of the window used for editing t0, the race start time'''

    def __init__(self, path, parent, t0, okclicked_cb):
        '''Builds and display the edit t0 window'''
        super(EditT0Win, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.okclicked_cb = okclicked_cb
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        self.set_title('fsTimer - ' + os.path.basename(path))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_transient_for(parent)
        self.set_modal(True)
        self.connect('delete_event', lambda b, jnk: self.hide())
        label = Gtk.Label("""This is the starting time in seconds.\
            \nAdd or subtract seconds from this number to adjust the start time by that many seconds.\
            \nNote that this will NOT affect times that have already been marked, only future times.""")
        self.t0box = Gtk.Entry()
        self.t0box.set_text(str(t0))
        hbox = Gtk.HBox(False, 8)
        btnOK = GtkStockButton('ok',"OK")
        btnOK.connect('clicked', self.okclicked)

# 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/editt0.py
import gi
import fstimer.gui
import os
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton


#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#The author/copyright holder can be contacted at bletham@gmail.com
'''Handling of the window used for editing t0, the race start time'''

gi.require_version('Gtk', '3.0')

class EditT0Win(Gtk.Window):
    '''Handling of the window used for editing t0, the race start time'''

    def __init__(self, path, parent, t0, okclicked_cb):
        '''Builds and display the edit t0 window'''
        super(EditT0Win, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.okclicked_cb = okclicked_cb
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        self.set_title('fsTimer - ' + os.path.basename(path))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_transient_for(parent)
        self.set_modal(True)
        self.connect('delete_event', lambda b, jnk: self.hide())
        label = Gtk.Label("""This is the starting time in seconds.\
            \nAdd or subtract seconds from this number to adjust the start time by that many seconds.\
            \nNote that this will NOT affect times that have already been marked, only future times.""")
        self.t0box = Gtk.Entry()
        self.t0box.set_text(str(t0))
        hbox = Gtk.HBox(False, 8)
        btnOK = GtkStockButton('ok',"OK")
        btnOK.connect('clicked', self.okclicked)

        btnCANCEL = GtkStockButton('close',"Cancel")