switch to aur tab if there is no result in repos and fix search an already selected term
This commit is contained in:
parent
1984420add
commit
552257c491
@ -1020,7 +1020,6 @@ namespace Pamac {
|
|||||||
refresh_packages_list ();
|
refresh_packages_list ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async void search_in_aur (string search_string) {
|
public async void search_in_aur (string search_string) {
|
||||||
if (!aur_search_results.contains (search_string)) {
|
if (!aur_search_results.contains (search_string)) {
|
||||||
Json.Array results = AUR.search (search_string.split (" "));
|
Json.Array results = AUR.search (search_string.split (" "));
|
||||||
@ -1030,7 +1029,30 @@ namespace Pamac {
|
|||||||
|
|
||||||
[GtkCallback]
|
[GtkCallback]
|
||||||
public void on_packages_notebook_switch_page (Gtk.Widget page, uint page_num) {
|
public void on_packages_notebook_switch_page (Gtk.Widget page, uint page_num) {
|
||||||
refresh_packages_list ();
|
Gtk.TreeModel model;
|
||||||
|
Gtk.TreeIter? iter;
|
||||||
|
Gtk.TreeSelection selection = search_treeview.get_selection ();
|
||||||
|
if (selection.get_selected (out model, out iter)) {
|
||||||
|
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||||
|
GLib.Value val;
|
||||||
|
model.get_value (iter, 0, out val);
|
||||||
|
string search_string = val.get_string ();
|
||||||
|
switch (packages_notebook.get_current_page ()) {
|
||||||
|
case 0:
|
||||||
|
search_all_dbs.begin (search_string, (obj, res) => {
|
||||||
|
var pkgs = search_all_dbs.end (res);
|
||||||
|
populate_packages_list ((owned) pkgs);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
search_in_aur.begin (search_string, (obj, res) => {
|
||||||
|
populate_aur_list (aur_search_results.lookup (search_string));
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[GtkCallback]
|
[GtkCallback]
|
||||||
@ -1326,10 +1348,22 @@ namespace Pamac {
|
|||||||
unowned string search_string = search_entry.get_text ();
|
unowned string search_string = search_entry.get_text ();
|
||||||
if (search_string != "") {
|
if (search_string != "") {
|
||||||
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||||
|
Gtk.TreeModel model;
|
||||||
|
Gtk.TreeIter? iter;
|
||||||
Gtk.TreeSelection selection = search_treeview.get_selection ();
|
Gtk.TreeSelection selection = search_treeview.get_selection ();
|
||||||
// add search string in search_list if needed
|
// add search string in search_list if needed
|
||||||
bool found = false;
|
bool found = false;
|
||||||
// check if search string is already selected in search list
|
// check if search string is already selected in search list
|
||||||
|
if (selection.get_selected (out model, out iter)) {
|
||||||
|
GLib.Value selected_string;
|
||||||
|
model.get_value (iter, 0, out selected_string);
|
||||||
|
if ((string) selected_string == search_string) {
|
||||||
|
on_search_treeview_selection_changed ();
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if search string exists in search list
|
||||||
|
if (!found) {
|
||||||
search_list.foreach ((_model, _path, _iter) => {
|
search_list.foreach ((_model, _path, _iter) => {
|
||||||
GLib.Value line;
|
GLib.Value line;
|
||||||
_model.get_value (_iter, 0, out line);
|
_model.get_value (_iter, 0, out line);
|
||||||
@ -1341,8 +1375,9 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
Gtk.TreeIter? iter;
|
|
||||||
search_list.insert_with_values (out iter, -1, 0, search_string);
|
search_list.insert_with_values (out iter, -1, 0, search_string);
|
||||||
// we select the iter in search_list
|
// we select the iter in search_list
|
||||||
// it will populate the list with the selection changed signal
|
// it will populate the list with the selection changed signal
|
||||||
@ -1352,7 +1387,7 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[GtkCallback]
|
[GtkCallback]
|
||||||
public void on_search_entry_icon_press (Gtk.EntryIconPosition p0, Gdk.Event? p1) {
|
public void on_search_entry_icon_press () {
|
||||||
on_search_entry_activate ();
|
on_search_entry_activate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1371,10 +1406,21 @@ namespace Pamac {
|
|||||||
search_all_dbs.begin (search_string, (obj, res) => {
|
search_all_dbs.begin (search_string, (obj, res) => {
|
||||||
var pkgs = search_all_dbs.end (res);
|
var pkgs = search_all_dbs.end (res);
|
||||||
if (search_aur_button.get_active ()) {
|
if (search_aur_button.get_active ()) {
|
||||||
search_in_aur.begin (search_string);
|
search_in_aur.begin (search_string, (obj, res) => {
|
||||||
|
if (pkgs.length == 0) {
|
||||||
|
if (aur_search_results.lookup (search_string) != null) {
|
||||||
|
packages_notebook.set_current_page (1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (aur_search_results.lookup (search_string) != null) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
populate_packages_list ((owned) pkgs);
|
populate_packages_list ((owned) pkgs);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
populate_packages_list ((owned) pkgs);
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
search_in_aur.begin (search_string, (obj, res) => {
|
search_in_aur.begin (search_string, (obj, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user