Esempio n. 1
0
    def __init__(self, canvas, group_name, parent, theme=None):
        EdjeWidget.__init__(self, canvas, group_name,
                            parent, theme)

        self.image = canvas.FilledImage()
        self.part_swallow("image", self.image)
        self.callback_preloaded = None
        self.image.on_image_preloaded_add(self.cb_preloaded)

        self.model = None
Esempio n. 2
0
 def __init__(self, parent, create_thumb, cancel_thumb, theme=None):
     EdjeWidget.__init__(self, parent.evas, "images/grid_item",
                         parent, theme)
     self._model = None
     self._img = self.evas.FilledImage()
     self._img.on_image_preloaded_add(self._on_preloaded_cb)
     self.part_swallow("contents", self._img)
     self.signal_emit("image,hide", "")
     self.callback_create_thumb = create_thumb
     self.callback_cancel_thumb = cancel_thumb
     self.loading_thumb = False
Esempio n. 3
0
    def _setup_gui(self):
        self.image_frame_cur = ImageItemFullscreen(self.evas)
        self.image_frame_new = ImageItemFullscreen(self.evas)

        self._btn_back = EdjeWidget(self.evas, "bt_back_custom", self)
        self._btn_back.hide()
        self._btn_options = EdjeWidget(self.evas, "bt_options_custom", self)
        self._btn_options.hide()

        self._controls_hide_timer = None
        self.prev_image = evas.Image(self.evas)
        self.next_image = evas.Image(self.evas)
        self.prev_image.hide()
        self.next_image.hide()
Esempio n. 4
0
 def theme_changed(self):
     EdjeWidget.theme_changed(self)
     self.force_redraw()
Esempio n. 5
0
class ImageFullScreen(Screen, TerraObject):
    view_name = "images_fullscreen"
    terra_type = "Model/Media/Image/Fullscreen"

    def __init__(self, canvas, main_window, title="Photos",
                 elements=None, theme=None):
        Screen.__init__(self, canvas, "images/fullscreen",
                        main_window, title, theme)
        self._setup_gui()

        self.elements = elements

        self.throbber = self.part_swallow_get("image_throbber");
        self.controls_right = self.part_swallow_get("fullscreen/controls_right")
        self.controls_left = self.part_swallow_get("fullscreen/controls_left")
        self.controls_visible = False

        self.callback_transition_from = None

        self.callback_mouse_down = None
        self.callback_mouse_up = None
        self.callback_mouse_move = None
        self.callback_rotate_clockwise = None
        self.callback_zoom_in = None
        self.callback_zoom_out = None
        self.callback_prev = None
        self.callback_play_pause_toggle = None
        self.callback_next = None
        self.callback_back = None
        self.callback_show_image_finished = None

    def _setup_gui(self):
        self.image_frame_cur = ImageItemFullscreen(self.evas)
        self.image_frame_new = ImageItemFullscreen(self.evas)

        self._btn_back = EdjeWidget(self.evas, "bt_back_custom", self)
        self._btn_back.hide()
        self._btn_options = EdjeWidget(self.evas, "bt_options_custom", self)
        self._btn_options.hide()

        self._controls_hide_timer = None
        self.prev_image = evas.Image(self.evas)
        self.next_image = evas.Image(self.evas)
        self.prev_image.hide()
        self.next_image.hide()

    def custom_back_button(self):
        return self._btn_back

    def custom_options_button(self):
        return self._btn_options

    def image_prev_preload_cancel(self):
        self.prev_image.preload(True)

    def image_next_preload_cancel(self):
        self.next_image.preload(True)

    def image_prev_next_preload(self, prev, next):
        if prev:
            download_file(prev, prev.path, prev.url, self.prev_image.preload,\
                            self.prev_image.preload, self.prev_image.preload)
        if next:
            download_file(next, next.path, next.url, self.next_image.preload,\
                            self.next_image.preload, self.next_image.preload)

    def image_current_get(self):
        return self.image_frame_cur.image

    def image_new_set(self, model, end_callback=None):
        self.part_swallow("image_new", self.image_frame_new)
        self.calc_force()
        self.hide_image()

        def down_finish_cb():
            self.image_frame_new.image_set(model, end_callback)

        download_file( model, model.path, model.url, down_finish_cb, \
                                        down_finish_cb, down_finish_cb)

    def show_image(self, slideshow=False):
        if slideshow:
            self.signal_emit("show,image,slideshow", "")
        else:
            self.signal_emit("show,image", "")

    def swap_images(self):
        self.part_unswallow(self.image_frame_new)
        self.part_swallow("image_current", self.image_frame_new)
        self.image_frame_cur.hide()

        tmp = self.image_frame_cur
        self.image_frame_cur = self.image_frame_new
        self.image_frame_new = tmp

    @edje.decorators.signal_callback("show,image,finished", "")
    def cb_show_image_finished(self, emission, source):
        self.callback_show_image_finished()

    def hide_image(self):
        self.signal_emit("hide,image", "")

    def play_pause_toggle(self):
        self.controls_right.signal_emit("play_pause,toggle", "")

    def rotate_clockwise(self, end_callback):
        self.rotate(evas.EVAS_IMAGE_ROTATE_270)
        end_callback()

    def rotate(self, rotation):
        image_view = self.image_frame_cur
        if image_view.geometry_rotated:
            w, h = image_view.model.height, image_view.model.width
        else:
            w, h = image_view.model.width, image_view.model.height

        image_view.image.rotate(rotation)
        image_view.resize_image(h, w)
        image_view.geometry_rotated = not image_view.geometry_rotated

    def zoom_in_enable(self):
        self.controls_left.signal_emit("zoom,in,enable", "")

    def zoom_in_disable(self):
        self.controls_left.signal_emit("zoom,in,disable", "")

    def zoom_out_enable(self):
        self.controls_left.signal_emit("zoom,out,enable", "")

    def zoom_out_disable(self):
        self.controls_left.signal_emit("zoom,out,disable", "")

    def loaded(self):
        self._check_has_elements()
        self.throbber_stop()

    def _check_has_elements(self):
        if self.elements:
            self.signal_emit("message,hide", "")
        else:
            self.image_current_get().hide()
            self.part_text_set("message", "No pictures found.")
            self.signal_emit("message,show", "")

    def throbber_start(self):
        self.throbber.signal_emit("throbber,start", "")

    def throbber_stop(self):
        self.throbber.signal_emit("throbber,stop", "")

    def controls_show(self, show_parent_controls=True):
        self.image_controls_show()
        show_parent_controls and self._parent_widget.controls_show()
        self.controls_visible = True
        return False

    def controls_hide(self, hide_parent_controls=True):
        self.image_controls_hide()
        hide_parent_controls and self._parent_widget.controls_hide()
        self.controls_visible = False
        return False

    def controls_invert(self):
        if self.controls_visible:
            self.controls_hide()
        else:
            self.controls_show()

    def image_controls_show(self):
        self.signal_emit("all,show", "")

    def image_controls_hide(self):
        self.signal_emit("all,hide", "")

    def controls_hide_timer_delete(self):
        self._delete_timer(self._controls_hide_timer)

    def controls_hide_timeout(self):
        self.controls_hide_timer_delete()

        self._controls_hide_timer = \
            ecore.timer_add(1.0, self.controls_hide)

    def _delete_timer(self, timer):
        if timer is not None:
            timer.delete()
            timer = None

    # XXX: used by photocast to disable buttons
    def show_buttons_control(self):
        self.controls_right.signal_emit("show,buttons", "")
        self.controls_left.signal_emit("show,buttons", "")

    def hide_buttons_control(self):
        self.controls_right.signal_emit("hide,buttons", "")
        self.controls_left.signal_emit("hide,buttons", "")

    def show_next_control(self):
        self.controls_right.signal_emit("show,next", "")

    def hide_next_control(self):
        self.controls_right.signal_emit("hide,next", "")

    def show_prev_control(self):
        self.controls_right.signal_emit("show,prev", "")

    def hide_prev_control(self):
        self.controls_right.signal_emit("hide,prev", "")

    def theme_changed(self):
        Screen.theme_changed(self)
        self._btn_back.theme_changed()
        self._btn_options.theme_changed()

        self._update_edje_refs()

        # restore hidden state, lost in theme change
        self.hide_image()
        self.controls_show()

    def _update_edje_refs(self):
        self.throbber = self.part_swallow_get("image_throbber");
        self.controls_right = self.part_swallow_get("fullscreen/controls_right")
        self.controls_left = self.part_swallow_get("fullscreen/controls_left")

    def transition_from(self, old_view, end_callback=None):
        self._parent_widget.titlebar_hide()
        self.callback_transition_from()
        Screen.transition_from(self, old_view, end_callback)

    def transition_to(self, new_view, end_callback=None):
        self.controls_hide(hide_parent_controls=False)
        self._parent_widget.titlebar_show()
        Screen.transition_to(self, new_view, end_callback)

    def transition_finished(self, old_view, new_view):
        if self is new_view:
            self.controls_show(show_parent_controls=False)

    @edje.decorators.signal_callback("transition,in,finished", "")
    def cb_transition_in_finished(self, emission, source):
        self.callback_transition_in_finished()

    @edje.decorators.signal_callback("mouse,down,1", "background")
    def cb_mouse_down(self, emission, source):
        x, y = self.evas.pointer_canvas_xy
        self.callback_mouse_down(x, y)

    @edje.decorators.signal_callback("mouse,up,1", "background")
    def cb_mouse_up(self, emission, source):
        x, y = self.evas.pointer_canvas_xy
        self.callback_mouse_up(x, y)

    @edje.decorators.signal_callback("mouse,move", "background")
    def cb_mouse_move(self, emission, source):
        x, y = self.evas.pointer_canvas_xy
        self.callback_mouse_move(x, y)

    @edje.decorators.signal_callback("image,rotate_clock",
                                     "fullscreen/controls_left:")
    def cb_rotate_clockwise(self, emission, source):
        self.callback_rotate_clockwise()

    @edje.decorators.signal_callback("image,zoom,in",
                                     "fullscreen/controls_left:")
    def cb_zoom_in(self, emission, source):
        self.callback_zoom_in()

    @edje.decorators.signal_callback("image,zoom,out",
                                     "fullscreen/controls_left:")
    def cb_zoom_out(self, emission, source):
        self.callback_zoom_out()

    @edje.decorators.signal_callback("image,prev",
                                     "fullscreen/controls_right:")
    def cb_prev(self, emission, source):
        self.callback_prev()

    @edje.decorators.signal_callback("action,clicked",
                    "fullscreen/controls_right:play_pause,toggle")
    def cb_play_pause(self, emission, source):
        self.callback_play_pause_toggle()

    @edje.decorators.signal_callback("image,next",
                                     "fullscreen/controls_right:")
    def cb_next(self, emission, source):
        self.callback_next()

    @edje.decorators.signal_callback("action,clicked", "back")
    def cb_back(self, emission, source):
        self.callback_back()

    def handle_key_down(self, event):
        # Handle keys while focus is on canvas
        if event.keyname == "Left":
            self.callback_prev()
        elif event.keyname == "Right":
            self.callback_next()
        else:
            self._parent_widget.handle_key_down(event)
        return True

    @evas.decorators.del_callback
    def _cb_on_delete(self):
        self.image_frame_cur.delete()
        self.image_frame_new.delete()
        self._btn_back.delete()
        self._btn_options.delete()
        self.controls_hide_timer_delete()
        self.prev_image.delete()
        self.next_image.delete()