This might seem like a simple question. I'm a beginner in Gtk and Vala Programming. I'm a beginner Programmer as well. I started off with Vala Gtk GUI and now I have an undecorated Window that is not draggable. I need to set a custom titlebar-like widget to drag the window. I have read that it is doable and seen it in action using Python, but not Vala.
I want to make the area between Add and Close draggable - it is a Gtk Horizontal box.
I need help in implementing this in Vala. Please Help.
Thanks in Advance.
GTK+ does support client-side decorations, which means that you provide the window decoration instead of the window manager. This is done with gtk_window_set_titlebar()
, which takes an arbitrary GtkWidget to use as the titlebar.
GTK+ provides GtkHeaderBar, a complete titlebar that you can add arbitrary widgets to (in the same way as GtkBox). You may have seen many GNOME programs use them already. Your screenshot looks like a job for GtkHeaderBar, with the Add button packed to the start and the Close button packed to the end. Just set that as the GtkWindow's titlebar and you should be good to go. (You may also need to remove the standard minimize/maximize/close buttons; there's a GtkHeaderBar method for that too.)
Of course, GtkHeaderBar by default looks like standard window manager decorations. You can use CSS to change the appearance, even to the point of changing the appearance of the buttons inside the headerbar (only). Your screenshots in your comments show you have already done that; great job!