Re: [Vala] C# developer, newbie question

2018-12-19 Thread Wolfgang Mauer

Thanks, but same result, does it work that way at all?

GLib-GObject-CRITICAL **: 23:22:53.584: g_enum_get_value_by_name: 
assertion 'G_IS_ENUM_CLASS (enum_class)' failed


EnumClass enumc = (EnumClass)typeof(Gdk.WindowState).class_ref ();
var state = (Gdk.WindowState)enumc.get_value_by_name("FOCUSED").value;


I think it is better and easier to use int and string instead of enum

var val = ((int)get_window().get_state()).to_string();
.
var state = (Gdk.WindowState)int.parse(val);


Am 19.12.18 um 22:51 schrieb Andy Lees:
I believe it's because the string produced in your first assignment to 
strState is the C transformed enum value which concatenates the type 
and value with an "_".  It does this to map the nested name space of 
Vala enums into the flat C name space.  You would need to remove the 
type + "_" from the returned string to create the associated enum value.


On Wed, Dec 19, 2018 at 10:28 PM Wolfgang Mauer 
mailto:wolfgang.ma...@kabelmail.de>> wrote:


Hi all,
i try to put a enum to string and back, with no success.

var strState = get_window().get_state().to_string(); <--
"GDK_WINDOW_STATE_FOCUSED"

and back dont work

EnumClass enumc = (EnumClass)typeof(Gdk.WindowState).class_ref ();
var state = (Gdk.WindowState)enumc.get_value_by_name(strState).value;

What im doing wrong?

Thanks for help

Wolfgang


___
vala-list mailing list
vala-list@gnome.org 
https://mail.gnome.org/mailman/listinfo/vala-list


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] C# developer, newbie question

2018-12-19 Thread Andy Lees via vala-list
I believe it's because the string produced in your first assignment to
strState is the C transformed enum value which concatenates the type and
value with an "_".  It does this to map the nested name space of Vala enums
into the flat C name space.  You would need to remove the type + "_" from
the returned string to create the associated enum value.

On Wed, Dec 19, 2018 at 10:28 PM Wolfgang Mauer 
wrote:

> Hi all,
> i try to put a enum to string and back, with no success.
>
> var strState = get_window().get_state().to_string(); <--
> "GDK_WINDOW_STATE_FOCUSED"
>
> and back dont work
>
> EnumClass enumc = (EnumClass)typeof(Gdk.WindowState).class_ref ();
> var state = (Gdk.WindowState)enumc.get_value_by_name(strState).value;
>
> What im doing wrong?
>
> Thanks for help
>
> Wolfgang
>
>
> ___
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] C# developer, newbie question

2018-12-19 Thread Wolfgang Mauer

Hi all,
i try to put a enum to string and back, with no success.

var strState = get_window().get_state().to_string(); <-- 
"GDK_WINDOW_STATE_FOCUSED"


and back dont work

EnumClass enumc = (EnumClass)typeof(Gdk.WindowState).class_ref ();
var state = (Gdk.WindowState)enumc.get_value_by_name(strState).value;

What im doing wrong?

Thanks for help

Wolfgang


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] C# developer, newbie question

2018-12-19 Thread Wolfgang Mauer

Hi all,
i try to put a enum to string and back, with no success.

var strState = get_window().get_state().to_string(); <-- 
"GDK_WINDOW_STATE_FOCUSED"


and back dont work

EnumClass enumc = (EnumClass)typeof(Gdk.WindowState).class_ref ();
var state = (Gdk.WindowState)enumc.get_value_by_name(strState).value;

What im doing wrong?

Thanks for help
Wolfgang

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list