Пример #1
0
        def __init__(self, parent, service_key, refresh_callable,
                     filename_tagging_options,
                     present_for_accompanying_file_list):

            wx.Panel.__init__(self, parent)

            self._service_key = service_key
            self._refresh_callable = refresh_callable
            self._present_for_accompanying_file_list = present_for_accompanying_file_list

            #

            self._tags_panel = ClientGUICommon.StaticBox(self, 'tags for all')

            self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove(
                self._tags_panel, self._service_key, self.TagsRemoved)

            expand_parents = True

            self._tag_box = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite(
                self._tags_panel, self.EnterTags, expand_parents,
                CC.LOCAL_FILE_SERVICE_KEY, service_key)

            self._tags_paste_button = ClientGUICommon.BetterButton(
                self._tags_panel, 'paste tags', self._PasteTags)

            #

            self._single_tags_panel = ClientGUICommon.StaticBox(
                self, 'tags just for selected files')

            self._paths_to_single_tags = collections.defaultdict(set)

            self._single_tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove(
                self._single_tags_panel, self._service_key,
                self.SingleTagsRemoved)

            self._single_tags_paste_button = ClientGUICommon.BetterButton(
                self._single_tags_panel, 'paste tags', self._PasteSingleTags)

            expand_parents = True

            self._single_tag_box = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite(
                self._single_tags_panel, self.EnterTagsSingle, expand_parents,
                CC.LOCAL_FILE_SERVICE_KEY, service_key)

            self.SetSelectedPaths([])

            if not self._present_for_accompanying_file_list:

                self._single_tags_panel.Hide()

            #

            self._checkboxes_panel = ClientGUICommon.StaticBox(self, 'misc')

            self._load_from_txt_files_checkbox = wx.CheckBox(
                self._checkboxes_panel,
                label='try to load tags from neighbouring .txt files')

            txt_files_help_button = ClientGUICommon.BetterBitmapButton(
                self._checkboxes_panel, CC.GlobalBMPs.help, self._ShowTXTHelp)
            txt_files_help_button.SetToolTip(
                'Show help regarding importing tags from .txt files.')

            self._filename_namespace = wx.TextCtrl(self._checkboxes_panel)
            self._filename_namespace.SetMinSize((100, -1))

            self._filename_checkbox = wx.CheckBox(
                self._checkboxes_panel, label='add filename? [namespace]')

            self._dir_namespace_1 = wx.TextCtrl(self._checkboxes_panel)
            self._dir_namespace_1.SetMinSize((100, -1))

            self._dir_checkbox_1 = wx.CheckBox(
                self._checkboxes_panel,
                label='add first directory? [namespace]')

            self._dir_namespace_2 = wx.TextCtrl(self._checkboxes_panel)
            self._dir_namespace_2.SetMinSize((100, -1))

            self._dir_checkbox_2 = wx.CheckBox(
                self._checkboxes_panel,
                label='add second directory? [namespace]')

            self._dir_namespace_3 = wx.TextCtrl(self._checkboxes_panel)
            self._dir_namespace_3.SetMinSize((100, -1))

            self._dir_checkbox_3 = wx.CheckBox(
                self._checkboxes_panel,
                label='add third directory? [namespace]')

            #

            (tags_for_all, load_from_neighbouring_txt_files, add_filename,
             add_first_directory, add_second_directory,
             add_third_directory) = filename_tagging_options.SimpleToTuple()

            self._tags.AddTags(tags_for_all)
            self._load_from_txt_files_checkbox.SetValue(
                load_from_neighbouring_txt_files)

            (add_filename_boolean, add_filename_namespace) = add_filename

            self._filename_checkbox.SetValue(add_filename_boolean)
            self._filename_namespace.SetValue(add_filename_namespace)

            (dir_1_boolean, dir_1_namespace) = add_first_directory

            self._dir_checkbox_1.SetValue(dir_1_boolean)
            self._dir_namespace_1.SetValue(dir_1_namespace)

            (dir_2_boolean, dir_2_namespace) = add_second_directory

            self._dir_checkbox_2.SetValue(dir_2_boolean)
            self._dir_namespace_2.SetValue(dir_2_namespace)

            (dir_3_boolean, dir_3_namespace) = add_third_directory

            self._dir_checkbox_3.SetValue(dir_3_boolean)
            self._dir_namespace_3.SetValue(dir_3_namespace)

            #

            self._tags_panel.Add(self._tags, CC.FLAGS_EXPAND_BOTH_WAYS)
            self._tags_panel.Add(self._tag_box, CC.FLAGS_EXPAND_PERPENDICULAR)
            self._tags_panel.Add(self._tags_paste_button,
                                 CC.FLAGS_EXPAND_PERPENDICULAR)

            self._single_tags_panel.Add(self._single_tags,
                                        CC.FLAGS_EXPAND_BOTH_WAYS)
            self._single_tags_panel.Add(self._single_tag_box,
                                        CC.FLAGS_EXPAND_PERPENDICULAR)
            self._single_tags_panel.Add(self._single_tags_paste_button,
                                        CC.FLAGS_EXPAND_PERPENDICULAR)

            txt_hbox = wx.BoxSizer(wx.HORIZONTAL)

            txt_hbox.Add(self._load_from_txt_files_checkbox,
                         CC.FLAGS_EXPAND_BOTH_WAYS)
            txt_hbox.Add(txt_files_help_button, CC.FLAGS_VCENTER)

            filename_hbox = wx.BoxSizer(wx.HORIZONTAL)

            filename_hbox.Add(self._filename_checkbox, CC.FLAGS_VCENTER)
            filename_hbox.Add(self._filename_namespace,
                              CC.FLAGS_EXPAND_BOTH_WAYS)

            dir_hbox_1 = wx.BoxSizer(wx.HORIZONTAL)

            dir_hbox_1.Add(self._dir_checkbox_1, CC.FLAGS_VCENTER)
            dir_hbox_1.Add(self._dir_namespace_1, CC.FLAGS_EXPAND_BOTH_WAYS)

            dir_hbox_2 = wx.BoxSizer(wx.HORIZONTAL)

            dir_hbox_2.Add(self._dir_checkbox_2, CC.FLAGS_VCENTER)
            dir_hbox_2.Add(self._dir_namespace_2, CC.FLAGS_EXPAND_BOTH_WAYS)

            dir_hbox_3 = wx.BoxSizer(wx.HORIZONTAL)

            dir_hbox_3.Add(self._dir_checkbox_3, CC.FLAGS_VCENTER)
            dir_hbox_3.Add(self._dir_namespace_3, CC.FLAGS_EXPAND_BOTH_WAYS)

            self._checkboxes_panel.Add(txt_hbox,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
            self._checkboxes_panel.Add(filename_hbox,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
            self._checkboxes_panel.Add(dir_hbox_1,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
            self._checkboxes_panel.Add(dir_hbox_2,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
            self._checkboxes_panel.Add(dir_hbox_3,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

            hbox = wx.BoxSizer(wx.HORIZONTAL)

            hbox.Add(self._tags_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
            hbox.Add(self._single_tags_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
            hbox.Add(self._checkboxes_panel, CC.FLAGS_EXPAND_PERPENDICULAR)

            self.SetSizer(hbox)

            #

            self._load_from_txt_files_checkbox.Bind(wx.EVT_CHECKBOX,
                                                    self.EventRefresh)
            self._filename_namespace.Bind(wx.EVT_TEXT, self.EventRefresh)
            self._filename_checkbox.Bind(wx.EVT_CHECKBOX, self.EventRefresh)
            self._dir_namespace_1.Bind(wx.EVT_TEXT, self.EventRefresh)
            self._dir_checkbox_1.Bind(wx.EVT_CHECKBOX, self.EventRefresh)
            self._dir_namespace_2.Bind(wx.EVT_TEXT, self.EventRefresh)
            self._dir_checkbox_2.Bind(wx.EVT_CHECKBOX, self.EventRefresh)
            self._dir_namespace_3.Bind(wx.EVT_TEXT, self.EventRefresh)
            self._dir_checkbox_3.Bind(wx.EVT_CHECKBOX, self.EventRefresh)
Пример #2
0
    def __init__(self, parent, flat_media, do_export_and_then_quit=False):

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        new_options = HG.client_controller.new_options

        self._media_to_paths = {}
        self._existing_filenames = set()
        self._last_phrase_used = ''
        self._last_dir_used = ''

        self._tags_box = ClientGUICommon.StaticBoxSorterForListBoxTags(
            self, 'files\' tags')

        services_manager = HG.client_controller.services_manager

        self._neighbouring_txt_tag_service_keys = services_manager.FilterValidServiceKeys(
            new_options.GetKeyList(
                'default_neighbouring_txt_tag_service_keys'))

        t = ClientGUIListBoxes.ListBoxTagsSelection(self._tags_box,
                                                    include_counts=True,
                                                    collapse_siblings=True)

        self._tags_box.SetTagsBox(t)

        self._tags_box.SetMinSize((220, 300))

        columns = [('number', 8), ('mime', 20), ('expected path', -1)]

        self._paths = ClientGUIListCtrl.BetterListCtrl(
            self,
            'export_files',
            24,
            64,
            columns,
            self._ConvertDataToListCtrlTuples,
            use_simple_delete=True)

        self._paths.Sort(0)

        self._export_path_box = ClientGUICommon.StaticBox(self, 'export path')

        self._directory_picker = wx.DirPickerCtrl(self._export_path_box)
        self._directory_picker.Bind(wx.EVT_DIRPICKER_CHANGED,
                                    self.EventRecalcPaths)

        self._open_location = wx.Button(self._export_path_box,
                                        label='open this location')
        self._open_location.Bind(wx.EVT_BUTTON, self.EventOpenLocation)

        self._filenames_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = wx.TextCtrl(self._filenames_box)

        self._update = wx.Button(self._filenames_box, label='update')
        self._update.Bind(wx.EVT_BUTTON, self.EventRecalcPaths)

        self._examples = ClientGUICommon.ExportPatternButton(
            self._filenames_box)

        self._delete_files_after_export = wx.CheckBox(
            self, label='delete files from client after export?')
        self._delete_files_after_export.SetForegroundColour(
            wx.Colour(127, 0, 0))

        text = 'This will export all the files\' tags, newline separated, into .txts beside the files themselves.'

        self._export_tag_txts = wx.CheckBox(self,
                                            label='export tags to .txt files?')
        self._export_tag_txts.SetToolTip(text)
        self._export_tag_txts.Bind(wx.EVT_CHECKBOX,
                                   self.EventExportTagTxtsChanged)

        self._export = wx.Button(self, label='export')
        self._export.Bind(wx.EVT_BUTTON, self.EventExport)

        #

        export_path = ClientExporting.GetExportPath()

        self._directory_picker.SetPath(export_path)

        phrase = new_options.GetString('export_phrase')

        self._pattern.SetValue(phrase)

        if len(self._neighbouring_txt_tag_service_keys) > 0:

            self._export_tag_txts.SetValue(True)

        self._paths.SetData(list(enumerate(flat_media)))

        self._delete_files_after_export.SetValue(
            HG.client_controller.new_options.GetBoolean(
                'delete_files_after_export'))
        self._delete_files_after_export.Bind(wx.EVT_CHECKBOX,
                                             self.EventDeleteFilesChanged)

        #

        top_hbox = wx.BoxSizer(wx.HORIZONTAL)

        top_hbox.Add(self._tags_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        top_hbox.Add(self._paths, CC.FLAGS_EXPAND_BOTH_WAYS)

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        hbox.Add(self._directory_picker, CC.FLAGS_EXPAND_BOTH_WAYS)
        hbox.Add(self._open_location, CC.FLAGS_VCENTER)

        self._export_path_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        hbox.Add(self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        hbox.Add(self._update, CC.FLAGS_VCENTER)
        hbox.Add(self._examples, CC.FLAGS_VCENTER)

        self._filenames_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        vbox = wx.BoxSizer(wx.VERTICAL)

        vbox.Add(top_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        vbox.Add(self._export_path_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        vbox.Add(self._filenames_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        vbox.Add(self._delete_files_after_export, CC.FLAGS_LONE_BUTTON)
        vbox.Add(self._export_tag_txts, CC.FLAGS_LONE_BUTTON)
        vbox.Add(self._export, CC.FLAGS_LONE_BUTTON)

        self.SetSizer(vbox)

        self._RefreshTags()

        wx.CallAfter(self._export.SetFocus)

        self._paths.Bind(wx.EVT_LIST_ITEM_SELECTED, self.EventSelectPath)
        self._paths.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.EventSelectPath)

        if do_export_and_then_quit:

            wx.CallAfter(self._DoExport, True)
Пример #3
0
        def __init__(self, parent, service_key, refresh_callable,
                     filename_tagging_options,
                     present_for_accompanying_file_list):

            wx.Panel.__init__(self, parent)

            self._service_key = service_key
            self._refresh_callable = refresh_callable
            self._present_for_accompanying_file_list = present_for_accompanying_file_list

            #

            self._quick_namespaces_panel = ClientGUICommon.StaticBox(
                self, 'quick namespaces')

            self._quick_namespaces_list = ClientGUIListCtrl.BetterListCtrl(
                self._quick_namespaces_panel,
                'quick_namespaces',
                4,
                20, [('namespace', 12), ('regex', -1)],
                self._ConvertQuickRegexDataToListCtrlTuples,
                delete_key_callback=self.DeleteQuickNamespaces,
                activation_callback=self.EditQuickNamespaces)

            self._add_quick_namespace_button = wx.Button(
                self._quick_namespaces_panel, label='add')
            self._add_quick_namespace_button.Bind(wx.EVT_BUTTON,
                                                  self.EventAddQuickNamespace)
            self._add_quick_namespace_button.SetMinSize((20, -1))

            self._edit_quick_namespace_button = wx.Button(
                self._quick_namespaces_panel, label='edit')
            self._edit_quick_namespace_button.Bind(
                wx.EVT_BUTTON, self.EventEditQuickNamespace)
            self._edit_quick_namespace_button.SetMinSize((20, -1))

            self._delete_quick_namespace_button = wx.Button(
                self._quick_namespaces_panel, label='delete')
            self._delete_quick_namespace_button.Bind(
                wx.EVT_BUTTON, self.EventDeleteQuickNamespace)
            self._delete_quick_namespace_button.SetMinSize((20, -1))

            #

            self._regexes_panel = ClientGUICommon.StaticBox(self, 'regexes')

            self._regexes = wx.ListBox(self._regexes_panel)
            self._regexes.Bind(wx.EVT_LISTBOX_DCLICK, self.EventRemoveRegex)

            self._regex_box = wx.TextCtrl(self._regexes_panel,
                                          style=wx.TE_PROCESS_ENTER)
            self._regex_box.Bind(wx.EVT_TEXT_ENTER, self.EventAddRegex)

            self._regex_shortcuts = ClientGUICommon.RegexButton(
                self._regexes_panel)

            self._regex_intro_link = wx.adv.HyperlinkCtrl(
                self._regexes_panel,
                id=-1,
                label='a good regex introduction',
                url='http://www.aivosto.com/vbtips/regex.html')
            self._regex_practise_link = wx.adv.HyperlinkCtrl(
                self._regexes_panel,
                id=-1,
                label='regex practise',
                url='http://regexr.com/3cvmf')

            #

            self._num_panel = ClientGUICommon.StaticBox(self, '#')

            self._num_base = wx.SpinCtrl(self._num_panel,
                                         min=-10000000,
                                         max=10000000,
                                         size=(60, -1))
            self._num_base.SetValue(1)
            self._num_base.Bind(wx.EVT_SPINCTRL, self.EventRecalcNum)

            self._num_step = wx.SpinCtrl(self._num_panel,
                                         min=-1000000,
                                         max=1000000,
                                         size=(60, -1))
            self._num_step.SetValue(1)
            self._num_step.Bind(wx.EVT_SPINCTRL, self.EventRecalcNum)

            self._num_namespace = wx.TextCtrl(self._num_panel, size=(100, -1))
            self._num_namespace.Bind(wx.EVT_TEXT,
                                     self.EventNumNamespaceChanged)

            if not self._present_for_accompanying_file_list:

                self._num_panel.Hide()

            #

            (quick_namespaces,
             regexes) = filename_tagging_options.AdvancedToTuple()

            self._quick_namespaces_list.AddDatas(quick_namespaces)

            for regex in regexes:

                self._regexes.Append(regex)

            #

            button_box = wx.BoxSizer(wx.HORIZONTAL)

            button_box.Add(self._add_quick_namespace_button,
                           CC.FLAGS_EXPAND_BOTH_WAYS)
            button_box.Add(self._edit_quick_namespace_button,
                           CC.FLAGS_EXPAND_BOTH_WAYS)
            button_box.Add(self._delete_quick_namespace_button,
                           CC.FLAGS_EXPAND_BOTH_WAYS)

            self._quick_namespaces_panel.Add(self._quick_namespaces_list,
                                             CC.FLAGS_EXPAND_BOTH_WAYS)
            self._quick_namespaces_panel.Add(
                button_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

            #

            self._regexes_panel.Add(self._regexes, CC.FLAGS_EXPAND_BOTH_WAYS)
            self._regexes_panel.Add(self._regex_box,
                                    CC.FLAGS_EXPAND_PERPENDICULAR)
            self._regexes_panel.Add(self._regex_shortcuts,
                                    CC.FLAGS_LONE_BUTTON)
            self._regexes_panel.Add(self._regex_intro_link,
                                    CC.FLAGS_LONE_BUTTON)
            self._regexes_panel.Add(self._regex_practise_link,
                                    CC.FLAGS_LONE_BUTTON)

            #

            hbox = wx.BoxSizer(wx.HORIZONTAL)

            hbox.Add(wx.StaticText(self._num_panel, label='# base/step: '),
                     CC.FLAGS_VCENTER)
            hbox.Add(self._num_base, CC.FLAGS_VCENTER)
            hbox.Add(self._num_step, CC.FLAGS_VCENTER)

            self._num_panel.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

            hbox = wx.BoxSizer(wx.HORIZONTAL)

            hbox.Add(wx.StaticText(self._num_panel, label='# namespace: '),
                     CC.FLAGS_VCENTER)
            hbox.Add(self._num_namespace, CC.FLAGS_EXPAND_BOTH_WAYS)

            self._num_panel.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

            second_vbox = wx.BoxSizer(wx.VERTICAL)

            second_vbox.Add(self._regexes_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
            second_vbox.Add(self._num_panel, CC.FLAGS_EXPAND_PERPENDICULAR)

            #

            hbox = wx.BoxSizer(wx.HORIZONTAL)

            hbox.Add(self._quick_namespaces_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
            hbox.Add(second_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

            self.SetSizer(hbox)
Пример #4
0
    def __init__(self, parent, export_folder):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._export_folder = export_folder

        (name, path, export_type, delete_from_client_after_export,
         file_search_context, period, phrase) = self._export_folder.ToTuple()

        self._path_box = ClientGUICommon.StaticBox(self, 'name and location')

        self._name = wx.TextCtrl(self._path_box)

        self._path = wx.DirPickerCtrl(self._path_box,
                                      style=wx.DIRP_USE_TEXTCTRL)

        #

        self._type_box = ClientGUICommon.StaticBox(self, 'type of export')

        self._type = ClientGUICommon.BetterChoice(self._type_box)
        self._type.Append('regular', HC.EXPORT_FOLDER_TYPE_REGULAR)
        self._type.Append('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE)

        self._delete_from_client_after_export = wx.CheckBox(self._type_box)

        #

        self._query_box = ClientGUICommon.StaticBox(self, 'query to export')

        self._page_key = 'export folders placeholder'

        predicates = file_search_context.GetPredicates()

        self._predicates_box = ClientGUIListBoxes.ListBoxTagsActiveSearchPredicates(
            self._query_box, self._page_key, predicates)

        self._searchbox = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self._query_box, self._page_key, file_search_context)

        #

        self._period_box = ClientGUICommon.StaticBox(self, 'export period')

        self._period = ClientGUITime.TimeDeltaButton(self._period_box,
                                                     min=3 * 60,
                                                     days=True,
                                                     hours=True,
                                                     minutes=True)

        #

        self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = wx.TextCtrl(self._phrase_box)

        self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box)

        #

        self._name.SetValue(name)

        self._path.SetPath(path)

        self._type.SelectClientData(export_type)

        self._delete_from_client_after_export.SetValue(
            delete_from_client_after_export)

        self._period.SetValue(period)

        self._pattern.SetValue(phrase)

        #

        rows = []

        rows.append(('name: ', self._name))
        rows.append(('folder path: ', self._path))

        gridbox = ClientGUICommon.WrapInGrid(self._path_box, rows)

        self._path_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        text = '''regular - try to export the files to the directory, overwriting if the filesize if different

synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory

If you select synchronise, be careful!'''

        st = ClientGUICommon.BetterStaticText(self._type_box, label=text)

        st.SetWrapWidth(440)

        self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('delete files from client after export: ',
                     self._delete_from_client_after_export))

        gridbox = ClientGUICommon.WrapInGrid(self._type_box, rows)

        self._type_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self._query_box.Add(self._predicates_box, CC.FLAGS_EXPAND_BOTH_WAYS)
        self._query_box.Add(self._searchbox, CC.FLAGS_EXPAND_PERPENDICULAR)

        self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR)

        phrase_hbox = wx.BoxSizer(wx.HORIZONTAL)

        phrase_hbox.Add(self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        phrase_hbox.Add(self._examples, CC.FLAGS_VCENTER)

        self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        vbox = wx.BoxSizer(wx.VERTICAL)

        vbox.Add(self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        vbox.Add(self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        vbox.Add(self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS)
        vbox.Add(self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        vbox.Add(self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.SetSizer(vbox)

        self._UpdateTypeDeleteUI()

        self._type.Bind(wx.EVT_CHOICE, self.EventTypeChoice)
        self._delete_from_client_after_export.Bind(
            wx.EVT_CHECKBOX, self.EventDeleteFilesAfterExport)
Пример #5
0
 def __init__( self, parent, subscription ):
     
     subscription = subscription.Duplicate()
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._original_subscription = subscription
     
     #
     
     self._name = wx.TextCtrl( self )
     
     #
     
     self._info_panel = ClientGUICommon.StaticBox( self, 'info' )
     
     self._last_checked_st = wx.StaticText( self._info_panel )
     self._next_check_st = wx.StaticText( self._info_panel )
     self._seed_info_st = wx.StaticText( self._info_panel )
     
     #
     
     self._query_panel = ClientGUICommon.StaticBox( self, 'site and query' )
     
     self._site_type = ClientGUICommon.BetterChoice( self._query_panel )
     
     site_types = []
     site_types.append( HC.SITE_TYPE_BOORU )
     site_types.append( HC.SITE_TYPE_DEVIANT_ART )
     site_types.append( HC.SITE_TYPE_HENTAI_FOUNDRY_ARTIST )
     site_types.append( HC.SITE_TYPE_HENTAI_FOUNDRY_TAGS )
     site_types.append( HC.SITE_TYPE_NEWGROUNDS )
     site_types.append( HC.SITE_TYPE_PIXIV_ARTIST_ID )
     site_types.append( HC.SITE_TYPE_PIXIV_TAG )
     site_types.append( HC.SITE_TYPE_TUMBLR )
     
     for site_type in site_types:
         
         self._site_type.Append( HC.site_type_string_lookup[ site_type ], site_type )
         
     
     self._site_type.Bind( wx.EVT_CHOICE, self.EventSiteChanged )
     
     self._query = wx.TextCtrl( self._query_panel )
     
     self._booru_selector = wx.ListBox( self._query_panel )
     self._booru_selector.Bind( wx.EVT_LISTBOX, self.EventBooruSelected )
     
     self._period = ClientGUICommon.TimeDeltaButton( self._query_panel, min = 3600 * 4, days = True, hours = True )
     self._period.Bind( ClientGUICommon.EVT_TIME_DELTA, self.EventPeriodChanged )
     
     #
     
     self._options_panel = ClientGUICommon.StaticBox( self, 'options' )
     
     menu_items = []
     
     invert_call = self._InvertGetTagsIfURLKnownAndFileRedundant
     value_call = self._GetTagsIfURLKnownAndFileRedundant
     
     check_manager = ClientGUICommon.CheckboxManagerCalls( invert_call, value_call )
     
     menu_items.append( ( 'check', 'get tags even if url is known and file is already in db (this downloader)', 'If this is selected, the client will fetch the tags from a file\'s page even if it has the file and already previously downloaded it from that location.', check_manager ) )
     
     menu_items.append( ( 'separator', 0, 0, 0 ) )
     
     check_manager = ClientGUICommon.CheckboxManagerOptions( 'get_tags_if_url_known_and_file_redundant' )
     
     menu_items.append( ( 'check', 'get tags even if url is known and file is already in db (default)', 'Set the default for this value.', check_manager ) )
     
     cog_button = ClientGUICommon.MenuBitmapButton( self._options_panel, CC.GlobalBMPs.cog, menu_items )
     
     self._initial_file_limit = ClientGUICommon.NoneableSpinCtrl( self._options_panel, '', none_phrase = 'get everything', min = 1, max = 1000000 )
     self._initial_file_limit.SetToolTipString( 'If set, the first sync will add no more than this many files. Otherwise, it will get everything the gallery has.' )
     
     self._periodic_file_limit = ClientGUICommon.NoneableSpinCtrl( self._options_panel, '', none_phrase = 'get everything', min = 1, max = 1000000 )
     self._periodic_file_limit.SetToolTipString( 'If set, normal syncs will add no more than this many files. Otherwise, they will get everything up until they find a file they have seen before.' )
     
     #
     
     self._control_panel = ClientGUICommon.StaticBox( self, 'control' )
     
     self._paused = wx.CheckBox( self._control_panel )
     
     self._seed_cache_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.seed_cache, self._SeedCache )
     self._seed_cache_button.SetToolTipString( 'open detailed url cache status' )
     
     self._retry_failed = ClientGUICommon.BetterButton( self._control_panel, 'retry failed', self.RetryFailed )
     
     self._check_now_button = ClientGUICommon.BetterButton( self._control_panel, 'force check on dialog ok', self.CheckNow )
     
     self._reset_cache_button = ClientGUICommon.BetterButton( self._control_panel, 'reset url cache', self.ResetCache )
     
     #
     
     self._import_tag_options = ClientGUICollapsible.CollapsibleOptionsTags( self )
     
     self._import_file_options = ClientGUICollapsible.CollapsibleOptionsImportFiles( self )
     
     #
     
     ( name, gallery_identifier, gallery_stream_identifiers, query, period, self._get_tags_if_url_known_and_file_redundant, initial_file_limit, periodic_file_limit, paused, import_file_options, import_tag_options, self._last_checked, self._last_error, self._check_now, self._seed_cache ) = subscription.ToTuple()
     
     self._name.SetValue( name )
     
     site_type = gallery_identifier.GetSiteType()
     
     self._site_type.SelectClientData( site_type )
     
     self._PresentForSiteType()
     
     if site_type == HC.SITE_TYPE_BOORU:
         
         booru_name = gallery_identifier.GetAdditionalInfo()
         
         index = self._booru_selector.FindString( booru_name )
         
         if index != wx.NOT_FOUND:
             
             self._booru_selector.Select( index )
             
         
     
     # set gallery_stream_identifiers selection here--some kind of list of checkboxes or whatever
     
     self._query.SetValue( query )
     
     self._period.SetValue( period )
     
     self._initial_file_limit.SetValue( initial_file_limit )
     self._periodic_file_limit.SetValue( periodic_file_limit )
     
     self._paused.SetValue( paused )
     
     self._import_file_options.SetOptions( import_file_options )
     
     self._import_tag_options.SetOptions( import_tag_options )
     
     if self._last_checked == 0:
         
         self._reset_cache_button.Disable()
         
     
     if self._check_now:
         
         self._check_now_button.Disable()
         
     
     self._UpdateCommandButtons()
     self._UpdateLastNextCheck()
     self._UpdateSeedInfo()
     
     #
     
     self._info_panel.AddF( self._last_checked_st, CC.FLAGS_EXPAND_PERPENDICULAR )
     self._info_panel.AddF( self._next_check_st, CC.FLAGS_EXPAND_PERPENDICULAR )
     self._info_panel.AddF( self._seed_info_st, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     #
     
     rows = []
     
     rows.append( ( 'search text: ', self._query ) )
     rows.append( ( 'check for new files every: ', self._period ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self._query_panel, rows )
     
     self._query_panel.AddF( self._site_type, CC.FLAGS_EXPAND_PERPENDICULAR )
     self._query_panel.AddF( self._booru_selector, CC.FLAGS_EXPAND_PERPENDICULAR )
     self._query_panel.AddF( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     #
     
     rows = []
     
     rows.append( ( 'on first check, get at most this many files: ', self._initial_file_limit ) )
     rows.append( ( 'on normal checks, get at most this many newer files: ', self._periodic_file_limit ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self._options_panel, rows )
     
     self._options_panel.AddF( cog_button, CC.FLAGS_LONE_BUTTON )
     self._options_panel.AddF( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     #
     
     self._control_panel.AddF( self._seed_cache_button, CC.FLAGS_LONE_BUTTON )
     
     rows = []
     
     rows.append( ( 'currently paused: ', self._paused ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self._control_panel, rows )
     
     self._control_panel.AddF( gridbox, CC.FLAGS_LONE_BUTTON )
     self._control_panel.AddF( self._retry_failed, CC.FLAGS_LONE_BUTTON )
     self._control_panel.AddF( self._check_now_button, CC.FLAGS_LONE_BUTTON )
     self._control_panel.AddF( self._reset_cache_button, CC.FLAGS_LONE_BUTTON )
     
     #
     
     vbox = wx.BoxSizer( wx.VERTICAL )
     
     vbox.AddF( ClientGUICommon.WrapInText( self._name, self, 'name: ' ), CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     vbox.AddF( self._info_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._query_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._options_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._control_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._import_tag_options, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._import_file_options, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.SetSizer( vbox )
Пример #6
0
 def __init__( self, parent, service_type, account_type ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     ( self._account_type_key, title, permissions, bandwidth_rules ) = account_type.ToTuple()
     
     self._title = wx.TextCtrl( self )
     
     permission_choices = self._GeneratePermissionChoices( service_type )
     
     self._permission_controls = []
     
     self._permissions_panel = ClientGUICommon.StaticBox( self, 'permissions' )
     
     gridbox_rows = []
     
     for ( content_type, action_rows ) in permission_choices:
         
         choice_control = ClientGUICommon.BetterChoice( self._permissions_panel )
         
         for ( label, action ) in action_rows:
             
             choice_control.Append( label, ( content_type, action ) )
             
         
         if content_type in permissions:
             
             selection_row = ( content_type, permissions[ content_type ] )
             
         else:
             
             selection_row = ( content_type, None )
             
         
         try:
             
             choice_control.SelectClientData( selection_row )
             
         except:
             
             choice_control.SelectClientData( ( content_type, None ) )
             
         
         self._permission_controls.append( choice_control )
         
         gridbox_label = HC.content_type_string_lookup[ content_type ]
         
         gridbox_rows.append( ( gridbox_label, choice_control ) )
         
     
     gridbox = ClientGUICommon.WrapInGrid( self._permissions_panel, gridbox_rows )
     
     self._bandwidth_rules_control = ClientGUIControls.BandwidthRulesCtrl( self, bandwidth_rules )
     
     #
     
     self._title.SetValue( title )
     
     #
     
     t_hbox = ClientGUICommon.WrapInText( self._title, self, 'title: ' )
     
     self._permissions_panel.AddF( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     vbox = wx.BoxSizer( wx.VERTICAL )
     
     vbox.AddF( t_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     vbox.AddF( self._permissions_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.AddF( self._bandwidth_rules_control, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.SetSizer( vbox )
Пример #7
0
    def _InitAdvancedPanel(self):

        advanced_panel = wx.Panel(self._notebook)

        #

        blacklist_panel = ClientGUICommon.StaticBox(advanced_panel,
                                                    'exclude these')

        self._advanced_blacklist = ClientGUIListBoxes.ListBoxTagsCensorship(
            blacklist_panel)

        self._advanced_blacklist_input = ClientGUIControls.TextAndPasteCtrl(
            blacklist_panel,
            self._AdvancedAddBlacklistMultiple,
            allow_empty_input=True)

        add_blacklist_button = ClientGUICommon.BetterButton(
            blacklist_panel, 'add', self._AdvancedAddBlacklist)
        delete_blacklist_button = ClientGUICommon.BetterButton(
            blacklist_panel, 'delete', self._AdvancedDeleteBlacklist)
        blacklist_everything_button = ClientGUICommon.BetterButton(
            blacklist_panel, 'block everything',
            self._AdvancedBlacklistEverything)

        #

        whitelist_panel = ClientGUICommon.StaticBox(advanced_panel,
                                                    'except for these')

        self._advanced_whitelist = ClientGUIListBoxes.ListBoxTagsCensorship(
            whitelist_panel)

        self._advanced_whitelist_input = ClientGUIControls.TextAndPasteCtrl(
            whitelist_panel,
            self._AdvancedAddWhitelistMultiple,
            allow_empty_input=True)

        self._advanced_add_whitelist_button = ClientGUICommon.BetterButton(
            whitelist_panel, 'add', self._AdvancedAddWhitelist)
        delete_whitelist_button = ClientGUICommon.BetterButton(
            whitelist_panel, 'delete', self._AdvancedDeleteWhitelist)

        #

        button_hbox = wx.BoxSizer(wx.HORIZONTAL)

        button_hbox.Add(self._advanced_blacklist_input,
                        CC.FLAGS_EXPAND_BOTH_WAYS)
        button_hbox.Add(add_blacklist_button, CC.FLAGS_VCENTER)
        button_hbox.Add(delete_blacklist_button, CC.FLAGS_VCENTER)
        button_hbox.Add(blacklist_everything_button, CC.FLAGS_VCENTER)

        blacklist_panel.Add(self._advanced_blacklist,
                            CC.FLAGS_EXPAND_BOTH_WAYS)
        blacklist_panel.Add(button_hbox, CC.FLAGS_EXPAND_PERPENDICULAR)

        #

        button_hbox = wx.BoxSizer(wx.HORIZONTAL)

        button_hbox.Add(self._advanced_whitelist_input,
                        CC.FLAGS_EXPAND_BOTH_WAYS)
        button_hbox.Add(self._advanced_add_whitelist_button, CC.FLAGS_VCENTER)
        button_hbox.Add(delete_whitelist_button, CC.FLAGS_VCENTER)

        whitelist_panel.Add(self._advanced_whitelist,
                            CC.FLAGS_EXPAND_BOTH_WAYS)
        whitelist_panel.Add(button_hbox, CC.FLAGS_EXPAND_PERPENDICULAR)

        #

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        hbox.Add(blacklist_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        hbox.Add(whitelist_panel, CC.FLAGS_EXPAND_BOTH_WAYS)

        advanced_panel.SetSizer(hbox)

        return advanced_panel
Пример #8
0
 def __init__( self, parent, checker_options ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     help_button = ClientGUICommon.BetterBitmapButton( self, CC.GlobalBMPs.help, self._ShowHelp )
     help_button.SetToolTip( 'Show help regarding these checker options.' )
     
     help_hbox = ClientGUICommon.WrapInText( help_button, self, 'help for this panel -->', wx.Colour( 0, 0, 255 ) )
     
     import ClientDefaults
     
     defaults_panel = ClientGUICommon.StaticBox( self, 'reasonable defaults' )
     
     defaults_1 = ClientGUICommon.BetterButton( defaults_panel, 'thread', self.SetValue, ClientDefaults.GetDefaultCheckerOptions( 'thread' ) )
     defaults_2 = ClientGUICommon.BetterButton( defaults_panel, 'slow thread', self.SetValue, ClientDefaults.GetDefaultCheckerOptions( 'slow thread' ) )
     defaults_3 = ClientGUICommon.BetterButton( defaults_panel, 'faster tag subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions( 'fast tag subscription' ) )
     defaults_4 = ClientGUICommon.BetterButton( defaults_panel, 'medium tag/artist subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions( 'artist subscription' ) )
     defaults_5 = ClientGUICommon.BetterButton( defaults_panel, 'slower tag subscription', self.SetValue, ClientDefaults.GetDefaultCheckerOptions( 'slow tag subscription' ) )
     
     #
     
     # add statictext or whatever that will update on any updates above to say 'given velocity of blah and last check at blah, next check in 5 mins'
     # or indeed this could just take the file_seed cache and last check of the caller, if there is one
     # this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins'
     # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity
     
     #
     
     self._death_file_velocity = VelocityCtrl( self, min_time_delta = 60, days = True, hours = True, minutes = True, per_phrase = 'in', unit = 'files' )
     
     self._flat_check_period_checkbox = wx.CheckBox( self )
     
     #
     
     self._reactive_check_panel = ClientGUICommon.StaticBox( self, 'reactive checking' )
     
     self._intended_files_per_check = wx.SpinCtrl( self._reactive_check_panel, min = 1, max = 1000 )
     
     self._never_faster_than = TimeDeltaCtrl( self._reactive_check_panel, min = 30, days = True, hours = True, minutes = True, seconds = True )
     
     self._never_slower_than = TimeDeltaCtrl( self._reactive_check_panel, min = 600, days = True, hours = True, minutes = True )
     
     #
     
     self._static_check_panel = ClientGUICommon.StaticBox( self, 'static checking' )
     
     self._flat_check_period = TimeDeltaCtrl( self._static_check_panel, min = 180, days = True, hours = True, minutes = True )
     
     #
     
     self.SetValue( checker_options )
     
     #
     
     defaults_panel.Add( defaults_1, CC.FLAGS_EXPAND_PERPENDICULAR )
     defaults_panel.Add( defaults_2, CC.FLAGS_EXPAND_PERPENDICULAR )
     defaults_panel.Add( defaults_3, CC.FLAGS_EXPAND_PERPENDICULAR )
     defaults_panel.Add( defaults_4, CC.FLAGS_EXPAND_PERPENDICULAR )
     defaults_panel.Add( defaults_5, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     #
     
     rows = []
     
     rows.append( ( 'intended new files per check: ', self._intended_files_per_check ) )
     rows.append( ( 'never check faster than once per: ', self._never_faster_than ) )
     rows.append( ( 'never check slower than once per: ', self._never_slower_than ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self._reactive_check_panel, rows )
     
     self._reactive_check_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     #
     
     rows = []
     
     rows.append( ( 'check period: ', self._flat_check_period ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self._static_check_panel, rows )
     
     self._static_check_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     #
     
     rows = []
     
     rows.append( ( 'stop checking if new files found falls below: ', self._death_file_velocity ) )
     rows.append( ( 'just check at a static, regular interval: ', self._flat_check_period_checkbox ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     vbox = wx.BoxSizer( wx.VERTICAL )
     
     vbox.Add( help_hbox, CC.FLAGS_BUTTON_SIZER )
     vbox.Add( defaults_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     vbox.Add( self._reactive_check_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     vbox.Add( self._static_check_panel, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.SetSizer( vbox )
     
     #
     
     self._flat_check_period_checkbox.Bind( wx.EVT_CHECKBOX, self.EventFlatPeriodCheck )