Re: How to set initial size of TextView?

2017-03-14 Thread Eric Cashon via gtk-app-devel-list

 
Hi Chris,

Try getting the font height and base the textview height on that. If you use 
the font ascent you might have to pad it a little but it should give you a 
consistent value to size your textviews with based on font size.

Eric


/*
gcc -Wall textview_height1.c -o textview_height1 `pkg-config --cflags 
--libs gtk+-3.0`
Tested on Ubuntu16.04 with GTK3.18.
*/

#include
  
int main(int argc, char *argv[])
  {
gtk_init(, );

GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Textview Height");
gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_container_set_border_width(GTK_CONTAINER(window), 20);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *textview1=gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview1), GTK_WRAP_WORD);

//Testing different font sizes.
PangoFontDescription *font=pango_font_description_from_string("Monospace 
20");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS 
gtk_widget_override_font(textview1, font);
G_GNUC_END_IGNORE_DEPRECATIONS

PangoContext *pango_context=gtk_widget_get_pango_context(textview1);
PangoFontDescription 
*desc=pango_context_get_font_description(pango_context);
PangoFontMetrics *metrics=pango_context_get_metrics(pango_context, desc, 
NULL);
gdouble ascent=(gdouble)pango_font_metrics_get_ascent(metrics)/PANGO_SCALE;
pango_font_metrics_unref(metrics);

g_print("Ascent %f\n", ascent);
   
GtkWidget *scroll1=gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_hexpand(scroll1, TRUE);
gtk_widget_set_size_request(scroll1, 360, 3.0*ascent);
gtk_container_add(GTK_CONTAINER(scroll1), textview1);

//Assume the same font size for the second textview.
GtkWidget *textview2=gtk_text_view_new();
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview2), GTK_WRAP_WORD);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS 
gtk_widget_override_font(textview2, font);
G_GNUC_END_IGNORE_DEPRECATIONS

//Don't need this anymore.
pango_font_description_free(font);

GtkWidget *scroll2=gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_hexpand(scroll2, TRUE);
gtk_widget_set_size_request(scroll2, 360, 5.0*ascent);
gtk_container_add(GTK_CONTAINER(scroll2), textview2);

GtkWidget *grid=gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(grid), 10);
gtk_grid_set_row_homogeneous(GTK_GRID(grid), FALSE);
gtk_grid_attach(GTK_GRID(grid), scroll1, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), scroll2, 0, 1, 1, 1);

gtk_container_add(GTK_CONTAINER(window), grid);

gtk_widget_show_all(window);

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


Re: gtk3 layout background image

2017-03-14 Thread Eric Cashon via gtk-app-devel-list

The layout is similar to a drawing area. Set up your "draw" callback and draw 
what you like. You can put your pictures in there also and be able to scroll 
them easily. 

/*   
gcc -Wall layout1.c -o layout1 `pkg-config --cflags --libs gtk+-3.0`
Tested on Ubuntu16.04 and GTK3.18
*/

#include

static gboolean window_background(GtkWidget *widget, cairo_t *cr, gpointer 
data);
static gboolean layout_drawing(GtkWidget *da, cairo_t *cr, gpointer data);

int main(int argc, char **argv)
 {
   gtk_init(, );

   GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(window), "Layout");
   gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
   gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
   gtk_container_set_border_width(GTK_CONTAINER(window), 40);
   g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
   gtk_widget_set_app_paintable(window, TRUE);
   //Try to set transparency of main window.
   if(gtk_widget_is_composited(window))
 {
   GdkScreen *screen=gtk_widget_get_screen(window);  
   GdkVisual *visual=gdk_screen_get_rgba_visual(screen);
   gtk_widget_set_visual(window, visual);
 }
   else g_print("Can't set window transparency.\n");
   g_signal_connect(window, "draw", G_CALLBACK(window_background), NULL);

   GtkWidget *layout=gtk_layout_new(NULL, NULL);
   gtk_widget_set_hexpand(layout, TRUE);
   gtk_widget_set_vexpand(layout, TRUE);
   g_signal_connect(layout, "draw", G_CALLBACK(layout_drawing), NULL);
   
   GtkWidget *grid=gtk_grid_new();
   gtk_grid_attach(GTK_GRID(grid), layout, 0, 0, 1, 1);
   
   gtk_container_add(GTK_CONTAINER(window), grid);

   gtk_widget_show_all(window);

   gtk_main();

   return 0;  
 }
static gboolean window_background(GtkWidget *widget, cairo_t *cr, gpointer data)
 {
   //Draw background window transparent blue.
   cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 0.3);
   cairo_paint(cr);
   return FALSE;
 }
static gboolean layout_drawing(GtkWidget *da, cairo_t *cr, gpointer data)
 {
   cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
   cairo_paint(cr);
   return FALSE;
 }


 

 

 

-Original Message-
From: Rúben Rodrigues 
To: Emmanuele Bassi 
Cc: gtk-app-devel-list 
Sent: Tue, Mar 14, 2017 8:00 am
Subject: Re: gtk3 layout background image

Thanks again!

So, i will test with gtkbox. thanks for explanation..


Às 14:46 de 14/03/2017, Emmanuele Bassi escreveu:
> On 14 March 2017 at 14:31, Rúben Rodrigues  wrote:
>> Just window can have background?
> I was referring to GdkWindow, not GtkWindow.
>
> GtkBox draws background, for instance; GtkGrid does as well.
>
>> I don't know why is a violation, because in my case my
>> applicationdoesn't make sense without background image..
> I think the issue, here, is that you're not aware that 15 years passed
> in the internals of GTK+.
>
> Changing the background pixmap of a GdkWindow is a layering violation
> because it assumes that you're essentially working on X11 and you
> control the X server as well; on X11, you're telling the X server to
> clear the contents of the native window used by GtkLayout using the
> bytes you're passing. This worked in 1997, but it's not how modern
> toolkits work — and it's not even how different windowing systems
> work. Widgets do not have their own native window for rendering any
> more, for instance.
>
> If your application window has a background image then use the
> background-image CSS property on your GtkWindow widget.
>
> Ciao,
>   Emmanuele.
>
>> On 14-03-2017 14:01, Emmanuele Bassi wrote:
>>> You were not changing the background with your theme: you were
>>> programmatically replacing the base pixmap of the GdkWindow used by
>>> GtkLayout. It was essentially a layering violation, and would actually
>>> break your theme.
>>>
>>> The API reference for each GTK widget should tell you the CSS styling
>>> available; see the "CSS nodes" section, for instance, of GtkBox:
>>> https://developer.gnome.org/gtk3/stable/GtkBox.html
>>>
>>> Ciao,
>>>Emmanuele.
>>>
>>>
>>> On 14 March 2017 at 13:55, Rúben Rodrigues  wrote:
 Thanks!

 But in GTK+2 we could change background in layout with this:

 // Set picture as background.
 //gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
 //style = gtk_style_new ();
 //style->bg_pixmap[0] = background;
 //homeWindow = GTK_WIDGET(gtk_builder_get_object(builder,
 "layout_Home"));
 //   gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));

 How i know witch containers draw background?

 THanks


 On 14-03-2017 12:55, Emmanuele Bassi wrote:
> Not all GTK containers draw a background, mostly for historical
> reasons. This has been true for GTK 1.x, 2.x, and 3.x.
>
> In particular, GtkLayout does not draw any 

How to set initial size of TextView?

2017-03-14 Thread Chris Green
I have a top level window in which I have five or six TextView text
entry fields. I want to be able to set the fields to different sizes,
at least initially.  E.g. I have a couple of TextView fields that I
want to be just two lines high, two which should be four lines high
and one that needs to be five lines.

How should one do this?  I want this to work on different displays so
setting sizes of the widgets (or containing widgets) in pixels won't
work will it?

Is there no way to set a TextView's initial size to a specified number
of lines?  They may well get put inside ScrolledWindow widgets but I
can't see a way to set the default initial size of those either.

-- 
Chris Green
·

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

Re: gtk3 layout background image

2017-03-14 Thread Rúben Rodrigues
Thanks again!

So, i will test with gtkbox. thanks for explanation..


Às 14:46 de 14/03/2017, Emmanuele Bassi escreveu:
> On 14 March 2017 at 14:31, Rúben Rodrigues  wrote:
>> Just window can have background?
> I was referring to GdkWindow, not GtkWindow.
>
> GtkBox draws background, for instance; GtkGrid does as well.
>
>> I don't know why is a violation, because in my case my
>> applicationdoesn't make sense without background image..
> I think the issue, here, is that you're not aware that 15 years passed
> in the internals of GTK+.
>
> Changing the background pixmap of a GdkWindow is a layering violation
> because it assumes that you're essentially working on X11 and you
> control the X server as well; on X11, you're telling the X server to
> clear the contents of the native window used by GtkLayout using the
> bytes you're passing. This worked in 1997, but it's not how modern
> toolkits work — and it's not even how different windowing systems
> work. Widgets do not have their own native window for rendering any
> more, for instance.
>
> If your application window has a background image then use the
> background-image CSS property on your GtkWindow widget.
>
> Ciao,
>   Emmanuele.
>
>> On 14-03-2017 14:01, Emmanuele Bassi wrote:
>>> You were not changing the background with your theme: you were
>>> programmatically replacing the base pixmap of the GdkWindow used by
>>> GtkLayout. It was essentially a layering violation, and would actually
>>> break your theme.
>>>
>>> The API reference for each GTK widget should tell you the CSS styling
>>> available; see the "CSS nodes" section, for instance, of GtkBox:
>>> https://developer.gnome.org/gtk3/stable/GtkBox.html
>>>
>>> Ciao,
>>>Emmanuele.
>>>
>>>
>>> On 14 March 2017 at 13:55, Rúben Rodrigues  wrote:
 Thanks!

 But in GTK+2 we could change background in layout with this:

 // Set picture as background.
 //gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
 //style = gtk_style_new ();
 //style->bg_pixmap[0] = background;
 //homeWindow = GTK_WIDGET(gtk_builder_get_object(builder,
 "layout_Home"));
 //gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));

 How i know witch containers draw background?

 THanks


 On 14-03-2017 12:55, Emmanuele Bassi wrote:
> Not all GTK containers draw a background, mostly for historical
> reasons. This has been true for GTK 1.x, 2.x, and 3.x.
>
> In particular, GtkLayout does not draw any background with CSS, so you
> will need to either subclass GtkLayout, override the GtkWidget::draw
> virtual function, and call gtk_render_* functions yourself; or you
> will need to put a GtkLayout into a parent container that does draw a
> background. You will, of course, need to style the parent container's
> background, not the GtkLayout itself.
>
> Ciao,
> Emmanuele.
>
>
> On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
>> I verify that i can't use css provider, don't works.
>>
>> My css file is :
>>
>> GtkLayout#layout_Home.background{
>> background-image: url('background.png');
>> }
>>
>> GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
>> color: white;
>> }
>>
>> GtkLabel#Home_Sensors_MoistAvg_value{
>> font-family: Segoe UI;
>> font-weight: lighter;
>> font-size: 25px;
>> }
>>
>> And this code:
>>
>> static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
>> {
>> gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
>> GTK_STYLE_PROVIDER(provider),G_MAXUINT);
>> if(GTK_IS_CONTAINER(widget))
>> gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
>> apply_css,provider);
>>
>> }
>>
>> GFile *file= g_file_new_for_path("custom.css");
>> GtkStyleProvider *css_provider =
>> GTK_STYLE_PROVIDER(gtk_css_provider_new());
>> gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
>> );
>> apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);
>>
>> This is the code used in gtk3-demo and don't works for me.. Why
>>
>> THanks
>>
>> On 14-03-2017 10:00, Rúben Rodrigues wrote:
>>> Hi guys,
>>>
>>> Finnaly i migrate my application to gtk+3. So, now i neet to change some
>>> things like image background. I used css provider like in this :
>>>
>>> custom.css file:
>>>
>>> GtkLayout:layout_Home{
>>>  background-color: black;
>>> }
>>>
>>>
>>> C Program:
>>>
>>> GFile *file= g_file_new_for_path("custom.css");
>>>  GtkCssProvider *css_provider = 
>>> gtk_css_provider_get_default();
>>>  

Re: gtk3 layout background image

2017-03-14 Thread Emmanuele Bassi
On 14 March 2017 at 14:31, Rúben Rodrigues  wrote:
> Just window can have background?

I was referring to GdkWindow, not GtkWindow.

GtkBox draws background, for instance; GtkGrid does as well.

> I don't know why is a violation, because in my case my
> applicationdoesn't make sense without background image..

I think the issue, here, is that you're not aware that 15 years passed
in the internals of GTK+.

Changing the background pixmap of a GdkWindow is a layering violation
because it assumes that you're essentially working on X11 and you
control the X server as well; on X11, you're telling the X server to
clear the contents of the native window used by GtkLayout using the
bytes you're passing. This worked in 1997, but it's not how modern
toolkits work — and it's not even how different windowing systems
work. Widgets do not have their own native window for rendering any
more, for instance.

If your application window has a background image then use the
background-image CSS property on your GtkWindow widget.

Ciao,
 Emmanuele.

> On 14-03-2017 14:01, Emmanuele Bassi wrote:
>> You were not changing the background with your theme: you were
>> programmatically replacing the base pixmap of the GdkWindow used by
>> GtkLayout. It was essentially a layering violation, and would actually
>> break your theme.
>>
>> The API reference for each GTK widget should tell you the CSS styling
>> available; see the "CSS nodes" section, for instance, of GtkBox:
>> https://developer.gnome.org/gtk3/stable/GtkBox.html
>>
>> Ciao,
>>   Emmanuele.
>>
>>
>> On 14 March 2017 at 13:55, Rúben Rodrigues  wrote:
>>> Thanks!
>>>
>>> But in GTK+2 we could change background in layout with this:
>>>
>>> // Set picture as background.
>>> //gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
>>> //style = gtk_style_new ();
>>> //style->bg_pixmap[0] = background;
>>> //homeWindow = GTK_WIDGET(gtk_builder_get_object(builder,
>>> "layout_Home"));
>>> //gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));
>>>
>>> How i know witch containers draw background?
>>>
>>> THanks
>>>
>>>
>>> On 14-03-2017 12:55, Emmanuele Bassi wrote:
 Not all GTK containers draw a background, mostly for historical
 reasons. This has been true for GTK 1.x, 2.x, and 3.x.

 In particular, GtkLayout does not draw any background with CSS, so you
 will need to either subclass GtkLayout, override the GtkWidget::draw
 virtual function, and call gtk_render_* functions yourself; or you
 will need to put a GtkLayout into a parent container that does draw a
 background. You will, of course, need to style the parent container's
 background, not the GtkLayout itself.

 Ciao,
Emmanuele.


 On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
> I verify that i can't use css provider, don't works.
>
> My css file is :
>
> GtkLayout#layout_Home.background{
>background-image: url('background.png');
> }
>
> GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
>color: white;
> }
>
> GtkLabel#Home_Sensors_MoistAvg_value{
>font-family: Segoe UI;
>font-weight: lighter;
>font-size: 25px;
> }
>
> And this code:
>
> static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
> {
> gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
> GTK_STYLE_PROVIDER(provider),G_MAXUINT);
>if(GTK_IS_CONTAINER(widget))
>gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
> apply_css,provider);
>
> }
>
> GFile *file= g_file_new_for_path("custom.css");
>GtkStyleProvider *css_provider =
> GTK_STYLE_PROVIDER(gtk_css_provider_new());
> gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
> );
> apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);
>
> This is the code used in gtk3-demo and don't works for me.. Why
>
> THanks
>
> On 14-03-2017 10:00, Rúben Rodrigues wrote:
>> Hi guys,
>>
>> Finnaly i migrate my application to gtk+3. So, now i neet to change some
>> things like image background. I used css provider like in this :
>>
>> custom.css file:
>>
>> GtkLayout:layout_Home{
>> background-color: black;
>> }
>>
>>
>> C Program:
>>
>> GFile *file= g_file_new_for_path("custom.css");
>> GtkCssProvider *css_provider = 
>> gtk_css_provider_get_default();
>> gtk_css_provider_load_from_file(css_provider, file, );
>> GtkStyleContext *context = gtk_style_context_new();
>> gtk_style_context_add_provider(context,
>> GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
>>
>> But 

Re: gtk3 layout background image

2017-03-14 Thread Rúben Rodrigues
Just window can have background?

I don't know why is a violation, because in my case my 
applicationdoesn't make sense without background image..


On 14-03-2017 14:01, Emmanuele Bassi wrote:
> You were not changing the background with your theme: you were
> programmatically replacing the base pixmap of the GdkWindow used by
> GtkLayout. It was essentially a layering violation, and would actually
> break your theme.
>
> The API reference for each GTK widget should tell you the CSS styling
> available; see the "CSS nodes" section, for instance, of GtkBox:
> https://developer.gnome.org/gtk3/stable/GtkBox.html
>
> Ciao,
>   Emmanuele.
>
>
> On 14 March 2017 at 13:55, Rúben Rodrigues  wrote:
>> Thanks!
>>
>> But in GTK+2 we could change background in layout with this:
>>
>> // Set picture as background.
>> //gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
>> //style = gtk_style_new ();
>> //style->bg_pixmap[0] = background;
>> //homeWindow = GTK_WIDGET(gtk_builder_get_object(builder,
>> "layout_Home"));
>> //gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));
>>
>> How i know witch containers draw background?
>>
>> THanks
>>
>>
>> On 14-03-2017 12:55, Emmanuele Bassi wrote:
>>> Not all GTK containers draw a background, mostly for historical
>>> reasons. This has been true for GTK 1.x, 2.x, and 3.x.
>>>
>>> In particular, GtkLayout does not draw any background with CSS, so you
>>> will need to either subclass GtkLayout, override the GtkWidget::draw
>>> virtual function, and call gtk_render_* functions yourself; or you
>>> will need to put a GtkLayout into a parent container that does draw a
>>> background. You will, of course, need to style the parent container's
>>> background, not the GtkLayout itself.
>>>
>>> Ciao,
>>>Emmanuele.
>>>
>>>
>>> On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
 I verify that i can't use css provider, don't works.

 My css file is :

 GtkLayout#layout_Home.background{
background-image: url('background.png');
 }

 GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
color: white;
 }

 GtkLabel#Home_Sensors_MoistAvg_value{
font-family: Segoe UI;
font-weight: lighter;
font-size: 25px;
 }

 And this code:

 static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
 {
 gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
 GTK_STYLE_PROVIDER(provider),G_MAXUINT);
if(GTK_IS_CONTAINER(widget))
gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
 apply_css,provider);

 }

 GFile *file= g_file_new_for_path("custom.css");
GtkStyleProvider *css_provider =
 GTK_STYLE_PROVIDER(gtk_css_provider_new());
 gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
 );
 apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);

 This is the code used in gtk3-demo and don't works for me.. Why

 THanks

 On 14-03-2017 10:00, Rúben Rodrigues wrote:
> Hi guys,
>
> Finnaly i migrate my application to gtk+3. So, now i neet to change some
> things like image background. I used css provider like in this :
>
> custom.css file:
>
> GtkLayout:layout_Home{
> background-color: black;
> }
>
>
> C Program:
>
> GFile *file= g_file_new_for_path("custom.css");
> GtkCssProvider *css_provider = gtk_css_provider_get_default();
> gtk_css_provider_load_from_file(css_provider, file, );
> GtkStyleContext *context = gtk_style_context_new();
> gtk_style_context_add_provider(context,
> GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
>
> But nothing happens. I tried this too:
>
> http://stackoverflow.com/questions/7375624/gtk3-window-background-image
>
>
> Someone can help me?
>
>
> THanks
>
> ___
> 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
>>>
>
>

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

Re: gtk3 layout background image

2017-03-14 Thread Emmanuele Bassi
You were not changing the background with your theme: you were
programmatically replacing the base pixmap of the GdkWindow used by
GtkLayout. It was essentially a layering violation, and would actually
break your theme.

The API reference for each GTK widget should tell you the CSS styling
available; see the "CSS nodes" section, for instance, of GtkBox:
https://developer.gnome.org/gtk3/stable/GtkBox.html

Ciao,
 Emmanuele.


On 14 March 2017 at 13:55, Rúben Rodrigues  wrote:
> Thanks!
>
> But in GTK+2 we could change background in layout with this:
>
> // Set picture as background.
> //gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
> //style = gtk_style_new ();
> //style->bg_pixmap[0] = background;
> //homeWindow = GTK_WIDGET(gtk_builder_get_object(builder,
> "layout_Home"));
> //gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));
>
> How i know witch containers draw background?
>
> THanks
>
>
> On 14-03-2017 12:55, Emmanuele Bassi wrote:
>> Not all GTK containers draw a background, mostly for historical
>> reasons. This has been true for GTK 1.x, 2.x, and 3.x.
>>
>> In particular, GtkLayout does not draw any background with CSS, so you
>> will need to either subclass GtkLayout, override the GtkWidget::draw
>> virtual function, and call gtk_render_* functions yourself; or you
>> will need to put a GtkLayout into a parent container that does draw a
>> background. You will, of course, need to style the parent container's
>> background, not the GtkLayout itself.
>>
>> Ciao,
>>   Emmanuele.
>>
>>
>> On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
>>> I verify that i can't use css provider, don't works.
>>>
>>> My css file is :
>>>
>>> GtkLayout#layout_Home.background{
>>>   background-image: url('background.png');
>>> }
>>>
>>> GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
>>>   color: white;
>>> }
>>>
>>> GtkLabel#Home_Sensors_MoistAvg_value{
>>>   font-family: Segoe UI;
>>>   font-weight: lighter;
>>>   font-size: 25px;
>>> }
>>>
>>> And this code:
>>>
>>> static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
>>> {
>>> gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
>>> GTK_STYLE_PROVIDER(provider),G_MAXUINT);
>>>   if(GTK_IS_CONTAINER(widget))
>>>   gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
>>> apply_css,provider);
>>>
>>> }
>>>
>>> GFile *file= g_file_new_for_path("custom.css");
>>>   GtkStyleProvider *css_provider =
>>> GTK_STYLE_PROVIDER(gtk_css_provider_new());
>>> gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
>>> );
>>> apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);
>>>
>>> This is the code used in gtk3-demo and don't works for me.. Why
>>>
>>> THanks
>>>
>>> On 14-03-2017 10:00, Rúben Rodrigues wrote:
 Hi guys,

 Finnaly i migrate my application to gtk+3. So, now i neet to change some
 things like image background. I used css provider like in this :

 custom.css file:

 GtkLayout:layout_Home{
background-color: black;
 }


 C Program:

 GFile *file= g_file_new_for_path("custom.css");
GtkCssProvider *css_provider = gtk_css_provider_get_default();
gtk_css_provider_load_from_file(css_provider, file, );
GtkStyleContext *context = gtk_style_context_new();
gtk_style_context_add_provider(context,
 GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

 But nothing happens. I tried this too:

 http://stackoverflow.com/questions/7375624/gtk3-window-background-image


 Someone can help me?


 THanks

 ___
 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
>>
>>
>



-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk3 layout background image

2017-03-14 Thread Rúben Rodrigues
Thanks!

But in GTK+2 we could change background in layout with this:

// Set picture as background.
//gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
//style = gtk_style_new ();
//style->bg_pixmap[0] = background;
//homeWindow = GTK_WIDGET(gtk_builder_get_object(builder, 
"layout_Home"));
//gtk_widget_set_style (GTK_WIDGET(homeWindow), GTK_STYLE(style));

How i know witch containers draw background?

THanks


On 14-03-2017 12:55, Emmanuele Bassi wrote:
> Not all GTK containers draw a background, mostly for historical
> reasons. This has been true for GTK 1.x, 2.x, and 3.x.
>
> In particular, GtkLayout does not draw any background with CSS, so you
> will need to either subclass GtkLayout, override the GtkWidget::draw
> virtual function, and call gtk_render_* functions yourself; or you
> will need to put a GtkLayout into a parent container that does draw a
> background. You will, of course, need to style the parent container's
> background, not the GtkLayout itself.
>
> Ciao,
>   Emmanuele.
>
>
> On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
>> I verify that i can't use css provider, don't works.
>>
>> My css file is :
>>
>> GtkLayout#layout_Home.background{
>>   background-image: url('background.png');
>> }
>>
>> GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
>>   color: white;
>> }
>>
>> GtkLabel#Home_Sensors_MoistAvg_value{
>>   font-family: Segoe UI;
>>   font-weight: lighter;
>>   font-size: 25px;
>> }
>>
>> And this code:
>>
>> static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
>> {
>> gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
>> GTK_STYLE_PROVIDER(provider),G_MAXUINT);
>>   if(GTK_IS_CONTAINER(widget))
>>   gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
>> apply_css,provider);
>>
>> }
>>
>> GFile *file= g_file_new_for_path("custom.css");
>>   GtkStyleProvider *css_provider =
>> GTK_STYLE_PROVIDER(gtk_css_provider_new());
>> gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
>> );
>> apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);
>>
>> This is the code used in gtk3-demo and don't works for me.. Why
>>
>> THanks
>>
>> On 14-03-2017 10:00, Rúben Rodrigues wrote:
>>> Hi guys,
>>>
>>> Finnaly i migrate my application to gtk+3. So, now i neet to change some
>>> things like image background. I used css provider like in this :
>>>
>>> custom.css file:
>>>
>>> GtkLayout:layout_Home{
>>>background-color: black;
>>> }
>>>
>>>
>>> C Program:
>>>
>>> GFile *file= g_file_new_for_path("custom.css");
>>>GtkCssProvider *css_provider = gtk_css_provider_get_default();
>>>gtk_css_provider_load_from_file(css_provider, file, );
>>>GtkStyleContext *context = gtk_style_context_new();
>>>gtk_style_context_add_provider(context,
>>> GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
>>>
>>> But nothing happens. I tried this too:
>>>
>>> http://stackoverflow.com/questions/7375624/gtk3-window-background-image
>>>
>>>
>>> Someone can help me?
>>>
>>>
>>> THanks
>>>
>>> ___
>>> 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
>
>

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

Re: gtk3 layout background image

2017-03-14 Thread Emmanuele Bassi
Not all GTK containers draw a background, mostly for historical
reasons. This has been true for GTK 1.x, 2.x, and 3.x.

In particular, GtkLayout does not draw any background with CSS, so you
will need to either subclass GtkLayout, override the GtkWidget::draw
virtual function, and call gtk_render_* functions yourself; or you
will need to put a GtkLayout into a parent container that does draw a
background. You will, of course, need to style the parent container's
background, not the GtkLayout itself.

Ciao,
 Emmanuele.


On 14 March 2017 at 12:43, Rúben Rodrigues  wrote:
> I verify that i can't use css provider, don't works.
>
> My css file is :
>
> GtkLayout#layout_Home.background{
>  background-image: url('background.png');
> }
>
> GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
>  color: white;
> }
>
> GtkLabel#Home_Sensors_MoistAvg_value{
>  font-family: Segoe UI;
>  font-weight: lighter;
>  font-size: 25px;
> }
>
> And this code:
>
> static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
> {
> gtk_style_context_add_provider(gtk_widget_get_style_context(widget),
> GTK_STYLE_PROVIDER(provider),G_MAXUINT);
>  if(GTK_IS_CONTAINER(widget))
>  gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback)
> apply_css,provider);
>
> }
>
> GFile *file= g_file_new_for_path("custom.css");
>  GtkStyleProvider *css_provider =
> GTK_STYLE_PROVIDER(gtk_css_provider_new());
> gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file,
> );
> apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);
>
> This is the code used in gtk3-demo and don't works for me.. Why
>
> THanks
>
> On 14-03-2017 10:00, Rúben Rodrigues wrote:
>> Hi guys,
>>
>> Finnaly i migrate my application to gtk+3. So, now i neet to change some
>> things like image background. I used css provider like in this :
>>
>> custom.css file:
>>
>> GtkLayout:layout_Home{
>>   background-color: black;
>> }
>>
>>
>> C Program:
>>
>> GFile *file= g_file_new_for_path("custom.css");
>>   GtkCssProvider *css_provider = gtk_css_provider_get_default();
>>   gtk_css_provider_load_from_file(css_provider, file, );
>>   GtkStyleContext *context = gtk_style_context_new();
>>   gtk_style_context_add_provider(context,
>> GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
>>
>> But nothing happens. I tried this too:
>>
>> http://stackoverflow.com/questions/7375624/gtk3-window-background-image
>>
>>
>> Someone can help me?
>>
>>
>> THanks
>>
>> ___
>> 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



-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk3 layout background image

2017-03-14 Thread Rúben Rodrigues
I verify that i can't use css provider, don't works.

My css file is :

GtkLayout#layout_Home.background{
 background-image: url('background.png');
}

GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
 color: white;
}

GtkLabel#Home_Sensors_MoistAvg_value{
 font-family: Segoe UI;
 font-weight: lighter;
 font-size: 25px;
}

And this code:

static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
{
gtk_style_context_add_provider(gtk_widget_get_style_context(widget), 
GTK_STYLE_PROVIDER(provider),G_MAXUINT);
 if(GTK_IS_CONTAINER(widget))
 gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback) 
apply_css,provider);

}

GFile *file= g_file_new_for_path("custom.css");
 GtkStyleProvider *css_provider = 
GTK_STYLE_PROVIDER(gtk_css_provider_new());
gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file, 
);
apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);

This is the code used in gtk3-demo and don't works for me.. Why

THanks

On 14-03-2017 10:00, Rúben Rodrigues wrote:
> Hi guys,
>
> Finnaly i migrate my application to gtk+3. So, now i neet to change some
> things like image background. I used css provider like in this :
>
> custom.css file:
>
> GtkLayout:layout_Home{
>   background-color: black;
> }
>
>
> C Program:
>
> GFile *file= g_file_new_for_path("custom.css");
>   GtkCssProvider *css_provider = gtk_css_provider_get_default();
>   gtk_css_provider_load_from_file(css_provider, file, );
>   GtkStyleContext *context = gtk_style_context_new();
>   gtk_style_context_add_provider(context,
> GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
>
> But nothing happens. I tried this too:
>
> http://stackoverflow.com/questions/7375624/gtk3-window-background-image
>
>
> Someone can help me?
>
>
> THanks
>
> ___
> 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


gtk3 layout background image

2017-03-14 Thread Rúben Rodrigues
Hi guys,

Finnaly i migrate my application to gtk+3. So, now i neet to change some 
things like image background. I used css provider like in this :

custom.css file:

GtkLayout:layout_Home{
 background-color: black;
}


C Program:

GFile *file= g_file_new_for_path("custom.css");
 GtkCssProvider *css_provider = gtk_css_provider_get_default();
 gtk_css_provider_load_from_file(css_provider, file, );
 GtkStyleContext *context = gtk_style_context_new();
 gtk_style_context_add_provider(context, 
GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

But nothing happens. I tried this too:

http://stackoverflow.com/questions/7375624/gtk3-window-background-image


Someone can help me?


THanks

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