Page 1 of 2

GTK - Some GTK Questions...

Posted: Thu Jul 12, 2007 10:52 am
by Progi1984
Hi,
Question #1 :
i find the solution to Set Window Color with the funciton "gtk_widget_modify_bg_" but how can i get this color ?

Thank you for advance

Posted: Fri Jul 13, 2007 3:04 pm
by Progi1984
Question #2 :
How can I set the position (x,y) and the size (width, height) of a label in a window ?

Posted: Fri Jul 13, 2007 6:01 pm
by KarLKoX
Question #1 :

You can use gtk_widget_get_modifier_style(), modify the 'bg' member of the GtkRcStyle struct with your GdkColor then call gtk_widget_modify_style() passing the new GtkRcStyle.

Question #2 :
* set the position : gtk_widget_set_uposition() , works only for a widget outside a container.
* modifiy the size : gtk_widget_set_size_request ()

Posted: Sat Jul 14, 2007 4:51 pm
by Progi1984
Question 1 :
Have you got the declaration of the structure GtkRcStyle ? I'm on Windows...

Question 2 :
How can i do for positionning a widget in a gtkcontainer ?

Posted: Sat Jul 14, 2007 10:34 pm
by KarLKoX
Question 1 :

GtkRcStyle, gtk is a crossplateform toolkit, this is the same struct for all OSes supported ;)

Question 2 :
The easier way is to add a GtkTable to a box then pack your widget in a cell of the table.
You can then play with the space before and/or after the cell.

Posted: Sat Jul 14, 2007 10:57 pm
by Airr
Why not use GtkFixed and gtk_fixed_put?

Posted: Sun Jul 15, 2007 7:59 am
by KarLKoX
For most applications, you should not use this container! It keeps you from having to learn about the other GTK+ containers, but it results in broken applications. With GtkFixed, the following things will result in truncated text, overlapping widgets, and other display bugs:

*

Themes, which may change widget sizes.
*

Fonts other than the one you used to write the app will of course change the size of widgets containing text; keep in mind that users may use a larger font because of difficulty reading the default, or they may be using Windows or the framebuffer port of GTK+, where different fonts are available.
*

Translation of text into other languages changes its size. Also, display of non-English text will use a different font in many cases.

In addition, the fixed widget can't properly be mirrored in right-to-left languages such as Hebrew and Arabic. i.e. normally GTK+ will flip the interface to put labels to the right of the thing they label, but it can't do that with GtkFixed. So your application will not be usable in right-to-left languages.

Finally, fixed positioning makes it kind of annoying to add/remove GUI elements, since you have to reposition all the other elements. This is a long-term maintenance problem for your application.
http://developer.gnome.org/doc/API/2.0/ ... Fixed.html

Posted: Mon Jul 16, 2007 9:00 am
by Progi1984
Question 1 :
KarLKoX wrote:GtkRcStyle, gtk is a crossplateform toolkit, this is the same struct for all OSes supported ;)
Yep, but i know that GtkRcStyle must be already declared in the linux version so I want to get these declarations :)

Question 2 :
KarLKoX wrote:The easier way is to add a GtkTable to a box then pack your widget in a cell of the table.
You can then play with the space before and/or after the cell.
What is better : GtkTable or GtkFixed for easy moving and sizing ?

Posted: Tue Jul 17, 2007 4:15 pm
by Airr
Progi1984 wrote: What is better : GtkTable or GtkFixed for easy moving and sizing ?
Based on the documentation, GtkTable. As to which is simpler, I'd say GtkFixed as long as you can live with the potential "gotcha's".

Not to hijack this thread, but what does PB-Linux use?

AIR.

Posted: Wed Jul 18, 2007 10:32 am
by Progi1984
Question 1 :
Noone has the declaration of GtkRcStyle under Linux ?

Question 2 :
I finally use a GTKTable and that works... easily :)

Question 3 :
New Question : I load an image (always under Windows) with LoadImage. How can i draw this image in a GtkImage ?
Or How can I transform a hBitmap in GdkPixmap ?

Posted: Wed Jul 18, 2007 11:37 am
by ts-soft
1:

Code: Select all

Structure GtkRcStyle
  parent_instance.GObject
  *name.b
  *bg_pixmap_name.b[5]
  *font_desc.PangoFontDescription
  color_flags.l[5]
  fg.GdkColor[5]
  bg.GdkColor[5]
  text.GdkColor[5]
  base.GdkColor[5]
  xthickness.l
  ythickness.l
  *rc_properties.GArray
  *rc_style_lists.GSList
  *icon_factories.GSList
  PackedFlags.l
EndStructure

Posted: Wed Jul 18, 2007 1:45 pm
by Progi1984
Question 1:
ts-soft : Sorry to worry you again :
Can you give the declaration of :

Code: Select all

-GObject 
-PangoFontDescription 
-GdkColor
-GArray 
-GSList 
Thank you for advance :)

Posted: Wed Jul 18, 2007 2:17 pm
by freak
Progi1984:

Just copy the gtk related resident files from the Linux Version of PB to Windows.
They should work there as well.

Posted: Wed Jul 18, 2007 3:06 pm
by Progi1984
With the freak solution (very good solution : Thanks for it !),
The question #1 & #2 are solved. But the question #3 is always in stand by.

Question 3 :
New Question : I load an image (always under Windows) with LoadImage. How can i draw this image in a GtkImage ?
Or How can I transform a hBitmap in GdkPixmap ?

Posted: Mon Aug 06, 2007 8:09 am
by Progi1984
Question #4 : Question for Fred or Freak, which techniques do you use to position and size gadgets in your windows : gtkfixed, gtktable, gtkbox, others ?