# Path: pytrainer/gui/SimpleGladeApp.py
# class SimpleBuilderApp(dict):
#     def __init__(self, ui_filename):
#         self._builder = Gtk.Builder()
#         env = Environment()
#         file_path = os.path.join(env.glade_dir, ui_filename)
#         self._builder.add_from_file(file_path)
#         self.signal_autoconnect()
#         self._builder.connect_signals(self)
#         self.new()
# 
#     def signal_autoconnect(self):
#         signals = {}
#         for attr_name in dir(self):
#             attr = getattr(self, attr_name)
#             if callable(attr):
#                 signals[attr_name] = attr
#         self._builder.connect_signals(signals)
# 
#     def __getattr__(self, data_name):
#         if data_name in self:
#             data = self[data_name]
#             return data
#         else:
#             widget = self._builder.get_object(data_name)
#             if widget != None:
#                 self[data_name] = widget
#                 return widget
#             else:
#                 raise AttributeError(data_name)
# 
#     def __setattr__(self, name, value):
#         self[name] = value
# 
#     def new(self):
#         pass
# 
#     def on_keyboard_interrupt(self):
#         pass
# 
#     def gtk_widget_show(self, widget, *args):
#         widget.show()
# 
#     def gtk_widget_hide(self, widget, *args):
#         widget.hide()
# 
#     def gtk_widget_grab_focus(self, widget, *args):
#         widget.grab_focus()
# 
#     def gtk_widget_destroy(self, widget, *args):
#         widget.destroy()
# 
#     def gtk_window_activate_default(self, widget, *args):
#         widget.activate_default()
# 
#     def gtk_true(self, *args):
#         return True
# 
#     def gtk_false(self, *args):
#         return False
# 
#     def gtk_main_quit(self, *args):
#         Gtk.main_quit()
# 
#     def main(self):
#         Gtk.main()
# 
#     def quit(self, widget=None):
#         Gtk.main_quit()
# 
#     def run(self):
#         try:
#             self.main()
#         except KeyboardInterrupt:
#             self.on_keyboard_interrupt()
# 
#     def create_treeview(self,treeview,column_names):
#         i=0
#         for column_index, column_name in enumerate(column_names):
#             column = Gtk.TreeViewColumn(column_name, Gtk.CellRendererText(), text=column_index)
#             column.set_resizable(True)
#             if i==0:
#                 column.set_visible(False)
#             column.set_sort_column_id(i)
#             treeview.append_column(column)
# 
# Path: pytrainer/lib/localization.py
# def gtk_str(string):
#     """On Python 2 GTK returns all strings as UTF-8 encoded str. See
# https://python-gtk-3-tutorial.readthedocs.io/en/latest/unicode.html for
# more details."""
#     if sys.version_info[0] == 2:
#         if string is None:
#             return None
#         else:
#             return string.decode('utf-8')
#     else:
#         return string


from .SimpleGladeApp import SimpleBuilderApp
from gi.repository import Gtk
from gi.repository import GObject
from pytrainer.lib.localization import gtk_str
import os
            label = Gtk.Label(label="<b>%s</b>"%pref[0])
            label.set_use_markup(True)
            if pref[0] != "status":
                entry = Gtk.Entry()
                entry.set_text(pref[1])
                self.entryList.append(entry)
                table.attach(entry,1,2,i,i+1)
            else:
                combobox = Gtk.ComboBoxText()
                combobox.append_text(_("Disable"))
                combobox.append_text(_("Enable"))
                combobox.set_active(int(pref[1]))
                table.attach(combobox,1,2,i,i+1)
                self.entryList.append(combobox)
            table.attach(label,0,1,i,i+1)
            i+=1

        button = Gtk.Button(_("Ok"))
        button.connect("clicked", self.on_acceptSettings_clicked, None)
        table.attach(button,0,2,i,i+1)
        self.prefwindow.add(table)
        self.prefwindow.show_all()

    def on_acceptSettings_clicked(self, widget, widget2):
        selected,iter = self.pluginsTreeview.get_selection().get_selected()
        prefs = self.parent.getPluginConfParams(selected.get_value(iter,0))
        savedOptions = []
        i = 0
        for pref in prefs:
            try:

# Path: pytrainer/gui/SimpleGladeApp.py
# class SimpleBuilderApp(dict):
#     def __init__(self, ui_filename):
#         self._builder = Gtk.Builder()
#         env = Environment()
#         file_path = os.path.join(env.glade_dir, ui_filename)
#         self._builder.add_from_file(file_path)
#         self.signal_autoconnect()
#         self._builder.connect_signals(self)
#         self.new()
# 
#     def signal_autoconnect(self):
#         signals = {}
#         for attr_name in dir(self):
#             attr = getattr(self, attr_name)
#             if callable(attr):
#                 signals[attr_name] = attr
#         self._builder.connect_signals(signals)
# 
#     def __getattr__(self, data_name):
#         if data_name in self:
#             data = self[data_name]
#             return data
#         else:
#             widget = self._builder.get_object(data_name)
#             if widget != None:
#                 self[data_name] = widget
#                 return widget
#             else:
#                 raise AttributeError(data_name)
# 
#     def __setattr__(self, name, value):
#         self[name] = value
# 
#     def new(self):
#         pass
# 
#     def on_keyboard_interrupt(self):
#         pass
# 
#     def gtk_widget_show(self, widget, *args):
#         widget.show()
# 
#     def gtk_widget_hide(self, widget, *args):
#         widget.hide()
# 
#     def gtk_widget_grab_focus(self, widget, *args):
#         widget.grab_focus()
# 
#     def gtk_widget_destroy(self, widget, *args):
#         widget.destroy()
# 
#     def gtk_window_activate_default(self, widget, *args):
#         widget.activate_default()
# 
#     def gtk_true(self, *args):
#         return True
# 
#     def gtk_false(self, *args):
#         return False
# 
#     def gtk_main_quit(self, *args):
#         Gtk.main_quit()
# 
#     def main(self):
#         Gtk.main()
# 
#     def quit(self, widget=None):
#         Gtk.main_quit()
# 
#     def run(self):
#         try:
#             self.main()
#         except KeyboardInterrupt:
#             self.on_keyboard_interrupt()
# 
#     def create_treeview(self,treeview,column_names):
#         i=0
#         for column_index, column_name in enumerate(column_names):
#             column = Gtk.TreeViewColumn(column_name, Gtk.CellRendererText(), text=column_index)
#             column.set_resizable(True)
#             if i==0:
#                 column.set_visible(False)
#             column.set_sort_column_id(i)
#             treeview.append_column(column)
# 
# Path: pytrainer/lib/localization.py
# def gtk_str(string):
#     """On Python 2 GTK returns all strings as UTF-8 encoded str. See
# https://python-gtk-3-tutorial.readthedocs.io/en/latest/unicode.html for
# more details."""
#     if sys.version_info[0] == 2:
#         if string is None:
#             return None
#         else:
#             return string.decode('utf-8')
#     else:
#         return string


# Path: pytrainer/gui/windowplugins.py
from .SimpleGladeApp import SimpleBuilderApp
from gi.repository import Gtk
from gi.repository import GObject
from pytrainer.lib.localization import gtk_str
import os

            label = Gtk.Label(label="<b>%s</b>"%pref[0])
            label.set_use_markup(True)
            if pref[0] != "status":
                entry = Gtk.Entry()
                entry.set_text(pref[1])
                self.entryList.append(entry)
                table.attach(entry,1,2,i,i+1)
            else:
                combobox = Gtk.ComboBoxText()
                combobox.append_text(_("Disable"))
                combobox.append_text(_("Enable"))
                combobox.set_active(int(pref[1]))
                table.attach(combobox,1,2,i,i+1)
                self.entryList.append(combobox)
            table.attach(label,0,1,i,i+1)
            i+=1

        button = Gtk.Button(_("Ok"))
        button.connect("clicked", self.on_acceptSettings_clicked, None)
        table.attach(button,0,2,i,i+1)
        self.prefwindow.add(table)
        self.prefwindow.show_all()

    def on_acceptSettings_clicked(self, widget, widget2):
        selected,iter = self.pluginsTreeview.get_selection().get_selected()
        prefs = self.parent.getPluginConfParams(selected.get_value(iter,0))
        savedOptions = []
        i = 0
        for pref in prefs:
            try:

                savedOptions.append((pref[0], gtk_str(self.entryList[i].get_text())))