Re: Overriding CSS style

2018-04-19 Thread Eric Cashon via gtk-app-devel-list

 
Hi Yannick,

You have some options here. You can set a priority with

https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-add-provider

with CSS.

If you want to just stick with drawing in C, connect your "draw" handler for 
the window. If you need a pixbuf you can use

https://developer.gnome.org/gdk3/stable/gdk3-Cairo-Interaction.html#gdk-cairo-set-source-pixbuf

to add a pixbuf to the background.

Also, the CSS GTK+ recognizes is a little different between versions. I am 
still using GTK3.18 and it understands a little different CSS string than 
GTK3.22. Something to keep in mind if you are using CSS strings in code.

Eric

/*
   gcc -Wall css1.c -o css1 `pkg-config --cflags --libs gtk+-3.0`
   Tested with GTK3.18 and GTK3.22 on Ubuntu16.04
*/
#include

static gboolean draw_window(GtkWidget *window, cairo_t *cr, gpointer user_data)
  {
//A green window.
cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
cairo_paint(cr);
return FALSE;
  }
int main(int argc, char *argv[])
  {
gtk_init (, );

GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "CSS");
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

//Uncomment the following two line for drawing with cairo.
//gtk_widget_set_app_paintable(window, TRUE);
//g_signal_connect(window, "draw", G_CALLBACK(draw_window), NULL);

gtk_widget_show_all(window);

//Setup CSS for the program.
GError *css_error=NULL;
gint minor_version=gtk_get_minor_version();
gchar *css_string1=NULL;
//GTK CSS changed in 3.20.
if(minor_version>20)
  {
css_string1=g_strdup("window{background: blue;}");
  }
else
  {
css_string1=g_strdup("GtkWindow{background: blue;}");
  }
GtkCssProvider *provider=gtk_css_provider_new();
GdkDisplay *display=gdk_display_get_default();
GdkScreen *screen=gdk_display_get_default_screen(display);
gtk_style_context_add_provider_for_screen(screen, 
GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_css_provider_load_from_data(provider, css_string1, -1, _error);

if(css_error!=NULL)
  {
g_print("CSS loader error %s\n", css_error->message);
g_error_free(css_error);
  }
g_object_unref(provider);
if(css_string1!=NULL) g_free(css_string1);

gtk_main();

return 0;
  }  

 


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Gtk+-2.0 stylish coding

2018-04-19 Thread Joël Krähemann
Hi,

I do Gtk+-2.0 stylish coding. Any suggestions on changes on code are
appreciated?

I would love to get feedback for following code style:

http://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/audio/ags_audio.c?h=2.0.x
http://git.savannah.nongnu.org/cgit/gsequencer.git/tree/ags/audio/ags_channel.c?h=2.0.x

My intension is to provide thread-safe properties and objects. Further reading:
https://savannah.nongnu.org/forum/forum.php?forum_id=9145

Bests,
Joël
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Overriding CSS style

2018-04-19 Thread Lucky B.C
Did you run gtk3-demo > Theming > ... Animated Backgrounds ...?

On Wed, Apr 18, 2018 at 4:45 AM, Yannick POTIN  wrote:

> Hello everyone,
>
> I'm testing the style capabilities of GTK+, and after being amazed by the
> availability of CSS, I couldn't find anything in the documentation about
> modifying an existing rule.
>
> So, my questions are : is it possible to change the CSS « background-image
> » of my GTK+ main window using C only ? Or do I have to build a new CSS
> rule and reimport it ? Is the last one even possible without losing all
> other rules ?
>
> Thank you.
>
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Overriding CSS style

2018-04-19 Thread Yannick POTIN
Hello everyone,

I'm testing the style capabilities of GTK+, and after being amazed by the 
availability of CSS, I couldn't find anything in the documentation about 
modifying an existing rule.

So, my questions are : is it possible to change the CSS « background-image » of 
my GTK+ main window using C only ? Or do I have to build a new CSS rule and 
reimport it ? Is the last one even possible without losing all other rules ?

Thank you.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list