GNOME Bugzilla – Bug 675911
pygtkcompat bad flags handling
Last modified: 2012-05-14 11:30:53 UTC
In old pygtk the SHIFT_MASK is gtk.gdk.SHIFT_MASK = <flags GDK_SHIFT_MASK of type GdkModifierType> In new pygobject: Gdk.ModifierType.CONTROL_MASK = <flags GDK_SHIFT_MASK of type GdkModifierType> but current git with pygtkcompat enabled i get: gtk.gdk.SHIFT_MASK = <flags GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK | GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK | GDK_RELEASE_MASK | GDK_MODIFIER_MASK of type GdkModifierType> To workaround this I need to do: Gdk.CONTROL_MASK = Gdk.ModifierType.CONTROL_MASK Seems the _install_enums function in pygtkcompat.py is the one that is assigning the wrong value http://git.gnome.org/browse/pygobject/tree/gi/pygtkcompat.py#n52 Seeing that function if we do: print obj.__flags_values__.items() we get: [(4096, <flags GDK_BUTTON5_MASK of type GdkModifierType>), (1, <flags GDK_SHIFT_MASK of type GdkModifierType>), (2, <flags GDK_LOCK_MASK of type GdkModifierType>), (4, <flags GDK_CONTROL_MASK of type GdkModifierType>), (8192, <flags GDK_MODIFIER_RESERVED_13_MASK of type GdkModifierType>), (8, <flags GDK_MOD1_MASK of type GdkModifierType>), (128, <flags GDK_MOD5_MASK of type GdkModifierType>), (134217728, <flags GDK_HYPER_MASK of type GdkModifierType>), (256, <flags GDK_BUTTON1_MASK of type GdkModifierType>), (16, <flags GDK_MOD2_MASK of type GdkModifierType>), (8388608, <flags GDK_MODIFIER_RESERVED_23_MASK of type GdkModifierType>), (512, <flags GDK_BUTTON2_MASK of type GdkModifierType>), (4194304, <flags GDK_MODIFIER_RESERVED_22_MASK of type GdkModifierType>), (16777216, <flags GDK_MODIFIER_RESERVED_24_MASK of type GdkModifierType>), (524288, <flags GDK_MODIFIER_RESERVED_19_MASK of type GdkModifierType>), (32, <flags GDK_MOD3_MASK of type GdkModifierType>), (131072, <flags GDK_MODIFIER_RESERVED_17_MASK of type GdkModifierType>), (262144, <flags GDK_MODIFIER_RESERVED_18_MASK of type GdkModifierType>), (1024, <flags GDK_BUTTON3_MASK of type GdkModifierType>), (33554432, <flags GDK_MODIFIER_RESERVED_25_MASK of type GdkModifierType>), (16384, <flags GDK_MODIFIER_RESERVED_14_MASK of type GdkModifierType>), (1048576, <flags GDK_MODIFIER_RESERVED_20_MASK of type GdkModifierType>), (32768, <flags GDK_MODIFIER_RESERVED_15_MASK of type GdkModifierType>), (64, <flags GDK_MOD4_MASK of type GdkModifierType>), (2048, <flags GDK_BUTTON4_MASK of type GdkModifierType>), (268435456, <flags GDK_META_MASK of type GdkModifierType>), (67108864, <flags GDK_SUPER_MASK of type GdkModifierType>), (536870912, <flags GDK_MODIFIER_RESERVED_29_MASK of type GdkModifierType>), (2097152, <flags GDK_MODIFIER_RESERVED_21_MASK of type GdkModifierType>), (65536, <flags GDK_MODIFIER_RESERVED_16_MASK of type GdkModifierType>), (1073741824, <flags GDK_RELEASE_MASK of type GdkModifierType>), (1543512063, <flags GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK | GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK | GDK_RELEASE_MASK | GDK_MODIFIER_MASK of type GdkModifierType>)] The flag.value_names of <flags GDK_BUTTON5_MASK of type GdkModifierType> is ['GDK_BUTTON5_MASK'] but when you do it for the last value we get: ['GDK_SHIFT_MASK', 'GDK_LOCK_MASK', 'GDK_CONTROL_MASK', 'GDK_MOD1_MASK', 'GDK_MOD2_MASK', 'GDK_MOD3_MASK', 'GDK_MOD4_MASK', 'GDK_MOD5_MASK', 'GDK_BUTTON1_MASK', 'GDK_BUTTON2_MASK', 'GDK_BUTTON3_MASK', 'GDK_BUTTON4_MASK', 'GDK_BUTTON5_MASK', 'GDK_SUPER_MASK', 'GDK_HYPER_MASK', 'GDK_META_MASK', 'GDK_RELEASE_MASK', 'GDK_MODIFIER_MASK'] and then we override each value by this last flag when we iterate these names.
Created attachment 213891 [details] [review] pygtkcompat: Correctly set flags name The correct value for the name is the last in the flag.value_names list
Thanks for this! Committed to master with a test case.