www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - GTKD - get CSS class for button

reply TheDGuy <a.b gmail.de> writes:
Hello,
i would like to know if it possible to get the CSS-class which is 
asigned to a button (for example)? I didn't find any 
documentation about this, just the function 
"getStyleContext().getProperty()", my current attempt:

Value value;
bArr[0].getStyleContext().getProperty("Class",StateFlags.NORMAL,value);


(bArr is an array of buttons).

I get the error, that 'Value' is not defined, if i use 'GValue' 
(as it is described here: 
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-c
ntext-get-property) i get 'function is not callable with GValue'

Any ideas? Thanks alot!
Jun 22 2016
parent reply Gerald <gerald.b.nunn gmail.com> writes:
On Wednesday, 22 June 2016 at 08:08:20 UTC, TheDGuy wrote:
 Hello,
 i would like to know if it possible to get the CSS-class which 
 is asigned to a button (for example)? I didn't find any 
 documentation about this, just the function 
 "getStyleContext().getProperty()", my current attempt:

 Value value;
 bArr[0].getStyleContext().getProperty("Class",StateFlags.NORMAL,value);


 (bArr is an array of buttons).

 I get the error, that 'Value' is not defined, if i use 'GValue' 
 (as it is described here: 
 https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-c
ntext-get-property) i get 'function is not callable with GValue'

 Any ideas? Thanks alot!
widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass()
Jun 22 2016
parent reply TheDGuy <a.b gmail.de> writes:
 widget.getStyleContext().listClasses() to get a list of all 
 classes assigned to the widget. If you just want to see if a 
 specific class is assigned to the widget you can use 
 widget.getStyleContext().hasClass()
Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized.
Jun 22 2016
parent reply Gerald <gerald.b.nunn gmail.com> writes:
On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote:
 widget.getStyleContext().listClasses() to get a list of all 
 classes assigned to the widget. If you just want to see if a 
 specific class is assigned to the widget you can use 
 widget.getStyleContext().hasClass()
Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized.
ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html
Jun 22 2016
parent reply TheDGuy <a.b gmail.de> writes:
On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote:
 On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote:
 widget.getStyleContext().listClasses() to get a list of all 
 classes assigned to the widget. If you just want to see if a 
 specific class is assigned to the widget you can use 
 widget.getStyleContext().hasClass()
Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized.
ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html
"Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or 'T' is, i am afraid.
Jun 22 2016
parent reply Mike Wey <mike-wey example.com> writes:
On 06/22/2016 05:16 PM, TheDGuy wrote:
 On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote:
 On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote:
 widget.getStyleContext().listClasses() to get a list of all classes
 assigned to the widget. If you just want to see if a specific class
 is assigned to the widget you can use
 widget.getStyleContext().hasClass()
Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized.
ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html
"Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or 'T' is, i am afraid.
toArray currently only works for GtkD classes, so it doesn't work for lists of stings. ListG is a linked list, the data is stored in the data property. to iterate over the list do something like this: ``` ListG list = widget.getStyleContext().listClasses(); while(list !is null) { string str = to!string(cast(char*)list.data); //do something with str. list = list.next; } ``` -- Mike Wey
Jun 22 2016
parent TheDGuy <a.b gmail.de> writes:
On Wednesday, 22 June 2016 at 17:50:53 UTC, Mike Wey wrote:
 "Type T wraps should match the type of the data"

 Does string match the type of the data? What is the type of 
 the data?
 How do i tell the function that i want the Array as a string 
 array? I am
 not familiar with Types and what 'TC' or 'T' is, i am afraid.
toArray currently only works for GtkD classes, so it doesn't work for lists of stings. ListG is a linked list, the data is stored in the data property. to iterate over the list do something like this: ``` ListG list = widget.getStyleContext().listClasses(); while(list !is null) { string str = to!string(cast(char*)list.data); //do something with str. list = list.next; } ```
Thanks alot! Works perfectly!
Jun 22 2016