Пример #1
0
def launch(bundle,
           activity_id=None,
           object_id=None,
           uri=None,
           color=None,
           invited=False):
    if activity_id is None or not activity_id:
        activity_id = activityfactory.create_activity_id()

    logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s',
                  bundle.get_bundle_id(), activity_id, object_id, uri)

    shell_model = shell.get_model()
    activity = shell_model.get_activity_by_id(activity_id)
    if activity is not None:
        logging.debug('re-launch %r', activity.get_window())
        activity.get_window().activate(Gtk.get_current_event_time())
        return

    if color is None:
        client = GConf.Client.get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

    launcher.add_launcher(activity_id, bundle.get_icon(), color)
    activity_handle = ActivityHandle(activity_id=activity_id,
                                     object_id=object_id,
                                     uri=uri,
                                     invited=invited)
    activityfactory.create(bundle, activity_handle)
Пример #2
0
def launch(bundle,
           activity_id=None,
           object_id=None,
           uri=None,
           color=None,
           invited=False,
           alert_window=None):

    bundle_id = bundle.get_bundle_id()

    if activity_id is None or not activity_id:
        activity_id = activityfactory.create_activity_id()

    logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s',
                  bundle.get_bundle_id(), activity_id, object_id, uri)

    if isinstance(bundle, ContentBundle):
        # Content bundles are a special case: we treat them as launching
        # Browse with a specific URI.
        uri = bundle.get_start_uri()
        activities = _get_activities_for_mime('text/html')
        if len(activities) == 0:
            logging.error("No browser available for content bundle")
            return
        bundle = activities[0]
        logging.debug('Launching content bundle with uri %s', uri)

    shell_model = shell.get_model()
    activity = shell_model.get_activity_by_id(activity_id)
    if activity is not None:
        logging.debug('re-launch %r', activity.get_window())
        activity.get_window().activate(Gtk.get_current_event_time())
        return

    if not shell_model.can_launch_activity():
        if alert_window is None:
            from jarabe.desktop import homewindow
            alert_window = homewindow.get_instance()
        if alert_window is not None:
            alerts.show_max_open_activities_alert(alert_window)
        return

    if not shell_model.can_launch_activity_instance(bundle):
        if alert_window is None:
            from jarabe.desktop import homewindow
            alert_window = homewindow.get_instance()
        if alert_window is not None:
            alerts.show_multiple_instance_alert(
                alert_window, shell_model.get_name_from_bundle_id(bundle_id))
        return

    if color is None:
        color = profile.get_color()

    launcher.add_launcher(activity_id, bundle.get_icon(), color)
    activity_handle = ActivityHandle(activity_id=activity_id,
                                     object_id=object_id,
                                     uri=uri,
                                     invited=invited)
    activityfactory.create(bundle, activity_handle)
Пример #3
0
    def __run_actvity_cb(self, run_button):
        if self.save_unchanged:
            self.editor.save_all()

        registry = bundleregistry.get_registry()
        bundle = registry.get_bundle(self.bundle.get_bundle_id())
        activityfactory.create(bundle)
Пример #4
0
    def __run_actvity_cb(self, run_button):
        if self.save_unchanged:
            self.editor.save_all()

        registry = bundleregistry.get_registry()
        bundle = registry.get_bundle(self.bundle.get_bundle_id())
        activityfactory.create(bundle)
Пример #5
0
def launch(bundle, activity_id=None, object_id=None, uri=None, color=None,
           invited=False):
    if activity_id is None or not activity_id:
        activity_id = activityfactory.create_activity_id()

    logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s',
                  bundle.get_bundle_id(), activity_id, object_id, uri)

    shell_model = shell.get_model()
    activity = shell_model.get_activity_by_id(activity_id)
    if activity is not None:
        logging.debug('re-launch %r', activity.get_window())
        activity.get_window().activate(Gtk.get_current_event_time())
        return

    if color is None:
        client = GConf.Client.get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

    launcher.add_launcher(activity_id, bundle.get_icon(), color)
    activity_handle = ActivityHandle(activity_id=activity_id,
                                     object_id=object_id,
                                     uri=uri,
                                     invited=invited)
    activityfactory.create(bundle, activity_handle)
Пример #6
0
def launch(bundle, activity_id=None, object_id=None, uri=None, color=None,
           invited=False, alert_window=None):

    bundle_id = bundle.get_bundle_id()

    if activity_id is None or not activity_id:
        activity_id = activityfactory.create_activity_id()

    logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s',
                  bundle.get_bundle_id(), activity_id, object_id, uri)

    if isinstance(bundle, ContentBundle):
        # Content bundles are a special case: we treat them as launching
        # Browse with a specific URI.
        uri = bundle.get_start_uri()
        activities = _get_activities_for_mime('text/html')
        if len(activities) == 0:
            logging.error("No browser available for content bundle")
            return
        bundle = activities[0]
        logging.debug('Launching content bundle with uri %s', uri)

    shell_model = shell.get_model()
    activity = shell_model.get_activity_by_id(activity_id)
    if activity is not None:
        logging.debug('re-launch %r', activity.get_window())
        activity.get_window().activate(Gtk.get_current_event_time())
        return

    if not shell_model.can_launch_activity():
        if alert_window is None:
            from jarabe.desktop import homewindow
            alert_window = homewindow.get_instance()
        if alert_window is not None:
            alerts.show_max_open_activities_alert(alert_window)
        return

    if not shell_model.can_launch_activity_instance(bundle):
        if alert_window is None:
            from jarabe.desktop import homewindow
            alert_window = homewindow.get_instance()
        if alert_window is not None:
            alerts.show_multiple_instance_alert(
                alert_window, shell_model.get_name_from_bundle_id(bundle_id))
        return

    if color is None:
        client = GConf.Client.get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

    launcher.add_launcher(activity_id, bundle.get_icon(), color)
    activity_handle = ActivityHandle(activity_id=activity_id,
                                     object_id=object_id,
                                     uri=uri,
                                     invited=invited)
    activityfactory.create(bundle, activity_handle)
Пример #7
0
def launch_bundle(bundle_id=None, object_id=None):
    '''
    Launch a bundle with the given parameters.

    If an object_id is given, the bundle will be launched with the
    object that has that id.  Otherwise, the bundle with the given
    bundle_id will be launched.

    Note: this function should not be used out side of the sugar
    shell process.  The `JournalActivityDBusService` makes this
    avaliable over DBus.
    '''
    bundle = get_bundle(bundle_id, object_id)
    if bundle is None:
        return False

    activity_handle = ActivityHandle(activity_id=None,
                                     object_id=object_id,
                                     uri=None,
                                     invited=False)
    activityfactory.create(bundle, activity_handle)
    return True
Пример #8
0
def launch_bundle(bundle_id=None, object_id=None):
    '''
    Launch a bundle with the given parameters.

    If an object_id is given, the bundle will be launched with the
    object that has that id.  Otherwise, the bundle with the given
    bundle_id will be launched.

    Note: this function should not be used out side of the sugar
    shell process.  The `JournalActivityDBusService` makes this
    avaliable over DBus.
    '''
    bundle = get_bundle(bundle_id, object_id)
    if bundle is None:
        return False

    activity_handle = ActivityHandle(activity_id=None,
                                     object_id=object_id,
                                     uri=None,
                                     invited=False)
    activityfactory.create(bundle, activity_handle)
    return True
Пример #9
0
def launch(bundle, activity_id=None, object_id=None, uri=None, color=None,
           invited=False):
    if activity_id is None or not activity_id:
        activity_id = activityfactory.create_activity_id()

    logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s',
                  bundle.get_bundle_id(), activity_id, object_id, uri)

    if isinstance(bundle, ContentBundle):
        # Content bundles are a special case: we treat them as launching
        # Browse with a specific URI.
        uri = bundle.get_start_uri()
        activities = _get_activities_for_mime('text/html')
        if len(activities) == 0:
            logging.error("No browser available for content bundle")
            return
        bundle = activities[0]
        logging.debug('Launching content bundle with uri %s', uri)

    shell_model = shell.get_model()
    activity = shell_model.get_activity_by_id(activity_id)
    if activity is not None:
        logging.debug('re-launch %r', activity.get_window())
        activity.get_window().activate(Gtk.get_current_event_time())
        return

    if color is None:
        client = GConf.Client.get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

    launcher.add_launcher(activity_id, bundle.get_icon(), color)
    activity_handle = ActivityHandle(activity_id=activity_id,
                                     object_id=object_id,
                                     uri=uri,
                                     invited=invited)
    activityfactory.create(bundle, activity_handle)