#:import os os

<GestureDatabaseItem>:
    size_hint: None, None
    size: 120, 130
    on_pos: self._draw_trigger()
    on_size: self._draw_trigger()
    Label:
        id: namelbl
        text: root.name
        size_hint: 1, None
        height: 40
        font_size: 14
        color: 1, 0, 0, 1
    Label:
        id: stats
        text:
            ( str(root.template_count) + " templates\nin " +
            str(len(root.gesture_list)) + ' gestures' )
        size_hint: 1, None
        height: 60
    ToggleButton:
        id: select
        text: 'Select'
        size_hint: None, None
        size: 120, 30
        on_state: root.toggle_selected()

<GestureDatabase>:
    rows: 1
    spacing: 10
    padding: 10
    cols_minimum: {0: 200}
    GridLayout:
        id: menu
        cols: 1
        spacing: 10
        padding: 10
        size_hint: None, 1
        width: 200
        Button:
            text: root.selected_count and 'Deselect all' or 'Select all'
            size_hint_y: None
            height: 100
            on_press: root.mass_select()
        Button:
            text:
                (root.selected_count 
                and 'Save ' + str(root.selected_count) + ' gestures'
                or 'Save all')
            size_hint_y: None
            height: 100
            on_press: root.export_popup.open()
        Button:
            text:
                (root.selected_count 
                and 'Unload ' + str(root.selected_count) + ' gestures'
                or 'Unload all')
            size_hint_y: None
            height: 100
            on_press: root.unload_gestures()
        Button:
            text: 'Load from file'
            size_hint_y: None
            height: 100
            on_press: root.import_popup.open()
    ScrollView:
        on_scroll_y: root.redraw_all()
        StackLayout:
            id: gesture_list
            spacing: 10
            padding: 10
            size_hint: 1, None
            height: self.minimum_height

<GestureExportPopup>:
    title: 'Specify filename'
    auto_dismiss: True
    size_hint: None, None
    size: 400, 400
    GridLayout:
        cols: 1
        spacing: 10
        padding: 10
        rows_minimum: {0: 100}
        Label:
            text:
                ( 'The extension .kg will be appended automatically.\n' +
                'The file is saved to the current working directory, unless\n' +
                'you specify an absolute path')
        TextInput:
            id: filename
            multiline: False
            size_hint: 1, None
            height: 40
        Button:
            id: save_btn
            text: 'Save'
            size_hint: 1, None
            height: 45
        Button:
            id: cancel_btn
            text: 'Cancel'
            size_hint: 1, None
            height: 45
            on_press: root.dismiss()

<GestureImportPopup>:
    auto_dismiss: True
    size_hint: None, None
    size: 450, 400
    FileChooserListView:
        id: filechooser
        size_hint: None, None
        size: 400, 380
        filters: ['*.kg']
        path: os.getcwd()
