All pastes #333612 Raw Edit

Someone

public text v1 · immutable
#333612 ·published 2007-01-31 00:32 UTC
rendered paste body
            
            // FIXME: This is also seriously LAME. The MinSliderSize property is "protected"
            // according to gtkrange.h, and thus should be exposed and accessible through 
            // this sub-class, but GAPI does not bind protected structure fields. LAME LAME.
            
            [DllImport("libgobject-2.0-0.dll")]
            private static extern void g_type_query(IntPtr type, IntPtr query);
            
            private int min_slider_size_offset = -1;
    
            public int MinSliderSize {
                get { 
                    if(min_slider_size_offset < 0) {
                        IntPtr query = Marshal.AllocHGlobal(5 * IntPtr.Size);
                        g_type_query(Gtk.Widget.GType.Val, query);
                        min_slider_size_offset = (int)Marshal.ReadIntPtr(query, 2 * IntPtr.Size + 4) + IntPtr.Size + 8;
                        Marshal.FreeHGlobal(query);
                    }
                    
                    int size = (int)Marshal.ReadIntPtr(Handle, min_slider_size_offset);
                    Console.WriteLine(size);
                    return size;
                }
            }