Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
remove Toasts and subsequent use
temporarily disable closeDatabase function for checker
use sqlite databse
  • Loading branch information
BharatAtbrat committed Oct 9, 2024
1 parent af231fd commit 4f368bd
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 81 deletions.
130 changes: 64 additions & 66 deletions src/Database/main.blp
Original file line number Diff line number Diff line change
@@ -1,96 +1,94 @@
using Gtk 4.0;
using Adw 1;

Adw.ToastOverlay overlay {
Adw.StatusPage {
title: _("Database");
description: _("Search, load and store data in a database");
Adw.StatusPage {
title: _("Database");
description: _("Search, load and store data in a database");

Box {
orientation: vertical;
halign: center;
spacing: 18;

Box {
styles [
"linked"
]

Entry text_entry {
placeholder-text: _("Enter Text");
width-request: 300;
}

Button insert_button {
label: _("Insert");
}
}

Box {
orientation: vertical;
halign: center;
orientation: horizontal;
spacing: 18;

Box {
styles [
"linked"
]
orientation: vertical;
spacing: 12;

Entry text_entry {
placeholder-text: _("Enter Text");
width-request: 300;
Label {
label: _("Search by Text");
}

Button insert_button {
label: _("Insert");
SearchEntry search_entry {
search-delay: 100;
placeholder-text: _("Enter Text");
width-request: 250;
}
}

Box {
orientation: horizontal;
spacing: 18;

Box {
orientation: vertical;
spacing: 12;

Label {
label: _("Search by Text");
}

SearchEntry search_entry {
search-delay: 100;
placeholder-text: _("Enter Text");
width-request: 250;
}
spacing: 12;
orientation: vertical;

Label {
label: _("Search by ID");
}

Box {
spacing: 12;
orientation: vertical;

Label {
label: _("Search by ID");
}

SpinButton id_entry {
halign: center;
orientation: horizontal;
wrap: false;
climb-rate: 1;

adjustment: Adjustment {
step-increment: 1;
value: 0;
};
}
SpinButton id_entry {
halign: center;
orientation: horizontal;
wrap: false;
climb-rate: 1;

adjustment: Adjustment {
step-increment: 1;
value: 0;
};
}
}
}

Frame {
ColumnView column_view {
show-column-separators: true;
Frame {
ColumnView column_view {
show-column-separators: true;

ColumnViewColumn col1 {
title: _("Text");
expand: true;
ColumnViewColumn col1 {
title: _("Text");
expand: true;

factory: SignalListItemFactory {};
}
factory: SignalListItemFactory {};
}

ColumnViewColumn col2 {
title: _("ID");
expand: true;
ColumnViewColumn col2 {
title: _("ID");
expand: true;

factory: SignalListItemFactory {};
}
factory: SignalListItemFactory {};
}
}
}

Label result_label {
wrap: true;
width-request: 250;
}
Label result_label {
wrap: true;
width-request: 250;
}
}
}
18 changes: 3 additions & 15 deletions src/Database/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let adapter, repository;

function initDatabase() {
adapter = new Gom.Adapter();
adapter.open_sync(":memory:");
adapter.open_sync(workbench.resolve("/gom-js-test.db"));
repository = new Gom.Repository({ adapter: adapter });

// Set up table and primary key
Expand All @@ -44,29 +44,20 @@ function initDatabase() {
// Perform automatic migration
repository.automatic_migrate_sync(1, [ItemClass]);
}

/*
function closeDatabase() {
if (adapter) {
adapter.close_sync();
}
}

function showToast(overlay, message) {
const toast = new Adw.Toast({
title: message,
timeout: 2,
});
overlay.add_toast(toast);
}

*/
initDatabase();

const text_entry = workbench.builder.get_object("text_entry");
const id_entry = workbench.builder.get_object("id_entry");
const insert_button = workbench.builder.get_object("insert_button");
const search_entry = workbench.builder.get_object("search_entry");
const result_label = workbench.builder.get_object("result_label");
const overlay = workbench.builder.get_object("overlay");
const data_model = new Gio.ListStore({ item_type: ItemClass });
const column_view = workbench.builder.get_object("column_view");
const col1 = workbench.builder.get_object("col1");
Expand All @@ -79,11 +70,8 @@ insert_button.connect("clicked", () => {
const success = item.save_sync();

if (success) {
showToast(overlay, "Item inserted successfully");
data_model.append(item);
id_entry.set_range(1, ++count);
} else {
showToast(overlay, "Failed to insert item");
}
});

Expand Down

0 comments on commit 4f368bd

Please sign in to comment.