# Path: fstimer/gui/util_classes.py
# class MsgDialog(Gtk.Dialog):
#     
#     def __init__(self, parent, icon_name, buttons, title, text):
#         super(MsgDialog, self).__init__(title, parent, Gtk.DialogFlags.MODAL)
#         btn_list = []
#         for i, btn_name in enumerate(buttons):
#             icon, label, signal = dialog_buttons[btn_name]
#             btn = GtkStockButton(icon, label)
#             btn.connect('clicked', self.click_response, signal)
#             btn_list.append(btn)
#         self.set_border_width(5)
#         self.set_default_size(400, 50)
#         #Load in the icon
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         msg_icon = Gtk.Image.new_from_file(fname)
#         label = Gtk.Label(label=text)
#         #And pack
#         hbox = Gtk.HBox(False, 0)
#         hbox.pack_start(msg_icon, False, False,10)
#         hbox.pack_start(label, False, False,10)
#         vbox = Gtk.VBox(False, 0)
#         vbox.pack_start(hbox, True, True, 15)
#         # Pack in all of the buttons
#         hbox_btns = Gtk.HBox(False, 0)
#         align = Gtk.Alignment.new(1, 0, 1, 0)
#         hbox_btns.pack_start(align, True, True, 0)
#         for btn in btn_list:
#             hbox_btns.pack_start(btn, False, False, 5)
#         vbox.pack_start(hbox_btns, False, False, 0)
#         self.get_content_area().add(vbox)
#         self.show_all()
#     
#     def click_response(self, w, signal):
#         self.response(signal)
# 
# 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
import re
from gi.repository import Gtk
from fstimer.gui.util_classes import MsgDialog
from fstimer.gui.util_classes import GtkStockButton
                preregiter = self.prereg.index(current_info)
                # converts the treeiter from sorted to filter to model, and remove
                self.regmodel.remove(self.modelfilter.convert_iter_to_child_iter(self.modelfiltersorted.convert_iter_to_child_iter(treeiter)))
                try:
                    self.ids.remove(current_info['ID'])
                except:
                    pass
                self.prereg.pop(preregiter)
                # The latest stuff has no longer been saved.
                self.regstatus.set_markup('')

    def new_clicked(self, jnk_unused):
        '''Handles click on the 'new' button on the registration window
           Creates the editreg window with a None treeiter and clear initial values.'''
        self.edit_registration(None, None, None)

    def save_clicked(self, jnk_unused):
        '''Handles click on the 'save' button on the registration window.
           We do a json dump of self.prereg'''
        filename, success = self.save_registration_cb()
        if success:
            self.regstatus.set_markup('<span color="blue">Registration saved to %s</span>' % filename)
            return True
        else:
            self.regstatus.set_markup('<span color="red">Registration NOT saved: %s</span>' % filename)
            return False

    def close_clicked(self, jnk_unused):
        '''Handles click on the 'close' button on the registration window.
           Throws up a 'do you want to save' dialog, and close the window'''

# Path: fstimer/gui/util_classes.py
# class MsgDialog(Gtk.Dialog):
#     
#     def __init__(self, parent, icon_name, buttons, title, text):
#         super(MsgDialog, self).__init__(title, parent, Gtk.DialogFlags.MODAL)
#         btn_list = []
#         for i, btn_name in enumerate(buttons):
#             icon, label, signal = dialog_buttons[btn_name]
#             btn = GtkStockButton(icon, label)
#             btn.connect('clicked', self.click_response, signal)
#             btn_list.append(btn)
#         self.set_border_width(5)
#         self.set_default_size(400, 50)
#         #Load in the icon
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         msg_icon = Gtk.Image.new_from_file(fname)
#         label = Gtk.Label(label=text)
#         #And pack
#         hbox = Gtk.HBox(False, 0)
#         hbox.pack_start(msg_icon, False, False,10)
#         hbox.pack_start(label, False, False,10)
#         vbox = Gtk.VBox(False, 0)
#         vbox.pack_start(hbox, True, True, 15)
#         # Pack in all of the buttons
#         hbox_btns = Gtk.HBox(False, 0)
#         align = Gtk.Alignment.new(1, 0, 1, 0)
#         hbox_btns.pack_start(align, True, True, 0)
#         for btn in btn_list:
#             hbox_btns.pack_start(btn, False, False, 5)
#         vbox.pack_start(hbox_btns, False, False, 0)
#         self.get_content_area().add(vbox)
#         self.show_all()
#     
#     def click_response(self, w, signal):
#         self.response(signal)
# 
# 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/register.py
import gi
import fstimer.gui
import os
import re
from gi.repository import Gtk
from fstimer.gui.util_classes import MsgDialog
from fstimer.gui.util_classes import GtkStockButton

                preregiter = self.prereg.index(current_info)
                # converts the treeiter from sorted to filter to model, and remove
                self.regmodel.remove(self.modelfilter.convert_iter_to_child_iter(self.modelfiltersorted.convert_iter_to_child_iter(treeiter)))
                try:
                    self.ids.remove(current_info['ID'])
                except:
                    pass
                self.prereg.pop(preregiter)
                # The latest stuff has no longer been saved.
                self.regstatus.set_markup('')

    def new_clicked(self, jnk_unused):
        '''Handles click on the 'new' button on the registration window
           Creates the editreg window with a None treeiter and clear initial values.'''
        self.edit_registration(None, None, None)

    def save_clicked(self, jnk_unused):
        '''Handles click on the 'save' button on the registration window.
           We do a json dump of self.prereg'''
        filename, success = self.save_registration_cb()
        if success:
            self.regstatus.set_markup('<span color="blue">Registration saved to %s</span>' % filename)
            return True
        else:
            self.regstatus.set_markup('<span color="red">Registration NOT saved: %s</span>' % filename)
            return False

    def close_clicked(self, jnk_unused):
        '''Handles click on the 'close' button on the registration window.
           Throws up a 'do you want to save' dialog, and close the window'''

        okreg_dialog = MsgDialog(self, 'question', ['yes', 'no'], 'Save?', 'Do you want to save before finishing?\nUnsaved data will be lost.')