mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	Cleanups
This commit is contained in:
		| @@ -54,7 +54,7 @@ | |||||||
|  |  | ||||||
| static char * | static char * | ||||||
| get_registry_classes_key (const char    *subdir, | get_registry_classes_key (const char    *subdir, | ||||||
| 			  const wchar_t *key_name) |                           const wchar_t *key_name) | ||||||
| { | { | ||||||
|   wchar_t *wc_key; |   wchar_t *wc_key; | ||||||
|   HKEY reg_key = NULL; |   HKEY reg_key = NULL; | ||||||
| @@ -67,14 +67,14 @@ get_registry_classes_key (const char    *subdir, | |||||||
|   nbytes = 0; |   nbytes = 0; | ||||||
|   wc_key = g_utf8_to_utf16 (subdir, -1, NULL, NULL, NULL); |   wc_key = g_utf8_to_utf16 (subdir, -1, NULL, NULL, NULL); | ||||||
|   if (RegOpenKeyExW (HKEY_CLASSES_ROOT, wc_key, 0, |   if (RegOpenKeyExW (HKEY_CLASSES_ROOT, wc_key, 0, | ||||||
| 		     KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS && |                      KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS && | ||||||
|       RegQueryValueExW (reg_key, key_name, 0, |       RegQueryValueExW (reg_key, key_name, 0, | ||||||
| 			&key_type, NULL, &nbytes) == ERROR_SUCCESS && |                         &key_type, NULL, &nbytes) == ERROR_SUCCESS && | ||||||
|       (key_type == REG_SZ || key_type == REG_EXPAND_SZ)) |       (key_type == REG_SZ || key_type == REG_EXPAND_SZ)) | ||||||
|     { |     { | ||||||
|       wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1); |       wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1); | ||||||
|       RegQueryValueExW (reg_key, key_name, 0, |       RegQueryValueExW (reg_key, key_name, 0, | ||||||
| 			&key_type, (LPBYTE) wc_temp, &nbytes); |                         &key_type, (LPBYTE) wc_temp, &nbytes); | ||||||
|       wc_temp[nbytes/2] = '\0'; |       wc_temp[nbytes/2] = '\0'; | ||||||
|       if (key_type == REG_EXPAND_SZ) |       if (key_type == REG_EXPAND_SZ) | ||||||
|         { |         { | ||||||
| @@ -104,8 +104,8 @@ get_registry_classes_key (const char    *subdir, | |||||||
| } | } | ||||||
|  |  | ||||||
| gboolean | gboolean | ||||||
| g_content_type_equals (const char *type1, | g_content_type_equals (const gchar *type1, | ||||||
| 		       const char *type2) |                        const gchar *type2) | ||||||
| { | { | ||||||
|   char *progid1, *progid2; |   char *progid1, *progid2; | ||||||
|   gboolean res; |   gboolean res; | ||||||
| @@ -129,8 +129,8 @@ g_content_type_equals (const char *type1, | |||||||
| } | } | ||||||
|  |  | ||||||
| gboolean | gboolean | ||||||
| g_content_type_is_a (const char *type, | g_content_type_is_a (const gchar *type, | ||||||
| 		     const char *supertype) |                      const gchar *supertype) | ||||||
| { | { | ||||||
|   gboolean res; |   gboolean res; | ||||||
|   char *value_utf8; |   char *value_utf8; | ||||||
| @@ -151,15 +151,15 @@ g_content_type_is_a (const char *type, | |||||||
| } | } | ||||||
|  |  | ||||||
| gboolean | gboolean | ||||||
| g_content_type_is_unknown (const char *type) | g_content_type_is_unknown (const gchar *type) | ||||||
| { | { | ||||||
|   g_return_val_if_fail (type != NULL, FALSE); |   g_return_val_if_fail (type != NULL, FALSE); | ||||||
|  |  | ||||||
|   return strcmp ("*", type) == 0; |   return strcmp ("*", type) == 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | gchar * | ||||||
| g_content_type_get_description (const char *type) | g_content_type_get_description (const gchar *type) | ||||||
| { | { | ||||||
|   char *progid; |   char *progid; | ||||||
|   char *description; |   char *description; | ||||||
| @@ -173,7 +173,7 @@ g_content_type_get_description (const char *type) | |||||||
|       g_free (progid); |       g_free (progid); | ||||||
|  |  | ||||||
|       if (description) |       if (description) | ||||||
| 	return description; |         return description; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (g_content_type_is_unknown (type)) |   if (g_content_type_is_unknown (type)) | ||||||
| @@ -181,8 +181,8 @@ g_content_type_get_description (const char *type) | |||||||
|   return g_strdup_printf (_("%s filetype"), type); |   return g_strdup_printf (_("%s filetype"), type); | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | gchar * | ||||||
| g_content_type_get_mime_type (const char *type) | g_content_type_get_mime_type (const gchar *type) | ||||||
| { | { | ||||||
|   char *mime; |   char *mime; | ||||||
|  |  | ||||||
| @@ -204,7 +204,7 @@ G_LOCK_DEFINE_STATIC (_type_icons); | |||||||
| static GHashTable *_type_icons = NULL; | static GHashTable *_type_icons = NULL; | ||||||
|  |  | ||||||
| GIcon * | GIcon * | ||||||
| g_content_type_get_icon (const char *type) | g_content_type_get_icon (const gchar *type) | ||||||
| { | { | ||||||
|   GIcon *themed_icon; |   GIcon *themed_icon; | ||||||
|   char *name = NULL; |   char *name = NULL; | ||||||
| @@ -229,16 +229,16 @@ g_content_type_get_icon (const char *type) | |||||||
|         key = g_strconcat (type+1, "file\\DefaultIcon", NULL); |         key = g_strconcat (type+1, "file\\DefaultIcon", NULL); | ||||||
|       else |       else | ||||||
|         { |         { | ||||||
| 	  gchar *key2 = g_strconcat (key, "\\DefaultIcon", NULL); |           gchar *key2 = g_strconcat (key, "\\DefaultIcon", NULL); | ||||||
| 	  g_free (key); |           g_free (key); | ||||||
| 	  key = key2; |           key = key2; | ||||||
| 	} |         } | ||||||
|       name = get_registry_classes_key (key, NULL); |       name = get_registry_classes_key (key, NULL); | ||||||
|       if (name && strcmp (name, "%1") == 0) |       if (name && strcmp (name, "%1") == 0) | ||||||
|         { |         { | ||||||
| 	  g_free (name); |           g_free (name); | ||||||
| 	  name = NULL; |           name = NULL; | ||||||
| 	} |         } | ||||||
|       if (name) |       if (name) | ||||||
|         g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name)); |         g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name)); | ||||||
|       g_free (key); |       g_free (key); | ||||||
| @@ -253,7 +253,7 @@ g_content_type_get_icon (const char *type) | |||||||
|     { |     { | ||||||
|       /* if not found an icon fall back to gtk-builtins */ |       /* if not found an icon fall back to gtk-builtins */ | ||||||
|       name = strcmp (type, "inode/directory") == 0 ? "gtk-directory" :  |       name = strcmp (type, "inode/directory") == 0 ? "gtk-directory" :  | ||||||
| 	                   g_content_type_can_be_executable (type) ? "gtk-execute" : "gtk-file"; |                            g_content_type_can_be_executable (type) ? "gtk-execute" : "gtk-file"; | ||||||
|       g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name)); |       g_hash_table_insert (_type_icons, g_strdup (type), g_strdup (name)); | ||||||
|       themed_icon = g_themed_icon_new_with_default_fallbacks (name); |       themed_icon = g_themed_icon_new_with_default_fallbacks (name); | ||||||
|     } |     } | ||||||
| @@ -263,7 +263,7 @@ g_content_type_get_icon (const char *type) | |||||||
| } | } | ||||||
|  |  | ||||||
| gboolean | gboolean | ||||||
| g_content_type_can_be_executable (const char *type) | g_content_type_can_be_executable (const gchar *type) | ||||||
| { | { | ||||||
|   g_return_val_if_fail (type != NULL, FALSE); |   g_return_val_if_fail (type != NULL, FALSE); | ||||||
|  |  | ||||||
| @@ -296,13 +296,13 @@ looks_like_text (const guchar *data, | |||||||
|     { |     { | ||||||
|       c = data[i]; |       c = data[i]; | ||||||
|       if (g_ascii_iscntrl (c) && !g_ascii_isspace (c) && c != '\b') |       if (g_ascii_iscntrl (c) && !g_ascii_isspace (c) && c != '\b') | ||||||
| 	return FALSE; |         return FALSE; | ||||||
|     } |     } | ||||||
|   return TRUE; |   return TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | gchar * | ||||||
| g_content_type_from_mime_type (const char *mime_type) | g_content_type_from_mime_type (const gchar *mime_type) | ||||||
| { | { | ||||||
|   char *key, *content_type; |   char *key, *content_type; | ||||||
|  |  | ||||||
| @@ -315,11 +315,11 @@ g_content_type_from_mime_type (const char *mime_type) | |||||||
|   return content_type; |   return content_type; | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | gchar * | ||||||
| g_content_type_guess (const char   *filename, | g_content_type_guess (const gchar  *filename, | ||||||
| 		      const guchar *data, |                       const guchar *data, | ||||||
| 		      gsize         data_size, |                       gsize         data_size, | ||||||
| 		      gboolean     *result_uncertain) |                       gboolean     *result_uncertain) | ||||||
| { | { | ||||||
|   char *basename; |   char *basename; | ||||||
|   char *type; |   char *type; | ||||||
| @@ -335,7 +335,7 @@ g_content_type_guess (const char   *filename, | |||||||
|       basename = g_path_get_basename (filename); |       basename = g_path_get_basename (filename); | ||||||
|       dot = strrchr (basename, '.'); |       dot = strrchr (basename, '.'); | ||||||
|       if (dot) |       if (dot) | ||||||
| 	type = g_strdup (dot); |         type = g_strdup (dot); | ||||||
|       g_free (basename); |       g_free (basename); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -361,22 +361,22 @@ g_content_types_get_registered (void) | |||||||
|   index = 0; |   index = 0; | ||||||
|   key_len = 256; |   key_len = 256; | ||||||
|   while (RegEnumKeyExW(HKEY_CLASSES_ROOT, |   while (RegEnumKeyExW(HKEY_CLASSES_ROOT, | ||||||
| 		       index, |                        index, | ||||||
| 		       keyname, |                        keyname, | ||||||
| 		       &key_len, |                        &key_len, | ||||||
| 		       NULL, |                        NULL, | ||||||
| 		       NULL, |                        NULL, | ||||||
| 		       NULL, |                        NULL, | ||||||
| 		       NULL) == ERROR_SUCCESS) |                        NULL) == ERROR_SUCCESS) | ||||||
|     { |     { | ||||||
|       key_utf8 = g_utf16_to_utf8 (keyname, -1, NULL, NULL, NULL); |       key_utf8 = g_utf16_to_utf8 (keyname, -1, NULL, NULL, NULL); | ||||||
|       if (key_utf8) |       if (key_utf8) | ||||||
| 	{ |         { | ||||||
| 	  if (*key_utf8 == '.') |           if (*key_utf8 == '.') | ||||||
| 	    types = g_list_prepend (types, key_utf8); |             types = g_list_prepend (types, key_utf8); | ||||||
| 	  else |           else | ||||||
| 	    g_free (key_utf8); |             g_free (key_utf8); | ||||||
| 	} |         } | ||||||
|       index++; |       index++; | ||||||
|       key_len = 256; |       key_len = 256; | ||||||
|     } |     } | ||||||
| @@ -384,7 +384,7 @@ g_content_types_get_registered (void) | |||||||
|   return g_list_reverse (types); |   return g_list_reverse (types); | ||||||
| } | } | ||||||
|  |  | ||||||
| char ** | gchar ** | ||||||
| g_content_type_guess_for_tree (GFile *root) | g_content_type_guess_for_tree (GFile *root) | ||||||
| { | { | ||||||
|   /* FIXME: implement */ |   /* FIXME: implement */ | ||||||
| @@ -413,10 +413,10 @@ _g_unix_content_type_get_sniff_len (void) | |||||||
|   return size; |   return size; | ||||||
| } | } | ||||||
|  |  | ||||||
| char * | gchar * | ||||||
| _g_unix_content_type_unalias (const char *type) | _g_unix_content_type_unalias (const gchar *type) | ||||||
| { | { | ||||||
|   char *res; |   gchar *res; | ||||||
|  |  | ||||||
|   G_LOCK (gio_xdgmime); |   G_LOCK (gio_xdgmime); | ||||||
|   res = g_strdup (xdg_mime_unalias_mime_type (type)); |   res = g_strdup (xdg_mime_unalias_mime_type (type)); | ||||||
| @@ -425,11 +425,11 @@ _g_unix_content_type_unalias (const char *type) | |||||||
|   return res; |   return res; | ||||||
| } | } | ||||||
|  |  | ||||||
| char ** | gchar ** | ||||||
| _g_unix_content_type_get_parents (const char *type) | _g_unix_content_type_get_parents (const gchar *type) | ||||||
| { | { | ||||||
|   const char *umime; |   const gchar *umime; | ||||||
|   char **parents; |   gchar **parents; | ||||||
|   GPtrArray *array; |   GPtrArray *array; | ||||||
|   int i; |   int i; | ||||||
|  |  | ||||||
| @@ -451,22 +451,22 @@ _g_unix_content_type_get_parents (const char *type) | |||||||
|  |  | ||||||
|   g_ptr_array_add (array, NULL); |   g_ptr_array_add (array, NULL); | ||||||
|  |  | ||||||
|   return (char **)g_ptr_array_free (array, FALSE); |   return (gchar **)g_ptr_array_free (array, FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_equals: |  * g_content_type_equals: | ||||||
|  * @type1: a content type string. |  * @type1: a content type string | ||||||
|  * @type2: a content type string. |  * @type2: a content type string | ||||||
|  * |  * | ||||||
|  * Compares two content types for equality. |  * Compares two content types for equality. | ||||||
|  * |  * | ||||||
|  * Returns: %TRUE if the two strings are identical or equivalent, |  * Returns: %TRUE if the two strings are identical or equivalent, | ||||||
|  * %FALSE otherwise. |  *     %FALSE otherwise. | ||||||
|  **/   |  */ | ||||||
| gboolean | gboolean | ||||||
| g_content_type_equals (const char *type1, | g_content_type_equals (const gchar *type1, | ||||||
| 		       const char *type2) |                        const gchar *type2) | ||||||
| { | { | ||||||
|   gboolean res; |   gboolean res; | ||||||
|  |  | ||||||
| @@ -482,17 +482,17 @@ g_content_type_equals (const char *type1, | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_is_a: |  * g_content_type_is_a: | ||||||
|  * @type: a content type string.  |  * @type: a content type string | ||||||
|  * @supertype: a string. |  * @supertype: a content type string | ||||||
|  * |  * | ||||||
|  * Determines if @type is a subset of @supertype. |  * Determines if @type is a subset of @supertype. | ||||||
|  * |  * | ||||||
|  * Returns: %TRUE if @type is a kind of @supertype, |  * Returns: %TRUE if @type is a kind of @supertype, | ||||||
|  * %FALSE otherwise.  |  *     %FALSE otherwise. | ||||||
|  **/   |  */ | ||||||
| gboolean | gboolean | ||||||
| g_content_type_is_a (const char *type, | g_content_type_is_a (const gchar *type, | ||||||
| 		     const char *supertype) |                      const gchar *supertype) | ||||||
| { | { | ||||||
|   gboolean res; |   gboolean res; | ||||||
|  |  | ||||||
| @@ -508,16 +508,16 @@ g_content_type_is_a (const char *type, | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_is_unknown: |  * g_content_type_is_unknown: | ||||||
|  * @type: a content type string.  |  * @type: a content type string | ||||||
|  * |  * | ||||||
|  * Checks if the content type is the generic "unknown" type. |  * Checks if the content type is the generic "unknown" type. | ||||||
|  * On unix this is the "application/octet-stream" mimetype, |  * On UNIX this is the "application/octet-stream" mimetype, | ||||||
|  * while on win32 it is "*". |  * while on win32 it is "*". | ||||||
|  * |  * | ||||||
|  * Returns: %TRUE if the type is the unknown type. |  * Returns: %TRUE if the type is the unknown type. | ||||||
|  **/   |  */ | ||||||
| gboolean | gboolean | ||||||
| g_content_type_is_unknown (const char *type) | g_content_type_is_unknown (const gchar *type) | ||||||
| { | { | ||||||
|   g_return_val_if_fail (type != NULL, FALSE); |   g_return_val_if_fail (type != NULL, FALSE); | ||||||
|  |  | ||||||
| @@ -557,11 +557,11 @@ language_level (const char *lang) | |||||||
|  |  | ||||||
| static void | static void | ||||||
| mime_info_start_element (GMarkupParseContext  *context, | mime_info_start_element (GMarkupParseContext  *context, | ||||||
| 			 const gchar          *element_name, |                          const gchar          *element_name, | ||||||
| 			 const gchar         **attribute_names, |                          const gchar         **attribute_names, | ||||||
| 			 const gchar         **attribute_values, |                          const gchar         **attribute_values, | ||||||
| 			 gpointer              user_data, |                          gpointer              user_data, | ||||||
| 			 GError              **error) |                          GError              **error) | ||||||
| { | { | ||||||
|   int i; |   int i; | ||||||
|   const char *lang; |   const char *lang; | ||||||
| @@ -571,25 +571,24 @@ mime_info_start_element (GMarkupParseContext  *context, | |||||||
|     { |     { | ||||||
|       lang = "C"; |       lang = "C"; | ||||||
|       for (i = 0; attribute_names[i]; i++) |       for (i = 0; attribute_names[i]; i++) | ||||||
| 	if (strcmp (attribute_names[i], "xml:lang") == 0) |         if (strcmp (attribute_names[i], "xml:lang") == 0) | ||||||
| 	  { |           { | ||||||
| 	    lang = attribute_values[i]; |             lang = attribute_values[i]; | ||||||
| 	    break; |             break; | ||||||
| 	  } |           } | ||||||
|  |  | ||||||
|       parser->current_lang_level = language_level (lang); |       parser->current_lang_level = language_level (lang); | ||||||
|       parser->current_type = MIME_TAG_TYPE_COMMENT; |       parser->current_type = MIME_TAG_TYPE_COMMENT; | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     parser->current_type = MIME_TAG_TYPE_OTHER; |     parser->current_type = MIME_TAG_TYPE_OTHER; | ||||||
|    |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| mime_info_end_element (GMarkupParseContext  *context, | mime_info_end_element (GMarkupParseContext  *context, | ||||||
| 		       const gchar          *element_name, |                        const gchar          *element_name, | ||||||
| 		       gpointer              user_data, |                        gpointer              user_data, | ||||||
| 		       GError              **error) |                        GError              **error) | ||||||
| { | { | ||||||
|   MimeParser *parser = user_data; |   MimeParser *parser = user_data; | ||||||
|  |  | ||||||
| @@ -598,10 +597,10 @@ mime_info_end_element (GMarkupParseContext  *context, | |||||||
|  |  | ||||||
| static void | static void | ||||||
| mime_info_text (GMarkupParseContext  *context, | mime_info_text (GMarkupParseContext  *context, | ||||||
| 		const gchar          *text, |                 const gchar          *text, | ||||||
| 		gsize                 text_len,   |                 gsize                 text_len, | ||||||
| 		gpointer              user_data, |                 gpointer              user_data, | ||||||
| 		GError              **error) |                 GError              **error) | ||||||
| { | { | ||||||
|   MimeParser *parser = user_data; |   MimeParser *parser = user_data; | ||||||
|  |  | ||||||
| @@ -671,10 +670,10 @@ load_comment_for_mime (const char *mimetype) | |||||||
|     { |     { | ||||||
|       comment = load_comment_for_mime_helper (dirs[i], basename); |       comment = load_comment_for_mime_helper (dirs[i], basename); | ||||||
|       if (comment) |       if (comment) | ||||||
| 	{ |         { | ||||||
| 	  g_free (basename); |           g_free (basename); | ||||||
| 	  return comment; |           return comment; | ||||||
| 	} |         } | ||||||
|     } |     } | ||||||
|   g_free (basename); |   g_free (basename); | ||||||
|  |  | ||||||
| @@ -683,17 +682,18 @@ load_comment_for_mime (const char *mimetype) | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_get_description: |  * g_content_type_get_description: | ||||||
|  * @type: a content type string.  |  * @type: a content type string | ||||||
|  * |  * | ||||||
|  * Gets the human readable description of the content type. |  * Gets the human readable description of the content type. | ||||||
|  * |  * | ||||||
|  * Returns: a short description of the content type @type.  |  * Returns: a short description of the content type @type. Free the | ||||||
|  **/   |  *     returned string with g_free() | ||||||
| char * |  */ | ||||||
| g_content_type_get_description (const char *type) | gchar * | ||||||
|  | g_content_type_get_description (const gchar *type) | ||||||
| { | { | ||||||
|   static GHashTable *type_comment_cache = NULL; |   static GHashTable *type_comment_cache = NULL; | ||||||
|   char *comment; |   gchar *comment; | ||||||
|  |  | ||||||
|   g_return_val_if_fail (type != NULL, NULL); |   g_return_val_if_fail (type != NULL, NULL); | ||||||
|  |  | ||||||
| @@ -714,8 +714,8 @@ g_content_type_get_description (const char *type) | |||||||
|  |  | ||||||
|   G_LOCK (gio_xdgmime); |   G_LOCK (gio_xdgmime); | ||||||
|   g_hash_table_insert (type_comment_cache, |   g_hash_table_insert (type_comment_cache, | ||||||
| 		       g_strdup (type), |                        g_strdup (type), | ||||||
| 		       g_strdup (comment)); |                        g_strdup (comment)); | ||||||
|   G_UNLOCK (gio_xdgmime); |   G_UNLOCK (gio_xdgmime); | ||||||
|  |  | ||||||
|   return comment; |   return comment; | ||||||
| @@ -723,12 +723,13 @@ g_content_type_get_description (const char *type) | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_get_mime_type: |  * g_content_type_get_mime_type: | ||||||
|  * @type: a content type string.  |  * @type: a content type string | ||||||
|  * |  * | ||||||
|  * Gets the mime-type for the content type. If one is registered |  * Gets the mime type for the content type, if one is registered. | ||||||
|  * |  * | ||||||
|  * Returns: the registered mime-type for the given @type, or NULL if unknown. |  * Returns: (allow-none): the registered mime type for the given @type, | ||||||
|  **/   |  *     or %NULL if unknown. | ||||||
|  |  */ | ||||||
| char * | char * | ||||||
| g_content_type_get_mime_type (const char *type) | g_content_type_get_mime_type (const char *type) | ||||||
| { | { | ||||||
| @@ -739,14 +740,15 @@ g_content_type_get_mime_type (const char *type) | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_get_icon: |  * g_content_type_get_icon: | ||||||
|  * @type: a content type string. |  * @type: a content type string | ||||||
|  * |  * | ||||||
|  * Gets the icon for a content type. |  * Gets the icon for a content type. | ||||||
|  * |  * | ||||||
|  * Returns: #GIcon corresponding to the content type. |  * Returns: #GIcon corresponding to the content type. Free the returned | ||||||
|  **/   |  *     object with g_object_unref() | ||||||
|  |  */ | ||||||
| GIcon * | GIcon * | ||||||
| g_content_type_get_icon (const char *type) | g_content_type_get_icon (const gchar *type) | ||||||
| { | { | ||||||
|   char *mimetype_icon, *generic_mimetype_icon, *q; |   char *mimetype_icon, *generic_mimetype_icon, *q; | ||||||
|   char *xdg_mimetype_icon, *legacy_mimetype_icon; |   char *xdg_mimetype_icon, *legacy_mimetype_icon; | ||||||
| @@ -804,16 +806,16 @@ g_content_type_get_icon (const char *type) | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_can_be_executable: |  * g_content_type_can_be_executable: | ||||||
|  * @type: a content type string. |  * @type: a content type string | ||||||
|  * |  * | ||||||
|  * Checks if a content type can be executable. Note that for instance |  * Checks if a content type can be executable. Note that for instance | ||||||
|  * things like text files can be executables (i.e. scripts and batch files). |  * things like text files can be executables (i.e. scripts and batch files). | ||||||
|  * |  * | ||||||
|  * Returns: %TRUE if the file type corresponds to a type that |  * Returns: %TRUE if the file type corresponds to a type that | ||||||
|  * can be executable, %FALSE otherwise.  |  *     can be executable, %FALSE otherwise. | ||||||
|  **/   |  */ | ||||||
| gboolean | gboolean | ||||||
| g_content_type_can_be_executable (const char *type) | g_content_type_can_be_executable (const gchar *type) | ||||||
| { | { | ||||||
|   g_return_val_if_fail (type != NULL, FALSE); |   g_return_val_if_fail (type != NULL, FALSE); | ||||||
|  |  | ||||||
| @@ -835,25 +837,26 @@ looks_like_text (const guchar *data, gsize data_size) | |||||||
|       c = data[i]; |       c = data[i]; | ||||||
|  |  | ||||||
|       if (g_ascii_iscntrl (c) && |       if (g_ascii_iscntrl (c) && | ||||||
| 	  !g_ascii_isspace (c) && |           !g_ascii_isspace (c) && | ||||||
| 	  c != '\b') |           c != '\b') | ||||||
| 	return FALSE; |         return FALSE; | ||||||
|     } |     } | ||||||
|   return TRUE; |   return TRUE; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_from_mime_type: |  * g_content_type_from_mime_type: | ||||||
|  * @mime_type: a mime type string. |  * @mime_type: a mime type string | ||||||
|  * |  * | ||||||
|  * Tries to find a content type based on the mime type name. |  * Tries to find a content type based on the mime type name. | ||||||
|  * |  * | ||||||
|  * Returns: Newly allocated string with content type or NULL when does not know. |  * Returns: (allow-none): Newly allocated string with content type | ||||||
|  |  *     or %NULL. Free with g_free() | ||||||
|  * |  * | ||||||
|  * Since: 2.18 |  * Since: 2.18 | ||||||
|  **/ |  **/ | ||||||
| char * | gchar * | ||||||
| g_content_type_from_mime_type (const char *mime_type) | g_content_type_from_mime_type (const gchar *mime_type) | ||||||
| { | { | ||||||
|   char *umime; |   char *umime; | ||||||
|  |  | ||||||
| @@ -869,10 +872,11 @@ g_content_type_from_mime_type (const char *mime_type) | |||||||
|  |  | ||||||
| /** | /** | ||||||
|  * g_content_type_guess: |  * g_content_type_guess: | ||||||
|  * @filename: a string, or %NULL |  * @filename: (allow-none): a string, or %NULL | ||||||
|  * @data: a stream of data, or %NULL |  * @data: (allow-none) (array length=data_size): a stream of data, or %NULL | ||||||
|  * @data_size: the size of @data |  * @data_size: the size of @data | ||||||
|  * @result_uncertain: a flag indicating the certainty of the result |  * @result_uncertain: (allow-none) (out): return location for the certainty | ||||||
|  |  *     of the result, or %NULL | ||||||
|  * |  * | ||||||
|  * Guesses the content type based on example data. If the function is |  * Guesses the content type based on example data. If the function is | ||||||
|  * uncertain, @result_uncertain will be set to %TRUE. Either @filename |  * uncertain, @result_uncertain will be set to %TRUE. Either @filename | ||||||
| @@ -880,13 +884,13 @@ g_content_type_from_mime_type (const char *mime_type) | |||||||
|  * on the other argument. |  * on the other argument. | ||||||
|  * |  * | ||||||
|  * Returns: a string indicating a guessed content type for the |  * Returns: a string indicating a guessed content type for the | ||||||
|  * given data.  |  *     given data. Free with g_free() | ||||||
|  **/   |  */ | ||||||
| char * | gchar * | ||||||
| g_content_type_guess (const char   *filename, | g_content_type_guess (const gchar  *filename, | ||||||
| 		      const guchar *data, |                       const guchar *data, | ||||||
| 		      gsize         data_size, |                       gsize         data_size, | ||||||
| 		      gboolean     *result_uncertain) |                       gboolean     *result_uncertain) | ||||||
| { | { | ||||||
|   char *basename; |   char *basename; | ||||||
|   const char *name_mimetypes[10], *sniffed_mimetype; |   const char *name_mimetypes[10], *sniffed_mimetype; | ||||||
| @@ -934,9 +938,9 @@ g_content_type_guess (const char   *filename, | |||||||
|     { |     { | ||||||
|       sniffed_mimetype = xdg_mime_get_mime_type_for_data (data, data_size, &sniffed_prio); |       sniffed_mimetype = xdg_mime_get_mime_type_for_data (data, data_size, &sniffed_prio); | ||||||
|       if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN && |       if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN && | ||||||
| 	  data && |           data && | ||||||
| 	  looks_like_text (data, data_size)) |           looks_like_text (data, data_size)) | ||||||
| 	sniffed_mimetype = "text/plain"; |         sniffed_mimetype = "text/plain"; | ||||||
|  |  | ||||||
|       /* For security reasons we don't ever want to sniff desktop files |       /* For security reasons we don't ever want to sniff desktop files | ||||||
|        * where we know the filename and it doesn't have a .desktop extension. |        * where we know the filename and it doesn't have a .desktop extension. | ||||||
| @@ -952,8 +956,8 @@ g_content_type_guess (const char   *filename, | |||||||
|   if (n_name_mimetypes == 0) |   if (n_name_mimetypes == 0) | ||||||
|     { |     { | ||||||
|       if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN && |       if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN && | ||||||
| 	  result_uncertain) |           result_uncertain) | ||||||
| 	*result_uncertain = TRUE; |         *result_uncertain = TRUE; | ||||||
|  |  | ||||||
|       mimetype = g_strdup (sniffed_mimetype); |       mimetype = g_strdup (sniffed_mimetype); | ||||||
|     } |     } | ||||||
| @@ -961,34 +965,37 @@ g_content_type_guess (const char   *filename, | |||||||
|     { |     { | ||||||
|       mimetype = NULL; |       mimetype = NULL; | ||||||
|       if (sniffed_mimetype != XDG_MIME_TYPE_UNKNOWN) |       if (sniffed_mimetype != XDG_MIME_TYPE_UNKNOWN) | ||||||
| 	{ |         { | ||||||
| 	  if (sniffed_prio >= 80) /* High priority sniffing match, use that */ |           if (sniffed_prio >= 80) /* High priority sniffing match, use that */ | ||||||
| 	    mimetype = g_strdup (sniffed_mimetype); |             mimetype = g_strdup (sniffed_mimetype); | ||||||
| 	  else |           else | ||||||
| 	    { |             { | ||||||
| 	      /* There are conflicts between the name matches and we have a sniffed |               /* There are conflicts between the name matches and we | ||||||
| 		 type, use that as a tie breaker. */ |                * have a sniffed type, use that as a tie breaker. | ||||||
| 	       |                */ | ||||||
| 	      for (i = 0; i < n_name_mimetypes; i++) |               for (i = 0; i < n_name_mimetypes; i++) | ||||||
| 		{ |                 { | ||||||
| 		  if ( xdg_mime_mime_type_subclass (name_mimetypes[i], sniffed_mimetype)) |                   if ( xdg_mime_mime_type_subclass (name_mimetypes[i], sniffed_mimetype)) | ||||||
| 		    { |                     { | ||||||
| 		      /* This nametype match is derived from (or the same as) the sniffed type). |                       /* This nametype match is derived from (or the same as) | ||||||
| 			 This is probably it. */ |                        * the sniffed type). This is probably it. | ||||||
| 		      mimetype = g_strdup (name_mimetypes[i]); |                        */ | ||||||
| 		      break; |                       mimetype = g_strdup (name_mimetypes[i]); | ||||||
| 		    } |                       break; | ||||||
| 		} |                     } | ||||||
| 	    } |                 } | ||||||
| 	} |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|       if (mimetype == NULL) |       if (mimetype == NULL) | ||||||
| 	{ |         { | ||||||
| 	  /* Conflicts, and sniffed type was no help or not there. Guess on the first one */ |           /* Conflicts, and sniffed type was no help or not there. | ||||||
| 	  mimetype = g_strdup (name_mimetypes[0]); |            * Guess on the first one | ||||||
| 	  if (result_uncertain) |            */ | ||||||
| 	    *result_uncertain = TRUE; |           mimetype = g_strdup (name_mimetypes[0]); | ||||||
| 	} |           if (result_uncertain) | ||||||
|  |             *result_uncertain = TRUE; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   G_UNLOCK (gio_xdgmime); |   G_UNLOCK (gio_xdgmime); | ||||||
| @@ -1009,13 +1016,13 @@ enumerate_mimetypes_subdir (const char *dir, | |||||||
|   if (d) |   if (d) | ||||||
|     { |     { | ||||||
|       while ((ent = readdir (d)) != NULL) |       while ((ent = readdir (d)) != NULL) | ||||||
| 	{ |         { | ||||||
| 	  if (g_str_has_suffix (ent->d_name, ".xml")) |           if (g_str_has_suffix (ent->d_name, ".xml")) | ||||||
| 	    { |             { | ||||||
| 	      mimetype = g_strdup_printf ("%s/%.*s", prefix, (int) strlen (ent->d_name) - 4, ent->d_name); |               mimetype = g_strdup_printf ("%s/%.*s", prefix, (int) strlen (ent->d_name) - 4, ent->d_name); | ||||||
| 	      g_hash_table_replace (mimetypes, mimetype, NULL); |               g_hash_table_replace (mimetypes, mimetype, NULL); | ||||||
| 	    } |             } | ||||||
| 	} |         } | ||||||
|       closedir (d); |       closedir (d); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -1035,15 +1042,15 @@ enumerate_mimetypes_dir (const char *dir, | |||||||
|   if (d) |   if (d) | ||||||
|     { |     { | ||||||
|       while ((ent = readdir (d)) != NULL) |       while ((ent = readdir (d)) != NULL) | ||||||
| 	{ |         { | ||||||
| 	  if (strcmp (ent->d_name, "packages") != 0) |           if (strcmp (ent->d_name, "packages") != 0) | ||||||
| 	    { |             { | ||||||
| 	      name = g_build_filename (mimedir, ent->d_name, NULL); |               name = g_build_filename (mimedir, ent->d_name, NULL); | ||||||
| 	      if (g_file_test (name, G_FILE_TEST_IS_DIR)) |               if (g_file_test (name, G_FILE_TEST_IS_DIR)) | ||||||
| 		enumerate_mimetypes_subdir (name, ent->d_name, mimetypes); |                 enumerate_mimetypes_subdir (name, ent->d_name, mimetypes); | ||||||
| 	      g_free (name); |               g_free (name); | ||||||
| 	    } |             } | ||||||
| 	} |         } | ||||||
|       closedir (d); |       closedir (d); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -1055,9 +1062,13 @@ enumerate_mimetypes_dir (const char *dir, | |||||||
|  * |  * | ||||||
|  * Gets a list of strings containing all the registered content types |  * Gets a list of strings containing all the registered content types | ||||||
|  * known to the system. The list and its data should be freed using |  * known to the system. The list and its data should be freed using | ||||||
|  * @g_list_foreach(list, g_free, NULL) and @g_list_free(list) |  * <programlisting> | ||||||
|  * Returns: #GList of the registered content types. |  * g_list_foreach (list, g_free, NULL); | ||||||
|  **/   |  * g_list_free (list); | ||||||
|  |  * </programlisting> | ||||||
|  |  * | ||||||
|  |  * Returns: #GList of the registered content types | ||||||
|  |  */ | ||||||
| GList * | GList * | ||||||
| g_content_types_get_registered (void) | g_content_types_get_registered (void) | ||||||
| { | { | ||||||
| @@ -1159,7 +1170,7 @@ parse_header (gchar *line) | |||||||
|  |  | ||||||
| static TreeMatchlet * | static TreeMatchlet * | ||||||
| parse_match_line (gchar *line, | parse_match_line (gchar *line, | ||||||
| 		  gint  *depth) |                   gint  *depth) | ||||||
| { | { | ||||||
|   gchar *s, *p; |   gchar *s, *p; | ||||||
|   TreeMatchlet *matchlet; |   TreeMatchlet *matchlet; | ||||||
| @@ -1413,8 +1424,8 @@ next_match_recurse (Enumerator *e, | |||||||
|                   e->enumerators[depth] = g_file_enumerate_children (file, |                   e->enumerators[depth] = g_file_enumerate_children (file, | ||||||
|                                                                      G_FILE_ATTRIBUTE_STANDARD_NAME, |                                                                      G_FILE_ATTRIBUTE_STANDARD_NAME, | ||||||
|                                                                      G_FILE_QUERY_INFO_NONE, |                                                                      G_FILE_QUERY_INFO_NONE, | ||||||
| 							             NULL, |                                                                      NULL, | ||||||
| 							             NULL); |                                                                      NULL); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|           if (e->enumerators[depth] == NULL) |           if (e->enumerators[depth] == NULL) | ||||||
| @@ -1638,14 +1649,15 @@ match_match (TreeMatch    *match, | |||||||
|  * (for a camera memory card). See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> |  * (for a camera memory card). See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> | ||||||
|  * specification for more on x-content types. |  * specification for more on x-content types. | ||||||
|  * |  * | ||||||
|  * This function is useful in the implementation of g_mount_guess_content_type(). |  * This function is useful in the implementation of | ||||||
|  |  * g_mount_guess_content_type(). | ||||||
|  * |  * | ||||||
|  * Returns: an %NULL-terminated array of zero or more content types, or %NULL.  |  * Returns: an %NULL-terminated array of zero or more content types, | ||||||
|  *    Free with g_strfreev() |  *     or %NULL. Free with g_strfreev() | ||||||
|  * |  * | ||||||
|  * Since: 2.18 |  * Since: 2.18 | ||||||
|  */ |  */ | ||||||
| char ** | gchar ** | ||||||
| g_content_type_guess_for_tree (GFile *root) | g_content_type_guess_for_tree (GFile *root) | ||||||
| { | { | ||||||
|   GPtrArray *types; |   GPtrArray *types; | ||||||
| @@ -1666,7 +1678,7 @@ g_content_type_guess_for_tree (GFile *root) | |||||||
|  |  | ||||||
|   g_ptr_array_add (types, NULL); |   g_ptr_array_add (types, NULL); | ||||||
|  |  | ||||||
|   return (char **)g_ptr_array_free (types, FALSE); |   return (gchar **)g_ptr_array_free (types, FALSE); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif /* Unix version */ | #endif /* Unix version */ | ||||||
|   | |||||||
| @@ -31,24 +31,24 @@ | |||||||
|  |  | ||||||
| G_BEGIN_DECLS | G_BEGIN_DECLS | ||||||
|  |  | ||||||
| gboolean g_content_type_equals            (const char   *type1, | gboolean g_content_type_equals            (const gchar  *type1, | ||||||
| 					   const char   *type2); |                                            const gchar  *type2); | ||||||
| gboolean g_content_type_is_a              (const char   *type, | gboolean g_content_type_is_a              (const gchar  *type, | ||||||
| 					   const char   *supertype); |                                            const gchar  *supertype); | ||||||
| gboolean g_content_type_is_unknown        (const char   *type); | gboolean g_content_type_is_unknown        (const gchar  *type); | ||||||
| char *   g_content_type_get_description   (const char   *type); | gchar *  g_content_type_get_description   (const gchar  *type); | ||||||
| char *   g_content_type_get_mime_type     (const char   *type); | gchar *  g_content_type_get_mime_type     (const gchar  *type); | ||||||
| GIcon *  g_content_type_get_icon          (const char   *type); | GIcon *  g_content_type_get_icon          (const gchar  *type); | ||||||
| gboolean g_content_type_can_be_executable (const char   *type); | gboolean g_content_type_can_be_executable (const gchar  *type); | ||||||
|  |  | ||||||
| char *   g_content_type_from_mime_type    (const char   *mime_type); | gchar *  g_content_type_from_mime_type    (const gchar  *mime_type); | ||||||
|  |  | ||||||
| char *   g_content_type_guess             (const char   *filename, | gchar *  g_content_type_guess             (const gchar  *filename, | ||||||
| 					   const guchar *data, |                                            const guchar *data, | ||||||
| 					   gsize         data_size, |                                            gsize         data_size, | ||||||
| 					   gboolean     *result_uncertain); |                                            gboolean     *result_uncertain); | ||||||
|  |  | ||||||
| char **  g_content_type_guess_for_tree    (GFile        *root); | gchar ** g_content_type_guess_for_tree    (GFile        *root); | ||||||
|  |  | ||||||
| GList *  g_content_types_get_registered   (void); | GList *  g_content_types_get_registered   (void); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								gio/tests/appinfo-test2.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								gio/tests/appinfo-test2.desktop
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | [Desktop Entry] | ||||||
|  | Type=Application | ||||||
|  | Name=appinfo-test | ||||||
|  | Name[de]=appinfo-test-de | ||||||
|  | X-GNOME-FullName=example | ||||||
|  | X-GNOME-FullName[de]=Beispiel | ||||||
|  | Comment=GAppInfo example | ||||||
|  | Comment[de]=GAppInfo Beispiel | ||||||
|  | Exec=./appinfo-test --option | ||||||
|  | TryExec=does-not-exist | ||||||
|  | Icon=testicon | ||||||
		Reference in New Issue
	
	Block a user