remove SearchAURByDefault option and add BuildDirectory option

This commit is contained in:
guinux 2017-09-09 17:25:24 +02:00
parent bbd83ded95
commit 38a0f61ebd
8 changed files with 96 additions and 86 deletions

View File

@ -13,11 +13,8 @@ RefreshPeriod = 6
## Allow Pamac to search and install packages from AUR: ## Allow Pamac to search and install packages from AUR:
#EnableAUR #EnableAUR
## When AUR support is enabled search in AUR by default:
#SearchInAURByDefault
## When AUR support is enabled check for updates from AUR: ## When AUR support is enabled check for updates from AUR:
#CheckAURUpdates #CheckAURUpdates
## Do not ask for confirmation when building packages: ## AUR build directory:
#NoConfirmBuild BuildDirectory = /tmp

View File

@ -597,6 +597,10 @@ msgstr ""
msgid "Number of versions of each package to keep in the cache" msgid "Number of versions of each package to keep in the cache"
msgstr "" msgstr ""
#: ../src/preferences_dialog.vala
msgid "Build directory"
msgstr ""
#: ../src/preferences_dialog.vala #: ../src/preferences_dialog.vala
msgid "Worldwide" msgid "Worldwide"
msgstr "" msgstr ""
@ -775,10 +779,6 @@ msgstr ""
msgid "Allow Pamac to search and install packages from AUR" msgid "Allow Pamac to search and install packages from AUR"
msgstr "" msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Search in AUR by default"
msgstr ""
#: ../resources/preferences_dialog.ui #: ../resources/preferences_dialog.ui
msgid "Check for updates from AUR" msgid "Check for updates from AUR"
msgstr "" msgstr ""

View File

@ -586,18 +586,17 @@ All AUR users should be familiar with the build process.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="homogeneous">True</property>
<child> <child>
<object class="GtkLabel" id="enable_aur_label"> <object class="GtkLabel" id="enable_aur_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">6</property> <property name="margin_left">6</property>
<property name="margin_right">6</property> <property name="margin_right">6</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="label" translatable="yes">Enable AUR support</property> <property name="label" translatable="yes">Enable AUR support</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -630,8 +629,8 @@ All AUR users should be familiar with the build process.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkCheckButton" id="search_aur_checkbutton"> <object class="GtkCheckButton" id="check_aur_updates_checkbutton">
<property name="label" translatable="yes">Search in AUR by default</property> <property name="label" translatable="yes">Check for updates from AUR</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
@ -648,16 +647,40 @@ All AUR users should be familiar with the build process.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkCheckButton" id="check_aur_updates_checkbutton"> <object class="GtkBox" id="box3">
<property name="label" translatable="yes">Check for updates from AUR</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">False</property> <property name="margin_left">26</property>
<property name="spacing">12</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="aur_build_dir_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin_left">24</property>
<property name="margin_start">24</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="draw_indicator">True</property> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="aur_build_dir_file_chooser">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_left">24</property>
<property name="action">select-folder</property>
<property name="title" translatable="yes"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -369,7 +369,7 @@ namespace Pamac {
} }
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, 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); support_aur (enable_aur);
} }
@ -1058,8 +1058,10 @@ namespace Pamac {
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
return; return;
} else { } else {
if (main_stack.visible_child_name == "browse") {
select_all_button.visible = true; select_all_button.visible = true;
} }
}
foreach (unowned AlpmPackage pkg in pkgs) { foreach (unowned AlpmPackage pkg in pkgs) {
string version; string version;
uint64 size; uint64 size;
@ -1132,8 +1134,10 @@ namespace Pamac {
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
return; return;
} else { } else {
if (main_stack.visible_child_name == "browse") {
select_all_button.visible = true; select_all_button.visible = true;
} }
}
foreach (unowned AURPackage aur_pkg in pkgs) { foreach (unowned AURPackage aur_pkg in pkgs) {
string version; string version;
if (filters_stack.visible_child_name == "updates") { if (filters_stack.visible_child_name == "updates") {
@ -1291,11 +1295,6 @@ namespace Pamac {
if (aur_pkgs.length > 0 ) { if (aur_pkgs.length > 0 ) {
if (pkgs.length == 0) { if (pkgs.length == 0) {
origin_stack.visible_child_name = "aur"; 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) => { transaction.search_in_aur.begin (search_string, (obj, res) => {
populate_aur_list (transaction.search_in_aur.end (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") { } else if (filters_stack.visible_child_name == "updates") {
populate_aur_list (aur_updates); populate_aur_list (aur_updates);
} }
@ -1891,21 +1885,6 @@ namespace Pamac {
// get custom sort by relevance // get custom sort by relevance
packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0); packages_list.set_sort_column_id (Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
populate_packages_list (pkgs); 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 (); aur_list.clear ();
break; break;
@ -2325,7 +2304,9 @@ namespace Pamac {
} else if (origin_stack.visible_child_name == "aur") { } else if (origin_stack.visible_child_name == "aur") {
populate_aur_list (aur_updates); populate_aur_list (aur_updates);
} }
if (main_stack.visible_child_name == "browse") {
select_all_button.visible = true; select_all_button.visible = true;
}
set_pendings_operations (); set_pendings_operations ();
} }
} }

View File

@ -26,7 +26,7 @@ namespace Pamac {
public uint64 refresh_period { get; private set; } public uint64 refresh_period { get; private set; }
public bool no_update_hide_icon { get; private set; } public bool no_update_hide_icon { get; private set; }
public bool enable_aur { 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 bool check_aur_updates { get; private set; }
public unowned HashTable<string,string> environment_variables { public unowned HashTable<string,string> environment_variables {
get { get {
@ -70,7 +70,7 @@ namespace Pamac {
recurse = false; recurse = false;
no_update_hide_icon = false; no_update_hide_icon = false;
enable_aur = false; enable_aur = false;
search_aur = false; aur_build_dir = "/tmp";
check_aur_updates = false; check_aur_updates = false;
parse_file (conf_path); parse_file (conf_path);
} }
@ -107,8 +107,10 @@ namespace Pamac {
no_update_hide_icon = true; no_update_hide_icon = true;
} else if (key == "EnableAUR") { } else if (key == "EnableAUR") {
enable_aur = true; enable_aur = true;
} else if (key == "SearchInAURByDefault") { } else if (key == "BuildDirectory") {
search_aur = true; if (splitted.length == 2) {
aur_build_dir = splitted[1]._strip ();
}
} else if (key == "CheckAURUpdates") { } else if (key == "CheckAURUpdates") {
check_aur_updates = true; check_aur_updates = true;
} }
@ -177,14 +179,10 @@ namespace Pamac {
} else { } else {
data.append (line + "\n"); data.append (line + "\n");
} }
} else if (line.contains ("SearchInAURByDefault")) { } else if (line.contains ("BuildDirectory")) {
if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) { if (new_conf.lookup_extended ("BuildDirectory", null, out variant)) {
if (variant.get_boolean ()) { data.append ("BuildDirectory = %s\n".printf (variant.get_string ()));
data.append ("SearchInAURByDefault\n"); new_conf.remove ("BuildDirectory");
} else {
data.append ("#SearchInAURByDefault\n");
}
new_conf.remove ("SearchInAURByDefault");
} else { } else {
data.append (line + "\n"); data.append (line + "\n");
} }
@ -238,12 +236,8 @@ namespace Pamac {
} else { } else {
data.append ("#EnableAUR\n"); data.append ("#EnableAUR\n");
} }
} else if (key == "SearchInAURByDefault") { } else if (key == "BuildDirectory") {
if (val.get_boolean ()) { data.append ("BuildDirectory = %s\n".printf (val.get_string ()));
data.append ("SearchInAURByDefault\n");
} else {
data.append ("#SearchInAURByDefault\n");
}
} else if (key == "CheckAURUpdates") { } else if (key == "CheckAURUpdates") {
if (val.get_boolean ()) { if (val.get_boolean ()) {
data.append ("CheckAURUpdates\n"); data.append ("CheckAURUpdates\n");

View File

@ -49,7 +49,9 @@ namespace Pamac {
[GtkChild] [GtkChild]
Gtk.Switch enable_aur_button; Gtk.Switch enable_aur_button;
[GtkChild] [GtkChild]
Gtk.CheckButton search_aur_checkbutton; Gtk.Label aur_build_dir_label;
[GtkChild]
Gtk.FileChooserButton aur_build_dir_file_chooser;
[GtkChild] [GtkChild]
Gtk.CheckButton check_aur_updates_checkbutton; Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild] [GtkChild]
@ -71,6 +73,7 @@ namespace Pamac {
this.transaction = transaction; this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":"); 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") +":"); 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; remove_unrequired_deps_button.active = transaction.recurse;
check_space_button.active = transaction.get_checkspace (); check_space_button.active = transaction.get_checkspace ();
if (transaction.refresh_period == 0) { if (transaction.refresh_period == 0) {
@ -134,12 +137,19 @@ namespace Pamac {
} }
enable_aur_button.active = transaction.enable_aur; enable_aur_button.active = transaction.enable_aur;
search_aur_checkbutton.active = transaction.search_aur; aur_build_dir_label.sensitive = transaction.enable_aur;
search_aur_checkbutton.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.active = transaction.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.enable_aur; check_aur_updates_checkbutton.sensitive = transaction.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set); 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); check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
} }
@ -184,9 +194,9 @@ namespace Pamac {
return true; return true;
} }
void on_search_aur_checkbutton_toggled () { void on_aur_build_dir_set () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal); var new_pamac_conf = new HashTable<string,Variant> (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); 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, 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; remove_unrequired_deps_button.state = recurse;
if (refresh_period == 0) { if (refresh_period == 0) {
check_updates_button.state = false; check_updates_button.state = false;
@ -216,8 +226,8 @@ namespace Pamac {
} }
no_update_hide_icon_checkbutton.active = no_update_hide_icon; no_update_hide_icon_checkbutton.active = no_update_hide_icon;
enable_aur_button.state = enable_aur; enable_aur_button.state = enable_aur;
search_aur_checkbutton.active = search_aur; aur_build_dir_label.sensitive = enable_aur;
search_aur_checkbutton.sensitive = enable_aur; aur_build_dir_file_chooser.sensitive = enable_aur;
check_aur_updates_checkbutton.active = check_aur_updates; check_aur_updates_checkbutton.active = check_aur_updates;
check_aur_updates_checkbutton.sensitive = enable_aur; check_aur_updates_checkbutton.sensitive = enable_aur;
} }

View File

@ -87,7 +87,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success); public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized); 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, 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_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line); public signal void generate_mirrors_list_data (string line);
@ -339,7 +339,7 @@ namespace Pamac {
pamac_config.reload (); pamac_config.reload ();
} }
write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon, 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);
}); });
} }

View File

@ -88,7 +88,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success); public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized); 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, 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_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line); 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 no_update_hide_icon { get { return pamac_config.no_update_hide_icon; } }
public bool recurse { get { return pamac_config.recurse; } } public bool recurse { get { return pamac_config.recurse; } }
public uint64 refresh_period { get { return pamac_config.refresh_period; } } 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 //Alpm.TransFlag
int flags; int flags;
@ -173,7 +173,7 @@ namespace Pamac {
public signal void finished (bool success); public signal void finished (bool success);
public signal void set_pkgreason_finished (); public signal void set_pkgreason_finished ();
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, 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_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list (); public signal void generate_mirrors_list ();
@ -1092,7 +1092,12 @@ namespace Pamac {
to_build.remove_all (); to_build.remove_all ();
string [] built_pkgs = {}; string [] built_pkgs = {};
int status = 1; 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}); status = yield spawn_in_term ({"mkdir", "-p", builddir});
if (status == 0) { if (status == 0) {
status = yield spawn_in_term ({"rm", "-rf", pkgname}, builddir); 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, 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); system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished);
pamac_config.reload (); pamac_config.reload ();
flags = (1 << 4); //Alpm.TransFlag.CASCADE flags = (1 << 4); //Alpm.TransFlag.CASCADE
@ -1769,7 +1774,7 @@ namespace Pamac {
flags |= (1 << 5); //Alpm.TransFlag.RECURSE flags |= (1 << 5); //Alpm.TransFlag.RECURSE
} }
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, 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) { void on_write_alpm_config_finished (bool checkspace) {