Skip to content

Commit

Permalink
sample: Handle own titlebuttons (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryonakano authored Sep 20, 2024
1 parent e267beb commit d184188
Showing 1 changed file with 13 additions and 4 deletions.
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

0 comments on commit d184188

Please sign in to comment.