forked from cromer/pamac-classic
fix #294
This commit is contained in:
parent
83dedfc08f
commit
cce060f221
@ -361,7 +361,7 @@
|
|||||||
<property name="title" translatable="yes">Name</property>
|
<property name="title" translatable="yes">Name</property>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="clickable">True</property>
|
<property name="clickable">True</property>
|
||||||
<property name="sort_column_id">1</property>
|
<property name="sort_column_id">2</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererPixbuf" id="packages_pixbuf"/>
|
<object class="GtkCellRendererPixbuf" id="packages_pixbuf"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
|
@ -158,6 +158,9 @@ namespace Pamac {
|
|||||||
// liststores
|
// liststores
|
||||||
Gtk.ListStore packages_list;
|
Gtk.ListStore packages_list;
|
||||||
Gtk.ListStore aur_list;
|
Gtk.ListStore aur_list;
|
||||||
|
int sort_column_id;
|
||||||
|
Gtk.SortType sort_order;
|
||||||
|
bool restore_sort_order;
|
||||||
|
|
||||||
public Queue<string> display_package_queue;
|
public Queue<string> display_package_queue;
|
||||||
string current_package_displayed;
|
string current_package_displayed;
|
||||||
@ -231,6 +234,9 @@ namespace Pamac {
|
|||||||
typeof (string), //GLib.format (isize)
|
typeof (string), //GLib.format (isize)
|
||||||
typeof (string), //app_name
|
typeof (string), //app_name
|
||||||
typeof (Gdk.Pixbuf)); //icon
|
typeof (Gdk.Pixbuf)); //icon
|
||||||
|
// sort packages by app_name by default
|
||||||
|
packages_list.set_sort_column_id (2, Gtk.SortType.ASCENDING);
|
||||||
|
restore_sort_order = false;
|
||||||
packages_treeview.set_model (packages_list);
|
packages_treeview.set_model (packages_list);
|
||||||
// add custom cellrenderer to packages_treeview and aur_treewiew
|
// add custom cellrenderer to packages_treeview and aur_treewiew
|
||||||
var packages_state_renderer = new ActivableCellRendererPixbuf ();
|
var packages_state_renderer = new ActivableCellRendererPixbuf ();
|
||||||
@ -1191,6 +1197,20 @@ namespace Pamac {
|
|||||||
this.get_window ().set_cursor (null);
|
this.get_window ().set_cursor (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void save_packages_sort_order () {
|
||||||
|
if (restore_sort_order == false) {
|
||||||
|
packages_list.get_sort_column_id (out sort_column_id, out sort_order);
|
||||||
|
restore_sort_order = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_packages_sort_order () {
|
||||||
|
if (restore_sort_order == true) {
|
||||||
|
packages_list.set_sort_column_id (sort_column_id, sort_order);
|
||||||
|
restore_sort_order = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void refresh_packages_list () {
|
public void refresh_packages_list () {
|
||||||
if (filters_stack.visible_child_name != "search") {
|
if (filters_stack.visible_child_name != "search") {
|
||||||
searchbar.search_mode_enabled = false;
|
searchbar.search_mode_enabled = false;
|
||||||
@ -1205,12 +1225,16 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
switch (filters_stack.visible_child_name) {
|
switch (filters_stack.visible_child_name) {
|
||||||
case "categories":
|
case "categories":
|
||||||
|
restore_packages_sort_order ();
|
||||||
origin_stack.visible_child_name = "repos";
|
origin_stack.visible_child_name = "repos";
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
set_pendings_operations ();
|
set_pendings_operations ();
|
||||||
on_categories_listbox_row_activated (categories_listbox.get_selected_row ());
|
on_categories_listbox_row_activated (categories_listbox.get_selected_row ());
|
||||||
break;
|
break;
|
||||||
case "search":
|
case "search":
|
||||||
|
save_packages_sort_order ();
|
||||||
|
// pkgs are ordered by relevance so keep this
|
||||||
|
packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
|
||||||
if (search_string != null) {
|
if (search_string != null) {
|
||||||
if (transaction.enable_aur) {
|
if (transaction.enable_aur) {
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
@ -1247,24 +1271,30 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "groups":
|
case "groups":
|
||||||
|
restore_packages_sort_order ();
|
||||||
origin_stack.visible_child_name = "repos";
|
origin_stack.visible_child_name = "repos";
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
set_pendings_operations ();
|
set_pendings_operations ();
|
||||||
on_groups_listbox_row_activated (groups_listbox.get_selected_row ());
|
on_groups_listbox_row_activated (groups_listbox.get_selected_row ());
|
||||||
break;
|
break;
|
||||||
case "installed":
|
case "installed":
|
||||||
|
restore_packages_sort_order ();
|
||||||
origin_stack.visible_child_name = "repos";
|
origin_stack.visible_child_name = "repos";
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
set_pendings_operations ();
|
set_pendings_operations ();
|
||||||
on_installed_listbox_row_activated (installed_listbox.get_selected_row ());
|
on_installed_listbox_row_activated (installed_listbox.get_selected_row ());
|
||||||
break;
|
break;
|
||||||
case "repos":
|
case "repos":
|
||||||
|
restore_packages_sort_order ();
|
||||||
origin_stack.visible_child_name = "repos";
|
origin_stack.visible_child_name = "repos";
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
set_pendings_operations ();
|
set_pendings_operations ();
|
||||||
on_repos_listbox_row_activated (repos_listbox.get_selected_row ());
|
on_repos_listbox_row_activated (repos_listbox.get_selected_row ());
|
||||||
break;
|
break;
|
||||||
case "updates":
|
case "updates":
|
||||||
|
save_packages_sort_order ();
|
||||||
|
// order updates by name
|
||||||
|
packages_list.set_sort_column_id (2, Gtk.SortType.ASCENDING);
|
||||||
hide_sidebar ();
|
hide_sidebar ();
|
||||||
packages_list.clear ();
|
packages_list.clear ();
|
||||||
aur_list.clear ();
|
aur_list.clear ();
|
||||||
@ -1279,6 +1309,9 @@ namespace Pamac {
|
|||||||
transaction.start_get_updates ();
|
transaction.start_get_updates ();
|
||||||
break;
|
break;
|
||||||
case "pending":
|
case "pending":
|
||||||
|
save_packages_sort_order ();
|
||||||
|
// order pending by name
|
||||||
|
packages_list.set_sort_column_id (2, Gtk.SortType.ASCENDING);
|
||||||
if (transaction.to_build.length != 0) {
|
if (transaction.to_build.length != 0) {
|
||||||
show_sidebar ();
|
show_sidebar ();
|
||||||
} else {
|
} else {
|
||||||
@ -1620,8 +1653,6 @@ namespace Pamac {
|
|||||||
Gtk.main_iteration ();
|
Gtk.main_iteration ();
|
||||||
}
|
}
|
||||||
transaction.search_pkgs.begin (search_string, (obj, res) => {
|
transaction.search_pkgs.begin (search_string, (obj, res) => {
|
||||||
// get custom sort by relevance
|
|
||||||
packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
|
|
||||||
populate_packages_list (transaction.search_pkgs.end (res));
|
populate_packages_list (transaction.search_pkgs.end (res));
|
||||||
});
|
});
|
||||||
} else if (filters_stack.visible_child_name == "updates") {
|
} else if (filters_stack.visible_child_name == "updates") {
|
||||||
@ -1911,8 +1942,6 @@ namespace Pamac {
|
|||||||
hide_sidebar ();
|
hide_sidebar ();
|
||||||
}
|
}
|
||||||
var pkgs = transaction.search_pkgs.end (res);
|
var pkgs = transaction.search_pkgs.end (res);
|
||||||
// get custom sort by relevance
|
|
||||||
packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
|
|
||||||
populate_packages_list (pkgs);
|
populate_packages_list (pkgs);
|
||||||
});
|
});
|
||||||
aur_list.clear ();
|
aur_list.clear ();
|
||||||
@ -1971,8 +2000,6 @@ namespace Pamac {
|
|||||||
} else if (category == dgettext (null, "System Tools")) {
|
} else if (category == dgettext (null, "System Tools")) {
|
||||||
matching_cat = "System";
|
matching_cat = "System";
|
||||||
}
|
}
|
||||||
// get sort by app_name
|
|
||||||
packages_list.set_sort_column_id (2, Gtk.SortType.ASCENDING);
|
|
||||||
transaction.get_category_pkgs.begin (matching_cat, (obj, res) => {
|
transaction.get_category_pkgs.begin (matching_cat, (obj, res) => {
|
||||||
populate_packages_list (transaction.get_category_pkgs.end (res));
|
populate_packages_list (transaction.get_category_pkgs.end (res));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user