Exemple #1
0
static void
show_parsing_error (GtkCssProvider *provider,
                    GtkCssSection  *section,
                    const GError   *error,
                    GtkTextBuffer  *buffer)
{
  GtkTextIter start, end;
  const char *tag_name;

  gtk_text_buffer_get_iter_at_line_index (buffer,
                                          &start,
                                          gtk_css_section_get_start_line (section),
                                          gtk_css_section_get_start_position (section));
  gtk_text_buffer_get_iter_at_line_index (buffer,
                                          &end,
                                          gtk_css_section_get_end_line (section),
                                          gtk_css_section_get_end_position (section));

  if (g_error_matches (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_DEPRECATED))
    tag_name = "warning";
  else
    tag_name = "error";

  gtk_text_buffer_apply_tag_by_name (buffer, tag_name, &start, &end);
}
Exemple #2
0
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));
}
Exemple #3
0
/**
 * gl_util_on_css_provider_parsing_error:
 * @provider: the provider that had a parsing error
 * @section: section the error happened in
 * @error: the parsing error
 * @user_data: user data set when the signal handler was connected
 *
 * Handle the GtkCssProvider::parsing-error signal and print a warning based on
 * @section and @error.
 */
void
gl_util_on_css_provider_parsing_error (GtkCssProvider *provider,
                                       GtkCssSection *section,
                                       GError *error,
                                       G_GNUC_UNUSED gpointer user_data)
{
    g_critical ("Error while parsing CSS style (line: %u, character: %u): %s",
                gtk_css_section_get_end_line (section) + 1,
                gtk_css_section_get_end_position (section) + 1,
                error->message);
}
Exemple #4
0
static void
ide_keybindings_parsing_error (GtkCssProvider *css_provider,
                               GtkCssSection  *section,
                               GError         *error,
                               gpointer        user_data)
{
  g_autofree gchar *filename = NULL;
  GFile *file;
  guint start_line;
  guint end_line;

  file = gtk_css_section_get_file (section);
  filename = g_file_get_uri (file);
  start_line = gtk_css_section_get_start_line (section);
  end_line = gtk_css_section_get_end_line (section);

  g_warning ("CSS parsing error in %s between lines %u and %u", filename, start_line, end_line);
}
Exemple #5
0
static void
parsing_error_cb (GtkCssProvider *provider,
                  GtkCssSection  *section,
                  const GError   *error,
                  GString        *errors)
{
  char *basename;

  basename = g_file_get_basename (gtk_css_section_get_file (section));
  g_string_append_printf (errors,
                          "%s:%u: error: ",
                          basename, gtk_css_section_get_end_line (section) + 1);
  g_free (basename);
                          
  if (error->domain == GTK_CSS_PROVIDER_ERROR)
      append_error_value (errors, GTK_TYPE_CSS_PROVIDER_ERROR, error->code);
  else
    g_string_append_printf (errors, 
                            "%s %u\n",
                            g_quark_to_string (error->domain),
                            error->code);

  g_string_append_c (errors, '\n');
}