I have a problem, I want to use the header bar as the titlebar in gtk#, but here is the error that was created:
error CS1061: 'Window' does not contain a definition for 'gtk_window_set_titlebar' and no accessible extension method 'gtk_window_set_titlebar' accepting a first argument of type 'Window' could be found (are you missing a using directive or an assembly reference?)
This is the gtk# that I used: GTK#
And here is my code:
namespace gtkapp
{
class MainWindow : Window
{
private int _counter = 0;
static private int _max = 1000;
[UI] private Label _label1 = null;
[UI] private Label _label2 = null;
[UI] private Button _button1 = null;
[UI] private Button _button2 = null;
[UI] private LevelBar lb = new LevelBar(0, _max);
[UI] private HeaderBar _headerbar = null;
[UI] private Window MainWindoww = null;
public MainWindow() : this(new Builder("MainWindow.glade")) { }
private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow"))
{
builder.Autoconnect(this);
MainWindoww.gtk_window_set_titlebar(MainWindoww, _headerbar);
DeleteEvent += Window_DeleteEvent;
_button1.Clicked += Button1_Clicked;
_button2.Clicked += Button2_Clicked;
_headerbar.Title = "GTK clicker";
Decorated = false;
lb.Value = 0;
lb.MaxValue = 1000000;
}
private void Window_DeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
}
private void Button1_Clicked(object sender, EventArgs a)
{
_counter++;
// _counter += 100;
lb.Value += 10;
lb.MaxValue += 1;
if(lb.Value < _max)
{
_label1.Text = "This GTK button has been clicked " + _counter + " time(s).";
}
else if(lb.Value >= _max)
{
_label1.Text = "This GTK button has been clicked for the " + _counter + " time(s).";
}
}
private void Button2_Clicked(object sender, EventArgs a)
{
Application.Quit();
}
}
}
Something equivalent of gtk_window_set_titlebar()
Solution that I found from a comment.
use this.Titlebar = (the variable of the header bar, my variable name is _headerbar); Decotated = false;
The order must be above or it will not work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.