Change style of 'GtkTextTag' in GtkSourceBuffer

According to the documentation, I can change the internal ‘GtkTextTag’ of the ‘GtkSourceBuffer’ style, using the ‘gtk_source_style_apply’ method

This function modifies the GtkTextTag properties that are related to the GtkSourceStyle properties. Other GtkTextTag properties are left untouched.

For example, I am trying to change the style of ‘line-numbers’, but no change occurs.

  if ((scheme = gtk_source_buffer_get_style_scheme(buffer))) {
    if ((style = gtk_source_style_scheme_get_style(scheme, "line-numbers"))) {
		   "paragraph-background", NULL,
		   "background", NULL,
		   "foreground", NULL,
		   "paragraph-background-set", FALSE,
           "background-set", FALSE,
		   "foreground-set", FALSE,

      gtk_source_style_apply(style, n_selection);

      g_print("line-numbers style Apply!\n");

I also tried with the style of ‘search-match’ and ‘text’. But nothing happens, everything is seen in the standard way.

I would appreciate more information. Cheers

That’s because it works in the opposite direction. It’s so you can create a text tag that mimics what the source buffer’s style-scheme would have.

and is there no way to get the inner TextTag of a SourceView?

Well, it’s software so where there’s will there is a way. But by design, you are not given access to them so you can’t screw up any invariant expected by GtkSourceView internally.

That said, how you normally deal with wanting to change how things look, is to bundle your own style scheme with the changes, or to create new tags at a higher priority and set those on the spans of text you care about.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.