Commit e387f807 authored by Patrick Griffis's avatar Patrick Griffis Committed by Matthias Clasen

Improve GContentType usage

Convert to content type where needed.
Should fix various issues on Windows and OS X.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
parent 50432101
......@@ -669,13 +669,24 @@ gtk_file_filter_filter (GtkFileFilter *filter,
if ((filter_info->contains & rule->needed) != rule->needed)
continue;
switch (rule->type)
{
case FILTER_RULE_MIME_TYPE:
if (filter_info->mime_type != NULL &&
g_content_type_is_a (filter_info->mime_type, rule->u.mime_type))
return TRUE;
if (filter_info->mime_type != NULL)
{
gchar *filter_content_type, *rule_content_type;
gboolean match;
filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
match = g_content_type_is_a (filter_content_type, rule_content_type);
g_free (filter_content_type);
g_free (rule_content_type);
if (match)
return TRUE;
}
break;
case FILTER_RULE_PATTERN:
if (filter_info->display_name != NULL &&
......
......@@ -743,9 +743,20 @@ gtk_recent_filter_filter (GtkRecentFilter *filter,
switch (rule->type)
{
case FILTER_RULE_MIME_TYPE:
if (filter_info->mime_type != NULL &&
g_content_type_is_a (filter_info->mime_type, rule->u.mime_type))
return TRUE;
if (filter_info->mime_type != NULL)
{
gchar *filter_content_type, *rule_content_type;
gboolean match;
filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
match = g_content_type_is_a (filter_content_type, rule_content_type);
g_free (filter_content_type);
g_free (rule_content_type);
if (match)
return TRUE;
}
break;
case FILTER_RULE_APPLICATION:
if (filter_info->applications)
......
......@@ -775,7 +775,7 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
GtkRecentManager *manager = user_data;
GtkRecentData recent_data;
GFileInfo *file_info;
gchar *uri, *basename;
gchar *uri, *basename, *content_type;
uri = g_file_get_uri (file);
......@@ -801,8 +801,10 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
else
{
basename = g_file_get_basename (file);
recent_data.mime_type = g_content_type_guess (basename, NULL, 0, NULL);
content_type = g_content_type_guess (basename, NULL, 0, NULL);
recent_data.mime_type = g_content_type_get_mime_type (content_type);
g_free (basename);
g_free (content_type);
}
recent_data.app_name = g_strdup (g_get_application_name ());
......
......@@ -187,6 +187,11 @@ populate_details (GtkInspectorResourceList *rl,
else
{
gchar *text;
gchar *content_image;
gchar *content_text;
content_image = g_content_type_from_mime_type ("image/*");
content_text = g_content_type_from_mime_type ("text/*");
data = g_bytes_get_data (bytes, &size);
type = g_content_type_guess (name, data, size, NULL);
......@@ -199,12 +204,12 @@ populate_details (GtkInspectorResourceList *rl,
gtk_label_set_text (GTK_LABEL (rl->priv->size_label), text);
g_free (text);
if (g_content_type_is_a (type, "text/*"))
if (g_content_type_is_a (type, content_text))
{
gtk_text_buffer_set_text (rl->priv->buffer, data, -1);
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "text");
}
else if (g_content_type_is_a (type, "image/*"))
else if (g_content_type_is_a (type, content_image))
{
gtk_image_set_from_resource (GTK_IMAGE (rl->priv->image), path);
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "image");
......@@ -217,6 +222,9 @@ populate_details (GtkInspectorResourceList *rl,
g_free (type);
g_bytes_unref (bytes);
g_free (content_image);
g_free (content_text);
}
g_free (path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment