def on_leave_notify_event(self, widget, event): if self.drag_flag: self.drag_out_area = True else: if self.auto_hide: self.hide_progressbar() set_cursor(widget, None)
def weibo_login(self, widget, weibo): '''weibo button clicked callback''' self.web_view.load_uri("about:blank") utils.set_cursor(widget) self.set_slide_index(1) self.__current_weibo = weibo t = threading.Thread(target=self.__current_weibo.request_oauth) t.setDaemon(True) t.start()
def on_motion_notify(self, widget, event): if self.text_rect is not None: if is_in_rect((event.x, event.y), self.text_rect): self.is_hover = True set_cursor(widget, gtk.gdk.HAND2) else: self.is_hover = False set_cursor(widget, None) self.queue_draw()
def leave_notify_slide_switcher(self, widget, event): rect = widget.allocation if is_in_rect((event.x, event.y), (0, 0, rect.width, rect.height)): self.handle_animation(widget, event) else: self.start_auto_slide() set_cursor(widget, None) self.emit("leave-notify-index", self.active_index)
def on_motion_notify_event(self, widget, event): if self.pointer_in_state_icon(event): self.icon_state = STATE_HOVER set_cursor(widget, None) else: self.icon_state = STATE_NORMAL set_cursor(widget, gtk.gdk.HAND2) if self.drag_flag: self.update_progress_width(event, emit=True) self.queue_draw()
def handle_animation(self, widget, event, button_press=False): # Init. rect = widget.allocation start_x = rect.width + self.pointer_offset_x - self.pointer_radious start_y = rect.height + self.pointer_offset_y self.left_retangle = (0, 0, rect.width/3, rect.height - self.pointer_offset_y) self.right_retangle = (0 + 2*rect.width/3, 0, rect.width/3, rect.height - self.pointer_offset_y) if self.image_number > 1 and (start_y - 4 * self.pointer_radious < event.y < start_y + self.pointer_radious * 6 and start_x - 2 * self.pointer_radious < event.x < start_x + 4 * self.pointer_padding + 4 * self.pointer_radious): set_cursor(widget, gtk.gdk.HAND2) if self.hover_switch or button_press: self.motion_index = None for index in range(0, self.image_number): if start_x + index * self.pointer_padding < event.x < start_x + (index + 1) * self.pointer_padding: self.motion_index = index if self.active_index != index: self.start_animation(self.hover_animation_time, index) break elif self.image_number > 1 and is_in_rect((event.x, event.y), self.left_retangle) and self.navigate_switch: if not self.in_left_nav: self.in_left_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_LEFT_ARROW) widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/left_arrow.png'), 0, 0)) if button_press: self.to_left_animation() elif self.image_number > 1 and is_in_rect((event.x, event.y), self.right_retangle) and self.navigate_switch: if not self.in_right_nav: self.in_right_nav = True self.queue_draw() #set_cursor(widget, gtk.gdk.SB_RIGHT_ARROW) widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.display_get_default(), get_common_image_pixbuf('cursor/right_arrow.png'), 0, 0)) if button_press: self.to_right_animation() else: if self.in_left_nav or self.in_right_nav: self.in_left_nav = False self.in_right_nav = False self.queue_draw() set_cursor(widget, None) if button_press: self.emit("button-press-index", self.active_index) else: self.emit("motion-notify-index", self.active_index)
def on_motion_notify(self, widget, event): self.handle_animation(widget, event) pixbuf_rect = gtk.gdk.Rectangle(15, 15, 170, 170) if self.channel_infos: if is_in_rect((event.x, event.y), pixbuf_rect): new_mask_flag = True set_cursor(widget, gtk.gdk.HAND2) else: new_mask_flag = False set_cursor(widget, None) if new_mask_flag != self.mask_flag: self.mask_flag = new_mask_flag self.queue_draw()
def on_motion_notify_event(self, widget, event): if not self.coords: return for key, coord in self.coords.iteritems(): if coord.start_x <= event.x <= coord.end_x and coord.start_y <= event.y <= coord.end_y: set_cursor(widget, gtk.gdk.HAND2) current_item = self.items[key] if self.hover_item and current_item != self.hover_item: self.hover_item.lost_focus() current_item.motion_notify(event.x, event.y) self.hover_item = current_item break else: set_cursor(widget, None) if self.hover_item: self.hover_item.lost_focus() self.hover_item = None
def handle_animation(self, widget, event, button_press=False): # Init. rect = widget.allocation start_x = rect.width + self.pointer_offset_x - self.pointer_radious start_y = rect.height + self.pointer_offset_y self.left_retangle = (0, 0, rect.width / 3, rect.height - self.pointer_offset_y) self.right_retangle = (0 + 2 * rect.width / 3, 0, rect.width / 3, rect.height - self.pointer_offset_y) if self.image_number > 1 and ( start_y - 4 * self.pointer_radious < event.y < start_y + self.pointer_radious * 6 and start_x - 2 * self.pointer_radious < event.x < start_x + 4 * self.pointer_padding + 4 * self.pointer_radious): set_cursor(widget, gtk.gdk.HAND2) if self.hover_switch or button_press: self.motion_index = None for index in range(0, self.image_number): if start_x + index * self.pointer_padding < event.x < start_x + ( index + 1) * self.pointer_padding: self.motion_index = index if self.active_index != index: self.start_animation(self.hover_animation_time, index) break elif self.image_number > 1 and is_in_rect( (event.x, event.y), self.left_retangle) and self.navigate_switch: if not self.in_left_nav: self.in_left_nav = True self.queue_draw() set_cursor(widget, gtk.gdk.SB_LEFT_ARROW) if button_press: self.to_left_animation() elif self.image_number > 1 and is_in_rect( (event.x, event.y), self.right_retangle) and self.navigate_switch: if not self.in_right_nav: self.in_right_nav = True self.queue_draw() set_cursor(widget, gtk.gdk.SB_RIGHT_ARROW) if button_press: self.to_right_animation() else: if self.in_left_nav or self.in_right_nav: self.in_left_nav = False self.in_right_nav = False self.queue_draw() set_cursor(widget, None) if button_press: self.emit("button-press-index", self.active_index) else: self.emit("motion-notify-index", self.active_index)
def motion_rank_tab(self, widget, event): if not self.active_flag: set_cursor(widget, gtk.gdk.HAND2)
def leave_rank_tab(self, widget, event): set_cursor(widget, None)
def on_leave_notify(self, widget, event): self.start_auto_slide() self.mask_flag = False self.queue_draw() set_cursor(widget, None)
def hide_progressbar(self): self.hide_progress_flag = True self.set_size_request(self.base_width, self.default_height) self.icon_state = STATE_NORMAL set_cursor(self, None) self.queue_draw()
def on_leave_notify_event(self, widget, event): set_cursor(widget, None) if self.hover_item: self.hover_item.lost_focus() self.hover_item = None
def init_backend(self): # Init detail view. self.detail_page = DetailPage(self.data_manager) self.page_switcher.append_page(self.detail_page) log("Init pages.") self.loginfo("Init pages") self.upgrade_page = UpgradePage(self.bus_interface, self.data_manager, self.preference_dialog) self.uninstall_page = UninstallPage(self.bus_interface, self.data_manager) self.install_page = InstallPage(self.bus_interface, self.data_manager) log("Handle global event.") # Handle global event. global_event.register_event("install-pkg", lambda pkg_names: install_pkg( self.bus_interface, self.install_page, pkg_names, self.application.window)) global_event.register_event("upgrade-pkg", self.upgrade_pkgs) global_event.register_event("uninstall-pkg", lambda pkg_name, purge_flag: self.uninstall_pkg(pkg_name, purge_flag)) global_event.register_event("stop-download-pkg", self.bus_interface.stop_download_pkg) global_event.register_event("switch-to-detail-page", lambda pkg_name : switch_to_detail_page(self.page_switcher, self.detail_page, pkg_name)) global_event.register_event("switch-from-detail-page", lambda : switch_from_detail_page(self.page_switcher, self.detail_page, self.page_box)) global_event.register_event("remove-wait-action", self.bus_interface.RemoveWaitMissions) global_event.register_event("remove-wait-download", self.bus_interface.remove_wait_downloads) global_event.register_event("request-clear-action-pages", request_clear_action_pages) global_event.register_event("request-stop-install-actions", request_stop_install_actions) global_event.register_event("request-clear-failed-action", request_clear_failed_action) global_event.register_event("update-upgrade-notify-number", lambda number: update_navigatebar_number(self.navigatebar, 1, number)) global_event.register_event("update-install-notify-number", lambda number: update_navigatebar_number(self.navigatebar, 3, number)) global_event.register_event("jump-to-category", lambda first_category_name, second_category_name: jump_to_category(self.page_switcher, self.page_box, self.home_page, self.detail_page, first_category_name, second_category_name)) global_event.register_event("grade-pkg", lambda pkg, star: grade_pkg(self.application.window, pkg, star)) global_event.register_event("set-cursor", lambda cursor: set_cursor(self.application.window, cursor)) global_event.register_event("show-message", self.update_status_bar_message) global_event.register_event("start-pkg", lambda alias_name, desktop_infos, offset: start_pkg( alias_name, desktop_infos, offset, self.application.window)) global_event.register_event("show-pkg-name-tooltip", lambda pkg_name: show_tooltip(self.application.window, pkg_name)) global_event.register_event("hide-pkg-name-tooltip", lambda :tool_tip.hide()) global_event.register_event("update-current-status-pkg-page", update_current_status_pkg_page) global_event.register_event('start-change-mirror', self.change_mirror_action) global_event.register_event('download-directory-changed', self.set_software_download_dir) global_event.register_event('vote-send-success', lambda p: vote_send_success_callback(p, self.application.window)) global_event.register_event('vote-send-failed', lambda p: vote_send_failed_callback(p, self.application.window)) global_event.register_event('max-download-number-changed', self.init_download_manager) global_event.register_event('update-list-finish', self.update_list_finish) global_event.register_event('start-update-list', self.update_list_handler) global_event.register_event("upgrade-finish-action", self.upgrade_finish_action) global_event.register_event("upload-error-log", self.exec_upload_error_log) self.bus_interface.connect_to_signal( signal_name="update_signal", handler_function=lambda messages: message_handler(messages, self.bus_interface, self.upgrade_page, self.uninstall_page, self.install_page, self.home_page, self.inhibit_obj, ), ) glib.timeout_add(1000, lambda : clear_action_pages(self.bus_interface, self.upgrade_page, self.uninstall_page, self.install_page)) glib.timeout_add(1000, lambda : clear_install_stop_list(self.install_page)) glib.timeout_add(1000, lambda : clear_failed_action(self.install_page, self.upgrade_page)) #self.init_download_manager() #self.request_update_list() self.upgrade_page.fetch_upgrade_info(utils.get_backend_running())