当前位置: 首页>>代码示例>>Python>>正文


Python Icon.disconnect方法代码示例

本文整理汇总了Python中sugar3.graphics.icon.Icon.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.disconnect方法的具体用法?Python Icon.disconnect怎么用?Python Icon.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.icon.Icon的用法示例。


在下文中一共展示了Icon.disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Sidebar

# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import disconnect [as 别名]

#.........这里部分代码省略.........
    def __bookmark_icon_query_tooltip_cb(self, widget, x, y, keyboard_mode,
            tip, bookmark):
        tooltip_header = bookmark.get_note_title()
        tooltip_body = bookmark.get_note_body()
        #TRANS: This goes like Bookmark added by User 5 days ago
        #TRANS: (the elapsed string gets translated automatically)
        tooltip_footer = (_('Bookmark added by %(user)s %(time)s') \
                % {'user': bookmark.nick,
                'time': timestamp_to_elapsed_string(bookmark.timestamp)})

        vbox = Gtk.VBox()

        l = Gtk.Label('<big>%s</big>' % tooltip_header)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        l = Gtk.Label('%s' % tooltip_body)
        l.set_use_markup(True)
        l.set_alignment(0, 0)
        l.set_padding(2, 6)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        l.set_justify(Gtk.Justification.FILL)
        vbox.pack_start(l, True, True, 0)
        l.show()

        l = Gtk.Label('<small><i>%s</i></small>' % tooltip_footer)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        tip.set_custom(vbox)

        return True

    def __event_cb(self, widget, event, bookmark):
        if event.type == Gdk.EventType.BUTTON_PRESS and \
                    self._bookmark_icon is not None:

            bookmark_title = bookmark.get_note_title()
            bookmark_content = bookmark.get_note_body()

            dialog = BookmarkEditDialog(
                parent_xid=self.get_toplevel().window.xid,
                dialog_title=_("Add notes for bookmark: "),
                bookmark_title=bookmark_title,
                bookmark_content=bookmark_content, page=bookmark.page_no,
                sidebarinstance=self)
            dialog.show_all()

        return False

    def _clear_bookmarks(self):
        if self._bookmark_icon is not None:
            self._bookmark_icon.disconnect(
                    self.__bookmark_icon_query_tooltip_cb_id)
            self.disconnect(self.__event_cb_id)

            self._bookmark_icon.hide()  # XXX: Is this needed??
            self._bookmark_icon.destroy()

            self._bookmark_icon = None

            self._is_showing_local_bookmark = False

    def set_bookmarkmanager(self, bookmark_manager):
        self._bookmark_manager = bookmark_manager

    def get_bookmarkmanager(self):
        return (self._bookmark_manager)

    def update_for_page(self, page):
        self._clear_bookmarks()
        if self._bookmark_manager is None:
            return

        bookmarks = self._bookmark_manager.get_bookmarks_for_page(page)

        for bookmark in bookmarks:
            self._add_bookmark_icon(bookmark)

    def add_bookmark(self, number_of_times_zoomed):
        self._real_add_bookmark(number_of_times_zoomed)

    def _real_add_bookmark(self, number_of_times_zoomed):
        self._bookmark_manager.add_bookmark(number_of_times_zoomed)

    def del_bookmark(self, page):
        self._bookmark_manager.del_bookmark(page)

    def is_showing_local_bookmark(self):
        return self._is_showing_local_bookmark

    def set_view(self, view):
        self._view = view
开发者ID:tanmoydeb07,项目名称:ebookreader,代码行数:104,代码来源:readsidebar.py


注:本文中的sugar3.graphics.icon.Icon.disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。