Esempio n. 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.WINDOW_NORMAL:
            home_activity = None

            activity_id = wm.get_activity_id(window)

            service_name = wm.get_bundle_id(window)
            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)

                xid = window.get_xid()
                gdk_window = gtk.gdk.window_foreign_new(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 wm.get_sugar_window_type(window) != 'launcher' \
                    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)
Esempio n. 2
0
 def get_type(self):
     """Retrieve the activity bundle id for future reference"""
     if not self._windows:
         return None
     else:
         return wm.get_bundle_id(self._windows[0])