Skip to content

Commit 1f5c098

Browse files
danirabbitzeebok
andauthored
Add ToolBox (#776)
Co-authored-by: Ryan Kornheisl <ryan@skarva.tech>
1 parent b31be11 commit 1f5c098

25 files changed

+166
-39
lines changed

demo/DemoPage.vala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* SPDX-License-Identifier: LGPL-3.0-or-later
44
*/
55

6-
public class DemoPage : Gtk.Box {
6+
public class DemoPage : Granite.ToolBox {
77
public string title { get; set; }
88

9-
public Gtk.Widget content {
9+
public Gtk.Widget child {
1010
set {
1111
scrolled_window.child = value;
1212
}
@@ -32,18 +32,14 @@ public class DemoPage : Gtk.Box {
3232
header_box.append (header_label);
3333
header_box.append (new Gtk.WindowControls (END) { valign = START });
3434

35-
var window_handle = new Gtk.WindowHandle () {
36-
child = header_box
37-
};
35+
add_top_bar (header_box);
3836

3937
scrolled_window = new Gtk.ScrolledWindow () {
4038
hscrollbar_policy = NEVER,
4139
vexpand = true
4240
};
4341

44-
orientation = VERTICAL;
45-
append (window_handle);
46-
append (scrolled_window);
42+
content = scrolled_window;
4743

4844
bind_property ("title", header_label, "label");
4945
}

demo/GraniteDemo.vala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public class Granite.Demo : Gtk.Application {
3636
var dialogs_view = new DialogsView (window);
3737
var application_view = new ApplicationView ();
3838

39-
var main_stack = new Gtk.Stack ();
39+
var main_stack = new Gtk.Stack () {
40+
vhomogeneous = false
41+
};
4042
main_stack.add_titled (placeholder, "placeholder", "Placeholder");
4143
main_stack.add_titled (box_view, "box", "Box");
4244
main_stack.add_titled (lists_view, "lists", "Lists");
@@ -68,9 +70,10 @@ public class Granite.Demo : Gtk.Application {
6870
vexpand = true
6971
};
7072

71-
var start_box = new Gtk.Box (VERTICAL, 0);
72-
start_box.append (start_header);
73-
start_box.append (stack_sidebar);
73+
var start_box = new Granite.ToolBox () {
74+
content = stack_sidebar
75+
};
76+
start_box.add_top_bar (start_header);
7477
start_box.add_css_class (Granite.STYLE_CLASS_SIDEBAR);
7578

7679
var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL) {
@@ -83,7 +86,7 @@ public class Granite.Demo : Gtk.Application {
8386

8487
window.child = paned;
8588
window.set_default_size (900, 600);
86-
window.set_size_request (750, 500);
89+
window.set_size_request (300, 200);
8790
window.titlebar = new Gtk.Grid () { visible = false };
8891
window.title = "Granite Demo";
8992

demo/Views/AccelLabelView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public class AccelLabelView : DemoPage {
5353
grid.attach (popover_label, 0, 1);
5454
grid.attach (popover_button, 1, 1);
5555

56-
content = grid;
56+
child = grid;
5757
}
5858
}

demo/Views/ApplicationView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ApplicationView : DemoPage {
3232
grid.attach (badge_visible_switch, 1, 1);
3333
grid.attach (badge_spin, 2, 1);
3434

35-
content = grid;
35+
child = grid;
3636

3737
progress_visible_switch.bind_property ("active", progress_scale, "sensitive", GLib.BindingFlags.SYNC_CREATE);
3838
badge_visible_switch.bind_property ("active", badge_spin, "sensitive", GLib.BindingFlags.SYNC_CREATE);

demo/Views/BoxView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ public class BoxView : DemoPage {
8787
vbox.append (double_container);
8888
vbox.append (linked_box);
8989

90-
content = vbox;
90+
child = vbox;
9191
}
9292
}

demo/Views/CSSView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,6 @@ public class CSSView : DemoPage {
142142
box.append (error_color_box);
143143
box.append (dimmed_box);
144144

145-
content = box;
145+
child = box;
146146
}
147147
}

demo/Views/ControlsView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ public class ControlsView : DemoPage {
179179
box.append (scale_header);
180180
box.append (scale_box);
181181

182-
content = box;
182+
child = box;
183183
}
184184
}

demo/Views/DateTimePickerView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class DateTimePickerView : DemoPage {
7373
grid.attach (relative_datetime_label, 0, 6);
7474
grid.attach (relative_datetime, 1, 6);
7575

76-
content = grid;
76+
child = grid;
7777
}
7878

7979
private void set_selected_datetime () {

demo/Views/DialogsView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class DialogsView : DemoPage {
3333
};
3434
overlay.add_overlay (toast);
3535

36-
content = overlay;
36+
child = overlay;
3737

3838
dialog_button.clicked.connect (show_dialog);
3939
message_button.clicked.connect (show_message_dialog);

demo/Views/FormView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class FormView : DemoPage {
3333
box.append (username_entry);
3434
box.append (button);
3535

36-
content = box;
36+
child = box;
3737

3838
username_entry.bind_property ("is-valid", button, "sensitive", SYNC_CREATE);
3939
}

0 commit comments

Comments
 (0)