forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
60ab85c7bc
commit
47f4e44aec
@ -669,13 +669,24 @@ gtk_file_filter_filter (GtkFileFilter *filter,
|
|||||||
|
|
||||||
if ((filter_info->contains & rule->needed) != rule->needed)
|
if ((filter_info->contains & rule->needed) != rule->needed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (rule->type)
|
switch (rule->type)
|
||||||
{
|
{
|
||||||
case FILTER_RULE_MIME_TYPE:
|
case FILTER_RULE_MIME_TYPE:
|
||||||
if (filter_info->mime_type != NULL &&
|
if (filter_info->mime_type != NULL)
|
||||||
g_content_type_is_a (filter_info->mime_type, rule->u.mime_type))
|
{
|
||||||
return TRUE;
|
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;
|
break;
|
||||||
case FILTER_RULE_PATTERN:
|
case FILTER_RULE_PATTERN:
|
||||||
if (filter_info->display_name != NULL &&
|
if (filter_info->display_name != NULL &&
|
||||||
|
@ -743,9 +743,20 @@ gtk_recent_filter_filter (GtkRecentFilter *filter,
|
|||||||
switch (rule->type)
|
switch (rule->type)
|
||||||
{
|
{
|
||||||
case FILTER_RULE_MIME_TYPE:
|
case FILTER_RULE_MIME_TYPE:
|
||||||
if (filter_info->mime_type != NULL &&
|
if (filter_info->mime_type != NULL)
|
||||||
g_content_type_is_a (filter_info->mime_type, rule->u.mime_type))
|
{
|
||||||
return TRUE;
|
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;
|
break;
|
||||||
case FILTER_RULE_APPLICATION:
|
case FILTER_RULE_APPLICATION:
|
||||||
if (filter_info->applications)
|
if (filter_info->applications)
|
||||||
|
@ -775,7 +775,7 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
|
|||||||
GtkRecentManager *manager = user_data;
|
GtkRecentManager *manager = user_data;
|
||||||
GtkRecentData recent_data;
|
GtkRecentData recent_data;
|
||||||
GFileInfo *file_info;
|
GFileInfo *file_info;
|
||||||
gchar *uri, *basename;
|
gchar *uri, *basename, *content_type;
|
||||||
|
|
||||||
uri = g_file_get_uri (file);
|
uri = g_file_get_uri (file);
|
||||||
|
|
||||||
@ -801,8 +801,10 @@ gtk_recent_manager_add_item_query_info (GObject *source_object,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
basename = g_file_get_basename (file);
|
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 (basename);
|
||||||
|
g_free (content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
recent_data.app_name = g_strdup (g_get_application_name ());
|
recent_data.app_name = g_strdup (g_get_application_name ());
|
||||||
|
@ -187,6 +187,11 @@ populate_details (GtkInspectorResourceList *rl,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *text;
|
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);
|
data = g_bytes_get_data (bytes, &size);
|
||||||
type = g_content_type_guess (name, data, size, NULL);
|
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);
|
gtk_label_set_text (GTK_LABEL (rl->priv->size_label), text);
|
||||||
g_free (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_text_buffer_set_text (rl->priv->buffer, data, -1);
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "text");
|
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_image_set_from_resource (GTK_IMAGE (rl->priv->image), path);
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "image");
|
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "image");
|
||||||
@ -217,6 +222,9 @@ populate_details (GtkInspectorResourceList *rl,
|
|||||||
|
|
||||||
g_free (type);
|
g_free (type);
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
|
g_free (content_image);
|
||||||
|
g_free (content_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
Loading…
Reference in New Issue
Block a user