forked from AuroraMiddleware/gtk
inspector: better type detection for resources
Pass the name to g_content_type_guess. With this, most CSS gets sniffed as C source code.
This commit is contained in:
parent
5880c9e365
commit
921b6519f1
@ -86,6 +86,7 @@ selection_changed (GtkTreeSelection *selection,
|
|||||||
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||||
{
|
{
|
||||||
gchar *path;
|
gchar *path;
|
||||||
|
gchar *name;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
gchar *type;
|
gchar *type;
|
||||||
gconstpointer data;
|
gconstpointer data;
|
||||||
@ -96,6 +97,7 @@ selection_changed (GtkTreeSelection *selection,
|
|||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (rl->priv->model), &iter,
|
gtk_tree_model_get (GTK_TREE_MODEL (rl->priv->model), &iter,
|
||||||
COLUMN_PATH, &path,
|
COLUMN_PATH, &path,
|
||||||
|
COLUMN_NAME, &name,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (g_str_has_suffix (path, "/"))
|
if (g_str_has_suffix (path, "/"))
|
||||||
@ -116,7 +118,7 @@ selection_changed (GtkTreeSelection *selection,
|
|||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
data = g_bytes_get_data (bytes, &size);
|
data = g_bytes_get_data (bytes, &size);
|
||||||
type = g_content_type_guess (NULL, data, size, NULL);
|
type = g_content_type_guess (name, data, size, NULL);
|
||||||
|
|
||||||
text = g_content_type_get_description (type);
|
text = g_content_type_get_description (type);
|
||||||
gtk_label_set_text (GTK_LABEL (rl->priv->type_label), text);
|
gtk_label_set_text (GTK_LABEL (rl->priv->type_label), text);
|
||||||
@ -149,6 +151,7 @@ selection_changed (GtkTreeSelection *selection,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
g_free (name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user