def prepare_viewer_library_view(app, window, script, data): library_data = script.get_object("library_data") library_data.item_handler = lambda tile, album: window.load_view( "blog/viewer_album", {"album_id": album}) handlers.button_to_view(window, script, "button_start") handlers.button_to_view( window, script, "button_publish_blog", "blog/all_posts")
def prepare_photo_editing_view(app, window, script, data): photo = script.get_object("slide") photo.photo_path = data[0].slide.photo_path handlers.button_to_view(window, script, "button_photo", "viewer/photo", {"photo_id": data[2], "album_id": data[1]}) handlers.button_to_view(window, script, "button_start")
def prepare_viewer_about_me_album_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ library = viewer_model.get_library() def pick_photo(tile): try: wordpress.blog.update_about_me_photo(tile.preview_path) except socket.timeout: window.load_popup(MESSAGES['too-slow-connection'], 'main_panel/main') else: window.load_view("blog/about_me") handlers.button_to_view(window, script, "button_library", "blog/viewer_about_me_library") handlers.button_to_view(window, script, "button_start") album_id = data["album_id"] header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) album_data = script.get_object("album_data") album_data.item_handler = lambda tile, photo_id, album_id: pick_photo(tile) album_data.data_set_idx = album_id
def prepare_speller_message_subject_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ if data and 'original_msg' in data: subject = data['original_msg']['Subject'] action = data.get('action') if action == 'forward': pre = 'PD: ' elif action in ('reply', 'reply_all'): pre = 'Odp: ' else: pre = '' window.ui.text_box.type_text(pre + subject) elif app.box['new_message'].subject: window.ui.text_box.type_text(app.box['new_message'].subject) handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_proceed", "email/speller_message_body", data)
def prepare_album_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ album_id = data["album_id"] handlers.button_to_view(window, script, "button_library", "viewer/main") handlers.button_to_view(window, script, "button_start") library = model.get_library() header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) data_source = script.get_object("library_data") def photo_tile_handler(tile, photo_id, album_id): window.load_view("viewer/photo", { "photo_id": photo_id, "album_id": album_id }) data_source.item_handler = photo_tile_handler data_source.data_set_idx = album_id data_source.emit('data-is-ready')
def prepare_speller_comment_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ def publish_comment(): text_widget = script.get_object("text_box") text = html_parsers.apply_linebreaks(text_widget.get_text()) try: if data['previous_view'] == 'blog/single_post': own_blog = wordpress.blog own_blog.add_comment(data['post'].id, text) else: followed_blog = wordpress.Blog(data["blog_url"]) followed_blog.add_comment(data["post"]["ID"], text) except socket.timeout: window.load_popup(MESSAGES['too-slow-connection'], 'main_panel/main') handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", publish_comment) handlers.button_to_view( window, script, "button_proceed", data['previous_view'], data)
def prepare_viewer_contact_album_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ contact_id = data["contact_id"] handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_library", "email/viewer_contact_library", {"contact_id": contact_id}) album_id = data["album_id"] library = model.get_library() header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) data_source = script.get_object("album_data") def photo_tile_handler(tile, photo_id, album_id): try: app.box["address_book"].edit_contact_photo( contact_id, library.get_item_by_id(photo_id).path) except address_book.AddressBookError: pass # TODO: display warning window.load_view("email/contact", {"contact_id": contact_id}) data_source.item_handler = photo_tile_handler data_source.data_set_idx = album_id
def prepare_viewer_library_view(app, window, script, data): library_data = script.get_object("library_data") library_data.item_handler = lambda tile, album: window.load_view( "blog/viewer_album", {"album_id": album}) handlers.button_to_view(window, script, "button_start") handlers.button_to_view(window, script, "button_publish_blog", "blog/all_posts")
def prepare_viewer_contact_album_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ contact_id = data["contact_id"] handlers.button_to_view(window, script, "button_exit") handlers.button_to_view( window, script, "button_library", "email/viewer_contact_library", {"contact_id": contact_id}) album_id = data["album_id"] library = model.get_library() header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) data_source = script.get_object("album_data") def photo_tile_handler(tile, photo_id, album_id): try: app.box["address_book"].edit_contact_photo( contact_id, library.get_item_by_id(photo_id).path) except address_book.AddressBookError: pass # TODO: display warning window.load_view("email/contact", {"contact_id": contact_id}) data_source.item_handler = photo_tile_handler data_source.data_set_idx = album_id
def prepare_album_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ album_id = data["album_id"] handlers.button_to_view(window, script, "button_library", "viewer/main") handlers.button_to_view(window, script, "button_start") library = model.get_library() header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) data_source = script.get_object("library_data") def photo_tile_handler(tile, photo_id, album_id): window.load_view( "viewer/photo", {"photo_id": photo_id, "album_id": album_id}) data_source.item_handler = photo_tile_handler data_source.data_set_idx = album_id data_source.emit('data-is-ready')
def prepare_speller_comment_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ def publish_comment(): text_widget = script.get_object("text_box") text = html_parsers.apply_linebreaks(text_widget.get_text()) try: if data['previous_view'] == 'blog/single_post': own_blog = wordpress.blog own_blog.add_comment(data['post'].id, text) else: followed_blog = wordpress.Blog(data["blog_url"]) followed_blog.add_comment(data["post"]["ID"], text) except socket.timeout: window.load_popup(MESSAGES['too-slow-connection'], 'main_panel/main') handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", publish_comment) handlers.button_to_view(window, script, "button_proceed", data['previous_view'], data)
def prepare_speller_about_me_view(app, window, script, data): text_widget = script.get_object("text_box") plain_bio = html_parsers.extract_text( wordpress.blog.get_about_me_page().content) if plain_bio: text_widget.type_text(plain_bio) handlers.button_to_view(window, script, "button_proceed", "blog/about_me") handlers.button_to_view(window, script, "button_exit")
def prepare_speller_title_view(app, window, script, data): text_field = script.get_object("text_box") post = wordpress.blog.pending_post if post.title and post.title != "Untitled": text_field.type_text(post.title) handlers.button_to_view(window, script, "button_proceed", "blog/viewer_library") handlers.button_to_view(window, script, "button_exit")
def prepare_folders_view(app, window, script, data): def _folder_tile_handler(tile, playlist_id): window.load_view("audio/playlist", {"playlist_id": playlist_id}) data_source = script.get_object("data_source") data_source.item_handler = _folder_tile_handler handlers.button_to_view(window, script, "button_exit") data_source.emit('data-is-ready')
def prepare_speller_title_view(app, window, script, data): text_field = script.get_object("text_box") post = wordpress.blog.pending_post if post.title and post.title != "Untitled": text_field.type_text(post.title) handlers.button_to_view( window, script, "button_proceed", "blog/viewer_library") handlers.button_to_view(window, script, "button_exit")
def prepare_viewer_contact_library_view(app, window, script, data): handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_back", "email/contact", {"contact_id": data["contact_id"]}) tile_source = script.get_object("library_data") tile_source.item_handler = lambda tile, album: window.load_view( "email/viewer_contact_album", {"album_id": album, "contact_id": data["contact_id"]} )
def prepare_flat_view(app, window, script, data): def movie_tile_handler(tile, movie_id): window.load_view("movie/player", {"movie_id": movie_id}) data_source = script.get_object("library_data") data_source.item_handler = movie_tile_handler handlers.button_to_view(window, script, "button_start") data_source.emit("data-is-ready")
def prepare_flat_view(app, window, script, data): def movie_tile_handler(tile, movie_id): window.load_view( "movie/player", {"movie_id": movie_id}) data_source = script.get_object("library_data") data_source.item_handler = movie_tile_handler handlers.button_to_view(window, script, "button_start") data_source.emit('data-is-ready')
def prepare_player_view(app, window, script, data): movie_id = data.get("movie_id") library = model.get_library() movie = library.get_item_by_id(movie_id) movie_path = movie.path playback = script.get_object("playback") playback.filename = movie_path handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_library", "movie/main")
def prepare_photo_editing_view(app, window, script, data): photo = script.get_object("slide") photo.photo_path = data[0].slide.photo_path handlers.button_to_view(window, script, "button_photo", "viewer/photo", { "photo_id": data[2], "album_id": data[1] }) handlers.button_to_view(window, script, "button_start")
def prepare_viewer_contact_library_view(app, window, script, data): handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_back", "email/contact", {"contact_id": data["contact_id"]}) tile_source = script.get_object("library_data") tile_source.item_handler = lambda tile, album: window.load_view( "email/viewer_contact_album", {"album_id": album, "contact_id": data["contact_id"]})
def prepare_speller_message_body_view(app, window, script, data): if data and "original_msg" in data and data["original_msg"].get("Body"): body = "\n" + textwrap.indent(data["original_msg"]["Body"], ">", lambda line: True) window.ui.text_box.type_text(body) window.ui.text_box.set_cursor_position(0) elif app.box["new_message"].body: window.ui.text_box.type_text(app.box["new_message"].body) handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_proceed", "email/address_book", {"pick_recipients_mode": True})
def prepare_main_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ handlers.button_to_view(window, script, "button_exit")
def prepare_speller_contact_address_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ text_box = window.ui.text_box if not data or (data and data.get("new")): def create_contact(): address = text_box.get_text() if address: try: resp = app.box["address_book"].add_contact( {"address": address}) if not resp: # TODO: say that address is not unique pass contact = app.box["address_book"].get_contact_by_address( address) load = ("email/speller_contact_name", { "contact_id": contact.id }) except address_book.AddressBookError: # TODO: notify about failure load = ("email/address_book", ) else: load = ("email/address_book", ) window.load_view(*load) button_proceed_handler = create_contact else: if data.get("contact_address"): text_box.type_text(data["contact_address"]) def edit_contact_address(): try: app.box["address_book"].edit_contact_address( data["contact_id"], text_box.get_text()) except address_book.AddressBookError: pass # TODO: display warning window.load_view("email/contact", {"contact_id": data["contact_id"]}) button_proceed_handler = edit_contact_address handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", button_proceed_handler)
def prepare_speller_message_body_view(app, window, script, data): if data and 'original_msg' in data and data['original_msg'].get('Body'): body = '\n' + textwrap.indent( data['original_msg']['Body'], '>', lambda line: True) window.ui.text_box.type_text(body) window.ui.text_box.set_cursor_position(0) elif app.box['new_message'].body: window.ui.text_box.type_text(app.box['new_message'].body) handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_proceed", "email/address_book", {"pick_recipients_mode": True})
def prepare_speller_post_view(app, window, script, data): if wordpress.blog.pending_post is not None: text_field = script.get_object("text_box") plain_text = html_parsers.extract_text( wordpress.blog.pending_post.content) if plain_text: text_field.type_text(plain_text) else: wordpress.blog.prepare_empty_post() handlers.button_to_view( window, script, "button_proceed", "blog/speller_title") handlers.button_to_view(window, script, "button_exit")
def prepare_speller_post_view(app, window, script, data): if wordpress.blog.pending_post is not None: text_field = script.get_object("text_box") plain_text = html_parsers.extract_text( wordpress.blog.pending_post.content) if plain_text: text_field.type_text(plain_text) else: wordpress.blog.prepare_empty_post() handlers.button_to_view(window, script, "button_proceed", "blog/speller_title") handlers.button_to_view(window, script, "button_exit")
def prepare_speller_contact_address_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ text_box = window.ui.text_box if not data or (data and data.get("new")): def create_contact(): address = text_box.get_text() if address: try: resp = app.box["address_book"].add_contact( {"address": address}) if not resp: # TODO: say that address is not unique pass contact = app.box["address_book"].get_contact_by_address( address) load = ("email/speller_contact_name", {"contact_id": contact.id}) except address_book.AddressBookError: # TODO: notify about failure load = ("email/address_book",) else: load = ("email/address_book",) window.load_view(*load) button_proceed_handler = create_contact else: if data.get("contact_address"): text_box.type_text(data["contact_address"]) def edit_contact_address(): try: app.box["address_book"].edit_contact_address( data["contact_id"], text_box.get_text()) except address_book.AddressBookError: pass # TODO: display warning window.load_view("email/contact", {"contact_id": data["contact_id"]}) button_proceed_handler = edit_contact_address handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", button_proceed_handler)
def prepare_speller_contact_name_view(app, window, script, data): def edit_contact_name(): try: app.box["address_book"].edit_contact_name(data["contact_id"], window.ui.text_box.get_text()) except address_book.AddressBookError as e: pass # TODO: display warning handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", edit_contact_name) handlers.button_to_view(window, script, "button_proceed", "email/contact", {"contact_id": data["contact_id"]}) if data.get("contact_name"): window.ui.text_box.type_text(data["contact_name"])
def prepare_viewer_about_me_library_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ library_data = script.get_object("library_data") library_data.item_handler = lambda tile, album: window.load_view( "blog/viewer_about_me_album", {"album_id": album}) handlers.button_to_view(window, script, "button_start")
def prepare_playlist_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ ds = script.get_object("data_source") ds.data_set_idx = ds.data_sets_ids_list.index(data["playlist_id"]) + 1 handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_return", "audio/main")
def prepare_about_me_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ try: about = wordpress.blog.get_about_me_page() except socket.timeout: window.load_popup(MESSAGES['too-slow-connection'], 'main_panel/main') else: about_info = script.get_object("about") plain = html_parsers.extract_text(about.content) if plain: about_info.set_text(plain) handlers.button_to_view(window, script, "button_edit_desc", "blog/speller_about_me") handlers.button_to_view(window, script, "button_edit_photo", "blog/viewer_about_me_library") handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_back", "blog/main")
def prepare_all_posts_view(app, window, script, data): wordpress.blog.pending_post = None handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_about", "blog/about_me") handlers.button_to_view(window, script, "button_back", "blog/main") handlers.button_to_view(window, script, "button_new_post", "blog/speller_post") posts_data = script.get_object("posts_data") def load_view(tile, post): posts_data.clean_up() window.load_view("blog/single_post", { "post": post.content, "posts": posts_data.data, "post_item": post }) posts_data.item_handler = load_view title = config.get_blog_config()["title"] blog_title = script.get_object("header") blog_title.set_text(title) date_widget = script.get_object("date") today = "DATA: " + time.strftime("%d-%m-%Y") date_widget.set_text(today) posts_data.lazy_loading = True
def prepare_address_book_view(app, window, script, data): data_source = script.get_object("data_source") contacts = [] try: contacts = app.box["address_book"].get_all_contacts() except address_book.AddressBookError as e: pass # TODO: display warning and/or try to reload the view def on_contact_select(tile, contact): """ On contact tile select. :param tile: tile representing single contact :param contact: contact dictionary """ tile.toggled = contact.flags["picked"] = \ not contact.flags["picked"] if "picked" in \ contact.flags else True if tile.toggled: app.box["new_message"].recipients = contact.content.address else: app.box["new_message"].remove_recipient(contact.content.address) handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_back", "email/main") if data and data.get("pick_recipients_mode"): specific_button= window.ui.button_send_message tile_handler = lambda tile, contact: on_contact_select(tile, contact) handlers.button_to_view(window, script, "button_send_message", "email/sent") else: specific_button = window.ui.button_new_contact tile_handler = lambda tile, contact: window.load_view( "email/contact", {"contact_id": contact.content.id}) handlers.button_to_view( window, script, "button_new_contact", "email/speller_contact_address") window.ui.button_menu_box.replace_child( window.ui.button_specific, specific_button) data_source.item_handler = tile_handler # set 'picked' flag of a given contact to True if the view is in the # 'pick recipients' mode and the contact's email address has already been # on the new message recipients list. data_source.data = sorted(data_source.produce_data( [ ( contact, {'picked': True} if (data and data.get("pick_recipients_mode")) and contact.address in app.box["new_message"].recipients else None ) for contact in contacts ], lambda contact: contact.name if contact.name else contact.address) )
def prepare_all_posts_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ wordpress.blog.pending_post = None handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_about", "blog/about_me") handlers.button_to_view(window, script, "button_back", "blog/main") handlers.button_to_view(window, script, "button_new_post", "blog/speller_post") posts_data = script.get_object("posts_data") def load_view(tile, post): posts_data.clean_up() window.load_view("blog/single_post", { "post": post.content, "posts": posts_data, "post_item": post }) posts_data.item_handler = load_view title = config.get_blog_config()["title"] blog_title = script.get_object("header") blog_title.set_text(title) date_widget = script.get_object("date") today = "DATA: " + time.strftime("%d-%m-%Y") date_widget.set_text(today) posts_data.lazy_loading = True
def prepare_all_posts_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ wordpress.blog.pending_post = None handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_about", "blog/about_me") handlers.button_to_view(window, script, "button_back", "blog/main") handlers.button_to_view( window, script, "button_new_post", "blog/speller_post") posts_data = script.get_object("posts_data") def load_view(tile, post): posts_data.clean_up() window.load_view("blog/single_post", {"post": post.content, "posts": posts_data, "post_item": post}) posts_data.item_handler = load_view title = config.get_blog_config()["title"] blog_title = script.get_object("header") blog_title.set_text(title) date_widget = script.get_object("date") today = "DATA: " + time.strftime("%d-%m-%Y") date_widget.set_text(today) posts_data.lazy_loading = True
def prepare_followed_blog_single_post_view(app, window, script, data): post = data["post"] post_item = data['post_item'] posts = data["posts"] content = script.get_object("post_text") blog_name = script.get_object("header") blog_name.set_text(data["blog_name"]) def load_new_post(direction, arbitrary_post=None): if arbitrary_post: post_to_load = arbitrary_post else: nonlocal post_item index = posts.index(post_item) index += direction if index == len(posts): index = 0 post_to_load = posts[index] content.load_html(data["blog"].compose_post_view(post_to_load.content)) load_new_post(0, post_item) data['previous_view'] = 'blog/followed_blog_single_post' handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_back", "blog/followed_blog_all_posts", data) handlers.button_to_view(window, script, "button_about", "blog/about_me") handlers.button_to_view(window, script, "button_comment", "blog/speller_comment", data) handlers.connect_button(script, "button_next_post", load_new_post, 1) handlers.connect_button(script, "button_previous_post", load_new_post, -1)
def prepare_speller_contact_name_view(app, window, script, data): def edit_contact_name(): try: app.box["address_book"].edit_contact_name( data["contact_id"], window.ui.text_box.get_text()) except address_book.AddressBookError as e: pass # TODO: display warning handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", edit_contact_name) handlers.button_to_view(window, script, "button_proceed", "email/contact", {"contact_id": data["contact_id"]}) if data.get("contact_name"): window.ui.text_box.type_text(data["contact_name"])
def prepare_speller_title_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ text_field = script.get_object("text_box") post = wordpress.blog.pending_post if post.title and post.title != "Untitled": text_field.type_text(post.title) handlers.button_to_view(window, script, "button_proceed", "blog/viewer_library") handlers.button_to_view(window, script, "button_exit")
def prepare_flat_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ def movie_tile_handler(tile, movie_id): window.load_view("movie/player", {"movie_id": movie_id}) data_source = script.get_object("library_data") data_source.item_handler = movie_tile_handler handlers.button_to_view(window, script, "button_start") data_source.emit('data-is-ready')
def prepare_viewer_about_me_album_view(app, window, script, data): library = viewer_model.get_library() def pick_photo(tile): wordpress.blog.update_about_me_photo(tile.preview_path) window.load_view("blog/about_me") handlers.button_to_view(window, script, "button_library", "blog/viewer_about_me_library") handlers.button_to_view(window, script, "button_start") album_id = data["album_id"] header = script.get_object("header") header.set_text(library.get_category_by_id(album_id).name) album_data = script.get_object("album_data") album_data.item_handler = lambda tile, photo_id, album_id: pick_photo(tile) album_data.data_set_idx = album_id
def prepare_speller_comment_view(app, window, script, data): def publish_comment(): text_widget = script.get_object("text_box") text = html_parsers.apply_linebreaks(text_widget.get_text()) if data['previous_view'] == 'blog/single_post': own_blog = wordpress.blog own_blog.add_comment(data['post'].id, text) else: followed_blog = wordpress.Blog(data["blog_url"]) followed_blog.add_comment(data["post"]["ID"], text) handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", publish_comment) handlers.button_to_view(window, script, "button_proceed", data['previous_view'], data)
def prepare_speller_title_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ text_field = script.get_object("text_box") post = wordpress.blog.pending_post if post.title and post.title != "Untitled": text_field.type_text(post.title) handlers.button_to_view( window, script, "button_proceed", "blog/viewer_library") handlers.button_to_view(window, script, "button_exit")
def prepare_speller_comment_view(app, window, script, data): def publish_comment(): text_widget = script.get_object("text_box") text = html_parsers.apply_linebreaks(text_widget.get_text()) if data['previous_view'] == 'blog/single_post': own_blog = wordpress.blog own_blog.add_comment(data['post'].id, text) else: followed_blog = wordpress.Blog(data["blog_url"]) followed_blog.add_comment(data["post"]["ID"], text) handlers.button_to_view(window, script, "button_exit") handlers.connect_button(script, "button_proceed", publish_comment) handlers.button_to_view( window, script, "button_proceed", data['previous_view'], data)
def prepare_folders_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ def _folder_tile_handler(tile, playlist_id): window.load_view("audio/playlist", {"playlist_id": playlist_id}) data_source = script.get_object("data_source") data_source.item_handler = _folder_tile_handler handlers.button_to_view(window, script, "button_exit") data_source.emit('data-is-ready')
def prepare_speller_message_subject_view(app, window, script, data): if data and "original_msg" in data: subject = data["original_msg"]["Subject"] action = data.get("action") if action == "forward": pre = "PD: " elif action in ("reply", "reply_all"): pre = "Odp: " else: pre = "" window.ui.text_box.type_text(pre + subject) elif app.box["new_message"].subject: window.ui.text_box.type_text(app.box["new_message"].subject) handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_proceed", "email/speller_message_body", data)
def prepare_flat_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ def movie_tile_handler(tile, movie_id): window.load_view( "movie/player", {"movie_id": movie_id}) data_source = script.get_object("library_data") data_source.item_handler = movie_tile_handler handlers.button_to_view(window, script, "button_start") data_source.emit('data-is-ready')
def prepare_player_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ movie_id = data.get("movie_id") library = model.get_library() movie = library.get_item_by_id(movie_id) movie_path = movie.path playback = script.get_object("playback") playback.filename = movie_path handlers.button_to_view(window, script, "button_exit") handlers.button_to_view(window, script, "button_library", "movie/main")
def prepare_photo_editing_view(app, window, script, data): """ View preparator. :param app: reference to the application, :see: :module:`pisak.application`. :param window: application main window, :class:`pisak.window.Window` instance. :param script: ClutterScript with the view description. :param data: some specific data. """ slideshow_widget, album_id, photo_id = data photo = script.get_object("slide") photo.photo_path = slideshow_widget.slide.photo_path photo.album_id = album_id handlers.button_to_view(window, script, "button_photo", "viewer/photo", {"photo_id": photo_id, "album_id": album_id}) handlers.button_to_view(window, script, "button_start")