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

class EditBlockTimesWin(Gtk.Window):
    '''Handling of the window used for editing a block of times'''

    def __init__(self, parent, okclicked_cb):
        '''Builds and display the window for editing block of times'''
        super(EditBlockTimesWin, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.okclicked_cb = okclicked_cb
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        self.set_transient_for(parent)
        self.set_modal(True)
        self.set_title('fsTimer - Edit times')
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_border_width(20)
        self.connect('delete_event', lambda b, jnk: self.hide())
        label0 = Gtk.Label(label='')
        label0.set_markup('<span color="red">WARNING: Changes to times cannot be automatically undone</span>\nIf you change the times and forget the old values, they will be gone forever.')
        label1 = Gtk.Label(label='Time (h:mm:ss) to be added or subtracted from all selected times:')
        self.radiobutton = Gtk.RadioButton(group=None, label="ADD")
        self.radiobutton.set_active(True)
        radiobutton2 = Gtk.RadioButton(group=self.radiobutton, label="SUBTRACT")
        self.entrytime = Gtk.Entry()
        self.entrytime.set_max_length(7)
        self.entrytime.set_text('0:00:00')
        hbox1 = Gtk.HBox(False, 10)
        hbox1.pack_start(self.radiobutton, False, False, 0)
        hbox1.pack_start(radiobutton2, False, False, 0)
        hbox1.pack_start(self.entrytime, False, False, 0)
        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/editblocktimes.py
import gi
import fstimer.gui
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton


class EditBlockTimesWin(Gtk.Window):
    '''Handling of the window used for editing a block of times'''

    def __init__(self, parent, okclicked_cb):
        '''Builds and display the window for editing block of times'''
        super(EditBlockTimesWin, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.okclicked_cb = okclicked_cb
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        self.set_transient_for(parent)
        self.set_modal(True)
        self.set_title('fsTimer - Edit times')
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_border_width(20)
        self.connect('delete_event', lambda b, jnk: self.hide())
        label0 = Gtk.Label(label='')
        label0.set_markup('<span color="red">WARNING: Changes to times cannot be automatically undone</span>\nIf you change the times and forget the old values, they will be gone forever.')
        label1 = Gtk.Label(label='Time (h:mm:ss) to be added or subtracted from all selected times:')
        self.radiobutton = Gtk.RadioButton(group=None, label="ADD")
        self.radiobutton.set_active(True)
        radiobutton2 = Gtk.RadioButton(group=self.radiobutton, label="SUBTRACT")
        self.entrytime = Gtk.Entry()
        self.entrytime.set_max_length(7)
        self.entrytime.set_text('0:00:00')
        hbox1 = Gtk.HBox(False, 10)
        hbox1.pack_start(self.radiobutton, False, False, 0)
        hbox1.pack_start(radiobutton2, False, False, 0)
        hbox1.pack_start(self.entrytime, False, False, 0)
        btnOK = GtkStockButton('ok',"OK")
        btnOK.connect('clicked', self.okclicked)

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