From 38a0f61ebd4c82d2228eba1a2aae00f86c339ce7 Mon Sep 17 00:00:00 2001 From: guinux Date: Sat, 9 Sep 2017 17:25:24 +0200 Subject: [PATCH] remove SearchAURByDefault option and add BuildDirectory option --- data/config/pamac.conf | 7 ++--- po/pamac.pot | 8 +++--- resources/preferences_dialog.ui | 49 ++++++++++++++++++++++++--------- src/manager_window.vala | 39 +++++++------------------- src/pamac_config.vala | 30 ++++++++------------ src/preferences_dialog.vala | 28 +++++++++++++------ src/system_daemon.vala | 4 +-- src/transaction.vala | 17 ++++++++---- 8 files changed, 96 insertions(+), 86 deletions(-) diff --git a/data/config/pamac.conf b/data/config/pamac.conf index 1790da1..927d5ad 100644 --- a/data/config/pamac.conf +++ b/data/config/pamac.conf @@ -13,11 +13,8 @@ RefreshPeriod = 6 ## Allow Pamac to search and install packages from AUR: #EnableAUR -## When AUR support is enabled search in AUR by default: -#SearchInAURByDefault - ## When AUR support is enabled check for updates from AUR: #CheckAURUpdates -## Do not ask for confirmation when building packages: -#NoConfirmBuild +## AUR build directory: +BuildDirectory = /tmp diff --git a/po/pamac.pot b/po/pamac.pot index 47832bb..a863813 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -597,6 +597,10 @@ msgstr "" msgid "Number of versions of each package to keep in the cache" msgstr "" +#: ../src/preferences_dialog.vala +msgid "Build directory" +msgstr "" + #: ../src/preferences_dialog.vala msgid "Worldwide" msgstr "" @@ -775,10 +779,6 @@ msgstr "" msgid "Allow Pamac to search and install packages from AUR" msgstr "" -#: ../resources/preferences_dialog.ui -msgid "Search in AUR by default" -msgstr "" - #: ../resources/preferences_dialog.ui msgid "Check for updates from AUR" msgstr "" diff --git a/resources/preferences_dialog.ui b/resources/preferences_dialog.ui index 11d087e..9f344ae 100644 --- a/resources/preferences_dialog.ui +++ b/resources/preferences_dialog.ui @@ -586,18 +586,17 @@ All AUR users should be familiar with the build process. True False 12 - True True False + start 6 6 6 6 True Enable AUR support - 0 False @@ -630,8 +629,8 @@ All AUR users should be familiar with the build process. - - Search in AUR by default + + Check for updates from AUR True True False @@ -648,16 +647,40 @@ All AUR users should be familiar with the build process. - - Check for updates from AUR + True - True - False - start - 24 - 24 - True - True + False + 26 + 12 + True + + + True + False + start + True + + + False + True + 0 + + + + + True + False + end + 24 + select-folder + + + + False + True + 1 + + False diff --git a/src/manager_window.vala b/src/manager_window.vala index acc3166..54a65ea 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -369,7 +369,7 @@ namespace Pamac { } void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur) { + bool enable_aur) { support_aur (enable_aur); } @@ -1058,7 +1058,9 @@ namespace Pamac { this.get_window ().set_cursor (null); return; } else { - select_all_button.visible = true; + if (main_stack.visible_child_name == "browse") { + select_all_button.visible = true; + } } foreach (unowned AlpmPackage pkg in pkgs) { string version; @@ -1132,7 +1134,9 @@ namespace Pamac { this.get_window ().set_cursor (null); return; } else { - select_all_button.visible = true; + if (main_stack.visible_child_name == "browse") { + select_all_button.visible = true; + } } foreach (unowned AURPackage aur_pkg in pkgs) { string version; @@ -1291,11 +1295,6 @@ namespace Pamac { if (aur_pkgs.length > 0 ) { if (pkgs.length == 0) { origin_stack.visible_child_name = "aur"; - } else { - attention_val.set_boolean (true); - origin_stack.child_set_property (origin_stack.get_child_by_name ("aur"), - "needs-attention", - attention_val); } } } @@ -1622,11 +1621,6 @@ namespace Pamac { transaction.search_in_aur.begin (search_string, (obj, res) => { populate_aur_list (transaction.search_in_aur.end (res)); }); - var attention_val = GLib.Value (typeof (bool)); - attention_val.set_boolean (false); - origin_stack.child_set_property (origin_stack.get_child_by_name ("aur"), - "needs-attention", - attention_val); } else if (filters_stack.visible_child_name == "updates") { populate_aur_list (aur_updates); } @@ -1891,21 +1885,6 @@ namespace Pamac { // get custom sort by relevance packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0); populate_packages_list (pkgs); - if (transaction.search_aur) { - transaction.search_in_aur.begin (search_string, (obj, res) => { - if (transaction.search_in_aur.end (res).length > 0) { - if (pkgs.length > 0) { - var attention_val = GLib.Value (typeof (bool)); - attention_val.set_boolean (true); - origin_stack.child_set_property (origin_stack.get_child_by_name ("aur"), - "needs-attention", - attention_val); - } else { - origin_stack.visible_child_name = "aur"; - } - } - }); - } }); aur_list.clear (); break; @@ -2325,7 +2304,9 @@ namespace Pamac { } else if (origin_stack.visible_child_name == "aur") { populate_aur_list (aur_updates); } - select_all_button.visible = true; + if (main_stack.visible_child_name == "browse") { + select_all_button.visible = true; + } set_pendings_operations (); } } diff --git a/src/pamac_config.vala b/src/pamac_config.vala index a0116d4..f910ba4 100644 --- a/src/pamac_config.vala +++ b/src/pamac_config.vala @@ -26,7 +26,7 @@ namespace Pamac { public uint64 refresh_period { get; private set; } public bool no_update_hide_icon { get; private set; } public bool enable_aur { get; private set; } - public bool search_aur { get; private set; } + public string aur_build_dir { get; private set; } public bool check_aur_updates { get; private set; } public unowned HashTable environment_variables { get { @@ -70,7 +70,7 @@ namespace Pamac { recurse = false; no_update_hide_icon = false; enable_aur = false; - search_aur = false; + aur_build_dir = "/tmp"; check_aur_updates = false; parse_file (conf_path); } @@ -107,8 +107,10 @@ namespace Pamac { no_update_hide_icon = true; } else if (key == "EnableAUR") { enable_aur = true; - } else if (key == "SearchInAURByDefault") { - search_aur = true; + } else if (key == "BuildDirectory") { + if (splitted.length == 2) { + aur_build_dir = splitted[1]._strip (); + } } else if (key == "CheckAURUpdates") { check_aur_updates = true; } @@ -177,14 +179,10 @@ namespace Pamac { } else { data.append (line + "\n"); } - } else if (line.contains ("SearchInAURByDefault")) { - if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("SearchInAURByDefault\n"); - } else { - data.append ("#SearchInAURByDefault\n"); - } - new_conf.remove ("SearchInAURByDefault"); + } else if (line.contains ("BuildDirectory")) { + if (new_conf.lookup_extended ("BuildDirectory", null, out variant)) { + data.append ("BuildDirectory = %s\n".printf (variant.get_string ())); + new_conf.remove ("BuildDirectory"); } else { data.append (line + "\n"); } @@ -238,12 +236,8 @@ namespace Pamac { } else { data.append ("#EnableAUR\n"); } - } else if (key == "SearchInAURByDefault") { - if (val.get_boolean ()) { - data.append ("SearchInAURByDefault\n"); - } else { - data.append ("#SearchInAURByDefault\n"); - } + } else if (key == "BuildDirectory") { + data.append ("BuildDirectory = %s\n".printf (val.get_string ())); } else if (key == "CheckAURUpdates") { if (val.get_boolean ()) { data.append ("CheckAURUpdates\n"); diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala index f78e3fa..90a3f67 100644 --- a/src/preferences_dialog.vala +++ b/src/preferences_dialog.vala @@ -49,7 +49,9 @@ namespace Pamac { [GtkChild] Gtk.Switch enable_aur_button; [GtkChild] - Gtk.CheckButton search_aur_checkbutton; + Gtk.Label aur_build_dir_label; + [GtkChild] + Gtk.FileChooserButton aur_build_dir_file_chooser; [GtkChild] Gtk.CheckButton check_aur_updates_checkbutton; [GtkChild] @@ -71,6 +73,7 @@ namespace Pamac { this.transaction = transaction; refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":"); cache_keep_nb_label.set_markup (dgettext (null, "Number of versions of each package to keep in the cache") +":"); + aur_build_dir_label.set_markup (dgettext (null, "Build directory") +":"); remove_unrequired_deps_button.active = transaction.recurse; check_space_button.active = transaction.get_checkspace (); if (transaction.refresh_period == 0) { @@ -134,12 +137,19 @@ namespace Pamac { } enable_aur_button.active = transaction.enable_aur; - search_aur_checkbutton.active = transaction.search_aur; - search_aur_checkbutton.sensitive = transaction.enable_aur; + aur_build_dir_label.sensitive = transaction.enable_aur; + aur_build_dir_file_chooser.sensitive = transaction.enable_aur; + aur_build_dir_file_chooser.set_filename (transaction.aur_build_dir); + // add /tmp choice always visible + try { + aur_build_dir_file_chooser.add_shortcut_folder ("/tmp"); + } catch (GLib.Error e) { + stderr.printf ("%s\n", e.message); + } check_aur_updates_checkbutton.active = transaction.check_aur_updates; check_aur_updates_checkbutton.sensitive = transaction.enable_aur; enable_aur_button.state_set.connect (on_enable_aur_button_state_set); - search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled); + aur_build_dir_file_chooser.file_set.connect (on_aur_build_dir_set); check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled); } @@ -184,9 +194,9 @@ namespace Pamac { return true; } - void on_search_aur_checkbutton_toggled () { + void on_aur_build_dir_set () { var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("SearchInAURByDefault", new Variant.boolean (search_aur_checkbutton.active)); + new_pamac_conf.insert ("BuildDirectory", new Variant.string (aur_build_dir_file_chooser.get_filename ())); transaction.start_write_pamac_config (new_pamac_conf); } @@ -197,7 +207,7 @@ namespace Pamac { } void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, bool check_aur_updates) { + bool enable_aur, string aur_build_dir, bool check_aur_updates) { remove_unrequired_deps_button.state = recurse; if (refresh_period == 0) { check_updates_button.state = false; @@ -216,8 +226,8 @@ namespace Pamac { } no_update_hide_icon_checkbutton.active = no_update_hide_icon; enable_aur_button.state = enable_aur; - search_aur_checkbutton.active = search_aur; - search_aur_checkbutton.sensitive = enable_aur; + aur_build_dir_label.sensitive = enable_aur; + aur_build_dir_file_chooser.sensitive = enable_aur; check_aur_updates_checkbutton.active = check_aur_updates; check_aur_updates_checkbutton.sensitive = enable_aur; } diff --git a/src/system_daemon.vala b/src/system_daemon.vala index 477bd99..fce33e1 100644 --- a/src/system_daemon.vala +++ b/src/system_daemon.vala @@ -87,7 +87,7 @@ namespace Pamac { public signal void trans_commit_finished (bool success); public signal void get_authorization_finished (bool authorized); public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, bool check_aur_updates); + bool enable_aur, string aur_build_dir, bool check_aur_updates); public signal void write_alpm_config_finished (bool checkspace); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void generate_mirrors_list_data (string line); @@ -339,7 +339,7 @@ namespace Pamac { pamac_config.reload (); } write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon, - pamac_config.enable_aur, pamac_config.search_aur, pamac_config.check_aur_updates); + pamac_config.enable_aur, pamac_config.aur_build_dir, pamac_config.check_aur_updates); }); } diff --git a/src/transaction.vala b/src/transaction.vala index 113a877..c9ce977 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -88,7 +88,7 @@ namespace Pamac { public signal void trans_commit_finished (bool success); public signal void get_authorization_finished (bool authorized); public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, bool check_aur_updates); + bool enable_aur, string aur_build_dir, bool check_aur_updates); public signal void write_alpm_config_finished (bool checkspace); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void generate_mirrors_list_data (string line); @@ -119,7 +119,7 @@ namespace Pamac { public bool no_update_hide_icon { get { return pamac_config.no_update_hide_icon; } } public bool recurse { get { return pamac_config.recurse; } } public uint64 refresh_period { get { return pamac_config.refresh_period; } } - public bool search_aur { get { return pamac_config.search_aur; } } + public string aur_build_dir { get { return pamac_config.aur_build_dir; } } //Alpm.TransFlag int flags; @@ -173,7 +173,7 @@ namespace Pamac { public signal void finished (bool success); public signal void set_pkgreason_finished (); public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, bool check_aur_updates); + bool enable_aur, string aur_build_dir, bool check_aur_updates); public signal void write_alpm_config_finished (bool checkspace); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void generate_mirrors_list (); @@ -1092,7 +1092,12 @@ namespace Pamac { to_build.remove_all (); string [] built_pkgs = {}; int status = 1; - string builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ()); + string builddir; + if (aur_build_dir == "/tmp") { + builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ()); + } else { + builddir = aur_build_dir; + } status = yield spawn_in_term ({"mkdir", "-p", builddir}); if (status == 0) { status = yield spawn_in_term ({"rm", "-rf", pkgname}, builddir); @@ -1761,7 +1766,7 @@ namespace Pamac { } void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, bool check_aur_updates) { + bool enable_aur, string aur_build_dir, bool check_aur_updates) { system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished); pamac_config.reload (); flags = (1 << 4); //Alpm.TransFlag.CASCADE @@ -1769,7 +1774,7 @@ namespace Pamac { flags |= (1 << 5); //Alpm.TransFlag.RECURSE } write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, - enable_aur, search_aur, check_aur_updates); + enable_aur, aur_build_dir, check_aur_updates); } void on_write_alpm_config_finished (bool checkspace) {