I am trying to create a custom GTK Widget by subclassing Gtk.Bin. I am not using the Stetic GUI builder. This widget will contain several standard Gtk widgets (VBoxs, Labels, Buttons, etc).
public class MyWidget : Gtk.Bin
{
public MyWidget : base ()
{
build ();
}
private void build ()
{
VBox vbox1 = new Vbox (true, 0);
vbox1.PackStart (new Label ("MyWidget"), true, true, 0);
this.Add (vbox1);
}
}
Meanwhile when I add my custom widget to the main window, I don't see anything. The windows other controls show up, space is allocated for this custom widget. I expect to see the label "MyWidget" in its space, but nothing shows up. I step thru the code in the debugger and it all gets called but its a no show at runtime.
Any help would be appreciated.
To create a GTK3 theme, developers can start with an empty file or they can use a pre-existing theme as a template. It may help beginners to start with a pre-existing theme. For instance, a theme can be copied to the user's home folder and then the developer can start editing the files.
Enabling Custom GNOME Shell ThemesEnable the “User Themes” extension, as shown in the screenshot below. Be sure that the “Extensions” toggle is enabled at the top. Once you are finished with this step, close and relaunch the Tweaks app. Now, you will be able to change the GS theme from the “Appearance” tab.
need to override:
protected override void OnSizeAllocated (Gdk.Rectangle allocation)
{
if (this.Child != null)
{
this.Child.Allocation = allocation;
}
}
protected override void OnSizeRequested (ref Requisition requisition)
{
if (this.Child != null)
{
requisition = this.Child.SizeRequest ();
}
}
Or probably more likely, ShowAll () as the last line in the build method after all children are packed in, unless you don't want some of them to be visible by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With