]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcsssection.c
separator: Don't use padding and borders wrongly
[~andy/gtk] / gtk / gtkcsssection.c
index 85fd0647eff63925a39f3aced1b4428d286bb1d9..9246d2d27c65fcd446e1e00f479bf404df5f8e7a 100644 (file)
@@ -168,10 +168,10 @@ gtk_css_section_get_section_type (const GtkCssSection *section)
  *
  * Gets the parent section for the given @section. The parent section is
  * the section that contains this @section. A special case are sections of
- * type #GTK_CSS_SECTION_TYPE_DOCUMENT. Their parent will either be %NULL
+ * type #GTK_CSS_SECTION_DOCUMENT. Their parent will either be %NULL
  * if they are the original CSS document that was loaded by
  * gtk_css_provider_load_from_file() or a section of type
- * #GTK_CSS_SECTION_TYPE_IMPORT if it was loaded with an import rule from
+ * #GTK_CSS_SECTION_IMPORT if it was loaded with an import rule from
  * a different file.
  *
  * Returns: the parent section or %NULL if none
@@ -303,3 +303,45 @@ gtk_css_section_get_end_position (const GtkCssSection *section)
     return section->end_position;
 }
 
+void
+_gtk_css_section_print (const GtkCssSection  *section,
+                        GString              *string)
+{
+  if (section->file)
+    {
+      GFileInfo *info;
+
+      info = g_file_query_info (section->file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, NULL);
+
+      if (info)
+        {
+          g_string_append (string, g_file_info_get_display_name (info));
+          g_object_unref (info);
+        }
+      else
+        {
+          g_string_append (string, "<broken file>");
+        }
+    }
+  else
+    {
+      g_string_append (string, "<data>");
+    }
+
+  g_string_append_printf (string, ":%u:%u", 
+                          gtk_css_section_get_end_line (section) + 1,
+                          gtk_css_section_get_end_position (section));
+}
+
+char *
+_gtk_css_section_to_string (const GtkCssSection *section)
+{
+  GString *string;
+
+  g_return_val_if_fail (section != NULL, NULL);
+
+  string = g_string_new (NULL);
+  _gtk_css_section_print (section, string);
+
+  return g_string_free (string, FALSE);
+}