コード例 #1
0
    def __init__(self, parent, controller):

        self._controller = controller

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        self._notebook = wx.Notebook(self)

        self._local_listbook = ClientGUICommon.ListBook(self._notebook)
        self._remote_listbook = ClientGUICommon.ListBook(self._notebook)

        self._notebook.AddPage(self._local_listbook, 'local')
        self._notebook.AddPage(self._remote_listbook, 'remote')

        self._InitialiseServices()

        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.EventPageChanged)

        vbox = wx.BoxSizer(wx.VERTICAL)

        vbox.AddF(self._notebook, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.SetSizer(vbox)

        self._controller.sub(self, 'RefreshServices',
                             'notify_new_services_gui')
コード例 #2
0
ファイル: ClientGUIImport.py プロジェクト: Xaegrek/hydrus
    def __init__(self, parent, paths):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._paths = paths

        self._tag_repositories = ClientGUICommon.ListBook(self)

        #

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

        for service in services:

            if service.HasPermission(HC.CONTENT_TYPE_MAPPINGS,
                                     HC.PERMISSION_ACTION_CREATE):

                service_key = service.GetServiceKey()

                name = service.GetName()

                self._tag_repositories.AddPageArgs(
                    name, service_key, self._Panel,
                    (self._tag_repositories, service_key, paths), {})

        page = self._Panel(self._tag_repositories, CC.LOCAL_TAG_SERVICE_KEY,
                           paths)

        name = CC.LOCAL_TAG_SERVICE_KEY

        self._tag_repositories.AddPage(name, name, page)

        default_tag_repository_key = HC.options['default_tag_repository']

        self._tag_repositories.Select(default_tag_repository_key)

        #

        vbox = wx.BoxSizer(wx.VERTICAL)

        vbox.Add(self._tag_repositories, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.SetSizer(vbox)
コード例 #3
0
    def _InitialiseServices(self):

        lb = self._notebook.GetCurrentPage()

        if lb.GetPageCount() == 0:

            previous_service_key = CC.LOCAL_FILE_SERVICE_KEY

        else:

            page = lb.GetCurrentPage().GetCurrentPage()

            previous_service_key = page.GetServiceKey()

        self._local_listbook.DeleteAllPages()
        self._remote_listbook.DeleteAllPages()

        listbook_dict = {}

        services = self._controller.GetServicesManager().GetServices(
            randomised=False)

        lb_to_select = None
        service_type_name_to_select = None
        service_type_lb = None
        service_name_to_select = None

        for service in services:

            service_type = service.GetServiceType()

            if service_type in HC.LOCAL_SERVICES:
                parent_listbook = self._local_listbook
            else:
                parent_listbook = self._remote_listbook

            if service_type == HC.TAG_REPOSITORY:
                service_type_name = 'tag repositories'
            elif service_type == HC.FILE_REPOSITORY:
                service_type_name = 'file repositories'
            elif service_type == HC.MESSAGE_DEPOT:
                service_type_name = 'message depots'
            elif service_type == HC.SERVER_ADMIN:
                service_type_name = 'administrative servers'
            elif service_type in HC.LOCAL_FILE_SERVICES:
                service_type_name = 'files'
            elif service_type == HC.LOCAL_TAG:
                service_type_name = 'tags'
            elif service_type == HC.LOCAL_RATING_LIKE:
                service_type_name = 'like/dislike ratings'
            elif service_type == HC.LOCAL_RATING_NUMERICAL:
                service_type_name = 'numerical ratings'
            elif service_type == HC.LOCAL_BOORU:
                service_type_name = 'booru'
            elif service_type == HC.IPFS:
                service_type_name = 'ipfs'
            else:
                continue

            if service_type_name not in listbook_dict:

                listbook = ClientGUICommon.ListBook(parent_listbook)

                listbook_dict[service_type_name] = listbook

                parent_listbook.AddPage(service_type_name, service_type_name,
                                        listbook)

            listbook = listbook_dict[service_type_name]

            name = service.GetName()

            panel_class = ClientGUIPanels.ReviewServicePanel

            listbook.AddPageArgs(name, name, panel_class, (listbook, service),
                                 {})

            if service.GetServiceKey() == previous_service_key:

                lb_to_select = parent_listbook
                service_type_name_to_select = service_name_to_select
                service_type_lb = listbook
                name_to_select = name

        if lb_to_select is not None:

            if self._notebook.GetCurrentPage() != lb_to_select:

                selection = self._notebook.GetSelection()

                if selection == 0:

                    self._notebook.SetSelection(1)

                else:

                    self._notebook.SetSelection(0)

            lb_to_select.Select(service_name_to_select)

            service_type_lb.Select(name_to_select)