g_app_info_add_supports_type
g_app_info_can_remove_supports_type
g_app_info_remove_supports_type
+g_app_info_get_supported_types
g_app_info_get_all
g_app_info_get_all_for_type
g_app_info_get_default_for_type
return FALSE;
}
+/**
+ * g_app_info_get_supported_types:
+ * @info: a #GAppInfo that can handle files
+ *
+ * Retrieves the list of content types that @app_info claims to support.
+ * If this information is not provided by the environment, this function
+ * will return %NULL.
+ * This function does not take in consideration associations added with
+ * g_app_info_add_supports_type(), but only those exported directly by
+ * the application.
+ *
+ * Returns: (transfer none) (array zero-terminated=1) (element-type utf8):
+ * a list of content types.
+ *
+ * Since: 2.34
+ */
+const char **
+g_app_info_get_supported_types (GAppInfo *appinfo)
+{
+ GAppInfoIface *iface;
+
+ g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
+
+ iface = G_APP_INFO_GET_IFACE (appinfo);
+
+ if (iface->get_supported_types)
+ return iface->get_supported_types (appinfo);
+ else
+ return NULL;
+}
+
/**
* g_app_info_get_icon:
gboolean (* set_as_last_used_for_type) (GAppInfo *appinfo,
const char *content_type,
GError **error);
+ const char ** (* get_supported_types) (GAppInfo *appinfo);
};
GType g_app_info_get_type (void) G_GNUC_CONST;
gboolean g_app_info_remove_supports_type (GAppInfo *appinfo,
const char *content_type,
GError **error);
+GLIB_AVAILABLE_IN_2_34
+const char **g_app_info_get_supported_types (GAppInfo *appinfo);
+
gboolean g_app_info_can_delete (GAppInfo *appinfo);
gboolean g_app_info_delete (GAppInfo *appinfo);
char *path;
char *categories;
char *startup_wm_class;
+ char **mime_types;
guint nodisplay : 1;
guint hidden : 1;
g_free (info->path);
g_free (info->categories);
g_free (info->startup_wm_class);
+ g_strfreev (info->mime_types);
G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
}
info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
info->categories = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_CATEGORIES, NULL);
info->startup_wm_class = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, STARTUP_WM_CLASS_KEY, NULL);
+ info->mime_types = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL);
info->icon = NULL;
if (info->icon_name)
error);
}
+static const char **
+g_desktop_app_info_get_supported_types (GAppInfo *appinfo)
+{
+ GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
+
+ return (const char**) info->mime_types;
+}
+
+
static gboolean
g_desktop_app_info_ensure_saved (GDesktopAppInfo *info,
GError **error)
iface->get_commandline = g_desktop_app_info_get_commandline;
iface->get_display_name = g_desktop_app_info_get_display_name;
iface->set_as_last_used_for_type = g_desktop_app_info_set_as_last_used_for_type;
+ iface->get_supported_types = g_desktop_app_info_get_supported_types;
}
static gboolean
g_app_info_get_executable
g_app_info_get_commandline
g_app_info_get_icon
+g_app_info_get_supported_types
g_app_info_launch
g_app_info_supports_uris
g_app_info_supports_files
Icon=testicon
StartupNotify=true
StartupWMClass=appinfo-class
+MimeType=image/png;image/jpeg;
g_object_unref (appinfo);
}
+static void
+test_supported_types (void)
+{
+ GAppInfo *appinfo;
+ const char * const *content_types;
+
+ appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"));
+ content_types = g_app_info_get_supported_types (appinfo);
+
+ g_assert_cmpint (g_strv_length ((char**)content_types), ==, 2);
+ g_assert_cmpstr (content_types[0], ==, "image/png");
+
+ g_object_unref (appinfo);
+}
+
int
main (int argc, char *argv[])
{
g_test_add_func ("/appinfo/associations", test_associations);
g_test_add_func ("/appinfo/environment", test_environment);
g_test_add_func ("/appinfo/startup-wm-class", test_startup_wm_class);
+ g_test_add_func ("/appinfo/supported-types", test_supported_types);
return g_test_run ();
}