示例#1
0
    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)
示例#2
0
    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()

            def is_main_window(window, home_activity):
                # Check if window is the 'main' app window, not the
                # launcher window.
                return window.get_window_type() != \
                    Wnck.WindowType.SPLASHSCREEN and \
                    home_activity.get_launch_status() == Activity.LAUNCHING

            if home_activity is None and \
                    window.get_window_type() == Wnck.WindowType.NORMAL:
                # This is a special case for the Journal
                # We check if is not a splash screen to avoid #4767
                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,
                                         is_main_window(window, home_activity))

            if is_main_window(window, home_activity):
                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)
示例#3
0
 def get_type(self):
     """Retrieve the activity bundle id for future reference"""
     if not self._windows:
         return None
     else:
         return SugarExt.wm_get_bundle_id(self._windows[0].get_xid())
示例#4
0
 def get_type(self):
     """Retrieve the activity bundle id for future reference"""
     if not self._windows:
         return None
     else:
         return SugarExt.wm_get_bundle_id(self._windows[0].get_xid())