From 0105b98f9ee6ff36b5560b0b9a30926ea0452bcc Mon Sep 17 00:00:00 2001 From: guinux Date: Sat, 16 Apr 2016 14:37:31 +0200 Subject: [PATCH] little fix in AUR and remove no more needed files --- po/files_to_translate | 2 - po/pamac.pot | 22 ++-- src/aur_model.vala | 271 ---------------------------------------- src/manager_window.vala | 20 +++ src/packages_model.vala | 261 -------------------------------------- src/transaction.vala | 1 + 6 files changed, 34 insertions(+), 543 deletions(-) delete mode 100644 src/aur_model.vala delete mode 100644 src/packages_model.vala diff --git a/po/files_to_translate b/po/files_to_translate index ea6f4dd..1d3f40b 100644 --- a/po/files_to_translate +++ b/po/files_to_translate @@ -5,8 +5,6 @@ ../src/manager.vala ../src/updater.vala ../src/manager_window.vala -../src/aur_model.vala -../src/packages_model.vala ../src/updater_window.vala ../src/preferences_dialog.vala ../src/choose_ignorepkgs_dialog.vala diff --git a/po/pamac.pot b/po/pamac.pot index f90e59c..263dd6d 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -500,6 +500,14 @@ msgstr "" msgid "Out of Date" msgstr "" +#: ../src/manager_window.vala +msgid "Make Dependencies" +msgstr "" + +#: ../src/manager_window.vala +msgid "Check Dependencies" +msgstr "" + #: ../src/manager_window.vala ../resources/manager_window.ui #: ../resources/updater_window.ui msgid "Name" @@ -538,10 +546,6 @@ msgstr "" msgid "A Gtk3 frontend for libalpm" msgstr "" -#: ../src/aur_model.vala ../src/packages_model.vala -msgid "No package found" -msgstr "" - #: ../src/preferences_dialog.vala ../resources/preferences_dialog.ui msgid "How often to check for updates, value in hours" msgstr "" @@ -598,6 +602,10 @@ msgstr "" msgid "Choose Optional Dependencies" msgstr "" +#: ../resources/manager_window.ui +msgid "Refresh databases" +msgstr "" + #: ../resources/manager_window.ui msgid "View History" msgstr "" @@ -611,17 +619,13 @@ msgid "_About" msgstr "" #: ../resources/manager_window.ui -msgid "Refresh databases" +msgid "Search" msgstr "" #: ../resources/manager_window.ui msgid "Search in AUR" msgstr "" -#: ../resources/manager_window.ui -msgid "Search" -msgstr "" - #: ../resources/manager_window.ui ../resources/updater_window.ui msgid "State" msgstr "" diff --git a/src/aur_model.vala b/src/aur_model.vala deleted file mode 100644 index 3b453ac..0000000 --- a/src/aur_model.vala +++ /dev/null @@ -1,271 +0,0 @@ -/* - * pamac-vala - * - * Copyright (C) 2014-2016 Guillaume Benoit - * - * 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 3 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 . - */ - -Pamac.ManagerWindow manager_window; - -// custom sort functions -int aur_compare_name (Json.Object pkg_a, Json.Object pkg_b) { - return strcmp (pkg_a.get_string_member ("Name"), pkg_b.get_string_member ("Name")); -} - -int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) { - unowned Alpm.Package? alpm_pkg_a = manager_window.transaction.alpm_utils.get_installed_pkg (pkg_a.get_string_member ("Name")); - unowned Alpm.Package? alpm_pkg_b = manager_window.transaction.alpm_utils.get_installed_pkg (pkg_b.get_string_member ("Name")); - if (pkg_a != null) { - if (pkg_b != null) { - return (int) (alpm_pkg_a.origin > alpm_pkg_b.origin) - (int) (alpm_pkg_a.origin < alpm_pkg_b.origin); - } else { - return 1; - } - } else { - if (pkg_b != null) { - return -1; - } else { - return 0; - } - } -} - -int aur_compare_version (Json.Object pkg_a, Json.Object pkg_b) { - return Alpm.pkg_vercmp (pkg_a.get_string_member ("Version"), pkg_b.get_string_member ("Version")); -} - -int aur_compare_votes (Json.Object pkg_a, Json.Object pkg_b) { - return (int) (pkg_a.get_int_member ("NumVotes") > pkg_b.get_int_member ("NumVotes")) - (int) (pkg_a.get_int_member ("NumVotes") < pkg_b.get_int_member ("NumVotes")); -} - -namespace Pamac { - - class AURModel : Object, Gtk.TreeModel { - private Json.Array pkgs_infos; - private GLib.List pkgs; - - public AURModel (Json.Array? pkgs_infos, ManagerWindow _manager_window) { - manager_window = _manager_window; - this.pkgs_infos = pkgs_infos; - pkgs = new GLib.List (); - if (pkgs_infos != null) { - pkgs_infos.foreach_element ((array, index, node) => { - pkgs.append (node.get_object ()); - }); - } - } - - // TreeModel interface - Type get_column_type (int index) { - switch (index) { - case 0: // name - case 2: // version - return typeof (string); - case 3: // votes - return typeof (int64); - case 1: // icon - return typeof (Gdk.Pixbuf); - default: - return Type.INVALID; - } - } - - Gtk.TreeModelFlags get_flags () { - return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST; - } - - void get_value (Gtk.TreeIter iter, int column, out Value val) { - unowned Json.Object? pkg_info = pkgs.nth_data (iter.stamp); - switch (column) { - case 0: - val = Value (typeof (string)); - if (pkg_info == null) { - val.set_string (dgettext (null, "No package found")); - } else { - val.set_string (pkg_info.get_string_member ("Name")); - } - break; - case 1: - val = Value (typeof (Object)); - if (pkg_info != null) { - unowned Alpm.Package? pkg = manager_window.transaction.alpm_utils.get_installed_pkg (pkg_info.get_string_member ("Name")); - if (pkg != null) { - if (manager_window.transaction.alpm_utils.get_holdpkgs ().find_custom (pkg.name, strcmp) != null) { - val.set_object (manager_window.locked_icon); - } else if (manager_window.transaction.to_add.contains (pkg.name)) { - val.set_object (manager_window.to_reinstall_icon); - } else if (manager_window.transaction.to_remove.contains (pkg.name)) { - val.set_object (manager_window.to_remove_icon); - } else { - val.set_object (manager_window.installed_icon); - } - } else if (manager_window.transaction.to_build.contains (pkg_info.get_string_member ("Name"))) { - val.set_object (manager_window.to_install_icon); - } else { - val.set_object (manager_window.uninstalled_icon); - } - } - break; - case 2: - val = Value (typeof (string)); - if (pkg_info != null) { - unowned Alpm.Package? pkg = manager_window.transaction.alpm_utils.get_installed_pkg (pkg_info.get_string_member ("Name")); - if (pkg != null) { - val.set_string (pkg.version); - } else { - val.set_string (pkg_info.get_string_member ("Version")); - } - } - break; - case 3: - if (pkg_info != null) { - val = Value (typeof (int64)); - val.set_int64 (pkg_info.get_int_member ("NumVotes")); - } else { - // if pkg_info is null, set val to an empty string to not display "0" - val = Value (typeof (string)); - } - break; - default: - val = Value (Type.INVALID); - break; - } - } - - bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {; - if (path.get_depth () != 1) { - return invalid_iter (out iter); - } - iter = Gtk.TreeIter (); - int pos = path.get_indices ()[0]; - iter.stamp = pos; - return true; - } - - int get_n_columns () { - // name, icon, version, votes - return 4; - } - - Gtk.TreePath? get_path (Gtk.TreeIter iter) { - return new Gtk.TreePath.from_indices (iter.stamp); - } - - int iter_n_children (Gtk.TreeIter? iter) { - return 0; - } - - bool iter_next (ref Gtk.TreeIter iter) { - int pos = (iter.stamp) + 1; - if (pos >= pkgs.length ()) { - return false; - } - iter.stamp = pos; - return true; - } - - bool iter_previous (ref Gtk.TreeIter iter) { - int pos = iter.stamp; - if (pos >= 0) { - return false; - } - iter.stamp = (--pos); - return true; - } - - bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) { - return invalid_iter (out iter); - } - - bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) { - return invalid_iter (out iter); - } - - bool iter_has_child (Gtk.TreeIter iter) { - return false; - } - - bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) { - return invalid_iter (out iter); - } - - bool invalid_iter (out Gtk.TreeIter iter) { - iter = Gtk.TreeIter (); - iter.stamp = -1; - return false; - } - - // custom get pkg function - public unowned Json.Object? get_pkg_at_path (Gtk.TreePath path) { - return pkgs.nth_data (path.get_indices ()[0]); - } - - public void sort_by_name (Gtk.SortType order) { - pkgs.sort ((GLib.CompareFunc) aur_compare_name); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.aur_name_column.sort_order = order; - manager_window.aur_state_column.sort_indicator = false; - manager_window.aur_name_column.sort_indicator = true; - manager_window.aur_version_column.sort_indicator = false; - manager_window.aur_votes_column.sort_indicator = false; - manager_window.sortinfo.column_number = 0; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_state (Gtk.SortType order) { - pkgs.sort ((GLib.CompareFunc) aur_compare_state); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.aur_state_column.sort_order = order; - manager_window.aur_state_column.sort_indicator = true; - manager_window.aur_name_column.sort_indicator = false; - manager_window.aur_version_column.sort_indicator = false; - manager_window.aur_votes_column.sort_indicator = false; - manager_window.sortinfo.column_number = 1; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_version (Gtk.SortType order) { - pkgs.sort ((GLib.CompareFunc) aur_compare_version); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.aur_version_column.sort_order = order; - manager_window.aur_state_column.sort_indicator = false; - manager_window.aur_name_column.sort_indicator = false; - manager_window.aur_version_column.sort_indicator = true; - manager_window.aur_votes_column.sort_indicator = false; - manager_window.sortinfo.column_number = 2; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_votes (Gtk.SortType order) { - pkgs.sort ((GLib.CompareFunc) aur_compare_votes); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.aur_votes_column.sort_order = order; - manager_window.aur_state_column.sort_indicator = false; - manager_window.aur_name_column.sort_indicator = false; - manager_window.aur_version_column.sort_indicator = false; - manager_window.aur_votes_column.sort_indicator = true; - manager_window.sortinfo.column_number = 3; - manager_window.sortinfo.sort_type = order; - } - } -} diff --git a/src/manager_window.vala b/src/manager_window.vala index ab6e6fc..0e042e1 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -607,6 +607,26 @@ namespace Pamac { deps_list.get_iter (out iter, new Gtk.TreePath.from_indices (pos)); deps_list.set (iter, 0, "%s".printf (dgettext (null, "Depends On") + ":")); } + if (details.makedepends.length > 0) { + foreach (unowned string name in details.makedepends) { + deps_list.insert_with_values (out iter, -1, + 1, name); + } + Gtk.TreePath path = deps_list.get_path (iter); + int pos = (path.get_indices ()[0]) - (details.makedepends.length - 1); + deps_list.get_iter (out iter, new Gtk.TreePath.from_indices (pos)); + deps_list.set (iter, 0, "%s".printf (dgettext (null, "Make Dependencies") + ":")); + } + if (details.checkdepends.length > 0) { + foreach (unowned string name in details.checkdepends) { + deps_list.insert_with_values (out iter, -1, + 1, name); + } + Gtk.TreePath path = deps_list.get_path (iter); + int pos = (path.get_indices ()[0]) - (details.checkdepends.length - 1); + deps_list.get_iter (out iter, new Gtk.TreePath.from_indices (pos)); + deps_list.set (iter, 0, "%s".printf (dgettext (null, "Check Dependencies") + ":")); + } if (details.optdepends.length > 0) { foreach (unowned string name in details.optdepends) { var optdep = new StringBuilder (name); diff --git a/src/packages_model.vala b/src/packages_model.vala deleted file mode 100644 index 01991e2..0000000 --- a/src/packages_model.vala +++ /dev/null @@ -1,261 +0,0 @@ -/* - * pamac-vala - * - * Copyright (C) 2014-2016 Guillaume Benoit - * - * 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 3 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 . - */ - -namespace Pamac { - - class PackagesModel : Object, Gtk.TreeModel { - private Alpm.List? pkgs; - private ManagerWindow manager_window; - - public PackagesModel (owned Alpm.List? pkgs, ManagerWindow manager_window) { - this.manager_window = manager_window; - this.pkgs = (owned) pkgs; - } - - // TreeModel interface - public Type get_column_type (int index) { - switch (index) { - case 0: // name - case 2: // version - case 3: // repo - case 4: // installed size - return typeof (string); - case 1: // icon - return typeof (Gdk.Pixbuf); - default: - return Type.INVALID; - } - } - - Gtk.TreeModelFlags get_flags () { - return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST; - } - - void get_value (Gtk.TreeIter iter, int column, out Value val) { - unowned Alpm.Package? pkg = pkgs.nth (iter.stamp).data; - switch (column) { - case 0: - val = Value (typeof (string)); - if (pkg == null) { - val.set_string (dgettext (null, "No package found")); - } else { - val.set_string (pkg.name); - } - break; - case 1: - val = Value (typeof (Object)); - if (pkg != null) { - if (pkg.origin == Alpm.Package.From.LOCALDB) { - if (manager_window.transaction.alpm_utils.get_holdpkgs ().find_custom (pkg.name, strcmp) != null) { - val.set_object (manager_window.locked_icon); - } else if (manager_window.transaction.to_add.contains (pkg.name)) { - val.set_object (manager_window.to_reinstall_icon); - } else if (manager_window.transaction.to_remove.contains (pkg.name)) { - val.set_object (manager_window.to_remove_icon); - } else { - val.set_object (manager_window.installed_icon); - } - } else if (manager_window.transaction.to_add.contains (pkg.name)) { - val.set_object (manager_window.to_install_icon); - } else { - val.set_object (manager_window.uninstalled_icon); - } - } - break; - case 2: - val = Value (typeof (string)); - if (pkg != null) { - val.set_string (pkg.version); - } - break; - case 3: - val = Value (typeof (string)); - if (pkg != null) { - val.set_string (pkg.db.name); - } - break; - case 4: - val = Value (typeof (string)); - if (pkg != null) { - val.set_string (format_size (pkg.isize)); - } - break; - default: - val = Value (Type.INVALID); - break; - } - } - - bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) { - if (path.get_depth () == 1) { - int pos = path.get_indices ()[0]; - // return a valid iter for pos == 0 to display "No package found" - if (pos < pkgs.length || pos == 0) { - iter = Gtk.TreeIter (); - iter.stamp = pos; - return true; - } - } - return invalid_iter (out iter); - } - - int get_n_columns () { - // name, icon, version, repo, isize - return 5; - } - - Gtk.TreePath? get_path (Gtk.TreeIter iter) { - int pos = iter.stamp; - // return a valid path for pos == 0 to display "No package found" - if (pos < pkgs.length || pos == 0) { - return new Gtk.TreePath.from_indices (pos); - } - return null; - } - - int iter_n_children (Gtk.TreeIter? iter) { - return 0; - } - - bool iter_next (ref Gtk.TreeIter iter) { - int pos = (iter.stamp) + 1; - if (pos >= pkgs.length) { - return false; - } - iter.stamp = pos; - return true; - } - - bool iter_previous (ref Gtk.TreeIter iter) { - int pos = iter.stamp; - if (pos >= 0) { - return false; - } - iter.stamp = (--pos); - return true; - } - - bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) { - return invalid_iter (out iter); - } - - bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) { - return invalid_iter (out iter); - } - - bool iter_has_child (Gtk.TreeIter iter) { - return false; - } - - bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) { - return invalid_iter (out iter); - } - - bool invalid_iter (out Gtk.TreeIter iter) { - iter = Gtk.TreeIter (); - iter.stamp = -1; - return false; - } - - // custom get pkg function - public unowned Alpm.Package? get_pkg_at_path (Gtk.TreePath path) { - int pos = path.get_indices ()[0]; - if (pos < pkgs.length) { - return pkgs.nth (pos).data; - } - return null; - } - - // custom sort functions - public void sort_by_name (Gtk.SortType order) { - pkgs.sort ((Alpm.List.CompareFunc) alpm_pkg_compare_name); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.packages_name_column.sort_order = order; - manager_window.packages_state_column.sort_indicator = false; - manager_window.packages_name_column.sort_indicator = true; - manager_window.packages_version_column.sort_indicator = false; - manager_window.packages_repo_column.sort_indicator = false; - manager_window.packages_size_column.sort_indicator = false; - manager_window.sortinfo.column_number = 0; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_state (Gtk.SortType order) { - pkgs.sort ((Alpm.List.CompareFunc) alpm_pkg_compare_origin); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.packages_state_column.sort_order = order; - manager_window.packages_state_column.sort_indicator = true; - manager_window.packages_name_column.sort_indicator = false; - manager_window.packages_version_column.sort_indicator = false; - manager_window.packages_repo_column.sort_indicator = false; - manager_window.packages_size_column.sort_indicator = false; - manager_window.sortinfo.column_number = 1; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_version (Gtk.SortType order) { - pkgs.sort ((Alpm.List.CompareFunc) alpm_pkg_compare_version); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.packages_version_column.sort_order = order; - manager_window.packages_state_column.sort_indicator = false; - manager_window.packages_name_column.sort_indicator = false; - manager_window.packages_version_column.sort_indicator = true; - manager_window.packages_repo_column.sort_indicator = false; - manager_window.packages_size_column.sort_indicator = false; - manager_window.sortinfo.column_number = 2; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_repo (Gtk.SortType order) { - pkgs.sort ((Alpm.List.CompareFunc) alpm_pkg_compare_db_name); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.packages_repo_column.sort_order = order; - manager_window.packages_state_column.sort_indicator = false; - manager_window.packages_name_column.sort_indicator = false; - manager_window.packages_version_column.sort_indicator = false; - manager_window.packages_repo_column.sort_indicator = true; - manager_window.packages_size_column.sort_indicator = false; - manager_window.sortinfo.column_number = 3; - manager_window.sortinfo.sort_type = order; - } - - public void sort_by_size (Gtk.SortType order) { - pkgs.sort ((Alpm.List.CompareFunc) alpm_pkg_compare_installed_size); - if (order == Gtk.SortType.DESCENDING) { - pkgs.reverse (); - } - manager_window.packages_size_column.sort_order = order; - manager_window.packages_state_column.sort_indicator = false; - manager_window.packages_name_column.sort_indicator = false; - manager_window.packages_version_column.sort_indicator = false; - manager_window.packages_repo_column.sort_indicator = false; - manager_window.packages_size_column.sort_indicator = true; - manager_window.sortinfo.column_number = 4; - manager_window.sortinfo.sort_type = order; - } - } -} diff --git a/src/transaction.vala b/src/transaction.vala index 3c0e66d..fdc7f9a 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -938,6 +938,7 @@ namespace Pamac { while (Gtk.events_pending ()) { Gtk.main_iteration (); } + start_transaction (); string[] cmds = {"yaourt", "-S"}; if (pamac_config.no_confirm_build) { cmds += "--noconfirm";