Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample: Handle own titlebuttons #322

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sample/SamplePlug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

public class Sample.Plug : Switchboard.Plug {
private Gtk.Grid main_grid;
private Gtk.Box box;
private Gtk.Label hello_label;

public Plug () {
Expand All @@ -33,13 +33,22 @@ public class Sample.Plug : Switchboard.Plug {
}

public override Gtk.Widget get_widget () {
if (main_grid == null) {
main_grid = new Gtk.Grid ();
if (box == null) {
var headerbar = new Adw.HeaderBar () {
show_title = false
};
headerbar.add_css_class (Granite.STYLE_CLASS_FLAT);

var main_grid = new Gtk.Grid ();
hello_label = new Gtk.Label ("Hello World!");
main_grid.attach (hello_label, 0, 0, 1, 1);

box = new Gtk.Box (VERTICAL, 0);
box.append (headerbar);
box.append (main_grid);
}

return main_grid;
return box;
}

public override void shown () {
Expand Down