Logo Search packages:      
Sourcecode: libhildonmime version File versions  Download package

gboolean hildon_uri_set_default_action_by_uri ( const gchar *  uri_str,
HildonURIAction *  action,
GError **  error 

hildon_uri_set_default_action_by_uri: : A string which represents a uri. : A pointer. : The address of a pointer to a structure. This is optional and can be NULL.

Sets the default which should be used with a when hildon_uri_open() is called. The is saved by the scheme and mime type.

If is NULL, the default action is unset. It is important to note that ONLY the user's default actions are unset NOT the system default actions. The user's default actions are in $home/.local/share/applications/defaults.list (the system default actions are in $prefix/share/applications/defaults.list). This means that if you remove a user's default action, the system default will be used instead if there is one.

If FALSE is returned and is non-NULL, it will hold the error that occurred while trying to set the default .

Return: TRUE if it was successfully set or FALSE.

Definition at line 2197 of file hildon-uri.c.

References hildon_uri_get_scheme_from_uri(), and hildon_uri_set_default_action().

      gchar       *scheme = NULL;
      const gchar *mime_type;
      const gchar *desktop_file = NULL;
      const gchar *action_id = NULL;
      gboolean     ok;

      g_return_val_if_fail (uri_str != NULL && uri_str[0] != '\0', FALSE);

      /* If we are a neutral or fallback action we just use the old
       * API because that only needs the scheme.
      if (action && 
          (action->type == HILDON_URI_ACTION_NEUTRAL || 
           action->type == HILDON_URI_ACTION_FALLBACK)) {
            return hildon_uri_set_default_action (action->scheme, action, error);

      scheme = hildon_uri_get_scheme_from_uri (uri_str, error);
      if (!scheme || scheme[0] == '\0') {
            return FALSE;

      mime_type = gnome_vfs_get_mime_type_for_name (uri_str);
      if (strcmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) {
            mime_type = NULL;

      DEBUG_MSG (("URI: Setting default action by uri:'%s', with scheme:'%s' and mime type'%s'", 
                uri_str, scheme, mime_type));

      /* We can have a NULL action to remove the default action. */
      if (action) {
            desktop_file = action->desktop_file;
            action_id = action->id;

      ok = uri_set_defaults_file (scheme, mime_type, desktop_file, action_id);
      if (!ok) {
            g_set_error (error,
                       "The defaults file could not be saved.");

      g_free (scheme);

      return ok;

Generated by  Doxygen 1.6.0   Back to index