add a select all button

This commit is contained in:
guinux 2017-09-09 15:19:18 +02:00
parent 80ea4ea70f
commit bbd83ded95
3 changed files with 86 additions and 14 deletions

View File

@ -710,6 +710,10 @@ msgstr ""
msgid "_Apply" msgid "_Apply"
msgstr "" msgstr ""
#: ../resources/manager_window.ui
msgid "Select All"
msgstr ""
#: ../resources/preferences_dialog.ui #: ../resources/preferences_dialog.ui
msgid "Remove unrequired dependencies" msgid "Remove unrequired dependencies"
msgstr "" msgstr ""

View File

@ -1153,23 +1153,49 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="show_close_button">True</property> <property name="show_close_button">True</property>
<child> <child>
<object class="GtkButton" id="button_back"> <object class="GtkBox" id="header_left_buttonbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">False</property> <property name="spacing">3</property>
<property name="halign">start</property>
<signal name="clicked" handler="on_button_back_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="back_image"> <object class="GtkButton" id="button_back">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="icon_name">go-previous-symbolic</property> <property name="receives_default">False</property>
<property name="icon_size">1</property> <property name="halign">start</property>
<signal name="clicked" handler="on_button_back_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-previous-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="select_all_button">
<property name="label" translatable="yes">Select All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_select_all_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
<style>
<class name="image-button"/>
</style>
</object> </object>
</child> </child>
<child type="title"> <child type="title">
@ -1181,7 +1207,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkBox" id="header_buttonbox"> <object class="GtkBox" id="header_right_buttonbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">3</property> <property name="spacing">3</property>

View File

@ -55,6 +55,8 @@ namespace Pamac {
[GtkChild] [GtkChild]
Gtk.Button button_back; Gtk.Button button_back;
[GtkChild] [GtkChild]
Gtk.Button select_all_button;
[GtkChild]
Gtk.ModelButton preferences_button; Gtk.ModelButton preferences_button;
[GtkChild] [GtkChild]
Gtk.TreeView packages_treeview; Gtk.TreeView packages_treeview;
@ -434,6 +436,7 @@ namespace Pamac {
} }
void set_pendings_operations () { void set_pendings_operations () {
refresh_state_icons ();
if (!transaction_running && !generate_mirrors_list && !refreshing && !sysupgrade_running) { if (!transaction_running && !generate_mirrors_list && !refreshing && !sysupgrade_running) {
if (filters_stack.visible_child_name == "updates") { if (filters_stack.visible_child_name == "updates") {
uint64 total_dsize = 0; uint64 total_dsize = 0;
@ -1051,8 +1054,11 @@ namespace Pamac {
origin_stack.visible_child_name = "no_item"; origin_stack.visible_child_name = "no_item";
packages_treeview.thaw_child_notify (); packages_treeview.thaw_child_notify ();
packages_treeview.thaw_notify (); packages_treeview.thaw_notify ();
select_all_button.visible = false;
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
return; return;
} else {
select_all_button.visible = true;
} }
foreach (unowned AlpmPackage pkg in pkgs) { foreach (unowned AlpmPackage pkg in pkgs) {
string version; string version;
@ -1122,8 +1128,11 @@ namespace Pamac {
origin_stack.visible_child_name = "no_item"; origin_stack.visible_child_name = "no_item";
aur_treeview.thaw_child_notify (); aur_treeview.thaw_child_notify ();
aur_treeview.thaw_notify (); aur_treeview.thaw_notify ();
select_all_button.visible = false;
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
return; return;
} else {
select_all_button.visible = true;
} }
foreach (unowned AURPackage aur_pkg in pkgs) { foreach (unowned AURPackage aur_pkg in pkgs) {
string version; string version;
@ -1222,6 +1231,7 @@ namespace Pamac {
hide_sidebar (); hide_sidebar ();
packages_list.clear (); packages_list.clear ();
aur_list.clear (); aur_list.clear ();
select_all_button.visible = false;
var attention_val = GLib.Value (typeof (bool)); var attention_val = GLib.Value (typeof (bool));
attention_val.set_boolean (false); attention_val.set_boolean (false);
filters_stack.child_set_property (filters_stack.get_child_by_name ("updates"), 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 (); 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] [GtkCallback]
bool on_packages_treeview_button_press_event (Gdk.EventButton event) { bool on_packages_treeview_button_press_event (Gdk.EventButton event) {
// Check if right mouse button was clicked // Check if right mouse button was clicked
@ -2005,11 +2023,13 @@ namespace Pamac {
if (filters_stack.visible_child_name == "search") { if (filters_stack.visible_child_name == "search") {
search_button.activate (); search_button.activate ();
} }
select_all_button.visible = true;
filters_stackswitcher.visible = true; filters_stackswitcher.visible = true;
details_button.sensitive = true; details_button.sensitive = true;
break; break;
case "details": case "details":
button_back.visible = true; button_back.visible = true;
select_all_button.visible = false;
searchbar.search_mode_enabled = false; searchbar.search_mode_enabled = false;
search_button.active = false; search_button.active = false;
search_button.visible = false; search_button.visible = false;
@ -2018,6 +2038,7 @@ namespace Pamac {
break; break;
case "term": case "term":
button_back.visible = true; button_back.visible = true;
select_all_button.visible = false;
searchbar.search_mode_enabled = false; searchbar.search_mode_enabled = false;
search_button.active = false; search_button.active = false;
search_button.visible = 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 () { void run_transaction () {
transaction_running = true; transaction_running = true;
apply_button.sensitive = false; apply_button.sensitive = false;
cancel_button.sensitive = false; cancel_button.sensitive = false;
show_transaction_infobox (); show_transaction_infobox ();
transaction.run (); transaction.run ();
// let time to update packages states
Timeout.add (500, () => {
refresh_state_icons ();
return false;
});
} }
void run_sysupgrade () { void run_sysupgrade () {
@ -2183,6 +2219,11 @@ namespace Pamac {
apply_button.sensitive = false; apply_button.sensitive = false;
cancel_button.sensitive = false; cancel_button.sensitive = false;
transaction.sysupgrade (false); transaction.sysupgrade (false);
// let time to update packages states
Timeout.add (500, () => {
refresh_state_icons ();
return false;
});
} }
[GtkCallback] [GtkCallback]
@ -2284,6 +2325,7 @@ namespace Pamac {
} else if (origin_stack.visible_child_name == "aur") { } else if (origin_stack.visible_child_name == "aur") {
populate_aur_list (aur_updates); populate_aur_list (aur_updates);
} }
select_all_button.visible = true;
set_pendings_operations (); set_pendings_operations ();
} }
} }