From bbd83ded9531869dc7f09c8b5d272970c75e5078 Mon Sep 17 00:00:00 2001 From: guinux Date: Sat, 9 Sep 2017 15:19:18 +0200 Subject: [PATCH] add a select all button --- po/pamac.pot | 4 +++ resources/manager_window.ui | 52 +++++++++++++++++++++++++++---------- src/manager_window.vala | 44 ++++++++++++++++++++++++++++++- 3 files changed, 86 insertions(+), 14 deletions(-) diff --git a/po/pamac.pot b/po/pamac.pot index d8345f0..47832bb 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -710,6 +710,10 @@ msgstr "" msgid "_Apply" msgstr "" +#: ../resources/manager_window.ui +msgid "Select All" +msgstr "" + #: ../resources/preferences_dialog.ui msgid "Remove unrequired dependencies" msgstr "" diff --git a/resources/manager_window.ui b/resources/manager_window.ui index 8c38e5f..c8bbd03 100644 --- a/resources/manager_window.ui +++ b/resources/manager_window.ui @@ -1153,23 +1153,49 @@ False True - + True - True - False - start - + False + 3 - + True - False - go-previous-symbolic - 1 + True + False + start + + + + True + False + go-previous-symbolic + 1 + + + + + False + True + 0 + + + + + Select All + True + True + True + + + + False + True + 1 + - @@ -1181,7 +1207,7 @@ - + True False 3 diff --git a/src/manager_window.vala b/src/manager_window.vala index ed4f175..acc3166 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -55,6 +55,8 @@ namespace Pamac { [GtkChild] Gtk.Button button_back; [GtkChild] + Gtk.Button select_all_button; + [GtkChild] Gtk.ModelButton preferences_button; [GtkChild] Gtk.TreeView packages_treeview; @@ -434,6 +436,7 @@ namespace Pamac { } void set_pendings_operations () { + refresh_state_icons (); if (!transaction_running && !generate_mirrors_list && !refreshing && !sysupgrade_running) { if (filters_stack.visible_child_name == "updates") { uint64 total_dsize = 0; @@ -1051,8 +1054,11 @@ namespace Pamac { origin_stack.visible_child_name = "no_item"; packages_treeview.thaw_child_notify (); packages_treeview.thaw_notify (); + select_all_button.visible = false; this.get_window ().set_cursor (null); return; + } else { + select_all_button.visible = true; } foreach (unowned AlpmPackage pkg in pkgs) { string version; @@ -1122,8 +1128,11 @@ namespace Pamac { origin_stack.visible_child_name = "no_item"; aur_treeview.thaw_child_notify (); aur_treeview.thaw_notify (); + select_all_button.visible = false; this.get_window ().set_cursor (null); return; + } else { + select_all_button.visible = true; } foreach (unowned AURPackage aur_pkg in pkgs) { string version; @@ -1222,6 +1231,7 @@ namespace Pamac { hide_sidebar (); packages_list.clear (); aur_list.clear (); + select_all_button.visible = false; var attention_val = GLib.Value (typeof (bool)); attention_val.set_boolean (false); filters_stack.child_set_property (filters_stack.get_child_by_name ("updates"), @@ -1421,7 +1431,6 @@ namespace Pamac { } } } - packages_treeview.queue_draw (); set_pendings_operations (); } @@ -1627,6 +1636,15 @@ namespace Pamac { } } + [GtkCallback] + void on_select_all_button_clicked () { + if (origin_stack.visible_child_name == "repos") { + packages_treeview.get_selection ().select_all (); + } else if (origin_stack.visible_child_name == "aur") { + aur_treeview.get_selection ().select_all (); + } + } + [GtkCallback] bool on_packages_treeview_button_press_event (Gdk.EventButton event) { // Check if right mouse button was clicked @@ -2005,11 +2023,13 @@ namespace Pamac { if (filters_stack.visible_child_name == "search") { search_button.activate (); } + select_all_button.visible = true; filters_stackswitcher.visible = true; details_button.sensitive = true; break; case "details": button_back.visible = true; + select_all_button.visible = false; searchbar.search_mode_enabled = false; search_button.active = false; search_button.visible = false; @@ -2018,6 +2038,7 @@ namespace Pamac { break; case "term": button_back.visible = true; + select_all_button.visible = false; searchbar.search_mode_enabled = false; search_button.active = false; search_button.visible = false; @@ -2170,12 +2191,27 @@ namespace Pamac { } } + bool refresh_row (Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter) { + model.row_changed (path, iter); + return false; + } + + void refresh_state_icons () { + packages_list.foreach (refresh_row); + aur_list.foreach (refresh_row); + } + void run_transaction () { transaction_running = true; apply_button.sensitive = false; cancel_button.sensitive = false; show_transaction_infobox (); transaction.run (); + // let time to update packages states + Timeout.add (500, () => { + refresh_state_icons (); + return false; + }); } void run_sysupgrade () { @@ -2183,6 +2219,11 @@ namespace Pamac { apply_button.sensitive = false; cancel_button.sensitive = false; transaction.sysupgrade (false); + // let time to update packages states + Timeout.add (500, () => { + refresh_state_icons (); + return false; + }); } [GtkCallback] @@ -2284,6 +2325,7 @@ namespace Pamac { } else if (origin_stack.visible_child_name == "aur") { populate_aur_list (aur_updates); } + select_all_button.visible = true; set_pendings_operations (); } }