Exemple #1
0
def make_isni_lookup_dialog(query,
                            selection,
                            on_lookup,
                            on_assign,
                            parent=None,
                            delete_on_close=True):
    dialog = ISNILookupDialog(parent, delete_on_close)

    subscriptions = MultiSubscription()
    subscriptions += selection.on_identities_available.subscribe(
        in_event_loop(dialog.lookup_successful))
    subscriptions += selection.on_connection_failed.subscribe(
        in_event_loop(dialog.connection_failed))
    subscriptions += selection.on_permission_denied.subscribe(
        in_event_loop(dialog.permission_denied))
    subscriptions += selection.on_lookup_start.subscribe(
        in_event_loop(dialog.lookup_in_progress))
    subscriptions += selection.on_success.subscribe(
        in_event_loop(dialog.selection_successful))

    dialog.on_lookup.connect(on_lookup)
    dialog.on_assign.connect(on_assign)
    dialog.on_selected.connect(selection.identity_selected)
    dialog.on_query_changed.connect(selection.query_changed)
    dialog.finished.connect(lambda accepted: subscriptions.cancel())

    if query:
        dialog.lookup(query)

    return dialog
Exemple #2
0
def make_project_edition_page(project, session, track_list_tab, musician_tab,
                              on_select_artwork, on_select_identity,
                              on_isni_changed, **handlers):
    track_list = track_list_tab(project)
    musicians = musician_tab(project)
    page = ProjectEditionPage(track_list_tab=track_list,
                              musician_tab=musicians)
    page.display(project)

    page.on_select_artwork.connect(on_select_artwork)
    page.on_select_identity.connect(on_select_identity)
    page.on_isni_edited.connect(on_isni_changed)

    for name, handler in handlers.items():
        getattr(page, name)(handler)

    subscriptions = MultiSubscription()
    subscriptions += session.user_signed_in.subscribe(page.user_changed)
    subscriptions += session.user_signed_out.subscribe(
        lambda user: page.user_changed(session.current_user))
    subscriptions += project.metadata_changed.subscribe(page.display)
    page.closed.connect(lambda: subscriptions.cancel())
    page.closed.connect(track_list.close)

    page.user_changed(session.current_user)
    return page
def make_sign_in_dialog(login, on_sign_in, parent=None, delete_on_close=True):
    dialog = SignInDialog(parent, delete_on_close)
    dialog.on_sign_in.connect(on_sign_in)
    subscriptions = MultiSubscription()
    subscriptions += login.on_start.subscribe(in_event_loop(dialog.login_in_progress))
    subscriptions += login.on_success.subscribe(in_event_loop(lambda email: dialog.login_succeeded()))
    subscriptions += login.on_connection_failed.subscribe(in_event_loop(dialog.connection_failed))
    subscriptions += login.on_authentication_failed.subscribe(in_event_loop(dialog.login_failed))
    dialog.finished.connect(lambda accepted: subscriptions.cancel())
    return dialog
def make_project_screen(project, project_page, track_page):
    screen = ProjectScreen(project_page, track_page)

    subscriptions = MultiSubscription()
    subscriptions += project.track_inserted.subscribe(lambda index, track: screen.track_added(index, track, project))
    subscriptions += project.track_removed.subscribe(lambda position, track: screen.track_removed(position, project))
    subscriptions += project.track_moved.subscribe(lambda track, from_, to: screen.track_moved(from_, to, project))
    screen.closed.connect(lambda: subscriptions.cancel())

    screen.display(project)
    return screen
Exemple #5
0
def test_cancelling_a_multi_subscription_cancels_all_subscriptions(signal):
    subscribers = (Subscriber(), Subscriber(), Subscriber())

    subscriptions = MultiSubscription()

    for subscriber in subscribers:
        subscriptions += signal.subscribe(subscriber)

    subscriptions.cancel()

    for index, subscriber in enumerate(subscribers):
        assert_that(not signal.is_subscribed(subscriber), "subscription #{} still active".format(index))
def make_contributors_tab(project, track, on_metadata_changed, on_isni_local_lookup, on_ipi_local_lookup,
                          on_ipi_changed):
    tab = ContributorsTab(on_isni_local_lookup, on_ipi_local_lookup)
    tab.display(track)
    tab.on_metadata_changed.connect(lambda metadata: on_metadata_changed(**metadata))
    tab.on_ipi_changed.connect(on_ipi_changed)

    subscriptions = MultiSubscription()
    subscriptions += track.metadata_changed.subscribe(tab.display)
    subscriptions += project.metadata_changed.subscribe(tab.display_project)
    tab.closed.connect(lambda: subscriptions.cancel())

    return tab
Exemple #7
0
def test_cancelling_a_multi_subscription_cancels_all_subscriptions(signal):
    subscribers = (Subscriber(), Subscriber(), Subscriber())

    subscriptions = MultiSubscription()

    for subscriber in subscribers:
        subscriptions += signal.subscribe(subscriber)

    subscriptions.cancel()

    for index, subscriber in enumerate(subscribers):
        assert_that(not signal.is_subscribed(subscriber),
                    "subscription #{} still active".format(index))
Exemple #8
0
def make_sign_in_dialog(login, on_sign_in, parent=None, delete_on_close=True):
    dialog = SignInDialog(parent, delete_on_close)
    dialog.on_sign_in.connect(on_sign_in)
    subscriptions = MultiSubscription()
    subscriptions += login.on_start.subscribe(
        in_event_loop(dialog.login_in_progress))
    subscriptions += login.on_success.subscribe(
        in_event_loop(lambda email: dialog.login_succeeded()))
    subscriptions += login.on_connection_failed.subscribe(
        in_event_loop(dialog.connection_failed))
    subscriptions += login.on_authentication_failed.subscribe(
        in_event_loop(dialog.login_failed))
    dialog.finished.connect(lambda accepted: subscriptions.cancel())
    return dialog
def make_isni_assignation_review_dialog(selection, on_assign, parent=None, delete_on_close=True):
    dialog = ISNIAssignationReviewDialog(parent, delete_on_close)

    subscriptions = MultiSubscription()
    subscriptions += selection.on_assignation_start.subscribe(in_event_loop(dialog.assignation_in_progress))
    subscriptions += selection.on_success.subscribe(in_event_loop(dialog.assignation_succeeded))
    subscriptions += selection.on_connection_failed.subscribe(in_event_loop(dialog.connection_failed))
    subscriptions += selection.on_insufficient_information.subscribe(in_event_loop(dialog.insufficient_information))

    dialog.on_assign.connect(on_assign)
    dialog.finished.connect(lambda accepted: subscriptions.cancel())

    dialog.display(selection)
    return dialog
Exemple #10
0
def make_project_screen(project, project_page, track_page):
    screen = ProjectScreen(project_page, track_page)

    subscriptions = MultiSubscription()
    subscriptions += project.track_inserted.subscribe(
        lambda index, track: screen.track_added(index, track, project))
    subscriptions += project.track_removed.subscribe(
        lambda position, track: screen.track_removed(position, project))
    subscriptions += project.track_moved.subscribe(
        lambda track, from_, to: screen.track_moved(from_, to, project))
    screen.closed.connect(lambda: subscriptions.cancel())

    screen.display(project)
    return screen
Exemple #11
0
def make_contributors_tab(project, track, on_metadata_changed,
                          on_isni_local_lookup, on_ipi_local_lookup,
                          on_ipi_changed):
    tab = ContributorsTab(on_isni_local_lookup, on_ipi_local_lookup)
    tab.display(track)
    tab.on_metadata_changed.connect(
        lambda metadata: on_metadata_changed(**metadata))
    tab.on_ipi_changed.connect(on_ipi_changed)

    subscriptions = MultiSubscription()
    subscriptions += track.metadata_changed.subscribe(tab.display)
    subscriptions += project.metadata_changed.subscribe(tab.display_project)
    tab.closed.connect(lambda: subscriptions.cancel())

    return tab
def make_track_edition_page(project, track, contributors_tab, chain_of_title_tab, **handlers):
    contributors = contributors_tab(project, track)
    chain_of_title = chain_of_title_tab(track)
    page = TrackEditionPage(contributors, chain_of_title)
    page.display(album=project, track=track)

    for name, handler in handlers.items():
        getattr(page, name)(handler)

    subscriptions = MultiSubscription()
    subscriptions += track.metadata_changed.subscribe(lambda track_: page.display(track=track_))
    subscriptions += project.metadata_changed.subscribe(lambda project_: page.display(album=project_))
    page.closed.connect(lambda: subscriptions.cancel())

    return page
Exemple #13
0
def make_track_list_tab(project, player, select_tracks, **handlers):
    page = TrackListTab(select_tracks)
    page.display(project)

    for name, handler in handlers.items():
        getattr(page, name)(handler)

    subscriptions = MultiSubscription()
    subscriptions += project.metadata_changed.subscribe(page.album_metadata_changed)
    subscriptions += project.track_inserted.subscribe(page.track_added)
    subscriptions += project.track_removed.subscribe(page.track_removed)
    subscriptions += project.track_moved.subscribe(lambda _, from_, to: page.track_moved(from_, to))
    subscriptions += player.playing.subscribe(page.playback_started)
    subscriptions += player.stopped.subscribe(page.playback_stopped)
    subscriptions += player.error_occurred.subscribe(page.playback_error)
    page.closed.connect(lambda: subscriptions.cancel())

    return page
Exemple #14
0
def make_track_edition_page(project, track, contributors_tab,
                            chain_of_title_tab, **handlers):
    contributors = contributors_tab(project, track)
    chain_of_title = chain_of_title_tab(track)
    page = TrackEditionPage(contributors, chain_of_title)
    page.display(album=project, track=track)

    for name, handler in handlers.items():
        getattr(page, name)(handler)

    subscriptions = MultiSubscription()
    subscriptions += track.metadata_changed.subscribe(
        lambda track_: page.display(track=track_))
    subscriptions += project.metadata_changed.subscribe(
        lambda project_: page.display(album=project_))
    page.closed.connect(lambda: subscriptions.cancel())

    return page
def make_isni_lookup_dialog(query, selection, on_lookup, on_assign, parent=None, delete_on_close=True):
    dialog = ISNILookupDialog(parent, delete_on_close)

    subscriptions = MultiSubscription()
    subscriptions += selection.on_identities_available.subscribe(in_event_loop(dialog.lookup_successful))
    subscriptions += selection.on_connection_failed.subscribe(in_event_loop(dialog.connection_failed))
    subscriptions += selection.on_permission_denied.subscribe(in_event_loop(dialog.permission_denied))
    subscriptions += selection.on_lookup_start.subscribe(in_event_loop(dialog.lookup_in_progress))
    subscriptions += selection.on_success.subscribe(in_event_loop(dialog.selection_successful))

    dialog.on_lookup.connect(on_lookup)
    dialog.on_assign.connect(on_assign)
    dialog.on_selected.connect(selection.identity_selected)
    dialog.on_query_changed.connect(selection.query_changed)
    dialog.finished.connect(lambda accepted: subscriptions.cancel())

    if query:
        dialog.lookup(query)

    return dialog
Exemple #16
0
def test_cancels_subscription_removed_from_a_multi_subscription(signal):
    subscriber = Subscriber()
    subscriptions = MultiSubscription()
    subscription = signal.subscribe(subscriber)
    subscriptions += subscription
    assert_that(signal.is_subscribed(subscriber), "subscription not active")

    subscriptions -= subscription
    assert_that(subscriptions, empty())
    assert_that(not signal.is_subscribed(subscriber),
                "subscription still active")
Exemple #17
0
def make_isni_assignation_review_dialog(selection,
                                        on_assign,
                                        parent=None,
                                        delete_on_close=True):
    dialog = ISNIAssignationReviewDialog(parent, delete_on_close)

    subscriptions = MultiSubscription()
    subscriptions += selection.on_assignation_start.subscribe(
        in_event_loop(dialog.assignation_in_progress))
    subscriptions += selection.on_success.subscribe(
        in_event_loop(dialog.assignation_succeeded))
    subscriptions += selection.on_connection_failed.subscribe(
        in_event_loop(dialog.connection_failed))
    subscriptions += selection.on_insufficient_information.subscribe(
        in_event_loop(dialog.insufficient_information))

    dialog.on_assign.connect(on_assign)
    dialog.finished.connect(lambda accepted: subscriptions.cancel())

    dialog.display(selection)
    return dialog
def make_project_edition_page(project, session, track_list_tab, musician_tab, on_select_artwork, on_select_identity,
                              on_isni_changed, **handlers):
    track_list = track_list_tab(project)
    musicians = musician_tab(project)
    page = ProjectEditionPage(track_list_tab=track_list, musician_tab=musicians)
    page.display(project)

    page.on_select_artwork.connect(on_select_artwork)
    page.on_select_identity.connect(on_select_identity)
    page.on_isni_edited.connect(on_isni_changed)

    for name, handler in handlers.items():
        getattr(page, name)(handler)

    subscriptions = MultiSubscription()
    subscriptions += session.user_signed_in.subscribe(page.user_changed)
    subscriptions += session.user_signed_out.subscribe(lambda user: page.user_changed(session.current_user))
    subscriptions += project.metadata_changed.subscribe(page.display)
    page.closed.connect(lambda: subscriptions.cancel())
    page.closed.connect(track_list.close)

    page.user_changed(session.current_user)
    return page