Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Jun 20, 2024
1 parent 2a8107c commit e3337aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,10 @@ public class AppCenterCore.Package : Object {
}
}

public uint cached_search_prio = 0;
public uint matches_search (string search_term) {
return component.search_matches (search_term);
cached_search_prio = component.search_matches (search_term);
return cached_search_prio;
// if (search_term == "") {
// return true;
// }
Expand Down
2 changes: 1 addition & 1 deletion src/Core/SearchManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AppCenterCore.SearchManager : Object {
var sort_model = new Gtk.SortListModel (filter_model, new Gtk.CustomSorter ((obj1, obj2) => {
var package1 = (Package) obj1;
var package2 = (Package) obj2;
return (int) (package2.matches_search (query) - package1.matches_search (query));
return (int) (package2.cached_search_prio - package1.cached_search_prio);
}));

results = sort_model;
Expand Down
5 changes: 2 additions & 3 deletions src/Views/SearchView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ public class AppCenter.SearchView : Adw.NavigationPage {
});

var list_view = new Gtk.ListView (selection_model, factory) {
single_click_activate = true,
hexpand = true,
vexpand = true
};
// list_box.bind_model (list_store, create_row_from_package);
// list_box.set_placeholder (alert_view);

var scrolled = new Gtk.ScrolledWindow () {
child = list_view,
Expand All @@ -106,7 +105,7 @@ public class AppCenter.SearchView : Adw.NavigationPage {
});

list_view.activate.connect ((index) => {
show_app ((AppCenterCore.Package) list_store.get_item (index));
show_app ((AppCenterCore.Package) search_manager.results.get_item (index));
});

search_entry.search_changed.connect (search);
Expand Down
19 changes: 12 additions & 7 deletions src/Widgets/AppContainers/AbstractPackageRowGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ public abstract class AppCenter.Widgets.AbstractPackageRowGrid : Gtk.Box {
protected Gtk.Label package_name;
protected Gtk.Overlay app_icon_overlay;

private Gtk.Image app_icon;
private Gtk.Image badge_image;

protected AbstractPackageRowGrid (AppCenterCore.Package package) {
Object (package: package);
}

construct {
var app_icon = new Gtk.Image () {
app_icon = new Gtk.Image () {
pixel_size = 48
};

var badge_image = new Gtk.Image () {
badge_image = new Gtk.Image () {
halign = Gtk.Align.END,
valign = Gtk.Align.END,
pixel_size = 24
Expand All @@ -54,6 +57,13 @@ public abstract class AppCenter.Widgets.AbstractPackageRowGrid : Gtk.Box {
show_open = false
};

margin_top = 6;
margin_start = 12;
margin_bottom = 6;
margin_end = 12;
}

protected void update_package (AppCenterCore.Package package) {
var scale_factor = get_scale_factor ();

var plugin_host_package = package.get_plugin_host_package ();
Expand All @@ -70,10 +80,5 @@ public abstract class AppCenter.Widgets.AbstractPackageRowGrid : Gtk.Box {
app_icon_overlay.add_overlay (badge_image);
}
}

margin_top = 6;
margin_start = 12;
margin_bottom = 6;
margin_end = 12;
}
}
2 changes: 2 additions & 0 deletions src/Widgets/AppContainers/ListPackageRowGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@ public class AppCenter.Widgets.ListPackageRowGrid : AbstractPackageRowGrid {
public void bind (AppCenterCore.Package package) {
package_name.label = package.get_name ();
package_summary.label = package.get_summary ();

update_package (package);
}
}

0 comments on commit e3337aa

Please sign in to comment.