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


Python SugarExt.wm_get_activity_id方法代码示例

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


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

示例1: _window_opened_cb

# 需要导入模块: from gi.repository import SugarExt [as 别名]
# 或者: from gi.repository.SugarExt import wm_get_activity_id [as 别名]
    def _window_opened_cb(self, screen, window):
        """Handle the callback for the 'window opened' event.

           Most activities will register 2 windows during
           their lifetime: the launcher window, and the 'main'
           app window.

           When the main window appears, we send a signal to
           the launcher window to close.

           Some activities (notably non-native apps) open several
           windows during their lifetime, switching from one to
           the next as the 'main' window. We use a stack to track
           them.

         """
        if window.get_window_type() == Wnck.WindowType.NORMAL or \
                window.get_window_type() == Wnck.WindowType.SPLASHSCREEN:
            home_activity = None
            xid = window.get_xid()

            activity_id = SugarExt.wm_get_activity_id(xid)

            service_name = SugarExt.wm_get_bundle_id(xid)
            if service_name:
                registry = get_registry()
                activity_info = registry.get_bundle(service_name)
            else:
                activity_info = None

            if activity_id:
                home_activity = self.get_activity_by_id(activity_id)

                display = Gdk.Display.get_default()
                gdk_window = GdkX11.X11Window.foreign_new_for_display(display,
                                                                      xid)
                gdk_window.set_decorations(0)

                window.maximize()

            if not home_activity:
                logging.debug('first window registered for %s', activity_id)
                color = self._shared_activities.get(activity_id, None)
                home_activity = Activity(activity_info, activity_id,
                                         color, window)
                self._add_activity(home_activity)
            else:
                logging.debug('window registered for %s', activity_id)
                home_activity.add_window(window)

            if window.get_window_type() != Wnck.WindowType.SPLASHSCREEN \
                    and \
                    home_activity.get_launch_status() == Activity.LAUNCHING:
                self.emit('launch-completed', home_activity)
                startup_time = time.time() - home_activity.get_launch_time()
                logging.debug('%s launched in %f seconds.',
                              activity_id, startup_time)

            if self._active_activity is None:
                self._set_active_activity(home_activity)
开发者ID:axitkhurana,项目名称:sugar,代码行数:62,代码来源:shell.py


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