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

HildonURIAction* hildon_uri_get_default_action ( const gchar *  scheme,
GError **  error 

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

This returns the which is the default for a . The can be obtained from a URI by calling hildon_uri_get_scheme_from_uri().

If NULL is returned and is NULL then there is no default for . If NULL is returned and is non-NULL, it will hold the error that occurred while trying to obtain the default .

Return: The default for .

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

References hildon_uri_action_ref(), and hildon_uri_action_unref().

Referenced by hildon_uri_get_default_action_by_uri(), and hildon_uri_is_default_action().

      GSList        *actions;
      GSList        *l;
      HildonURIAction *action = NULL;
      gchar         *desktop_file;
      gchar         *action_id;

      /* We do some interesting stuff here. Before we had the new
       * type of desktop files for v1.0 we didn't have the action
       * name in the defaults file, but now we do so that we can use
       * the same group in the file as we did before but for neutral
       * and fallback actions because they have no need for checking
       * against mime type. The new format here is:
       *   [Default Actions]
       *   <scheme>=<desktop file>:<action name>
       * Previously the action name and the colon were not present
       * so this new method means that old defaults files should
       * still works.

      if (!scheme || scheme[0] == '\0') {
            g_set_error (error,
                       "The scheme was not specified.");
            return NULL;

      if (!uri_get_desktop_file_by_scheme (scheme, &desktop_file, &action_id)) {
            DEBUG_MSG (("URI: No desktop file found for scheme:'%s'", scheme));
            g_free (desktop_file);
            g_free (action_id);
            return NULL;

      actions = uri_get_desktop_file_actions (desktop_file, scheme);

      for (l = actions; l && action_id; l = l->next) {
            action = l->data;
            if (action->id && strcmp (action->id, action_id) == 0) {
            action = NULL;

      /* If name not found, default to the first item */
      if (!action) {
            DEBUG_MSG (("URI: Using first action as default action"));

            if (actions) {
                  action = actions->data;

      if (action) {
            hildon_uri_action_ref (action);

      g_slist_foreach (actions, (GFunc) hildon_uri_action_unref, NULL);
      g_slist_free (actions);

      g_free (action_id);
      g_free (desktop_file);

      return action;

Generated by  Doxygen 1.6.0   Back to index