# 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/util_classes.py
# class MenuItemIcon(Gtk.MenuItem):
#     
#     def __init__(self, icon_name, text, cb, *args):
#         super(MenuItemIcon, self).__init__()
#         hbox = Gtk.HBox(False, 0)
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         msg_icon = Gtk.Image.new_from_file(fname)
#         hbox.pack_start(msg_icon, False, False, 0)
#         hbox.pack_start(Gtk.Label(label=text), False, False, 5)
#         hbox.pack_start(Gtk.Alignment.new(1, 0, 1, 0), True, True, 0)
#         self.add(hbox)
#         self.connect('activate', cb, *args)


import gi
import fstimer.gui
import webbrowser, os
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton
from fstimer.gui.util_classes import MenuItemIcon
'''Handles the root window of the application'''

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

class RootWin(Gtk.Window):
    '''Handles the root window of the application'''

    def __init__(self, path, show_about_cb, importprereg_cb,
                 prereg_cb, compreg_cb, pretime_cb, edit_cb):
        '''Creates the root window with choices for the tasks'''
        super(RootWin, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        fname = os.path.abspath(
            os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                '../data/icon.png'))
        self.set_icon_from_file(fname)
        self.set_title('fsTimer - ' + os.path.basename(path))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete_event', Gtk.main_quit)
        self.set_border_width(0)
        # Generate the menubar
        mb = Gtk.MenuBar()
        helpmenu = Gtk.Menu()
        helpm = Gtk.MenuItem('Menu')
        helpm.set_submenu(helpmenu)
        menuedit = MenuItemIcon('edit', 'Edit project settings', edit_cb, True)
        helpmenu.append(menuedit)
        menuhelp = MenuItemIcon('help', 'Documentation', lambda x: webbrowser.open_new('http://fstimer.org/documentation/documentation_sec2.htm'))
        helpmenu.append(menuhelp)

# 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/util_classes.py
# class MenuItemIcon(Gtk.MenuItem):
#     
#     def __init__(self, icon_name, text, cb, *args):
#         super(MenuItemIcon, self).__init__()
#         hbox = Gtk.HBox(False, 0)
#         fname = os.path.join(icon_path, icon_files[icon_name])
#         msg_icon = Gtk.Image.new_from_file(fname)
#         hbox.pack_start(msg_icon, False, False, 0)
#         hbox.pack_start(Gtk.Label(label=text), False, False, 5)
#         hbox.pack_start(Gtk.Alignment.new(1, 0, 1, 0), True, True, 0)
#         self.add(hbox)
#         self.connect('activate', cb, *args)


# Path: fstimer/gui/root.py
import gi
import fstimer.gui
import webbrowser, os
from gi.repository import Gtk
from fstimer.gui.util_classes import GtkStockButton
from fstimer.gui.util_classes import MenuItemIcon

'''Handles the root window of the application'''

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

class RootWin(Gtk.Window):
    '''Handles the root window of the application'''

    def __init__(self, path, show_about_cb, importprereg_cb,
                 prereg_cb, compreg_cb, pretime_cb, edit_cb):
        '''Creates the root window with choices for the tasks'''
        super(RootWin, self).__init__(Gtk.WindowType.TOPLEVEL)
        self.modify_bg(Gtk.StateType.NORMAL, fstimer.gui.bgcolor)
        fname = os.path.abspath(
            os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                '../data/icon.png'))
        self.set_icon_from_file(fname)
        self.set_title('fsTimer - ' + os.path.basename(path))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete_event', Gtk.main_quit)
        self.set_border_width(0)
        # Generate the menubar
        mb = Gtk.MenuBar()
        helpmenu = Gtk.Menu()
        helpm = Gtk.MenuItem('Menu')
        helpm.set_submenu(helpmenu)
        menuedit = MenuItemIcon('edit', 'Edit project settings', edit_cb, True)
        helpmenu.append(menuedit)
        menuhelp = MenuItemIcon('help', 'Documentation', lambda x: webbrowser.open_new('http://fstimer.org/documentation/documentation_sec2.htm'))
        helpmenu.append(menuhelp)

        menuabout = MenuItemIcon('about', 'About', show_about_cb, self)