def test_SERIALISABLE_TYPE_APPLICATION_COMMAND(self):
        def test(obj, dupe_obj):

            self.assertEqual(obj.GetCommandType(), dupe_obj.GetCommandType())

            self.assertEqual(obj.GetData(), dupe_obj.GetData())

        acs = []

        acs.append(
            (ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                           'archive_file'), 'archive_file'))
        acs.append((ClientData.ApplicationCommand(
            CC.APPLICATION_COMMAND_TYPE_CONTENT,
            (HydrusData.GenerateKey(), HC.CONTENT_TYPE_MAPPINGS,
             HC.CONTENT_UPDATE_FLIP, 'test')),
                    'flip on/off mappings "test" for unknown service!'))
        acs.append((ClientData.ApplicationCommand(
            CC.APPLICATION_COMMAND_TYPE_CONTENT,
            (CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_TYPE_MAPPINGS,
             HC.CONTENT_UPDATE_FLIP, 'test')),
                    'flip on/off mappings "test" for local tags'))
        acs.append((ClientData.ApplicationCommand(
            CC.APPLICATION_COMMAND_TYPE_CONTENT,
            (HydrusData.GenerateKey(), HC.CONTENT_TYPE_RATINGS,
             HC.CONTENT_UPDATE_SET, 0.4)),
                    'set ratings "0.4" for unknown service!'))

        for (ac, s) in acs:

            self._dump_and_load_and_test(ac, test)

            self.assertEqual(ac.ToString(), s)
Esempio n. 2
0
 def test_dict_to_content_updates( self ):
     
     hash = HydrusData.GenerateKey()
     
     hashes = { hash }
     
     local_key = CC.LOCAL_TAG_SERVICE_KEY
     remote_key = HydrusData.GenerateKey()
     
     service_keys_to_tags = { local_key : { 'a' } }
     
     content_updates = { local_key : [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ( 'a', hashes ) ) ] }
     
     self.assertEqual( ClientData.ConvertServiceKeysToTagsToServiceKeysToContentUpdates( { hash }, service_keys_to_tags ), content_updates )
     
     service_keys_to_tags = { remote_key : { 'c' } }
     
     content_updates = { remote_key : [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_PEND, ( 'c', hashes ) ) ] }
     
     self.assertEqual( ClientData.ConvertServiceKeysToTagsToServiceKeysToContentUpdates( { hash }, service_keys_to_tags ), content_updates )
     
     service_keys_to_tags = { local_key : [ 'a', 'character:b' ], remote_key : [ 'c', 'series:d' ] }
     
     content_updates = {}
     
     content_updates[ local_key ] = [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ( 'a', hashes ) ), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ( 'character:b', hashes ) ) ]
     content_updates[ remote_key ] = [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_PEND, ( 'c', hashes ) ), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_PEND, ( 'series:d', hashes ) ) ]
     
     self.assertEqual( HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_PEND, 'c' ), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_PEND, 'c' ) )
     self.assertEqual( ClientData.ConvertServiceKeysToTagsToServiceKeysToContentUpdates( { hash }, service_keys_to_tags ), content_updates )
Esempio n. 3
0
    def __init__(self,
                 parent,
                 name,
                 height_num_chars,
                 sizing_column_initial_width_num_chars,
                 columns,
                 data_to_tuples_func,
                 delete_key_callback=None,
                 activation_callback=None):

        wx.ListCtrl.__init__(self, parent, style=wx.LC_REPORT)
        ListCtrlAutoWidthMixin.__init__(self)

        self._data_to_tuples_func = data_to_tuples_func

        self._sort_column = 0
        self._sort_asc = True

        # eventually have it look up 'name' in some options somewhere and see previous height, width, and column selection
        # this thing should deal with missing entries but also have some filtered defaults for subs listctrl, which will have a bunch of possible columns

        self._indices_to_data_info = {}
        self._data_to_indices = {}

        (total_width, height) = ClientData.ConvertTextToPixels(
            self, (sizing_column_initial_width_num_chars, height_num_chars))

        resize_column = 1

        for (i, (name, width_num_chars)) in enumerate(columns):

            if width_num_chars == -1:

                width = -1

                resize_column = i + 1

            else:

                width = ClientData.ConvertTextToPixelWidth(
                    self, width_num_chars)

                total_width += width

            self.InsertColumn(i, name, width=width)

        self.setResizeColumn(resize_column)

        self.SetInitialSize((total_width, height))

        self._delete_key_callback = delete_key_callback
        self._activation_callback = activation_callback

        self.Bind(wx.EVT_KEY_DOWN, self.EventKeyDown)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.EventItemActivated)

        self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.EventBeginColDrag)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.EventColumnClick)
Esempio n. 4
0
    def test_services(self):
        def test_service(service, key, service_type, name, info):

            self.assertEqual(service.GetServiceKey(), key)
            self.assertEqual(service.GetServiceType(), service_type)
            self.assertEqual(service.GetName(), name)
            self.assertEqual(service.GetInfo(), info)

        repo_key = HydrusData.GenerateKey()
        repo_type = HC.TAG_REPOSITORY
        repo_name = 'test tag repo'
        repo_info = {'blah': 5}

        repo = ClientData.GenerateService(repo_key, repo_type, repo_name,
                                          repo_info)

        other_key = HydrusData.GenerateKey()

        other = ClientData.GenerateService(other_key, HC.LOCAL_BOORU, 'booru',
                                           {})

        services = []

        services.append(repo)
        services.append(other)

        HydrusGlobals.test_controller.SetRead('services', services)

        services_manager = ClientCaches.ServicesManager(
            HydrusGlobals.client_controller)

        #

        service = services_manager.GetService(repo_key)

        test_service(service, repo_key, repo_type, repo_name, repo_info)

        service = services_manager.GetService(other_key)

        #

        services = services_manager.GetServices((HC.TAG_REPOSITORY, ))

        self.assertEqual(len(services), 1)

        self.assertEqual(services[0].GetServiceKey(), repo_key)

        #

        services = []

        services.append(repo)

        HydrusGlobals.test_controller.SetRead('services', services)

        services_manager.RefreshServices()

        self.assertRaises(Exception, services_manager.GetService, other_key)
Esempio n. 5
0
 def _Archive( self ):
     
     if self._current_media.HasInbox():
         
         command = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_file' )
         
     else:
         
         command = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'inbox_file' )
         
     
     HG.client_controller.pub( 'canvas_application_command', command, self._canvas_key )
Esempio n. 6
0
    def AddCounts(self, predicate):

        (min_current_count, max_current_count, min_pending_count,
         max_pending_count) = predicate.GetAllCounts()

        (self._min_current_count,
         self._max_current_count) = ClientData.MergeCounts(
             self._min_current_count, self._max_current_count,
             min_current_count, max_current_count)
        (self._min_pending_count,
         self._max_pending_count) = ClientData.MergeCounts(
             self._min_pending_count, self._max_pending_count,
             min_pending_count, max_pending_count)
Esempio n. 7
0
 def test_SERIALISABLE_TYPE_SHORTCUT( self ):
     
     def test( obj, dupe_obj ):
         
         self.assertEqual( dupe_obj.__hash__(), ( dupe_obj._shortcut_type, dupe_obj._shortcut_key, tuple( dupe_obj._modifiers ) ).__hash__() )
         
         self.assertEqual( obj, dupe_obj )
         
     
     shortcuts = []
     
     shortcuts.append( ( ClientData.Shortcut(), 'f7' ) )
     
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, wx.WXK_SPACE, [] ), 'space' ) )
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, ord( 'a' ), [ CC.SHORTCUT_MODIFIER_CTRL ] ), 'ctrl+a' ) )
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, ord( 'A' ), [ CC.SHORTCUT_MODIFIER_CTRL ] ), 'ctrl+a' ) )
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, wx.WXK_HOME, [ CC.SHORTCUT_MODIFIER_ALT, CC.SHORTCUT_MODIFIER_CTRL ] ), 'ctrl+alt+home' ) )
     
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_LEFT, [] ), 'left-click' ) )
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_MIDDLE, [ CC.SHORTCUT_MODIFIER_CTRL ] ), 'ctrl+middle-click' ) )
     shortcuts.append( ( ClientData.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_SCROLL_DOWN, [ CC.SHORTCUT_MODIFIER_ALT, CC.SHORTCUT_MODIFIER_SHIFT ] ), 'alt+shift+scroll down' ) )
     
     for ( shortcut, s ) in shortcuts:
         
         self._dump_and_load_and_test( shortcut, test )
         
         self.assertEqual( shortcut.ToString(), s )
 def test_SERIALISABLE_TYPE_SHORTCUTS( self ):
     
     def test( obj, dupe_obj ):
         
         for ( shortcut, command ) in obj:
             
             self.assertEqual( dupe_obj.GetCommand( shortcut ).GetData(), command.GetData() )
             
         
     
     default_shortcuts = ClientDefaults.GetDefaultShortcuts()
     
     for shortcuts in default_shortcuts:
         
         self._dump_and_load_and_test( shortcuts, test )
         
     
     command_1 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_file' )
     command_2 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_CONTENT, ( HydrusData.GenerateKey(), HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_FLIP, 'test' ) )
     command_3 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_CONTENT, ( CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_FLIP, 'test' ) )
     
     k_shortcut_1 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, wx.WXK_SPACE, [] )
     k_shortcut_2 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, ord( 'a' ), [ CC.SHORTCUT_MODIFIER_CTRL ] )
     k_shortcut_3 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, ord( 'A' ), [ CC.SHORTCUT_MODIFIER_CTRL ] )
     k_shortcut_4 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, wx.WXK_HOME, [ CC.SHORTCUT_MODIFIER_ALT, CC.SHORTCUT_MODIFIER_CTRL ] )
     
     m_shortcut_1 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_LEFT, [] )
     m_shortcut_2 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_MIDDLE, [ CC.SHORTCUT_MODIFIER_CTRL ] )
     m_shortcut_3 = ClientGUIShortcuts.Shortcut( CC.SHORTCUT_TYPE_MOUSE, CC.SHORTCUT_MOUSE_SCROLL_DOWN, [ CC.SHORTCUT_MODIFIER_ALT, CC.SHORTCUT_MODIFIER_SHIFT ] )
     
     shortcuts = ClientGUIShortcuts.Shortcuts( 'test' )
     
     shortcuts.SetCommand( k_shortcut_1, command_1 )
     shortcuts.SetCommand( k_shortcut_2, command_2 )
     shortcuts.SetCommand( k_shortcut_3, command_2 )
     shortcuts.SetCommand( k_shortcut_4, command_3 )
     
     shortcuts.SetCommand( m_shortcut_1, command_1 )
     shortcuts.SetCommand( m_shortcut_2, command_2 )
     shortcuts.SetCommand( m_shortcut_3, command_3 )
     
     self._dump_and_load_and_test( shortcuts, test )
     
     self.assertEqual( shortcuts.GetCommand( k_shortcut_1 ).GetData(), command_1.GetData() )
     
     shortcuts.SetCommand( k_shortcut_1, command_3 )
     
     self.assertEqual( shortcuts.GetCommand( k_shortcut_1 ).GetData(), command_3.GetData() )
Esempio n. 9
0
    def _FetchRelatedTags(self, max_time_to_take):

        (m, ) = self._media

        hash = m.GetHash()

        (current_tags_to_count, deleted_tags_to_count, pending_tags_to_count,
         petitioned_tags_to_count) = ClientData.GetMediasTagCount(
             self._media,
             tag_service_key=self._service_key,
             collapse_siblings=False)

        tags_to_count = collections.Counter()

        tags_to_count.update(current_tags_to_count)
        tags_to_count.update(pending_tags_to_count)

        search_tags = set(tags_to_count.keys())

        max_results = 100

        predicates = HydrusGlobals.client_controller.Read(
            'related_tags', self._service_key, hash, search_tags, max_results,
            max_time_to_take)

        predicates = ClientSearch.SortPredicates(predicates)

        self._related_tags.SetPredicates(predicates)
Esempio n. 10
0
    def GetOptions(self):

        service_keys_to_namespaces = {}

        for (service_key,
             checkbox_info) in self._service_keys_to_checkbox_info.items():

            namespaces = [
                namespace for (namespace, checkbox) in checkbox_info
                if checkbox.GetValue() == True
            ]

            service_keys_to_namespaces[service_key] = namespaces

        service_keys_to_explicit_tags = {
            service_key: explicit_tags
            for (service_key, (explicit_tags, explicit_button)
                 ) in self._service_keys_to_explicit_button_info.items()
        }

        import_tag_options = ClientData.ImportTagOptions(
            service_keys_to_namespaces=service_keys_to_namespaces,
            service_keys_to_explicit_tags=service_keys_to_explicit_tags)

        return import_tag_options
Esempio n. 11
0
def ConvertKeyEventToShortcut( event ):
    
    key = event.KeyCode
    
    if ClientData.OrdIsSensibleASCII( key ) or key in CC.wxk_code_string_lookup.keys():
        
        modifiers = []
        
        if event.AltDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_ALT )
            
        
        if event.CmdDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_CTRL )
            
        
        if event.ShiftDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_SHIFT )
            
        
        shortcut = Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, key, modifiers )
        
        if HG.gui_report_mode:
            
            HydrusData.ShowText( 'key event caught: ' + repr( shortcut ) )
            
        
        return shortcut
        
    
    return None
Esempio n. 12
0
 def THREADExitEverything( self ):
     
     try:
         
         self.pub( 'splash_set_title_text', u'shutting down gui\u2026' )
         
         self.ShutdownView()
         
         self.pub( 'splash_set_title_text', u'shutting down db\u2026' )
         
         self.ShutdownModel()
         
         self.pub( 'splash_set_title_text', u'cleaning up\u2026' )
         self.pub( 'splash_set_status_text', u'' )
         
         HydrusData.CleanRunningFile( self.db_dir, 'client' )
         
     except HydrusExceptions.PermissionException:
         
         pass
         
     except HydrusExceptions.ShutdownException:
         
         pass
         
     except:
         
         ClientData.ReportShutdownException()
         
     finally:
         
         self._DestroySplash()
Esempio n. 13
0
 def __init__( self, db_dir, no_daemons, no_wal ):
     
     self._last_shutdown_was_bad = False
     
     self._is_booted = False
     
     self._splash = None
     
     HydrusController.HydrusController.__init__( self, db_dir, no_daemons, no_wal )
     
     self._name = 'client'
     
     HG.client_controller = self
     
     # just to set up some defaults, in case some db update expects something for an odd yaml-loading reason
     self.options = ClientDefaults.GetClientDefaultOptions()
     self.new_options = ClientData.ClientOptions( self.db_dir )
     
     HC.options = self.options
     
     self._last_mouse_position = None
     self._menu_open = False
     self._previously_idle = False
     self._idle_started = None
     
     self.client_files_manager = None
     self.services_manager = None
Esempio n. 14
0
 def ToString( self ):
     
     components = []
     
     if CC.SHORTCUT_MODIFIER_CTRL in self._modifiers:
         
         components.append( 'ctrl' )
         
     
     if CC.SHORTCUT_MODIFIER_ALT in self._modifiers:
         
         components.append( 'alt' )
         
     
     if CC.SHORTCUT_MODIFIER_SHIFT in self._modifiers:
         
         components.append( 'shift' )
         
     
     if self._shortcut_type == CC.SHORTCUT_TYPE_KEYBOARD:
         
         if self._shortcut_key in CC.wxk_code_string_lookup:
             
             components.append( CC.wxk_code_string_lookup[ self._shortcut_key ] )
             
         elif ClientData.OrdIsAlphaUpper( self._shortcut_key ):
             
             components.append( chr( self._shortcut_key + 32 ) ) # + 32 for converting ascii A -> a
             
         elif ClientData.OrdIsSensibleASCII( self._shortcut_key ):
             
             components.append( chr( self._shortcut_key ) )
             
         else:
             
             components.append( 'unknown key' )
             
         
     elif self._shortcut_type == CC.SHORTCUT_TYPE_MOUSE:
         
         components.append( CC.shortcut_mouse_string_lookup[ self._shortcut_key ] )
         
     
     return '+'.join( components )
Esempio n. 15
0
    def GetValue(self):

        intended_files_per_check = self._intended_files_per_check.GetValue()
        never_faster_than = self._never_faster_than.GetValue()
        never_slower_than = self._never_slower_than.GetValue()
        death_file_velocity = self._death_file_velocity.GetValue()

        return ClientData.CheckerOptions(intended_files_per_check,
                                         never_faster_than, never_slower_than,
                                         death_file_velocity)
Esempio n. 16
0
 def setUpClass( self ):
     
     services = []
     
     self._file_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.FILE_REPOSITORY, 'file repo', {} )
     self._tag_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.TAG_REPOSITORY, 'tag repo', {} )
     self._admin_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.SERVER_ADMIN, 'server admin', {} )
     
     services_manager = HydrusGlobals.test_controller.GetServicesManager()
     
     services_manager._keys_to_services[ self._file_service.GetServiceKey() ] = self._file_service
     services_manager._keys_to_services[ self._tag_service.GetServiceKey() ] = self._tag_service
     services_manager._keys_to_services[ self._admin_service.GetServiceKey() ] = self._admin_service
     
     HydrusPaths.MakeSureDirectoryExists( ServerFiles.GetExpectedUpdateDir( self._file_service.GetServiceKey() ) )
     HydrusPaths.MakeSureDirectoryExists( ServerFiles.GetExpectedUpdateDir( self._tag_service.GetServiceKey() ) )
     
     permissions = [ HC.GET_DATA, HC.POST_DATA, HC.POST_PETITIONS, HC.RESOLVE_PETITIONS, HC.MANAGE_USERS, HC.GENERAL_ADMIN, HC.EDIT_SERVICES ]
     
     account_key = HydrusData.GenerateKey()
     account_type = HydrusData.AccountType( 'account', permissions, ( None, None ) )
     created = HydrusData.GetNow() - 100000
     expires = None
     used_bytes = 0
     used_requests = 0
     
     self._account = HydrusData.Account( account_key, account_type, created, expires, used_bytes, used_requests )
     
     self._access_key = HydrusData.GenerateKey()
     self._file_hash = HydrusData.GenerateKey()
     
     def TWISTEDSetup():
         
         reactor.listenTCP( HC.DEFAULT_SERVER_ADMIN_PORT, ServerServer.HydrusServiceAdmin( self._admin_service.GetServiceKey(), HC.SERVER_ADMIN, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_LOCAL_FILE_PORT, ClientLocalServer.HydrusServiceLocal( CC.LOCAL_FILE_SERVICE_KEY, HC.LOCAL_FILE, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_LOCAL_BOORU_PORT, ClientLocalServer.HydrusServiceBooru( CC.LOCAL_BOORU_SERVICE_KEY, HC.LOCAL_BOORU, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_SERVICE_PORT, ServerServer.HydrusServiceRepositoryFile( self._file_service.GetServiceKey(), HC.FILE_REPOSITORY, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_SERVICE_PORT + 1, ServerServer.HydrusServiceRepositoryTag( self._tag_service.GetServiceKey(), HC.TAG_REPOSITORY, 'hello' ) )
         
     
     reactor.callFromThread( TWISTEDSetup )
     
     time.sleep( 1 )
Esempio n. 17
0
 def EventCharHook( self, event ):
     
     ( modifier, key ) = ClientData.ConvertKeyEventToSimpleTuple( event )
     
     if key == wx.WXK_ESCAPE:
         
         self.Close()
         
     else:
         
         event.Skip()
Esempio n. 18
0
    def SetCurrentZoom(self, canvas_key, zoom):

        if canvas_key == self._canvas_key:

            self._current_zoom = zoom

            label = ClientData.ConvertZoomToPercentage(self._current_zoom)

            self._zoom_text.SetLabelText(label)

            self._top_hbox.Layout()
Esempio n. 19
0
    def _PopulateLeftButtons(self):

        self._first_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.first, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'duplicate_filter_back'))
        self._first_button.SetToolTip('go back a pair')

        self._top_hbox.Add(self._first_button, CC.FLAGS_VCENTER)

        FullscreenHoverFrameTopNavigable._PopulateLeftButtons(self)

        self._last_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.last, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'duplicate_filter_skip'))
        self._last_button.SetToolTip('show a different pair')

        self._top_hbox.Add(self._last_button, CC.FLAGS_VCENTER)
Esempio n. 20
0
def GetDefaultImportFileOptions():
    
    options = HydrusGlobals.client_controller.GetOptions()
    
    automatic_archive = False
    exclude_deleted = options[ 'exclude_deleted_files' ]
    min_size = None
    min_resolution = None
    
    import_file_options = ClientData.ImportFileOptions( automatic_archive = automatic_archive, exclude_deleted = exclude_deleted, min_size = min_size, min_resolution = min_resolution )
    
    return import_file_options
Esempio n. 21
0
    def GetOptions(self):

        automatic_archive = self._auto_archive.GetValue()
        exclude_deleted = self._exclude_deleted.GetValue()
        min_size = self._min_size.GetValue()
        min_resolution = self._min_resolution.GetValue()

        return ClientData.ImportFileOptions(
            automatic_archive=automatic_archive,
            exclude_deleted=exclude_deleted,
            min_size=min_size,
            min_resolution=min_resolution)
Esempio n. 22
0
    def _UpdateBackgroundColour(self):

        colour = HG.client_controller.new_options.GetColour(
            CC.COLOUR_AUTOCOMPLETE_BACKGROUND)

        if not self._intercept_key_events:

            colour = ClientData.GetLighterDarkerColour(colour)

        self._text_ctrl.SetBackgroundColour(colour)

        self._text_ctrl.Refresh()
Esempio n. 23
0
    def _PopulateLeftButtons(self):

        self._first_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.first, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'view_first'))
        self._first_button.SetToolTipString('first')

        self._top_hbox.AddF(self._first_button, CC.FLAGS_VCENTER)

        FullscreenHoverFrameTopNavigable._PopulateLeftButtons(self)

        self._last_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.last, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'view_last'))
        self._last_button.SetToolTipString('last')

        self._top_hbox.AddF(self._last_button, CC.FLAGS_VCENTER)
Esempio n. 24
0
    def _PopulateLeftButtons(self):

        self._previous_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.previous, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'view_previous'))
        self._previous_button.SetToolTipString('previous')

        self._index_text = ClientGUICommon.BetterStaticText(self, 'index')

        self._next_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.next, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'view_next'))
        self._next_button.SetToolTipString('next')

        self._top_hbox.AddF(self._previous_button, CC.FLAGS_VCENTER)
        self._top_hbox.AddF(self._index_text, CC.FLAGS_VCENTER)
        self._top_hbox.AddF(self._next_button, CC.FLAGS_VCENTER)
Esempio n. 25
0
    def _PopulateLeftButtons(self):

        self._back_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.previous, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'archive_delete_filter_back'))
        self._back_button.SetToolTipString('back')

        self._top_hbox.AddF(self._back_button, CC.FLAGS_VCENTER)

        FullscreenHoverFrameTop._PopulateLeftButtons(self)

        self._skip_button = ClientGUICommon.BetterBitmapButton(
            self, CC.GlobalBMPs.next, HG.client_controller.pub,
            'canvas_application_command', self._canvas_key,
            ClientData.ApplicationCommand(CC.APPLICATION_COMMAND_TYPE_SIMPLE,
                                          'archive_delete_filter_skip'))
        self._skip_button.SetToolTipString('skip')

        self._top_hbox.AddF(self._skip_button, CC.FLAGS_VCENTER)
Esempio n. 26
0
    def EventMouse(self, event):

        shortcut = ClientData.ConvertMouseEventToShortcut(event)

        if shortcut is not None:

            shortcut_processed = self._ProcessShortcut(shortcut)

            if shortcut_processed:

                return

        event.Skip()
Esempio n. 27
0
 def test_SERIALISABLE_TYPE_SUBSCRIPTION( self ):
     
     def test( obj, dupe_obj ):
         
         self.assertEqual( obj.GetName(), dupe_obj.GetName() )
         
         self.assertEqual( obj._gallery_identifier, dupe_obj._gallery_identifier )
         self.assertEqual( obj._gallery_stream_identifiers, dupe_obj._gallery_stream_identifiers )
         self.assertEqual( len( obj._queries ), len( dupe_obj._queries ) )
         self.assertEqual( obj._get_tags_if_url_known_and_file_redundant, dupe_obj._get_tags_if_url_known_and_file_redundant )
         self.assertEqual( obj._initial_file_limit, dupe_obj._initial_file_limit )
         self.assertEqual( obj._periodic_file_limit, dupe_obj._periodic_file_limit )
         self.assertEqual( obj._paused, dupe_obj._paused )
         
         self.assertEqual( obj._file_import_options.GetSerialisableTuple(), dupe_obj._file_import_options.GetSerialisableTuple() )
         self.assertEqual( obj._tag_import_options.GetSerialisableTuple(), dupe_obj._tag_import_options.GetSerialisableTuple() )
         
         self.assertEqual( obj._no_work_until, dupe_obj._no_work_until )
         
     
     sub = ClientImporting.Subscription( 'test sub' )
     
     self._dump_and_load_and_test( sub, test )
     
     gallery_identifier = ClientDownloading.GalleryIdentifier( HC.SITE_TYPE_BOORU, 'gelbooru' )
     gallery_stream_identifiers = ClientDownloading.GetGalleryStreamIdentifiers( gallery_identifier )
     queries = [ ClientImporting.SubscriptionQuery( 'test query' ), ClientImporting.SubscriptionQuery( 'test query 2' ) ]
     checker_options = ClientData.CheckerOptions()
     get_tags_if_url_known_and_file_redundant = True
     initial_file_limit = 100
     periodic_file_limit = 50
     paused = False
     
     file_import_options = ClientImporting.FileImportOptions( automatic_archive = False, exclude_deleted = True, min_size = 8 * 1024, min_resolution = [ 25, 25 ] )
     tag_import_options = ClientImporting.TagImportOptions( service_keys_to_namespaces = { HydrusData.GenerateKey() : { 'series', '' } }, service_keys_to_explicit_tags = { HydrusData.GenerateKey() : { 'test explicit tag', 'and another' } } )
     
     no_work_until = HydrusData.GetNow() - 86400 * 20
     
     sub.SetTuple( gallery_identifier, gallery_stream_identifiers, queries, checker_options, get_tags_if_url_known_and_file_redundant, initial_file_limit, periodic_file_limit, paused, file_import_options, tag_import_options, no_work_until )
     
     self.assertEqual( sub.GetGalleryIdentifier(), gallery_identifier )
     self.assertEqual( sub.GetTagImportOptions(), tag_import_options )
     self.assertEqual( sub.GetQueries(), queries )
     
     self.assertEqual( sub._paused, False )
     sub.PauseResume()
     self.assertEqual( sub._paused, True )
     sub.PauseResume()
     self.assertEqual( sub._paused, False )
     
     self._dump_and_load_and_test( sub, test )
Esempio n. 28
0
    def EventCharHook(self, event):

        if IShouldCatchCharHook(self._parent):

            shortcut = ClientData.ConvertKeyEventToShortcut(event)

            if shortcut is not None:

                shortcut_processed = self._ProcessShortcut(shortcut)

                if shortcut_processed:

                    return

        event.Skip()
Esempio n. 29
0
    def __init__(self):

        HydrusController.HydrusController.__init__(self)

        HydrusGlobals.client_controller = self

        # just to set up some defaults, in case some db update expects something for an odd yaml-loading reason
        self._options = ClientDefaults.GetClientDefaultOptions()
        self._new_options = ClientData.ClientOptions()

        HC.options = self._options

        self._last_mouse_position = None
        self._menu_open = False
        self._previously_idle = False
        self._idle_started = None
Esempio n. 30
0
    def EventKeyDown(self, event):

        (modifier, key) = ClientData.ConvertKeyEventToSimpleTuple(event)

        if key in CC.DELETE_KEYS:

            if self._delete_key_callback is not None:

                self._delete_key_callback()

        elif key in (ord('A'), ord('a')) and modifier == wx.ACCEL_CTRL:

            self.SelectAll()

        else:

            event.Skip()