hydrus/include/ClientGUIPages.py

712 lines
26 KiB
Python
Raw Normal View History

2013-02-19 00:11:43 +00:00
import HydrusConstants as HC
import ClientConstants as CC
import ClientGUICommon
import ClientGUIDialogs
import ClientGUIManagement
import ClientGUIMedia
import ClientGUIMessages
import ClientGUICanvas
2014-01-22 21:11:22 +00:00
import HydrusDownloading
2015-03-18 21:46:29 +00:00
import HydrusThreading
2013-11-27 18:27:11 +00:00
import inspect
2013-02-19 00:11:43 +00:00
import os
2013-11-27 18:27:11 +00:00
import sys
2013-02-19 00:11:43 +00:00
import time
import traceback
import wx
2014-07-23 21:21:37 +00:00
class PageBase( object ):
2013-02-19 00:11:43 +00:00
2015-03-04 22:44:32 +00:00
_is_storable = False
2013-12-04 22:44:16 +00:00
def __init__( self, starting_from_session = False ):
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
self._starting_from_session = starting_from_session
2013-02-19 00:11:43 +00:00
self._page_key = os.urandom( 32 )
2015-03-04 22:44:32 +00:00
self._management_panel = None
self._media_panel = None
2014-01-22 21:11:22 +00:00
self._InitControllers()
2013-02-19 00:11:43 +00:00
self._pretty_status = ''
HC.pubsub.sub( self, 'SetPrettyStatus', 'new_page_status' )
2014-01-22 21:11:22 +00:00
def _InitControllers( self ): pass
2015-03-04 22:44:32 +00:00
def _InitManagementPanel( self ): pass
def _InitMediaPanel( self ): pass
2014-01-22 21:11:22 +00:00
def _PauseControllers( self ): pass
def _ResumeControllers( self ): pass
def CleanBeforeDestroy( self ): pass
2013-02-19 00:11:43 +00:00
def GetPrettyStatus( self ): return self._pretty_status
def GetSashPositions( self ):
2013-08-14 20:21:49 +00:00
x = HC.options[ 'hpos' ]
2013-02-19 00:11:43 +00:00
2013-08-14 20:21:49 +00:00
y = HC.options[ 'vpos' ]
2013-02-19 00:11:43 +00:00
return ( x, y )
2015-03-04 22:44:32 +00:00
def IsStorable( self ): return self._is_storable
2013-02-19 00:11:43 +00:00
def PageHidden( self ): HC.pubsub.pub( 'page_hidden', self._page_key )
def PageShown( self ): HC.pubsub.pub( 'page_shown', self._page_key )
2013-09-11 21:28:19 +00:00
def Pause( self ):
2014-01-22 21:11:22 +00:00
self._PauseControllers()
2013-09-11 21:28:19 +00:00
HC.pubsub.pub( 'pause', self._page_key )
HC.pubsub.pub( 'set_focus', self._page_key, None )
2013-02-19 00:11:43 +00:00
def SetPrettyStatus( self, page_key, status ):
if page_key == self._page_key:
self._pretty_status = status
HC.pubsub.pub( 'refresh_status' )
def RefreshQuery( self ): HC.pubsub.pub( 'refresh_query', self._page_key )
def SetMediaFocus( self ): pass
def SetSearchFocus( self ): HC.pubsub.pub( 'set_search_focus', self._page_key )
def SetSynchronisedWait( self ): HC.pubsub.pub( 'synchronised_wait_switch', self._page_key )
def ShowHideSplit( self ): pass
2014-01-22 21:11:22 +00:00
def TestAbleToClose( self ): pass
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def Resume( self ):
self._ResumeControllers()
HC.pubsub.pub( 'resume', self._page_key )
2013-09-11 21:28:19 +00:00
2013-02-19 00:11:43 +00:00
class PageMessages( PageBase, wx.SplitterWindow ):
2013-12-04 22:44:16 +00:00
def __init__( self, parent, identity, starting_from_session = False ):
2013-02-19 00:11:43 +00:00
wx.SplitterWindow.__init__( self, parent )
2013-12-04 22:44:16 +00:00
PageBase.__init__( self, starting_from_session = starting_from_session )
2013-02-19 00:11:43 +00:00
self.SetMinimumPaneSize( 120 )
self.SetSashGravity( 0.0 )
self._identity = identity
self._search_preview_split = wx.SplitterWindow( self, style=wx.SP_NOBORDER )
self._search_preview_split.SetMinimumPaneSize( 180 )
self._search_preview_split.SetSashGravity( 0.5 )
self._search_preview_split.Bind( wx.EVT_SPLITTER_DCLICK, self.EventPreviewUnsplit )
self._InitManagementPanel()
2014-08-27 22:15:22 +00:00
self._preview_panel = ClientGUICanvas.CanvasPanel( self._search_preview_split, self._page_key, HC.LOCAL_FILE_SERVICE_KEY )
2013-02-19 00:11:43 +00:00
self._InitMessagesPanel()
2013-08-14 20:21:49 +00:00
self.SplitVertically( self._search_preview_split, self._messages_panel, HC.options[ 'hpos' ] )
wx.CallAfter( self._search_preview_split.SplitHorizontally, self._management_panel, self._preview_panel, HC.options[ 'vpos' ] )
2013-02-19 00:11:43 +00:00
2013-12-11 22:09:25 +00:00
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelMessages( self._search_preview_split, self._page_key, self._identity, starting_from_session = self._starting_from_session )
2013-02-19 00:11:43 +00:00
def _InitMessagesPanel( self ): self._messages_panel = ClientGUIMessages.ConversationSplitter( self, self._page_key, self._identity )
def EventPreviewUnsplit( self, event ): self._search_preview_split.Unsplit( self._preview_panel )
def GetSashPositions( self ):
if self.IsSplit(): x = self.GetSashPosition()
2013-08-14 20:21:49 +00:00
else: x = HC.options[ 'hpos' ]
2013-02-19 00:11:43 +00:00
if self._search_preview_split.IsSplit(): y = -1 * self._preview_panel.GetSize()[1]
2013-08-14 20:21:49 +00:00
else: y = HC.options[ 'vpos' ]
2013-02-19 00:11:43 +00:00
return ( x, y )
def ShowHideSplit( self ):
if self._search_preview_split.IsSplit(): self._search_preview_split.Unsplit( self._preview_panel )
2013-08-14 20:21:49 +00:00
else: self._search_preview_split.SplitHorizontally( self._management_panel, self._preview_panel, HC.options[ 'vpos' ] )
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def TestAbleToClose( self ): self._management_panel.TestAbleToClose()
2013-02-19 00:11:43 +00:00
class PageWithMedia( PageBase, wx.SplitterWindow ):
2014-08-27 22:15:22 +00:00
def __init__( self, parent, file_service_key = HC.LOCAL_FILE_SERVICE_KEY, initial_hashes = [], initial_media_results = [], starting_from_session = False ):
2013-02-19 00:11:43 +00:00
wx.SplitterWindow.__init__( self, parent )
2013-12-04 22:44:16 +00:00
PageBase.__init__( self, starting_from_session = starting_from_session )
2014-08-27 22:15:22 +00:00
if len( initial_hashes ) > 0: initial_media_results = HC.app.Read( 'media_results', file_service_key, initial_hashes )
2013-02-19 00:11:43 +00:00
2014-08-27 22:15:22 +00:00
self._file_service_key = file_service_key
2013-12-04 22:44:16 +00:00
self._initial_media_results = initial_media_results
2013-02-19 00:11:43 +00:00
self.SetMinimumPaneSize( 120 )
self.SetSashGravity( 0.0 )
self.Bind( wx.EVT_SPLITTER_DCLICK, self.EventUnsplit )
self._search_preview_split = wx.SplitterWindow( self, style=wx.SP_NOBORDER )
self._search_preview_split.SetMinimumPaneSize( 180 )
self._search_preview_split.SetSashGravity( 0.5 )
self._search_preview_split.Bind( wx.EVT_SPLITTER_DCLICK, self.EventPreviewUnsplit )
self._InitManagementPanel()
2014-08-27 22:15:22 +00:00
self._preview_panel = ClientGUICanvas.CanvasPanel( self._search_preview_split, self._page_key, self._file_service_key )
2013-02-19 00:11:43 +00:00
self._InitMediaPanel()
2013-08-14 20:21:49 +00:00
self.SplitVertically( self._search_preview_split, self._media_panel, HC.options[ 'hpos' ] )
wx.CallAfter( self._search_preview_split.SplitHorizontally, self._management_panel, self._preview_panel, HC.options[ 'vpos' ] )
2013-02-19 00:11:43 +00:00
HC.pubsub.sub( self, 'SwapMediaPanel', 'swap_media_panel' )
2014-01-22 21:11:22 +00:00
def CleanBeforeDestroy( self ): self._management_panel.CleanBeforeDestroy()
2013-02-19 00:11:43 +00:00
def EventPreviewUnsplit( self, event ): self._search_preview_split.Unsplit( self._preview_panel )
def EventUnsplit( self, event ): self.Unsplit( self._search_preview_split )
# used by autocomplete
def GetMedia( self ): return self._media_panel.GetSortedMedia()
def GetSashPositions( self ):
if self.IsSplit(): x = self.GetSashPosition()
2013-08-14 20:21:49 +00:00
else: x = HC.options[ 'hpos' ]
2013-02-19 00:11:43 +00:00
if self._search_preview_split.IsSplit(): y = -1 * self._preview_panel.GetSize()[1]
2013-08-14 20:21:49 +00:00
else: y = HC.options[ 'vpos' ]
2013-02-19 00:11:43 +00:00
return ( x, y )
def ShowHideSplit( self ):
if self.IsSplit():
self.Unsplit( self._search_preview_split )
else:
2013-08-14 20:21:49 +00:00
self.SplitVertically( self._search_preview_split, self._media_panel, HC.options[ 'hpos' ] )
2013-02-19 00:11:43 +00:00
2013-08-14 20:21:49 +00:00
self._search_preview_split.SplitHorizontally( self._management_panel, self._preview_panel, HC.options[ 'vpos' ] )
2013-02-19 00:11:43 +00:00
def SetMediaFocus( self ): self._media_panel.SetFocus()
def SwapMediaPanel( self, page_key, new_panel ):
if page_key == self._page_key:
self._preview_panel.SetMedia( None )
self.ReplaceWindow( self._media_panel, new_panel )
2014-02-26 22:09:54 +00:00
wx.CallAfter( self._media_panel.Destroy )
2013-02-19 00:11:43 +00:00
self._media_panel = new_panel
2014-01-22 21:11:22 +00:00
def TestAbleToClose( self ): self._management_panel.TestAbleToClose()
2013-02-19 00:11:43 +00:00
class PageImport( PageWithMedia ):
2015-03-04 22:44:32 +00:00
_is_storable = True
2014-01-22 21:11:22 +00:00
def _GenerateImportArgsGeneratorFactory( self ):
def factory( job_key, item ):
2015-03-18 21:46:29 +00:00
advanced_import_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedImportOptions )
2014-01-22 21:11:22 +00:00
return HydrusDownloading.ImportArgsGenerator( job_key, item, advanced_import_options )
return factory
2015-01-14 22:27:55 +00:00
def _GenerateImportQueueBuilderFactory( self ):
2014-01-22 21:11:22 +00:00
def factory( job_key, item ):
2015-01-14 22:27:55 +00:00
return HydrusDownloading.ImportQueueBuilder( job_key, item )
2014-01-22 21:11:22 +00:00
return factory
2014-08-27 22:15:22 +00:00
def _InitMediaPanel( self ): self._media_panel = ClientGUIMedia.MediaPanelThumbnails( self, self._page_key, self._file_service_key, self._initial_media_results )
2013-12-04 22:44:16 +00:00
2014-01-22 21:11:22 +00:00
def _InitControllers( self ):
2013-12-04 22:44:16 +00:00
2014-01-22 21:11:22 +00:00
import_args_generator_factory = self._GenerateImportArgsGeneratorFactory()
2015-01-14 22:27:55 +00:00
import_queue_builder_factory = self._GenerateImportQueueBuilderFactory()
2013-12-04 22:44:16 +00:00
2015-01-14 22:27:55 +00:00
self._import_controller = HydrusDownloading.ImportController( import_args_generator_factory, import_queue_builder_factory, page_key = self._page_key )
2013-12-04 22:44:16 +00:00
2014-05-21 21:37:35 +00:00
self._import_controller.StartDaemon()
2013-12-04 22:44:16 +00:00
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def _PauseControllers( self ):
controller_job_key = self._import_controller.GetJobKey( 'controller' )
controller_job_key.Pause()
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def _ResumeControllers( self ):
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
controller_job_key = self._import_controller.GetJobKey( 'controller' )
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
controller_job_key.Resume()
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def CleanBeforeDestroy( self ):
PageWithMedia.CleanBeforeDestroy( self )
self._import_controller.CleanBeforeDestroy()
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
def GetSessionArgs( self ):
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
hashes = [ media.GetHash() for media in self._media_panel.GetFlatMedia() ]
2014-01-22 21:11:22 +00:00
args = tuple()
2013-12-04 22:44:16 +00:00
kwargs = { 'initial_hashes' : hashes }
return ( args, kwargs )
2013-02-19 00:11:43 +00:00
2013-12-11 22:09:25 +00:00
class PageImportGallery( PageImport ):
2013-12-04 22:44:16 +00:00
2014-01-22 21:11:22 +00:00
def __init__( self, parent, gallery_name, gallery_type, initial_hashes = [], starting_from_session = False ):
2013-12-11 22:09:25 +00:00
2014-01-22 21:11:22 +00:00
self._gallery_name = gallery_name
self._gallery_type = gallery_type
2013-12-11 22:09:25 +00:00
PageImport.__init__( self, parent, initial_hashes = initial_hashes, starting_from_session = starting_from_session )
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def _GenerateImportArgsGeneratorFactory( self ):
def factory( job_key, item ):
2015-03-18 21:46:29 +00:00
advanced_import_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedImportOptions )
advanced_tag_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedTagOptions )
2014-01-22 21:11:22 +00:00
downloaders_factory = self._GetDownloadersFactory()
return HydrusDownloading.ImportArgsGeneratorGallery( job_key, item, advanced_import_options, advanced_tag_options, downloaders_factory )
return factory
2015-01-14 22:27:55 +00:00
def _GenerateImportQueueBuilderFactory( self ):
2014-01-22 21:11:22 +00:00
def factory( job_key, item ):
downloaders_factory = self._GetDownloadersFactory()
2015-01-14 22:27:55 +00:00
return HydrusDownloading.ImportQueueBuilderGallery( job_key, item, downloaders_factory )
2014-01-22 21:11:22 +00:00
return factory
def _GetDownloadersFactory( self ):
if self._gallery_name == 'booru':
def downloaders_factory( raw_tags ):
booru = self._gallery_type
tags = raw_tags.split( ' ' )
return ( HydrusDownloading.DownloaderBooru( booru, tags ), )
elif self._gallery_name == 'deviant art':
if self._gallery_type == 'artist':
def downloaders_factory( artist ):
return ( HydrusDownloading.DownloaderDeviantArt( artist ), )
elif self._gallery_name == 'giphy':
def downloaders_factory( tag ):
return ( HydrusDownloading.DownloaderGiphy( tag ), )
elif self._gallery_name == 'hentai foundry':
if self._gallery_type == 'artist':
def downloaders_factory( artist ):
2015-03-18 21:46:29 +00:00
advanced_hentai_foundry_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedHentaiFoundryOptions )
2014-01-22 21:11:22 +00:00
pictures_downloader = HydrusDownloading.DownloaderHentaiFoundry( 'artist pictures', artist, advanced_hentai_foundry_options )
scraps_downloader = HydrusDownloading.DownloaderHentaiFoundry( 'artist scraps', artist, advanced_hentai_foundry_options )
return ( pictures_downloader, scraps_downloader )
elif self._gallery_type == 'tags':
def downloaders_factory( raw_tags ):
2015-03-18 21:46:29 +00:00
advanced_hentai_foundry_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedHentaiFoundryOptions )
2014-01-22 21:11:22 +00:00
tags = raw_tags.split( ' ' )
return ( HydrusDownloading.DownloaderHentaiFoundry( 'tags', tags, advanced_hentai_foundry_options ), )
elif self._gallery_name == 'newgrounds':
def downloaders_factory( artist ):
return ( HydrusDownloading.DownloaderNewgrounds( artist ), )
elif self._gallery_name == 'pixiv':
2015-01-07 23:09:00 +00:00
if self._gallery_type in ( 'artist', 'artist_id' ):
2014-01-22 21:11:22 +00:00
2015-01-07 23:09:00 +00:00
def downloaders_factory( artist_id ):
2014-01-22 21:11:22 +00:00
2015-01-07 23:09:00 +00:00
return ( HydrusDownloading.DownloaderPixiv( 'artist_id', artist_id ), )
2014-01-22 21:11:22 +00:00
elif self._gallery_type == 'tag':
def downloaders_factory( tag ):
2014-05-28 21:03:24 +00:00
return ( HydrusDownloading.DownloaderPixiv( 'tags', tag ), )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'tumblr':
def downloaders_factory( username ):
return ( HydrusDownloading.DownloaderTumblr( username ), )
2013-12-11 22:09:25 +00:00
2014-01-22 21:11:22 +00:00
return downloaders_factory
2013-12-11 22:09:25 +00:00
2014-01-22 21:11:22 +00:00
def _InitManagementPanel( self ):
if self._gallery_name == 'hentai foundry':
name = 'hentai foundry'
namespaces = [ 'creator', 'title', '' ]
if self._gallery_type == 'artist': initial_search_value = 'artist username'
elif self._gallery_type == 'tags': initial_search_value = 'search tags'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_HENTAI_FOUNDRY )
self._management_panel = ClientGUIManagement.ManagementPanelImportsGalleryHentaiFoundry( self._search_preview_split, self, self._page_key, self._import_controller, name, namespaces, ato, initial_search_value, starting_from_session = self._starting_from_session )
2014-01-22 21:11:22 +00:00
else:
if self._gallery_name == 'booru':
booru = self._gallery_type
name = booru.GetName()
namespaces = booru.GetNamespaces()
initial_search_value = 'search tags'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( ( HC.SITE_TYPE_BOORU, name ) )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'deviant art':
if self._gallery_type == 'artist':
name = 'deviant art'
2015-01-14 22:27:55 +00:00
namespaces = [ 'creator', 'title' ]
2014-01-22 21:11:22 +00:00
initial_search_value = 'artist username'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_DEVIANT_ART )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'giphy':
name = 'giphy'
namespaces = [ '' ]
initial_search_value = 'search tag'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_GIPHY )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'newgrounds':
name = 'newgrounds'
namespaces = [ 'creator', 'title', '' ]
initial_search_value = 'artist username'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_NEWGROUNDS )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'pixiv':
name = 'pixiv'
namespaces = [ 'creator', 'title', '' ]
2015-01-07 23:09:00 +00:00
if self._gallery_type in ( 'artist', 'artist_id' ): initial_search_value = 'numerical artist id'
2014-01-22 21:11:22 +00:00
elif self._gallery_type == 'tag': initial_search_value = 'search tag'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_PIXIV )
2014-01-22 21:11:22 +00:00
elif self._gallery_name == 'tumblr':
name = 'tumblr'
namespaces = [ '' ]
initial_search_value = 'username'
2014-09-03 20:26:49 +00:00
ato = HC.GetDefaultAdvancedTagOptions( HC.SITE_TYPE_TUMBLR )
2014-01-22 21:11:22 +00:00
2014-09-03 20:26:49 +00:00
self._management_panel = ClientGUIManagement.ManagementPanelImportsGallery( self._search_preview_split, self, self._page_key, self._import_controller, name, namespaces, ato, initial_search_value, starting_from_session = self._starting_from_session )
2014-01-22 21:11:22 +00:00
2013-12-11 22:09:25 +00:00
2013-03-15 02:38:12 +00:00
2013-12-11 22:09:25 +00:00
def GetSessionArgs( self ):
hashes = [ media.GetHash() for media in self._media_panel.GetFlatMedia() ]
2014-01-22 21:11:22 +00:00
args = ( self._gallery_name, self._gallery_type )
2013-12-11 22:09:25 +00:00
kwargs = { 'initial_hashes' : hashes }
return ( args, kwargs )
2013-03-15 02:38:12 +00:00
2013-02-19 00:11:43 +00:00
class PageImportHDD( PageImport ):
2013-12-04 22:44:16 +00:00
def __init__( self, parent, paths_info, initial_hashes = [], advanced_import_options = {}, paths_to_tags = {}, delete_after_success = False, starting_from_session = False ):
2013-02-19 00:11:43 +00:00
2013-05-01 17:21:53 +00:00
self._paths_info = paths_info
2013-12-04 22:44:16 +00:00
self._advanced_import_options = advanced_import_options
self._paths_to_tags = paths_to_tags
self._delete_after_success = delete_after_success
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
PageImport.__init__( self, parent, initial_hashes = initial_hashes, starting_from_session = starting_from_session )
2013-02-19 00:11:43 +00:00
2015-01-14 22:27:55 +00:00
self._import_controller.PendImportQueueJob( self._paths_info )
2014-01-22 21:11:22 +00:00
def _GenerateImportArgsGeneratorFactory( self ):
def factory( job_key, item ):
return HydrusDownloading.ImportArgsGeneratorHDD( job_key, item, self._advanced_import_options, self._paths_to_tags, self._delete_after_success )
return factory
2013-02-19 00:11:43 +00:00
2014-01-22 21:11:22 +00:00
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelImportHDD( self._search_preview_split, self, self._page_key, self._import_controller, starting_from_session = self._starting_from_session )
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
def GetSessionArgs( self ):
hashes = [ media.GetHash() for media in self._media_panel.GetFlatMedia() ]
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
args = ( [], )
kwargs = { 'initial_hashes' : hashes }
2013-02-19 00:11:43 +00:00
2013-12-04 22:44:16 +00:00
return ( args, kwargs )
2013-02-19 00:11:43 +00:00
class PageImportThreadWatcher( PageImport ):
2014-01-22 21:11:22 +00:00
def _GenerateImportArgsGeneratorFactory( self ):
def factory( job_key, item ):
2015-03-18 21:46:29 +00:00
advanced_import_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedImportOptions )
advanced_tag_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedTagOptions )
2014-01-22 21:11:22 +00:00
# fourchan_board should be on the job_key or whatever. it is stuck on initial queue generation
# we should not be getting it from the management_panel
# we should have access to this info from the job_key or w/e
return HydrusDownloading.ImportArgsGeneratorThread( job_key, item, advanced_import_options, advanced_tag_options )
return factory
2015-01-14 22:27:55 +00:00
def _GenerateImportQueueBuilderFactory( self ):
2014-01-22 21:11:22 +00:00
def factory( job_key, item ):
2015-01-14 22:27:55 +00:00
return HydrusDownloading.ImportQueueBuilderThread( job_key, item )
2014-01-22 21:11:22 +00:00
return factory
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelImportThreadWatcher( self._search_preview_split, self, self._page_key, self._import_controller, starting_from_session = self._starting_from_session )
2013-03-15 02:38:12 +00:00
2013-02-19 00:11:43 +00:00
class PageImportURL( PageImport ):
2014-01-22 21:11:22 +00:00
def _GenerateImportArgsGeneratorFactory( self ):
def factory( job_key, item ):
2015-03-18 21:46:29 +00:00
advanced_import_options = HydrusThreading.CallBlockingToWx( self._management_panel.GetAdvancedImportOptions )
2014-01-22 21:11:22 +00:00
return HydrusDownloading.ImportArgsGeneratorURLs( job_key, item, advanced_import_options )
return factory
2015-01-14 22:27:55 +00:00
def _GenerateImportQueueBuilderFactory( self ):
2014-01-22 21:11:22 +00:00
def factory( job_key, item ):
2015-01-14 22:27:55 +00:00
return HydrusDownloading.ImportQueueBuilderURLs( job_key, item )
2014-01-22 21:11:22 +00:00
return factory
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelImportsURL( self._search_preview_split, self, self._page_key, self._import_controller, starting_from_session = self._starting_from_session )
2013-02-19 00:11:43 +00:00
class PagePetitions( PageWithMedia ):
2014-08-27 22:15:22 +00:00
def __init__( self, parent, petition_service_key, starting_from_session = False ):
self._petition_service_key = petition_service_key
2013-06-12 22:53:31 +00:00
2014-08-27 22:15:22 +00:00
petition_service = HC.app.GetManager( 'services' ).GetService( petition_service_key )
2013-06-12 22:53:31 +00:00
2014-09-17 21:28:26 +00:00
petition_service_type = petition_service.GetServiceType()
2013-06-12 22:53:31 +00:00
2014-08-27 22:15:22 +00:00
if petition_service_type in ( HC.LOCAL_FILE, HC.FILE_REPOSITORY ): self._file_service_key = self._petition_service_key
else: self._file_service_key = HC.COMBINED_FILE_SERVICE_KEY
2013-06-12 22:53:31 +00:00
2014-08-27 22:15:22 +00:00
PageWithMedia.__init__( self, parent, self._file_service_key, starting_from_session = starting_from_session )
2013-06-12 22:53:31 +00:00
2014-08-27 22:15:22 +00:00
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelPetitions( self._search_preview_split, self, self._page_key, self._file_service_key, self._petition_service_key, starting_from_session = self._starting_from_session )
2013-02-19 00:11:43 +00:00
2014-08-27 22:15:22 +00:00
def _InitMediaPanel( self ): self._media_panel = ClientGUIMedia.MediaPanelNoQuery( self, self._page_key, self._file_service_key )
2013-02-19 00:11:43 +00:00
class PageQuery( PageWithMedia ):
2015-03-04 22:44:32 +00:00
_is_storable = True
2014-08-27 22:15:22 +00:00
def __init__( self, parent, file_service_key, initial_hashes = [], initial_media_results = [], initial_predicates = [], starting_from_session = False ):
2013-11-27 18:27:11 +00:00
2013-02-19 00:11:43 +00:00
self._initial_predicates = initial_predicates
2014-08-27 22:15:22 +00:00
PageWithMedia.__init__( self, parent, file_service_key, initial_hashes = initial_hashes, initial_media_results = initial_media_results, starting_from_session = starting_from_session )
2013-02-19 00:11:43 +00:00
2013-09-04 16:48:44 +00:00
def _InitManagementPanel( self ):
2013-11-27 18:27:11 +00:00
show_search = len( self._initial_predicates ) > 0 or len( self._initial_media_results ) == 0
2013-09-04 16:48:44 +00:00
2014-08-27 22:15:22 +00:00
self._management_panel = ClientGUIManagement.ManagementPanelQuery( self._search_preview_split, self, self._page_key, self._file_service_key, show_search = show_search, initial_predicates = self._initial_predicates, starting_from_session = self._starting_from_session )
2013-09-04 16:48:44 +00:00
2013-02-19 00:11:43 +00:00
2013-03-27 20:02:51 +00:00
def _InitMediaPanel( self ):
2014-08-27 22:15:22 +00:00
if len( self._initial_media_results ) == 0: self._media_panel = ClientGUIMedia.MediaPanelNoQuery( self, self._page_key, self._file_service_key )
2014-01-22 21:11:22 +00:00
else:
refreshable = len( self._initial_predicates ) > 0 or len( self._initial_media_results ) == 0
2014-08-27 22:15:22 +00:00
self._media_panel = ClientGUIMedia.MediaPanelThumbnails( self, self._page_key, self._file_service_key, self._initial_media_results, refreshable = refreshable )
2014-01-22 21:11:22 +00:00
2013-04-24 21:23:53 +00:00
2013-02-19 00:11:43 +00:00
2013-11-27 18:27:11 +00:00
def GetSessionArgs( self ):
hashes = [ media.GetHash() for media in self._media_panel.GetFlatMedia() ]
predicates = self._management_panel.GetPredicates()
2014-08-27 22:15:22 +00:00
args = ( self._file_service_key, )
2013-11-27 18:27:11 +00:00
kwargs = { 'initial_hashes' : hashes, 'initial_predicates' : predicates }
return ( args, kwargs )
2013-02-19 00:11:43 +00:00
class PageThreadDumper( PageWithMedia ):
2013-12-04 22:44:16 +00:00
def __init__( self, parent, imageboard, hashes, starting_from_session = False ):
2013-02-19 00:11:43 +00:00
self._imageboard = imageboard
2014-08-27 22:15:22 +00:00
media_results = HC.app.Read( 'media_results', HC.LOCAL_FILE_SERVICE_KEY, hashes )
2013-02-19 00:11:43 +00:00
2013-08-28 21:31:52 +00:00
hashes_to_media_results = { media_result.GetHash() : media_result for media_result in media_results }
2013-02-19 00:11:43 +00:00
self._media_results = [ hashes_to_media_results[ hash ] for hash in hashes ]
self._media_results = filter( self._imageboard.IsOkToPost, self._media_results )
2014-08-27 22:15:22 +00:00
PageWithMedia.__init__( self, parent, HC.LOCAL_FILE_SERVICE_KEY, starting_from_session = starting_from_session )
2013-02-19 00:11:43 +00:00
2013-12-11 22:09:25 +00:00
def _InitManagementPanel( self ): self._management_panel = ClientGUIManagement.ManagementPanelDumper( self._search_preview_split, self, self._page_key, self._imageboard, self._media_results, starting_from_session = self._starting_from_session )
2013-02-19 00:11:43 +00:00
2014-08-27 22:15:22 +00:00
def _InitMediaPanel( self ): self._media_panel = ClientGUIMedia.MediaPanelThumbnails( self, self._page_key, HC.LOCAL_FILE_SERVICE_KEY, self._media_results )
2013-11-27 18:27:11 +00:00
class_to_text = {}
text_to_class = {}
current_module = sys.modules[ __name__ ]
for ( name, c ) in inspect.getmembers( current_module ):
if inspect.isclass( c ):
class_to_text[ c ] = name
text_to_class[ name ] = c
2013-02-19 00:11:43 +00:00