[Gtk-sharp-list] Gtk.Builder & Autoconnect

Baltasar GarcĂ­a Perez-Schofield baltasarq at gmail.com
Wed Jan 18 11:58:23 UTC 2017


Hi, Sascha,

> i've written a new GUI for my program with Glade and Gtk.Builder.
>
Err... why? Nevermind.

> Actually i'm having that constructors:
>
> public static PublicanCreators Create()
> {
>     Builder builder = new Builder();
>     builder.AddFromFile("gui.glade");
>     return new PublicanCreators(builder, builder.GetObject("PublicanCreators").Handle);
> }protected PublicanCreators(Builder builder, IntPtr handle) : base(handle){
>     _builder = builder;
>     builder.Autoconnect(this);
>     SetupHandlers();}
>
> I don't have much experience with Glade 3, and Gtk 3. Glade 3 uses Gtk+ 3,
while Gtk# uses Gtk+2, so at first glance, they are incompatible.

I've found this answer in stack overflow:
http://stackoverflow.com/questions/15599497/how-do-i-use-gtk-builder-in-c-sharp#19352159

They seem to be able to build a user interface using both methods: with
Gtk.Builder, and with libglade (Glade.XML).

I've tried both. Using the libglade method, I was able to make the program
compile and run, even with the glade XML file as a resource (this is a must
to me).

==
public Ppal()
{
    Gtk.Application.Init();
    var uiInterface =
        new Glade.XML( "GladeTest.Res.glade_test-ui.glade", "AppWindow" );
    uiInterface.Autoconnect( this );
    Gtk.Application.Run();
}
==

Unfortunately, nothing shows on screen. I double-checked that the GtkWindow
had the Visible property set to true. Then I checked the output, to find:
==
(GladeTest:7658): libglade-WARNING **: Expected <glade-interface>.  Got
<interface>.

(GladeTest:7658): libglade-WARNING **: did not finish in PARSER_FINISH
state!

(GladeTest:7658): libglade-CRITICAL **: glade_xml_get_widget: assertion
'self != NULL' failed

(GladeTest:7658): libglade-CRITICAL **: glade_xml_signal_autoconnect_full:
assertion 'self != NULL' failed
==

It seems that the XML format generated by Glade is not the expected by
libglade.

So libglade does not work... what about Gtk.Builder? The same app, with the
same user interface generated by Glade.

==
public Ppal()
{
    Gtk.Application.Init();
    var guiBuilder = new Gtk.Builder();
    StreamReader uiFile = new StreamReader(
        System.Reflection.Assembly.GetEntryAssembly().
        GetManifestResourceStream( "GladeTest.Res.glade_test-ui.glade" ) );

    guiBuilder.AddFromString( uiFile.ReadToEnd() );
*    // ERROR autoconnect does not exist *

*    //guiBuilder.Autoconnect( this );*
    Gtk.Application.Run();
}
==

The problem with Builder is twofold: a) there is not an "autoconnect"
method, and b) (and most important) the execution fails while executing
AddFromString(), with a Glib.GException with message "<input>: required
gtk+ version 3.0, current version is 2.24"

This is actually the problem I had foreseen, they are not compatible since
Gtk# is stuck in Gtk+2. It requires gtk+3.0 because I messed with the
settings, by default it requires gtk+3.20.

Maybe someone can provide more info about this issue, perhaps a workaround
or something. I'm using Mono 4.6.2.

-- Baltasar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: twitter.png
Type: image/png
Size: 1418 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spacer.gif
Type: image/gif
Size: 1097 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: facebook.png
Type: image/png
Size: 956 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkedin.png
Type: image/png
Size: 1141 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: skype.png
Type: image/png
Size: 1632 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: github.png
Type: image/png
Size: 2345 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xing.png
Type: image/png
Size: 2636 bytes
Desc: not available
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170118/8bd70859/attachment-0011.png>


More information about the Gtk-sharp-list mailing list