Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion demo/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Application : Gtk.Application {
});

var window = new MainWindow (this);
window.show_all ();
window.present ();
}

public static int main (string[] args) {
Expand Down
41 changes: 23 additions & 18 deletions demo/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MainWindow : Gtk.ApplicationWindow {
private Gtk.Entry body_entry;
private Gtk.Entry icon_entry;
private Gtk.Entry id_entry;
private Gtk.ComboBoxText priority_combobox;
private Gtk.DropDown priority_dropdown;
private Gtk.SpinButton action_spinbutton;

public MainWindow (Gtk.Application application) {
Expand Down Expand Up @@ -60,51 +60,56 @@ public class MainWindow : Gtk.ApplicationWindow {

var priority_label = new Gtk.Label ("Priority:");

priority_combobox = new Gtk.ComboBoxText () {
hexpand = true
string[] priorities = {
"Low",
"Normal",
"High",
"Urgent",
};
priority_dropdown = new Gtk.DropDown.from_strings (priorities) {
hexpand = true,
selected = 1
};
priority_combobox.append_text ("Low");
priority_combobox.append_text ("Normal");
priority_combobox.append_text ("High");
priority_combobox.append_text ("Urgent");
priority_combobox.set_active (1);

var action_label = new Gtk.Label ("Actions:");

action_spinbutton = new Gtk.SpinButton.with_range (0, 3, 1);

var send_button = new Gtk.Button.with_label ("Send Notification") {
can_default = true,
halign = Gtk.Align.END,
margin_top = 12
};
send_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
send_button.add_css_class (Granite.CssClass.SUGGESTED);

var grid = new Gtk.Grid () {
valign = Gtk.Align.CENTER,
column_spacing = 12,
row_spacing = 12,
margin = 12
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};
grid.attach (title_entry, 0, 0, 2);
grid.attach (body_entry, 0, 1, 2);
grid.attach (id_entry, 0, 2, 2);
grid.attach (icon_entry, 0, 3, 2);
grid.attach (priority_label, 0, 4);
grid.attach (priority_combobox, 1, 4);
grid.attach (priority_dropdown, 1, 4);
grid.attach (action_label, 0, 5);
grid.attach (action_spinbutton, 1, 5);
grid.attach (send_button, 0, 6, 2);

var toast = new Granite.Widgets.Toast ("");
var toast = new Granite.Toast ("");

var overlay = new Gtk.Overlay ();
overlay.add (grid);
var overlay = new Gtk.Overlay () {
child = grid
};
overlay.add_overlay (toast);

add (overlay);
child = overlay;
default_widget = send_button;

send_button.has_default = true;
send_button.clicked.connect (send_notification);

var toast_action = new SimpleAction ("toast", VariantType.STRING);
Expand All @@ -119,7 +124,7 @@ public class MainWindow : Gtk.ApplicationWindow {

private void send_notification () {
NotificationPriority priority;
switch (priority_combobox.active) {
switch (priority_dropdown.selected) {
case 3:
priority = NotificationPriority.URGENT;
break;
Expand Down
4 changes: 2 additions & 2 deletions demo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ executable(
'Application.vala',
'MainWindow.vala',
dependencies : [
dependency ('granite'),
dependency ('gtk+-3.0'),
dependency ('granite-7', version: '>=7.7.0'),
dependency ('gtk4'),
],
install : true
)
Expand Down