pamac-classic/src/manager_window.vala

1635 lines
59 KiB
Vala
Raw Normal View History

2014-10-22 13:44:02 -03:00
/*
* pamac-vala
*
2016-02-02 05:28:07 -03:00
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
2014-10-22 13:44:02 -03:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
2016-04-14 13:19:20 -03:00
class ActivableCellRendererPixbuf : Gtk.CellRendererPixbuf {
public signal void activated (Gtk.TreePath path);
public ActivableCellRendererPixbuf () {
Object ();
this.mode = Gtk.CellRendererMode.ACTIVATABLE;
}
public override bool activate (Gdk.Event event, Gtk.Widget widget, string path, Gdk.Rectangle background_area,
Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
activated (new Gtk.TreePath.from_string (path));
return true;
}
2014-10-22 13:44:02 -03:00
}
[GtkTemplate (ui = "/org/manjaro/pamac/manager/manager_window.ui")]
class ManagerWindow : Gtk.ApplicationWindow {
2014-10-22 13:44:02 -03:00
// icons
Gdk.Pixbuf? installed_icon;
Gdk.Pixbuf? uninstalled_icon;
Gdk.Pixbuf? to_install_icon;
Gdk.Pixbuf? to_reinstall_icon;
Gdk.Pixbuf? to_remove_icon;
Gdk.Pixbuf? installed_locked_icon;
Gdk.Pixbuf? available_locked_icon;
2014-10-22 13:44:02 -03:00
// manager objects
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.Stack main_stack;
2016-02-02 05:28:07 -03:00
[GtkChild]
2016-04-23 15:58:46 -03:00
Gtk.Button button_back;
[GtkChild]
Gtk.ModelButton preferences_button;
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.TreeView packages_treeview;
2016-02-02 05:28:07 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.TreeViewColumn packages_state_column;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.TreeView aur_treeview;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.TreeViewColumn aur_state_column;
2016-02-02 05:28:07 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.Stack filters_stack;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.StackSwitcher filters_stackswitcher;
[GtkChild]
Gtk.SearchEntry search_entry;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.TreeView search_treeview;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.TreeView groups_treeview;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.TreeView states_treeview;
2016-02-02 05:28:07 -03:00
[GtkChild]
Gtk.TreeView repos_treeview;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.Stack packages_stack;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.StackSwitcher packages_stackswitcher;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-05-13 10:44:10 -03:00
Gtk.StackSwitcher properties_stackswitcher;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-05-13 10:44:10 -03:00
Gtk.Grid deps_grid;
2016-04-14 13:19:20 -03:00
[GtkChild]
2016-05-13 10:44:10 -03:00
Gtk.Grid details_grid;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.ScrolledWindow files_scrolledwindow;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.Label name_label;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.Label desc_label;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.Label link_label;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.Label licenses_label;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-05-13 10:44:10 -03:00
Gtk.ToggleButton remove_togglebutton;
[GtkChild]
Gtk.ToggleButton reinstall_togglebutton;
[GtkChild]
Gtk.ToggleButton install_togglebutton;
[GtkChild]
Gtk.TextView files_textview;
2014-10-22 13:44:02 -03:00
[GtkChild]
Gtk.Box search_aur_box;
[GtkChild]
Gtk.Switch search_aur_button;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-04-14 13:19:20 -03:00
Gtk.Box transaction_infobox;
2014-10-22 13:44:02 -03:00
[GtkChild]
2016-05-17 13:11:49 -04:00
Gtk.Button details_button;
2016-04-14 13:19:20 -03:00
[GtkChild]
Gtk.Button apply_button;
2016-04-14 13:19:20 -03:00
[GtkChild]
Gtk.Button cancel_button;
2014-10-22 13:44:02 -03:00
2014-11-16 07:31:44 -03:00
// menu
Gtk.Menu right_click_menu;
Gtk.MenuItem deselect_item;
Gtk.MenuItem install_item;
Gtk.MenuItem remove_item;
2016-05-13 10:44:10 -03:00
Gtk.MenuItem details_item;
2016-04-14 13:19:20 -03:00
GLib.List<string> selected_pkgs;
GLib.List<string> selected_aur;
2014-11-16 07:31:44 -03:00
2016-04-14 13:19:20 -03:00
// liststores
2015-03-04 11:55:36 -03:00
Gtk.ListStore search_list;
Gtk.ListStore groups_list;
Gtk.ListStore states_list;
Gtk.ListStore repos_list;
2016-04-14 13:19:20 -03:00
Gtk.ListStore packages_list;
Gtk.ListStore aur_list;
2014-10-22 13:44:02 -03:00
2016-04-14 13:19:20 -03:00
Queue<string> display_package_queue;
string current_package_displayed;
2014-10-22 13:44:02 -03:00
public Transaction transaction;
bool refreshing;
2016-05-17 13:11:49 -04:00
bool important_details;
bool transaction_running;
bool generate_mirrors_list;
2016-03-11 05:51:45 -03:00
uint search_entry_timeout_id;
2014-10-22 13:44:02 -03:00
public ManagerWindow (Gtk.Application application) {
Object (application: application);
2016-02-04 12:20:50 -03:00
support_aur (false, false);
2016-04-23 15:58:46 -03:00
button_back.visible = false;
transaction_infobox.visible = false;
refreshing = false;
2016-05-17 13:11:49 -04:00
important_details = false;
2016-04-14 13:19:20 -03:00
transaction_running = false;
generate_mirrors_list = false;
2016-02-04 12:20:50 -03:00
Timeout.add (100, populate_window);
}
bool populate_window () {
2016-02-04 12:20:50 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
right_click_menu = new Gtk.Menu ();
deselect_item = new Gtk.MenuItem.with_label (dgettext (null, "Deselect"));
deselect_item.activate.connect (on_deselect_item_activate);
right_click_menu.append (deselect_item);
install_item = new Gtk.MenuItem.with_label (dgettext (null, "Install"));
install_item.activate.connect (on_install_item_activate);
right_click_menu.append (install_item);
remove_item = new Gtk.MenuItem.with_label (dgettext (null, "Remove"));
remove_item.activate.connect (on_remove_item_activate);
right_click_menu.append (remove_item);
2016-02-02 05:28:07 -03:00
var separator_item = new Gtk.SeparatorMenuItem ();
right_click_menu.append (separator_item);
2016-05-13 10:44:10 -03:00
details_item = new Gtk.MenuItem.with_label (dgettext (null, "Details"));
details_item.activate.connect (on_details_item_activate);
right_click_menu.append (details_item);
right_click_menu.show_all ();
2014-10-22 13:44:02 -03:00
search_list = new Gtk.ListStore (1, typeof (string));
search_treeview.set_model (search_list);
groups_list = new Gtk.ListStore (1, typeof (string));
groups_treeview.set_model (groups_list);
states_list = new Gtk.ListStore (1, typeof (string));
states_treeview.set_model (states_list);
repos_list = new Gtk.ListStore (1, typeof (string));
repos_treeview.set_model (repos_list);
2016-04-14 13:19:20 -03:00
packages_list = new Gtk.ListStore (7,
typeof (uint), //origin
typeof (string), //name
typeof (string), //name+desc
typeof (string), //version
typeof (string), //repo
typeof (uint64), //isize
typeof (string)); //GLib.format (isize)
packages_treeview.set_model (packages_list);
// add custom cellrenderer to packages_treeview and aur_treewiew
var packages_state_renderer = new ActivableCellRendererPixbuf ();
packages_state_column.pack_start (packages_state_renderer, false);
2016-04-14 13:19:20 -03:00
packages_state_column.set_cell_data_func (packages_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
Gdk.Pixbuf pixbuf;
uint origin;
string pkgname;
treemodel.get (treeiter, 0, out origin, 1, out pkgname);
if (origin == 2 ) { //origin == Alpm.Package.From.LOCALDB)
if (unlikely (transaction.transaction_summary.contains (pkgname))) {
pixbuf = installed_locked_icon;
} else if (unlikely (transaction.should_hold (pkgname))) {
pixbuf = installed_locked_icon;
} else if (unlikely (transaction.to_install.contains (pkgname))) {
pixbuf = to_reinstall_icon;
} else if (unlikely (transaction.to_remove.contains (pkgname))) {
pixbuf = to_remove_icon;
} else {
pixbuf = installed_icon;
}
} else if (unlikely (transaction.transaction_summary.contains (pkgname))) {
pixbuf = available_locked_icon;
} else if (unlikely (transaction.to_install.contains (pkgname))) {
pixbuf = to_install_icon;
} else {
pixbuf = uninstalled_icon;
}
cellrenderer.set ("pixbuf", pixbuf);
});
packages_state_renderer.activated.connect (on_packages_state_icon_activated);
aur_list = new Gtk.ListStore (6,
typeof (uint), //origin
typeof (string), //name
typeof (string), //name+desc
typeof (string), //version
typeof (double), //popularity
typeof (string)); //populariy to string
// sort packages by popularity by default
aur_list.set_sort_column_id (4, Gtk.SortType.DESCENDING);
aur_treeview.set_model (aur_list);
// add custom cellrenderer to aur_treewiew
var aur_state_renderer = new ActivableCellRendererPixbuf ();
aur_state_column.pack_start (aur_state_renderer, false);
2016-04-14 13:19:20 -03:00
aur_state_column.set_cell_data_func (aur_state_renderer, (celllayout, cellrenderer, treemodel, treeiter) => {
Gdk.Pixbuf pixbuf;
uint origin;
string pkgname;
treemodel.get (treeiter, 0, out origin, 1, out pkgname);
if ((uint) origin == 2 ) { //origin == Alpm.Package.From.LOCALDB)
if (unlikely (transaction.transaction_summary.contains (pkgname))) {
pixbuf = installed_locked_icon;
} else if (unlikely (transaction.should_hold (pkgname))) {
pixbuf = installed_locked_icon;
} else if (unlikely (transaction.to_install.contains (pkgname))) {
pixbuf = to_reinstall_icon;
} else if (unlikely (transaction.to_remove.contains (pkgname))) {
pixbuf = to_remove_icon;
} else {
pixbuf = installed_icon;
}
} else if (unlikely (transaction.to_build.contains (pkgname))) {
pixbuf = to_install_icon;
} else {
pixbuf = uninstalled_icon;
}
cellrenderer.set ("pixbuf", pixbuf);
});
aur_state_renderer.activated.connect (on_aur_state_icon_activated);
2014-10-22 13:44:02 -03:00
try {
installed_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-installed-updated.png");
uninstalled_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-available.png");
to_install_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-install.png");
to_reinstall_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-reinstall.png");
to_remove_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-remove.png");
2016-04-14 13:19:20 -03:00
installed_locked_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-installed-locked.png");
available_locked_icon = new Gdk.Pixbuf.from_resource ("/org/manjaro/pamac/manager/package-available-locked.png");
2014-10-22 13:44:02 -03:00
} catch (GLib.Error e) {
stderr.printf (e.message);
}
2016-02-02 05:28:07 -03:00
transaction = new Transaction (this as Gtk.ApplicationWindow);
2015-03-04 11:55:36 -03:00
transaction.mode = Mode.MANAGER;
2016-04-14 13:19:20 -03:00
transaction.start_transaction.connect (on_start_transaction);
2016-05-17 13:11:49 -04:00
transaction.important_details_outpout.connect (on_important_details_outpout);
2015-03-04 11:55:36 -03:00
transaction.finished.connect (on_transaction_finished);
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished);
transaction.generate_mirrors_list.connect (on_generate_mirrors_list);
2016-02-02 05:28:07 -03:00
2016-05-17 13:11:49 -04:00
// integrate progress box and term widget
main_stack.add_named (transaction.term_grid, "term");
transaction_infobox.pack_start (transaction.progress_box);
2016-04-14 13:19:20 -03:00
AlpmPackage pkg = transaction.find_installed_satisfier ("yaourt");
if (pkg.name != "") {
support_aur (transaction.enable_aur, transaction.search_aur);
2015-08-20 10:11:18 -03:00
}
2014-10-22 13:44:02 -03:00
2016-04-14 13:19:20 -03:00
display_package_queue = new Queue<string> ();
2016-02-02 05:28:07 -03:00
2014-10-22 13:44:02 -03:00
update_lists ();
2016-02-02 05:28:07 -03:00
show_default_pkgs ();
2016-04-14 13:19:20 -03:00
search_entry.grab_focus ();
main_stack.notify["visible-child"].connect (on_main_stack_visible_child_changed);
2016-04-14 13:19:20 -03:00
filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
packages_stack.notify["visible-child"].connect (on_packages_stack_visible_child_changed);
2016-02-04 12:20:50 -03:00
return false;
2016-02-02 05:28:07 -03:00
}
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur) {
2016-04-14 13:19:20 -03:00
AlpmPackage pkg = transaction.find_installed_satisfier ("yaourt");
if (pkg.name != "") {
2016-02-02 05:28:07 -03:00
support_aur (enable_aur, search_aur);
}
2014-10-22 13:44:02 -03:00
}
void on_set_pkgreason_finished () {
refresh_packages_list ();
2016-05-13 10:44:10 -03:00
if (main_stack.visible_child_name == "details") {
display_package_properties (current_package_displayed);
}
}
void support_aur (bool enable_aur, bool search_aur) {
2015-08-24 11:13:18 -03:00
if (enable_aur) {
2016-04-14 13:19:20 -03:00
search_aur_button.active = search_aur;
search_aur_box.visible = true;
if (filters_stack.visible_child_name == "search") {
packages_stackswitcher.visible = true;
}
2015-08-24 11:13:18 -03:00
} else {
2016-04-14 13:19:20 -03:00
search_aur_button.active = false;
search_aur_box.visible = false;
packages_stackswitcher.visible = false;
2015-08-24 11:13:18 -03:00
}
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
void set_pendings_operations () {
if (!transaction_running && !generate_mirrors_list) {
2016-04-14 13:19:20 -03:00
uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length;
if (total_pending == 0) {
2016-05-17 13:11:49 -04:00
transaction.progress_box.action_label.label = "";
if (important_details) {
transaction_infobox.show_all ();
} else {
transaction_infobox.visible = false;
}
2016-04-14 13:19:20 -03:00
} else {
string info = dngettext (null, "%u pending operation", "%u pending operations", total_pending).printf (total_pending);
2016-05-17 13:11:49 -04:00
transaction.progress_box.action_label.label = info;
// fix an possible visibility issue
transaction_infobox.show_all ();
2016-04-14 13:19:20 -03:00
}
}
2014-10-22 13:44:02 -03:00
}
void show_default_pkgs () {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
2016-04-14 13:19:20 -03:00
transaction.get_installed_pkgs.begin ((obj, res) => {
populate_packages_list (transaction.get_installed_pkgs.end (res));
2015-03-04 11:55:36 -03:00
});
2014-11-16 07:31:44 -03:00
}
void update_lists () {
2015-03-04 11:55:36 -03:00
Gtk.TreeIter iter;
2016-04-14 13:19:20 -03:00
Gtk.TreeSelection selection = repos_treeview.get_selection ();
2014-11-16 07:31:44 -03:00
selection.changed.disconnect (on_repos_treeview_selection_changed);
2016-04-14 13:19:20 -03:00
foreach (unowned string repo in transaction.get_repos_names ()) {
repos_list.insert_with_values (null, -1, 0, repo);
2014-10-22 13:44:02 -03:00
}
2014-11-16 07:31:44 -03:00
repos_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_repos_treeview_selection_changed);
selection = groups_treeview.get_selection ();
selection.changed.disconnect (on_groups_treeview_selection_changed);
2016-04-14 13:19:20 -03:00
foreach (unowned string group in transaction.get_groups_names ()) {
groups_list.insert_with_values (null, -1, 0, group);
2015-03-04 11:55:36 -03:00
}
groups_list.set_sort_column_id (0, Gtk.SortType.ASCENDING);
2014-11-16 07:31:44 -03:00
groups_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_groups_treeview_selection_changed);
selection = states_treeview.get_selection ();
selection.changed.disconnect (on_states_treeview_selection_changed);
2016-04-14 13:19:20 -03:00
states_list.insert_with_values (null, -1, 0, dgettext (null, "Installed"));
states_list.insert_with_values (null, -1, 0, dgettext (null, "Orphans"));
states_list.insert_with_values (null, -1, 0, dgettext (null, "Foreign"));
states_list.insert_with_values (null, -1, 0, dgettext (null, "Pending"));
2014-11-16 07:31:44 -03:00
states_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_states_treeview_selection_changed);
2014-10-22 13:44:02 -03:00
}
2016-05-13 10:44:10 -03:00
void on_mark_explicit_button_clicked (Gtk.Button button) {
transaction.start_set_pkgreason (current_package_displayed, 0); //Alpm.Package.Reason.EXPLICIT
}
Gtk.Widget populate_details_grid (string detail_type, string detail, Gtk.Widget? previous_widget) {
var label = new Gtk.Label ("<b>%s</b>".printf (detail_type + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
if (!transaction_running
&& detail_type == dgettext (null, "Install Reason")
&& detail == dgettext (null, "Installed as a dependency for another package")) {
var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
box.homogeneous = false;
box.hexpand = true;
var label2 = new Gtk.Label (detail);
label2.halign = Gtk.Align.START;
box.pack_start (label2, false);
var mark_explicit_button = new Gtk.Button.with_label (dgettext (null, "Mark as explicitly installed"));
mark_explicit_button.margin = 3;
mark_explicit_button.clicked.connect (on_mark_explicit_button_clicked);
box.pack_end (mark_explicit_button, false);
details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
} else {
var label2 = new Gtk.Label (detail);
label2.halign = Gtk.Align.START;
details_grid.attach_next_to (label2, label, Gtk.PositionType.RIGHT);
}
return label as Gtk.Widget;
}
string find_install_button_dep_name (Gtk.Button button) {
string dep_name = "";
Gtk.Container container = button.get_parent ();
container.foreach ((widget) => {
if (widget.name == "GtkButton") {
var dep_button = widget as Gtk.Button;
AlpmPackage pkg = transaction.find_sync_satisfier (dep_button.label);
if (pkg.name != "") {
dep_name = pkg.name;
}
}
});
return dep_name;
}
void on_install_dep_button_toggled (Gtk.ToggleButton button) {
string dep_name = find_install_button_dep_name (button);
if (button.active) {
button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
transaction.to_install.add (dep_name);
} else {
button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
transaction.to_install.remove (dep_name);
}
set_pendings_operations ();
}
Gtk.Widget populate_dep_grid (string dep_type, string[] dep_list, Gtk.Widget? previous_widget, bool add_install_button = false) {
var label = new Gtk.Label ("<b>%s</b>".printf (dep_type + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
label.valign = Gtk.Align.START;
label.margin_top = 6;
deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3);
box.hexpand = true;
foreach (unowned string dep in dep_list) {
if (add_install_button) {
var box2 = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
box2.homogeneous = false;
var dep_button = new Gtk.Button.with_label (dep);
dep_button.relief = Gtk.ReliefStyle.NONE;
dep_button.clicked.connect (on_dep_button_clicked);
box2.pack_start (dep_button, false);
if (transaction.find_installed_satisfier (dep).name == "") {
var install_dep_button = new Gtk.ToggleButton.with_label (dgettext (null, "Install"));
install_dep_button.margin = 3;
install_dep_button.toggled.connect (on_install_dep_button_toggled);
box2.pack_end (install_dep_button, false);
string dep_name = find_install_button_dep_name (install_dep_button);
install_dep_button.active = (dep_name in transaction.to_install);
}
box.pack_start (box2);
} else {
var dep_button = new Gtk.Button.with_label (dep);
dep_button.relief = Gtk.ReliefStyle.NONE;
dep_button.halign = Gtk.Align.START;
dep_button.clicked.connect (on_dep_button_clicked);
box.pack_start (dep_button, false);
}
}
deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
return label as Gtk.Widget;
}
void destroy_widget (Gtk.Widget widget) {
widget.destroy ();
}
2016-04-14 13:19:20 -03:00
void set_package_details (string pkgname) {
AlpmPackageDetails details = transaction.get_pkg_details (pkgname);
// infos
name_label.set_markup ("<big><b>%s %s</b></big>".printf (details.name, details.version));
2016-04-16 04:43:14 -03:00
desc_label.set_text (details.desc);
string escaped_url = Markup.escape_text (details.url);
link_label.set_markup ("<a href=\"%s\">%s</a>".printf (escaped_url, escaped_url));
2016-02-02 05:28:07 -03:00
StringBuilder licenses = new StringBuilder ();
licenses.append (dgettext (null, "Licenses"));
2016-02-19 12:32:10 -03:00
licenses.append (":");
2016-04-14 13:19:20 -03:00
foreach (unowned string license in details.licenses) {
2016-02-19 12:32:10 -03:00
licenses.append (" ");
2016-02-02 05:28:07 -03:00
licenses.append (license);
}
2016-04-16 04:43:14 -03:00
licenses_label.set_text (licenses.str);
2016-05-13 10:44:10 -03:00
if (details.origin == 2) { //Alpm.Package.From.LOCALDB
install_togglebutton.visible = false;
remove_togglebutton.visible = true;
remove_togglebutton.active = transaction.to_remove.contains (details.name);
AlpmPackage find_pkg = transaction.get_sync_pkg (details.name);
if (find_pkg.name != "") {
if (find_pkg.version == details.version) {
reinstall_togglebutton.visible = true;
reinstall_togglebutton.active = transaction.to_install.contains (details.name);
}
}
} else if (details.origin == 3) { //Alpm.Package.From.SYNCDB
remove_togglebutton.visible = false;
reinstall_togglebutton.visible = false;
install_togglebutton.visible = true;
install_togglebutton.active = transaction.to_install.contains (details.name);
}
2016-04-14 13:19:20 -03:00
// details
2016-05-13 10:44:10 -03:00
details_grid.foreach (destroy_widget);
Gtk.Widget? previous_widget = null;
if (details.repo != "") {
previous_widget = populate_details_grid (dgettext (null, "Repository"), details.repo, previous_widget);
}
2016-04-14 13:19:20 -03:00
if (details.groups.length > 0) {
2016-05-13 10:44:10 -03:00
var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Groups") + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
label.valign = Gtk.Align.START;
details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
2016-04-14 13:19:20 -03:00
foreach (unowned string name in details.groups) {
2016-05-13 10:44:10 -03:00
var label2 = new Gtk.Label (name);
label2.halign = Gtk.Align.START;
box.pack_start (label2);
2016-04-14 13:19:20 -03:00
}
2016-05-13 10:44:10 -03:00
details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
previous_widget = label as Gtk.Widget;
2016-04-14 13:19:20 -03:00
}
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Packager"), details.packager, previous_widget);
previous_widget = populate_details_grid (dgettext (null, "Build Date"), details.builddate, previous_widget);
2016-04-14 13:19:20 -03:00
if (details.installdate != "") {
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Install Date"), details.installdate, previous_widget);
2016-04-14 13:19:20 -03:00
}
if (details.reason != "") {
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Install Reason"), details.reason, previous_widget);
2016-04-14 13:19:20 -03:00
}
if (details.has_signature != "") {
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Signatures"), details.has_signature, previous_widget);
2016-04-14 13:19:20 -03:00
}
if (details.backups.length > 0) {
2016-05-13 10:44:10 -03:00
var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Backup files") + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
label.valign = Gtk.Align.START;
details_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
2016-04-14 13:19:20 -03:00
foreach (unowned string name in details.backups) {
2016-05-13 10:44:10 -03:00
var label2 = new Gtk.Label (name);
label2.halign = Gtk.Align.START;
box.pack_start (label2);
2016-02-19 12:32:10 -03:00
}
2016-05-13 10:44:10 -03:00
details_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
2016-02-19 12:32:10 -03:00
}
2016-05-13 10:44:10 -03:00
details_grid.show_all ();
2016-04-14 13:19:20 -03:00
// deps
2016-05-13 10:44:10 -03:00
deps_grid.foreach (destroy_widget);
previous_widget = null;
2016-04-14 13:19:20 -03:00
if (details.depends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Depends On"), details.depends, previous_widget);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.optdepends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Optional Dependencies"), details.optdepends, previous_widget, true);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.requiredby.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Required By"), details.requiredby, previous_widget);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.optionalfor.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Optional For"), details.optionalfor, previous_widget);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.provides.length > 0) {
2016-05-13 10:44:10 -03:00
var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Provides") + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
label.valign = Gtk.Align.START;
label.margin_top = 6;
deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
box.margin = 3;
2016-04-14 13:19:20 -03:00
foreach (unowned string name in details.provides) {
2016-05-13 10:44:10 -03:00
var label2 = new Gtk.Label (name);
label2.halign = Gtk.Align.START;
label2.margin_start = 12;
box.pack_start (label2);
2016-02-19 12:32:10 -03:00
}
2016-05-13 10:44:10 -03:00
deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
previous_widget = label as Gtk.Widget;
2016-02-19 12:32:10 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.replaces.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Replaces"), details.replaces, previous_widget);
2016-02-19 12:32:10 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.conflicts.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Conflicts With"), details.conflicts, previous_widget);
2016-02-19 12:32:10 -03:00
}
2016-05-13 10:44:10 -03:00
deps_grid.show_all ();
2016-04-14 13:19:20 -03:00
// files
if (details.files.length > 0) {
files_scrolledwindow.visible = true;
StringBuilder text = new StringBuilder ();
foreach (unowned string file in details.files) {
2016-05-13 10:44:10 -03:00
if (text.len > 0) {
text.append ("\n");
}
2016-04-14 13:19:20 -03:00
text.append (file);
2016-02-19 12:32:10 -03:00
}
2016-04-14 13:19:20 -03:00
files_textview.buffer.set_text (text.str, (int) text.len);
} else {
files_scrolledwindow.visible = false;
2016-02-19 12:32:10 -03:00
}
}
2016-04-14 13:19:20 -03:00
void set_aur_details (string pkgname) {
name_label.set_text ("");
desc_label.set_text ("");
link_label.set_text ("");
licenses_label.set_text ("");
2016-05-13 10:44:10 -03:00
remove_togglebutton.visible = false;
reinstall_togglebutton.visible = false;
install_togglebutton.visible = false;
properties_stackswitcher.visible = false;
details_grid.foreach (destroy_widget);
deps_grid.foreach (destroy_widget);
2016-04-14 13:19:20 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
transaction.get_aur_details.begin (pkgname, (obj, res) => {
AURPackageDetails details = transaction.get_aur_details.end (res);
// infos
name_label.set_markup ("<big><b>%s %s</b></big>".printf (details.name, details.version));
desc_label.set_text (details.desc);
string aur_url = "http://aur.archlinux.org/packages/" + details.name;
2016-04-16 04:43:14 -03:00
string escaped_url = Markup.escape_text (details.url);
link_label.set_markup ("<a href=\"%s\">%s</a>\n\n<a href=\"%s\">%s</a>".printf (escaped_url, escaped_url, aur_url, aur_url));
2016-04-14 13:19:20 -03:00
StringBuilder licenses = new StringBuilder ();
licenses.append (dgettext (null, "Licenses"));
licenses.append (":");
foreach (unowned string license in details.licenses) {
licenses.append (" ");
licenses.append (license);
}
licenses_label.set_text (licenses.str);
2016-05-13 10:44:10 -03:00
install_togglebutton.visible = true;
install_togglebutton.active = transaction.to_build.contains (details.name);
AlpmPackage pkg = transaction.get_installed_pkg (details.name);
if (pkg.name != "") {
remove_togglebutton.visible = true;
remove_togglebutton.active = transaction.to_remove.contains (pkg.name);
}
2016-04-14 13:19:20 -03:00
// details
2016-05-13 10:44:10 -03:00
properties_stackswitcher.visible = true;
details_grid.foreach (destroy_widget);
Gtk.Widget? previous_widget = null;
2016-04-14 13:19:20 -03:00
if (details.packagebase != details.name) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Package Base"), details.packagebase, previous_widget);
2016-04-14 13:19:20 -03:00
}
if (details.maintainer != "") {
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Maintainer"), details.maintainer, previous_widget);
2016-04-14 13:19:20 -03:00
}
GLib.Time time = GLib.Time.local ((time_t) details.firstsubmitted);
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "First Submitted"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
2016-04-14 13:19:20 -03:00
time = GLib.Time.local ((time_t) details.lastmodified);
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Last Modified"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
previous_widget = populate_details_grid (dgettext (null, "Votes"), details.numvotes.to_string (), previous_widget);
2016-04-14 13:19:20 -03:00
if (details.outofdate != 0) {
time = GLib.Time.local ((time_t) details.outofdate);
2016-05-13 10:44:10 -03:00
previous_widget = populate_details_grid (dgettext (null, "Out of Date"), time.format ("%a %d %b %Y %X %Z"), previous_widget);
2016-04-14 13:19:20 -03:00
}
2016-05-13 10:44:10 -03:00
details_grid.show_all ();
2016-04-14 13:19:20 -03:00
// deps
2016-05-13 10:44:10 -03:00
previous_widget = null;
2016-04-14 13:19:20 -03:00
if (details.depends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Depends On"), details.depends, previous_widget);
2016-04-14 13:19:20 -03:00
}
if (details.makedepends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Make Dependencies"), details.makedepends, previous_widget);
}
if (details.checkdepends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Check Dependencies"), details.checkdepends, previous_widget);
}
2016-04-14 13:19:20 -03:00
if (details.optdepends.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Optional Dependencies"), details.optdepends, previous_widget);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.provides.length > 0) {
2016-05-13 10:44:10 -03:00
var label = new Gtk.Label ("<b>%s</b>".printf (dgettext (null, "Provides") + ":"));
label.use_markup = true;
label.halign = Gtk.Align.START;
label.valign = Gtk.Align.START;
label.margin_top = 6;
deps_grid.attach_next_to (label, previous_widget, Gtk.PositionType.BOTTOM);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
box.margin = 3;
2016-04-14 13:19:20 -03:00
foreach (unowned string name in details.provides) {
2016-05-13 10:44:10 -03:00
var label2 = new Gtk.Label (name);
label2.halign = Gtk.Align.START;
label2.margin_start = 12;
box.pack_start (label2);
2016-04-14 13:19:20 -03:00
}
2016-05-13 10:44:10 -03:00
deps_grid.attach_next_to (box, label, Gtk.PositionType.RIGHT);
previous_widget = label as Gtk.Widget;
2015-03-04 11:55:36 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.replaces.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Replaces"), details.replaces, previous_widget);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
if (details.conflicts.length > 0) {
2016-05-13 10:44:10 -03:00
previous_widget = populate_dep_grid (dgettext (null, "Conflicts With"), details.conflicts, previous_widget);
2015-03-04 11:55:36 -03:00
}
2016-05-13 10:44:10 -03:00
deps_grid.show_all ();
2016-04-14 13:19:20 -03:00
this.get_window ().set_cursor (null);
});
2014-10-22 13:44:02 -03:00
}
2016-05-13 10:44:10 -03:00
[GtkCallback]
void on_install_togglebutton_toggled () {
if (install_togglebutton.active) {
install_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
if (transaction.get_pkg_origin (current_package_displayed) == 3) { //Alpm.Package.From.SYNCDB
transaction.to_install.add (current_package_displayed);
} else {
transaction.to_build.add (current_package_displayed);
}
} else {
install_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
if (transaction.to_install.remove (current_package_displayed)) {
} else {
transaction.to_build.remove (current_package_displayed);
}
}
set_pendings_operations ();
}
[GtkCallback]
void on_remove_togglebutton_toggled () {
if (remove_togglebutton.active) {
reinstall_togglebutton.active = false;
reinstall_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
remove_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
transaction.to_install.remove (current_package_displayed);
transaction.to_remove.add (current_package_displayed);
} else {
remove_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
transaction.to_remove.remove (current_package_displayed);
}
set_pendings_operations ();
}
[GtkCallback]
void on_reinstall_togglebutton_toggled () {
if (reinstall_togglebutton.active) {
remove_togglebutton.active = false;
remove_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
reinstall_togglebutton.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
transaction.to_remove.remove (current_package_displayed);
transaction.to_install.add (current_package_displayed);
} else {
reinstall_togglebutton.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
transaction.to_install.remove (current_package_displayed);
}
set_pendings_operations ();
}
2016-04-14 13:19:20 -03:00
void populate_packages_list (AlpmPackage[] pkgs) {
2014-10-22 13:44:02 -03:00
// populate liststore
2016-04-14 13:19:20 -03:00
packages_treeview.freeze_notify ();
packages_treeview.freeze_child_notify ();
packages_list.clear ();
foreach (unowned AlpmPackage pkg in pkgs) {
packages_list.insert_with_values (null, -1,
0, pkg.origin,
1, pkg.name,
2016-04-16 04:43:14 -03:00
2, "<b>%s</b>\n%s".printf (pkg.name, Markup.escape_text (pkg.desc)),
2016-04-14 13:19:20 -03:00
3, pkg.version,
4, pkg.repo,
5, pkg.size,
6, GLib.format_size (pkg.size));
}
packages_treeview.thaw_child_notify ();
packages_treeview.thaw_notify ();
2014-10-22 13:44:02 -03:00
this.get_window ().set_cursor (null);
}
2016-04-14 13:19:20 -03:00
void populate_aur_list (AURPackage[] pkgs) {
2016-02-02 05:28:07 -03:00
// populate liststore
2016-04-14 13:19:20 -03:00
aur_treeview.freeze_notify ();
aur_treeview.freeze_child_notify ();
aur_list.clear ();
foreach (unowned AURPackage aur_pkg in pkgs) {
AlpmPackage alpm_pkg = transaction.get_installed_pkg (aur_pkg.name);
if (alpm_pkg.name != "") {
aur_list.insert_with_values (null, -1,
0, alpm_pkg.origin,
1, alpm_pkg.name,
2016-04-16 04:43:14 -03:00
2, "<b>%s</b>\n%s".printf (alpm_pkg.name, Markup.escape_text (alpm_pkg.desc)),
2016-04-14 13:19:20 -03:00
3, alpm_pkg.version,
4, aur_pkg.popularity,
5, "%.2f".printf (aur_pkg.popularity));
} else {
aur_list.insert_with_values (null, -1,
0, 0,
1, aur_pkg.name,
2016-04-16 04:43:14 -03:00
2, "<b>%s</b>\n%s".printf (aur_pkg.name, Markup.escape_text (aur_pkg.desc)),
2016-04-14 13:19:20 -03:00
3, aur_pkg.version,
4, aur_pkg.popularity,
5, "%.2f".printf (aur_pkg.popularity));
}
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
aur_treeview.thaw_child_notify ();
aur_treeview.thaw_notify ();
2016-02-02 05:28:07 -03:00
this.get_window ().set_cursor (null);
}
void refresh_packages_list () {
2016-04-14 13:19:20 -03:00
switch (filters_stack.visible_child_name) {
case "search":
if (search_aur_box.visible) {
packages_stackswitcher.visible = true;
2016-02-02 05:28:07 -03:00
}
Gtk.TreeSelection selection = search_treeview.get_selection ();
if (selection.get_selected (null, null)) {
on_search_treeview_selection_changed ();
} else {
show_default_pkgs ();
}
break;
2016-04-14 13:19:20 -03:00
case "groups":
packages_stack.visible_child_name = "repos";
packages_stackswitcher.visible = false;
2016-02-02 05:28:07 -03:00
on_groups_treeview_selection_changed ();
break;
2016-04-14 13:19:20 -03:00
case "states":
packages_stack.visible_child_name = "repos";
packages_stackswitcher.visible = false;
2016-02-02 05:28:07 -03:00
on_states_treeview_selection_changed ();
break;
2016-04-14 13:19:20 -03:00
case "repos":
packages_stack.visible_child_name = "repos";
packages_stackswitcher.visible = false;
2016-02-02 05:28:07 -03:00
on_repos_treeview_selection_changed ();
break;
default:
break;
2014-10-22 13:44:02 -03:00
}
}
2016-04-14 13:19:20 -03:00
void display_package_properties (string pkgname) {
2016-05-13 10:44:10 -03:00
current_package_displayed = pkgname;
set_package_details (current_package_displayed);
2014-10-22 13:44:02 -03:00
}
2016-04-14 13:19:20 -03:00
void display_aur_properties (string pkgname) {
current_package_displayed = pkgname;
files_scrolledwindow.visible = false;
set_aur_details (pkgname);
2015-03-04 11:55:36 -03:00
}
2016-02-02 05:28:07 -03:00
[GtkCallback]
2016-04-14 13:19:20 -03:00
void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
if (column.title == dgettext (null, "Name")) {
main_stack.visible_child_name = "details";
Gtk.TreeIter iter;
packages_list.get_iter (out iter, path);
string pkgname;
packages_list.get (iter, 1, out pkgname);
display_package_properties (pkgname);
}
2016-02-02 05:28:07 -03:00
}
2016-05-13 10:44:10 -03:00
void on_dep_button_clicked (Gtk.Button button) {
2016-04-14 13:19:20 -03:00
if (display_package_queue.find_custom (current_package_displayed, strcmp) == null) {
display_package_queue.push_tail (current_package_displayed);
}
2016-05-13 10:44:10 -03:00
string depstring = button.label;
2016-05-01 05:19:35 -03:00
// if depstring contains a version restriction search a satisfier directly
if (">" in depstring || "=" in depstring || "<" in depstring) {
var pkg = transaction.find_installed_satisfier (depstring);
if (pkg.name != "") {
display_package_properties (pkg.name);
} else {
pkg = transaction.find_sync_satisfier (depstring);
if (pkg.name != "") {
display_package_properties (pkg.name);
2016-04-14 13:19:20 -03:00
}
2016-05-01 05:19:35 -03:00
}
2016-04-14 13:19:20 -03:00
} else {
2016-05-01 05:19:35 -03:00
string pkgname = depstring.split (":", 2)[0].replace (" [" + dgettext (null, "Installed") + "]", "");
// just search for the name first to search for AUR after
if (transaction.get_installed_pkg (pkgname).name != "") {
display_package_properties (pkgname);
} else if (transaction.get_sync_pkg (pkgname).name != "") {
display_package_properties (pkgname);
} else {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
transaction.get_aur_details.begin (pkgname, (obj, res) => {
this.get_window ().set_cursor (null);
if (transaction.get_aur_details.end (res).name != "") {
display_aur_properties (pkgname);
} else {
var pkg = transaction.find_installed_satisfier (pkgname);
if (pkg.name != "") {
display_package_properties (pkg.name);
} else {
pkg = transaction.find_sync_satisfier (pkgname);
if (pkg.name != "") {
display_package_properties (pkg.name);
}
}
}
});
}
2016-04-14 13:19:20 -03:00
}
2015-03-04 11:55:36 -03:00
}
2016-04-14 13:19:20 -03:00
void on_packages_state_icon_activated (Gtk.TreePath path) {
Gtk.TreeIter iter;
packages_list.get_iter (out iter, path);
uint origin;
string pkgname;
packages_list.get (iter, 0, out origin, 1, out pkgname);
if (!transaction.transaction_summary.contains (pkgname)) {
if (transaction.to_install.remove (pkgname)) {
} else if (transaction.to_remove.remove (pkgname)) {
2016-02-02 05:28:07 -03:00
} else {
2016-04-14 13:19:20 -03:00
if (origin == 2) { //Alpm.Package.From.LOCALDB
if (!transaction.should_hold (pkgname)) {
transaction.to_remove.add (pkgname);
2014-10-22 13:44:02 -03:00
}
2016-02-02 05:28:07 -03:00
} else {
2016-04-14 13:19:20 -03:00
transaction.to_install.add (pkgname);
2014-10-22 13:44:02 -03:00
}
}
}
packages_treeview.queue_draw ();
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
2014-10-22 13:44:02 -03:00
}
2016-02-02 05:28:07 -03:00
[GtkCallback]
void on_aur_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
2016-04-14 13:19:20 -03:00
if (column.title == dgettext (null, "Name")) {
main_stack.visible_child_name = "details";
Gtk.TreeIter iter;
aur_list.get_iter (out iter, path);
uint origin;
string pkgname;
aur_list.get (iter, 0, out origin, 1, out pkgname);
if (origin == 2) { //Alpm.Package.From.LOCALDB
display_package_properties (pkgname);
2016-02-02 05:28:07 -03:00
} else {
2016-04-14 13:19:20 -03:00
display_aur_properties (pkgname);
}
}
2016-04-14 13:19:20 -03:00
}
void on_aur_state_icon_activated (Gtk.TreePath path) {
Gtk.TreeIter iter;
aur_list.get_iter (out iter, path);
uint origin;
string pkgname;
aur_list.get (iter, 0, out origin, 1, out pkgname);
if (origin == 2) { //Alpm.Package.From.LOCALDB
if (!transaction.transaction_summary.contains (pkgname)) {
if (transaction.to_remove.remove (pkgname)) {
} else if (!transaction.should_hold (pkgname)) {
transaction.to_remove.add (pkgname);
}
}
} else if (transaction.to_build.remove (pkgname)) {
2016-02-02 05:28:07 -03:00
} else {
2016-04-14 13:19:20 -03:00
transaction.to_build.add (pkgname);
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
[GtkCallback]
void on_button_back_clicked () {
string? pkgname = display_package_queue.pop_tail ();
if (pkgname != null) {
AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
if (pkg.name == "") {
pkg = transaction.get_sync_pkg (pkgname);
}
if (pkg.name == "") {
transaction.get_aur_details.begin (pkgname, (obj, res) => {
if (transaction.get_aur_details.end (res).name != "") {
display_aur_properties (pkgname);
} else {
pkg = transaction.find_installed_satisfier (pkgname);
if (pkg.name == "") {
pkg = transaction.find_sync_satisfier (pkgname);
}
if (pkg.name != "") {
display_package_properties (pkgname);
}
}
});
} else {
display_package_properties (pkgname);
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
} else {
main_stack.visible_child_name = "browse";
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
}
void on_install_item_activate () {
foreach (unowned string pkgname in selected_pkgs) {
if (transaction.get_pkg_origin (pkgname) == 3) { //Alpm.Package.From.SYNCDB
transaction.to_install.add (pkgname);
}
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_aur) {
transaction.to_build.add (pkgname);
}
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
}
2016-05-13 10:44:10 -03:00
void on_details_item_activate () {
// show details for the first selected package
if (selected_pkgs.length () == 1) {
display_package_properties (selected_pkgs.data);
main_stack.visible_child_name = "details";
} else if (selected_aur.length () == 1) {
display_aur_properties (selected_aur.data);
main_stack.visible_child_name = "details";
}
}
void on_remove_item_activate () {
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_pkgs) {
transaction.to_install.remove (pkgname);
if (!transaction.should_hold (pkgname)) {
if (transaction.get_pkg_origin (pkgname) == 2) { //Alpm.Package.From.LOCALDB
transaction.to_remove.add (pkgname);
2015-03-04 11:55:36 -03:00
}
}
}
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
}
void on_deselect_item_activate () {
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_pkgs) {
if (transaction.to_install.remove (pkgname)) {
2016-02-02 05:28:07 -03:00
} else {
2016-04-14 13:19:20 -03:00
transaction.to_remove.remove (pkgname);
}
}
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_aur) {
transaction.to_build.remove (pkgname);
}
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
}
2016-04-14 13:19:20 -03:00
void on_packages_stack_visible_child_changed () {
// do nothing if it we want to see pendings AUR operations
switch (filters_stack.visible_child_name) {
case "search":
Gtk.TreeIter iter;
Gtk.TreeSelection selection = search_treeview.get_selection ();
if (selection.get_selected (null, out iter)) {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
string search_string;
search_list.get (iter, 0, out search_string);
switch (packages_stack.visible_child_name) {
case "repos":
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);
2016-04-14 13:19:20 -03:00
populate_packages_list (transaction.search_pkgs.end (res));
});
break;
case "aur":
transaction.search_in_aur.begin (search_string, (obj, res) => {
populate_aur_list (transaction.search_in_aur.end (res));
});
break;
default:
break;
}
}
break;
default:
break;
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
if (packages_stack.visible_child_name == "aur") {
var attention_val = GLib.Value (typeof (bool));
attention_val.set_boolean (false);
packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
"needs-attention",
attention_val);
}
2016-02-02 05:28:07 -03:00
}
2014-10-22 13:44:02 -03:00
[GtkCallback]
bool on_packages_treeview_button_press_event (Gdk.EventButton event) {
// Check if right mouse button was clicked
if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
2016-04-14 13:19:20 -03:00
Gtk.TreePath treepath;
if (packages_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null)) {
packages_treeview.grab_focus ();
Gtk.TreeSelection selection = packages_treeview.get_selection ();
if (!selection.path_is_selected (treepath)) {
selection.unselect_all ();
selection.select_path (treepath);
}
2016-04-14 13:19:20 -03:00
GLib.List<Gtk.TreePath> selected_paths = selection.get_selected_rows (null);
selected_pkgs = new GLib.List<string> ();
2016-05-20 03:51:16 -04:00
selected_aur = new GLib.List<string> ();
2016-04-14 13:19:20 -03:00
deselect_item.sensitive = false;
install_item.sensitive = false;
remove_item.sensitive = false;
if (selected_paths.length () == 1) {
Gtk.TreePath path = selected_paths.data;
Gtk.TreeIter iter;
packages_list.get_iter (out iter, path);
uint origin;
string pkgname;
string pkgversion;
packages_list.get (iter, 0, out origin, 1, out pkgname, 3, out pkgversion);
selected_pkgs.append (pkgname);
2016-05-13 10:44:10 -03:00
details_item.sensitive = true;
2016-04-14 13:19:20 -03:00
if (transaction.to_install.contains (pkgname)
|| transaction.to_remove.contains (pkgname)) {
deselect_item.sensitive = true;
} else if (origin == 2) { //Alpm.Package.From.LOCALDB
remove_item.sensitive = true;
} else if (origin == 3) { //Alpm.Package.From.SYNCDB
install_item.sensitive = true;
}
2016-04-14 13:19:20 -03:00
} else {
2016-05-13 10:44:10 -03:00
details_item.sensitive = false;
2016-04-14 13:19:20 -03:00
foreach (unowned Gtk.TreePath path in selected_paths) {
Gtk.TreeIter iter;
packages_list.get_iter (out iter, path);
uint origin;
string pkgname;
packages_list.get (iter, 0, out origin, 1, out pkgname);
selected_pkgs.append (pkgname);
if (!deselect_item.sensitive) {
if (transaction.to_install.contains (pkgname)
|| transaction.to_remove.contains (pkgname)) {
deselect_item.sensitive = true;
}
}
if (origin == 3) { //Alpm.Package.From.SYNCDB
install_item.sensitive = true;
}
if (origin == 2) { //Alpm.Package.From.LOCALDB
remove_item.sensitive = true;
2015-03-04 11:55:36 -03:00
}
}
}
2016-04-14 13:19:20 -03:00
right_click_menu.popup (null, null, null, event.button, event.time);
return true;
}
2016-04-14 13:19:20 -03:00
}
return false;
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
bool on_aur_treeview_button_press_event (Gdk.EventButton event) {
2016-02-02 05:28:07 -03:00
aur_treeview.grab_focus ();
// Check if right mouse button was clicked
if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
Gtk.TreePath? treepath;
Gtk.TreeSelection selection = aur_treeview.get_selection ();
2016-04-14 13:19:20 -03:00
if (aur_treeview.get_path_at_pos ((int) event.x, (int) event.y, out treepath, null, null, null)) {
if (!selection.path_is_selected (treepath)) {
selection.unselect_all ();
selection.select_path (treepath);
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
GLib.List<Gtk.TreePath> selected_paths = selection.get_selected_rows (null);
selected_pkgs = new GLib.List<string> ();
selected_aur = new GLib.List<string> ();
deselect_item.sensitive = false;
install_item.sensitive = false;
remove_item.sensitive = false;
2016-05-13 10:44:10 -03:00
if (selected_paths.length () == 1) {
details_item.sensitive = true;
} else {
details_item.sensitive = false;
}
2016-04-14 13:19:20 -03:00
foreach (unowned Gtk.TreePath path in selected_paths) {
Gtk.TreeIter iter;
aur_list.get_iter (out iter, path);
string pkgname;
aur_list.get (iter, 1, out pkgname);
AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
if (pkg.name != "") {
selected_pkgs.append (pkgname);
// there is for sure a pkg to remove
remove_item.sensitive = true;
} else {
selected_aur.append (pkgname);
}
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_aur) {
if (transaction.to_build.contains (pkgname)) {
deselect_item.sensitive = true;
} else {
install_item.sensitive = true;
}
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
foreach (unowned string pkgname in selected_pkgs) {
if (transaction.to_remove.contains (pkgname)) {
deselect_item.sensitive = true;
break;
}
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
right_click_menu.popup (null, null, null, event.button, event.time);
return true;
2016-02-02 05:28:07 -03:00
}
}
2016-04-14 13:19:20 -03:00
return false;
2016-02-02 05:28:07 -03:00
}
2014-10-22 13:44:02 -03:00
[GtkCallback]
void on_search_entry_activate () {
2016-02-02 05:28:07 -03:00
unowned string search_string = search_entry.get_text ();
2014-10-22 13:44:02 -03:00
if (search_string != "") {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
Gtk.TreeModel model;
2016-04-14 13:19:20 -03:00
Gtk.TreeIter iter;
2016-02-02 05:28:07 -03:00
Gtk.TreeSelection selection = search_treeview.get_selection ();
// add search string in search_list if needed
bool found = false;
// check if search string is already selected in search list
if (selection.get_selected (out model, out iter)) {
2016-04-14 13:19:20 -03:00
string selected_string;
model.get (iter, 0, out selected_string);
if (selected_string == search_string) {
on_search_treeview_selection_changed ();
2016-02-02 05:28:07 -03:00
found = true;
2014-11-16 07:31:44 -03:00
}
}
// check if search string exists in search list
if (!found) {
search_list.foreach ((_model, _path, _iter) => {
2016-04-14 13:19:20 -03:00
string line;
_model.get (_iter, 0, out line);
if (line == search_string) {
found = true;
// we select the iter in search_list
// it will populate the list with the selection changed signal
selection.select_iter (_iter);
}
return found;
});
}
2016-02-02 05:28:07 -03:00
if (!found) {
search_list.insert_with_values (out iter, -1, 0, search_string);
// we select the iter in search_list
// it will populate the list with the selection changed signal
selection.select_iter (iter);
}
2014-10-22 13:44:02 -03:00
}
}
2016-03-11 05:51:45 -03:00
bool search_entry_timeout_callback () {
2014-10-22 13:44:02 -03:00
on_search_entry_activate ();
2016-03-11 05:51:45 -03:00
search_entry_timeout_id = 0;
return false;
}
[GtkCallback]
void on_search_entry_changed () {
if (search_entry.get_text () != "") {
if (search_entry_timeout_id != 0) {
Source.remove (search_entry_timeout_id);
}
search_entry_timeout_id = Timeout.add (750, search_entry_timeout_callback);
}
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
void on_search_treeview_selection_changed () {
2016-04-14 13:19:20 -03:00
Gtk.TreeIter iter;
2015-03-04 11:55:36 -03:00
Gtk.TreeSelection selection = search_treeview.get_selection ();
2016-04-14 13:19:20 -03:00
if (selection.get_selected (null, out iter)) {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
2016-04-14 13:19:20 -03:00
string search_string;
search_list.get (iter, 0, out search_string);
switch (packages_stack.visible_child_name) {
case "repos":
transaction.search_pkgs.begin (search_string, (obj, 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);
2016-04-14 13:19:20 -03:00
populate_packages_list (pkgs);
2016-02-02 05:28:07 -03:00
if (search_aur_button.get_active ()) {
2016-04-14 13:19:20 -03:00
if (pkgs.length == 0) {
transaction.search_in_aur.begin (search_string, (obj, res) => {
if (transaction.search_in_aur.end (res).length != 0) {
packages_stack.visible_child_name = "aur";
}
2016-04-14 13:19:20 -03:00
});
} else {
transaction.search_in_aur.begin (search_string, (obj, res) => {
if (transaction.search_in_aur.end (res).length != 0) {
var attention_val = GLib.Value (typeof (bool));
attention_val.set_boolean (true);
packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
"needs-attention",
attention_val);
}
2016-04-14 13:19:20 -03:00
});
}
2016-02-02 05:28:07 -03:00
}
});
2016-04-14 13:19:20 -03:00
aur_list.clear ();
2016-02-02 05:28:07 -03:00
break;
2016-04-14 13:19:20 -03:00
case "aur":
transaction.search_in_aur.begin (search_string, (obj, res) => {
populate_aur_list (transaction.search_in_aur.end (res));
2016-02-02 05:28:07 -03:00
});
2016-04-14 13:19:20 -03:00
packages_list.clear ();
2016-02-02 05:28:07 -03:00
break;
default:
break;
}
2014-10-22 13:44:02 -03:00
}
}
[GtkCallback]
void on_groups_treeview_selection_changed () {
2016-04-14 13:19:20 -03:00
Gtk.TreeIter iter;
2015-03-04 11:55:36 -03:00
Gtk.TreeSelection selection = groups_treeview.get_selection ();
2016-04-14 13:19:20 -03:00
if (selection.get_selected (null, out iter)) {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
2016-04-14 13:19:20 -03:00
string group_name;
groups_list.get (iter, 0, out group_name);
transaction.get_group_pkgs.begin (group_name, (obj, res) => {
populate_packages_list (transaction.get_group_pkgs.end (res));
2015-03-04 11:55:36 -03:00
});
2014-10-22 13:44:02 -03:00
}
}
[GtkCallback]
void on_states_treeview_selection_changed () {
2016-04-14 13:19:20 -03:00
Gtk.TreeIter iter;
2015-03-04 11:55:36 -03:00
Gtk.TreeSelection selection = states_treeview.get_selection ();
2016-04-14 13:19:20 -03:00
if (selection.get_selected (null, out iter)) {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
2016-04-14 13:19:20 -03:00
packages_stackswitcher.visible = false;
string state;
states_list.get (iter, 0, out state);
if (state == dgettext (null, "Installed")) {
transaction.get_installed_pkgs.begin ((obj, res) => {
populate_packages_list (transaction.get_installed_pkgs.end (res));
});
} else if (state == dgettext (null, "Orphans")) {
transaction.get_orphans.begin ((obj, res) => {
populate_packages_list (transaction.get_orphans.end (res));
});
} else if (state == dgettext (null, "Foreign")) {
transaction.get_foreign_pkgs.begin ((obj, res) => {
populate_packages_list (transaction.get_foreign_pkgs.end (res));
});
} else if (state == dgettext (null, "Pending")) {
AlpmPackage[] pkgs = {};
foreach (unowned string pkgname in transaction.to_install) {
AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
if (pkg.name == "") {
pkg = transaction.get_sync_pkg (pkgname);
2016-02-02 05:28:07 -03:00
}
2016-04-14 13:19:20 -03:00
if (pkg.name != "") {
pkgs += pkg;
2014-10-22 13:44:02 -03:00
}
}
2016-02-02 05:28:07 -03:00
foreach (unowned string pkgname in transaction.to_remove) {
2016-04-14 13:19:20 -03:00
AlpmPackage pkg = transaction.get_installed_pkg (pkgname);
if (pkg.name != "") {
pkgs += pkg;
}
}
populate_packages_list (pkgs);
if (transaction.to_build.length != 0) {
packages_stackswitcher.visible = true;
AURPackage[] aur_pkgs = {};
foreach (unowned string pkgname in transaction.to_build) {
transaction.get_aur_details.begin (pkgname, (obj, res) => {
AURPackageDetails details_pkg = transaction.get_aur_details.end (res);
if (details_pkg.name != "") {
var aur_pkg = AURPackage () {
name = details_pkg.name,
version = details_pkg.version,
desc = details_pkg.desc,
popularity = details_pkg.popularity
};
aur_pkgs += aur_pkg;
populate_aur_list (aur_pkgs);
if (aur_pkgs.length > 0 ) {
if (pkgs.length == 0) {
packages_stack.visible_child_name = "aur";
} else {
var attention_val = GLib.Value (typeof (bool));
attention_val.set_boolean (true);
packages_stack.child_set_property (packages_stack.get_child_by_name ("aur"),
"needs-attention",
attention_val);
}
}
}
});
2015-03-04 11:55:36 -03:00
}
2014-10-22 13:44:02 -03:00
}
}
}
}
[GtkCallback]
void on_repos_treeview_selection_changed () {
2016-04-14 13:19:20 -03:00
Gtk.TreeIter iter;
2015-03-04 11:55:36 -03:00
Gtk.TreeSelection selection = repos_treeview.get_selection ();
2016-04-14 13:19:20 -03:00
if (selection.get_selected (null, out iter)) {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
2016-04-14 13:19:20 -03:00
string repo;
repos_list.get (iter, 0, out repo);
transaction.get_repo_pkgs.begin (repo, (obj, res) => {
populate_packages_list (transaction.get_repo_pkgs.end (res));
});
2014-10-22 13:44:02 -03:00
}
}
void on_main_stack_visible_child_changed () {
switch (main_stack.visible_child_name) {
case "browse":
2016-04-23 15:58:46 -03:00
button_back.visible = false;
filters_stackswitcher.visible = true;
break;
case "details":
2016-05-17 13:11:49 -04:00
case "term":
filters_stackswitcher.visible = false;
2016-04-23 15:58:46 -03:00
button_back.visible = true;
break;
default:
break;
}
}
2016-04-14 13:19:20 -03:00
void on_filters_stack_visible_child_changed () {
2014-10-22 13:44:02 -03:00
refresh_packages_list ();
}
[GtkCallback]
void on_menu_button_toggled () {
preferences_button.sensitive = !transaction_running;
}
2014-10-22 13:44:02 -03:00
[GtkCallback]
void on_history_button_clicked () {
transaction.run_history_dialog ();
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
void on_local_button_clicked () {
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
2015-08-20 10:11:18 -03:00
dgettext (null, "Install Local Packages"), this, Gtk.FileChooserAction.OPEN,
dgettext (null, "_Cancel"), Gtk.ResponseType.CANCEL,
dgettext (null, "_Open"),Gtk.ResponseType.ACCEPT);
chooser.window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
chooser.icon_name = "system-software-install";
chooser.default_width = 900;
chooser.select_multiple = true;
chooser.local_only = false;
chooser.create_folders = false;
Gtk.FileFilter package_filter = new Gtk.FileFilter ();
package_filter.set_filter_name (dgettext (null, "Alpm Package"));
package_filter.add_pattern ("*.pkg.tar.xz");
chooser.add_filter (package_filter);
if (chooser.run () == Gtk.ResponseType.ACCEPT) {
SList<string> packages_paths = chooser.get_filenames ();
2014-10-22 13:44:02 -03:00
if (packages_paths.length () != 0) {
2016-02-02 05:28:07 -03:00
foreach (unowned string path in packages_paths) {
transaction.to_load.add (path);
2014-10-22 13:44:02 -03:00
}
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
chooser.destroy ();
2015-03-18 12:07:18 -03:00
while (Gtk.events_pending ()) {
2014-10-22 13:44:02 -03:00
Gtk.main_iteration ();
2015-03-18 12:07:18 -03:00
}
2016-04-14 13:19:20 -03:00
transaction_running = true;
2014-10-22 13:44:02 -03:00
transaction.run ();
}
2015-03-04 11:55:36 -03:00
} else {
chooser.destroy ();
2015-03-04 11:55:36 -03:00
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
2015-03-04 11:55:36 -03:00
}
}
2015-08-20 10:11:18 -03:00
}
2014-10-22 13:44:02 -03:00
[GtkCallback]
void on_preferences_button_clicked () {
transaction.run_preferences_dialog.begin ();
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
void on_about_button_clicked () {
transaction.run_about_dialog ();
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
void on_details_button_clicked () {
2016-05-17 13:11:49 -04:00
details_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
important_details = false;
2016-04-14 13:19:20 -03:00
if (transaction_running) {
2016-05-17 13:11:49 -04:00
main_stack.visible_child_name = "term";
2016-04-14 13:19:20 -03:00
} else {
2016-05-17 13:11:49 -04:00
uint total_pending = transaction.to_install.length + transaction.to_remove.length + transaction.to_build.length;
if (total_pending == 0) {
main_stack.visible_child_name = "term";
} else {
main_stack.visible_child_name = "browse";
filters_stack.notify["visible-child"].disconnect (on_filters_stack_visible_child_changed);
filters_stack.visible_child_name = "states";
filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
Gtk.TreeIter iter;
// show "Pending" in states_list
// "Pending" is at indice 3
states_list.get_iter (out iter, new Gtk.TreePath.from_indices (3));
Gtk.TreeSelection selection = states_treeview.get_selection ();
selection.changed.disconnect (on_states_treeview_selection_changed);
selection.select_iter (iter);
selection.changed.connect_after (on_states_treeview_selection_changed);
refresh_packages_list ();
}
2016-04-14 13:19:20 -03:00
}
}
[GtkCallback]
void on_apply_button_clicked () {
2016-04-14 13:19:20 -03:00
transaction_running = true;
2016-05-17 13:11:49 -04:00
apply_button.sensitive = false;
2014-10-22 13:44:02 -03:00
transaction.run ();
}
[GtkCallback]
void on_cancel_button_clicked () {
2016-04-14 13:19:20 -03:00
if (transaction_running) {
transaction.cancel ();
} else {
transaction.clear_lists ();
set_pendings_operations ();
refresh_packages_list ();
2016-05-13 10:44:10 -03:00
if (main_stack.visible_child_name == "details") {
display_package_properties (current_package_displayed);
}
2016-05-17 13:11:49 -04:00
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
2016-04-14 13:19:20 -03:00
}
2014-10-22 13:44:02 -03:00
}
[GtkCallback]
void on_refresh_button_clicked () {
2015-04-12 11:04:30 -03:00
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
refreshing = true;
2016-02-02 05:28:07 -03:00
transaction.start_refresh (false);
2016-05-17 13:11:49 -04:00
apply_button.sensitive = false;
transaction_infobox.show_all ();
2016-04-14 13:19:20 -03:00
}
void on_start_transaction () {
2016-05-17 13:11:49 -04:00
cancel_button.sensitive = false;
2016-04-14 13:19:20 -03:00
}
2016-05-17 13:11:49 -04:00
void on_important_details_outpout (bool must_show) {
if (must_show) {
main_stack.visible_child_name = "term";
button_back.visible = false;
} else if (main_stack.visible_child_name != "term") {
important_details = true;
details_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
}
2014-10-22 13:44:02 -03:00
}
void on_generate_mirrors_list () {
generate_mirrors_list = true;
apply_button.sensitive = false;
transaction_infobox.show_all ();
}
void on_transaction_finished (bool success) {
refresh_packages_list ();
2016-05-13 10:44:10 -03:00
if (main_stack.visible_child_name == "details") {
display_package_properties (current_package_displayed);
2016-05-17 13:11:49 -04:00
} else if (main_stack.visible_child_name == "term") {
button_back.visible = true;
2016-05-13 10:44:10 -03:00
}
transaction.to_load.remove_all ();
if (refreshing) {
if (success) {
2016-04-14 13:19:20 -03:00
transaction_running = true;
transaction.sysupgrade (false);
2016-08-27 09:51:34 -03:00
} else {
apply_button.sensitive = true;
}
refreshing = false;
2016-04-14 13:19:20 -03:00
} else {
transaction_running = false;
generate_mirrors_list = false;
2016-05-17 13:11:49 -04:00
cancel_button.sensitive = true;
apply_button.sensitive = true;
}
2016-04-14 13:19:20 -03:00
set_pendings_operations ();
2014-10-22 13:44:02 -03:00
}
}
}