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

GSList* hildon_uri_get_actions_by_uri ( const gchar *  uri_str,
HildonURIActionType  action_type,
GError **  error 

hildon_uri_action_get_actions_by_uri: : A const pointer to a URI. : The type of actions you want returned, can be -1 to all. : The address of a pointer to a structure. This is optional and can be NULL.

This function operates the same way () does but instead uses the mime type of the uri to know which actions it can return and has the added ability to specify the types you want returned. For most cases, this will be -1 to return all actions available for a given URI.

Return: A of actions. This list is freed using ().

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

References hildon_uri_get_scheme_from_uri(), and hildon_uri_is_default_action_by_uri().

Referenced by hildon_uri_open().

      GSList      *actions = NULL;
      GSList      *desktop_files;
      GSList      *l;
      gchar       *filename;
      gchar       *scheme = NULL;
      const gchar *mime_type;

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

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

      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: Getting actions by uri: %s, found scheme:'%s' and mime type'%s'", 
                uri_str, scheme, mime_type));

      /* Get desktop files */
      desktop_files = uri_get_desktop_files_by_scheme (scheme);

      DEBUG_MSG (("URI: Getting actions by uri: %s, found %d desktop files", 
                uri_str, g_slist_length (desktop_files)));

      for (l = desktop_files; l; l = l->next) {
            GSList *actions_found;

            filename = l->data;

            actions_found = uri_get_desktop_file_actions (filename, scheme);
            if (actions_found) {
                  actions = g_slist_concat (actions, actions_found);

      actions = uri_get_desktop_file_actions_filtered (actions, 

      /* Make sure the default action is the first item in the list */
      DEBUG_MSG (("URI: Making sure default action is the top of the list..."));

      if (actions && !hildon_uri_is_default_action_by_uri (uri_str, actions->data, NULL)) {
            HildonURIAction *default_action;

            for (l = actions->next; l; l = l->next) {
                  if (!hildon_uri_is_default_action_by_uri (uri_str, l->data, NULL)) {

                  DEBUG_MSG (("URI: Moving default action to the top of the list..."));

                  default_action = l->data;
                  actions = g_slist_remove_link (actions, l);
                  g_slist_free1 (l);
                  actions = g_slist_prepend (actions, default_action);

      g_slist_foreach (desktop_files, (GFunc) g_free, NULL);
      g_slist_free (desktop_files);
      g_free (scheme);

      return actions;

Generated by  Doxygen 1.6.0   Back to index