add search in AUR by default option

This commit is contained in:
guinux 2015-08-24 16:13:18 +02:00
parent 4f5eeea04b
commit f3c6e46baf
9 changed files with 102 additions and 35 deletions

View File

@ -13,6 +13,9 @@ 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

View File

@ -681,6 +681,10 @@ 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

@ -383,12 +383,12 @@
<object class="GtkBox" id="mirrors_config_box"> <object class="GtkBox" id="mirrors_config_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">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="margin_top">6</property> <property name="margin_top">6</property>
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkBox" id="box5"> <object class="GtkBox" id="box5">
<property name="visible">True</property> <property name="visible">True</property>
@ -602,6 +602,22 @@ All AUR users should be familiar with the build process.</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="search_aur_checkbutton">
<property name="label" translatable="yes">Search in AUR by default</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_start">24</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">2</property>
</packing>
</child>
<child> <child>
<object class="GtkCheckButton" id="check_aur_updates_checkbutton"> <object class="GtkCheckButton" id="check_aur_updates_checkbutton">
<property name="label" translatable="yes">Check for updates from AUR</property> <property name="label" translatable="yes">Check for updates from AUR</property>
@ -615,7 +631,7 @@ All AUR users should be familiar with the build process.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -631,7 +647,7 @@ All AUR users should be familiar with the build process.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -66,8 +66,8 @@ namespace Pamac {
public signal void trans_prepare_finished (ErrorInfos error); public signal void trans_prepare_finished (ErrorInfos error);
public signal void trans_commit_finished (ErrorInfos error); public signal void trans_commit_finished (ErrorInfos error);
public signal void get_authorization_finished (bool authorized); public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse, public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool no_update_hide_icon, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build); bool no_confirm_build);
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);
@ -183,9 +183,9 @@ namespace Pamac {
pamac_config.write (new_pamac_conf); pamac_config.write (new_pamac_conf);
pamac_config.reload (); pamac_config.reload ();
} }
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon,
pamac_config.recurse, pamac_config.no_update_hide_icon, pamac_config.enable_aur, pamac_config.search_aur, pamac_config.check_aur_updates,
pamac_config.check_aur_updates, pamac_config.no_confirm_build); pamac_config.no_confirm_build);
}); });
} }
@ -415,7 +415,7 @@ namespace Pamac {
return Pamac.Package (get_syncpkg (pkgname), null); return Pamac.Package (get_syncpkg (pkgname), null);
} }
public async Pamac.Package[] search_pkgs (string search_string, bool search_from_aur) { public async Pamac.Package[] search_pkgs (string search_string, bool search_aur) {
Pamac.Package[] result = {}; Pamac.Package[] result = {};
var needles = new Alpm.List<string> (); var needles = new Alpm.List<string> ();
string[] splitted = search_string.split (" "); string[] splitted = search_string.split (" ");
@ -426,7 +426,7 @@ namespace Pamac {
foreach (var alpm_pkg in alpm_pkgs) { foreach (var alpm_pkg in alpm_pkgs) {
result += Pamac.Package (alpm_pkg, null); result += Pamac.Package (alpm_pkg, null);
} }
if (search_from_aur) { if (search_aur) {
Json.Array aur_pkgs; Json.Array aur_pkgs;
if (aur_search_results.contains (search_string)) { if (aur_search_results.contains (search_string)) {
aur_pkgs = aur_search_results.get (search_string); aur_pkgs = aur_search_results.get (search_string);

View File

@ -173,7 +173,7 @@ namespace Pamac {
transaction = new Pamac.Transaction (this as Gtk.ApplicationWindow); transaction = new Pamac.Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.MANAGER; transaction.mode = Mode.MANAGER;
transaction.finished.connect (on_transaction_finished); transaction.finished.connect (on_transaction_finished);
transaction.enable_aur.connect (enable_aur); transaction.support_aur.connect (support_aur);
transaction.daemon.set_pkgreason_finished.connect (display_package_properties); transaction.daemon.set_pkgreason_finished.connect (display_package_properties);
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
@ -182,9 +182,9 @@ namespace Pamac {
} }
Pamac.Package pkg = transaction.find_local_satisfier ("yaourt"); Pamac.Package pkg = transaction.find_local_satisfier ("yaourt");
if (pkg.name == "") { if (pkg.name == "") {
enable_aur (false); support_aur (false, false);
} else { } else {
enable_aur (pamac_config.enable_aur); support_aur (pamac_config.enable_aur, pamac_config.search_aur);
} }
set_buttons_sensitive (false); set_buttons_sensitive (false);
@ -194,9 +194,14 @@ namespace Pamac {
update_lists (); update_lists ();
} }
public void enable_aur (bool enable) { public void support_aur (bool enable_aur, bool search_aur) {
search_aur_button.set_active (false); if (enable_aur) {
search_aur_box.set_visible (enable); search_aur_button.set_active (search_aur);
search_aur_box.set_visible (true);
} else {
search_aur_button.set_active (false);
search_aur_box.set_visible (false);
}
} }
public void set_buttons_sensitive (bool sensitive) { public void set_buttons_sensitive (bool sensitive) {

View File

@ -20,10 +20,11 @@
namespace Pamac { namespace Pamac {
public class Config: Object { public class Config: Object {
string conf_path; string conf_path;
public int refresh_period;
public bool enable_aur;
public bool recurse; public bool recurse;
public int refresh_period;
public bool no_update_hide_icon; public bool no_update_hide_icon;
public bool enable_aur;
public bool search_aur;
public bool check_aur_updates; public bool check_aur_updates;
public bool no_confirm_build; public bool no_confirm_build;
@ -36,9 +37,10 @@ namespace Pamac {
public void reload () { public void reload () {
// set default options // set default options
enable_aur = false;
recurse = false; recurse = false;
no_update_hide_icon = false; no_update_hide_icon = false;
enable_aur = false;
search_aur = false;
check_aur_updates = false; check_aur_updates = false;
no_confirm_build = false; no_confirm_build = false;
parse_file (conf_path); parse_file (conf_path);
@ -77,6 +79,8 @@ 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") {
search_aur = true;
} else if (key == "CheckAURUpdates") { } else if (key == "CheckAURUpdates") {
check_aur_updates = true; check_aur_updates = true;
} else if (key == "NoConfirmBuild") { } else if (key == "NoConfirmBuild") {
@ -150,6 +154,18 @@ namespace Pamac {
} else { } else {
data += line + "\n"; data += line + "\n";
} }
} else if (line.contains ("SearchInAURByDefault")) {
if (new_conf.contains ("SearchInAURByDefault")) {
bool val = new_conf.get ("SearchInAURByDefault").get_boolean ();
if (val == true) {
data += "SearchInAURByDefault\n";
} else {
data += "#SearchInAURByDefault\n";
}
new_conf.remove ("SearchInAURByDefault");
} else {
data += line + "\n";
}
} else if (line.contains ("CheckAURUpdates")) { } else if (line.contains ("CheckAURUpdates")) {
if (new_conf.contains ("CheckAURUpdates")) { if (new_conf.contains ("CheckAURUpdates")) {
bool val = new_conf.get ("CheckAURUpdates").get_boolean (); bool val = new_conf.get ("CheckAURUpdates").get_boolean ();
@ -210,6 +226,12 @@ namespace Pamac {
} else { } else {
data += "#EnableAUR\n"; data += "#EnableAUR\n";
} }
} else if (key == "SearchInAURByDefault") {
if (val.get_boolean () == true) {
data += "SearchInAURByDefault\n";
} else {
data += "#SearchInAURByDefault\n";
}
} else if (key == "CheckAURUpdates") { } else if (key == "CheckAURUpdates") {
if (val.get_boolean () == true) { if (val.get_boolean () == true) {
data += "CheckAURUpdates\n"; data += "CheckAURUpdates\n";

View File

@ -53,6 +53,8 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.Switch enable_aur_button; public Gtk.Switch enable_aur_button;
[GtkChild] [GtkChild]
public Gtk.CheckButton search_aur_checkbutton;
[GtkChild]
public Gtk.CheckButton check_aur_updates_checkbutton; public Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild] [GtkChild]
public Gtk.CheckButton no_confirm_build_checkbutton; public Gtk.CheckButton no_confirm_build_checkbutton;
@ -129,11 +131,14 @@ namespace Pamac {
aur_config_box.visible = false; aur_config_box.visible = false;
} else { } else {
enable_aur_button.active = pamac_config.enable_aur; enable_aur_button.active = pamac_config.enable_aur;
search_aur_checkbutton.active = pamac_config.search_aur;
search_aur_checkbutton.sensitive = pamac_config.enable_aur;
check_aur_updates_checkbutton.active = pamac_config.check_aur_updates; check_aur_updates_checkbutton.active = pamac_config.check_aur_updates;
check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur; check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur;
no_confirm_build_checkbutton.active = pamac_config.no_confirm_build; no_confirm_build_checkbutton.active = pamac_config.no_confirm_build;
no_confirm_build_checkbutton.sensitive = pamac_config.enable_aur; no_confirm_build_checkbutton.sensitive = pamac_config.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);
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled); check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
no_confirm_build_checkbutton.toggled.connect (on_no_confirm_build_checkbutton_toggled); no_confirm_build_checkbutton.toggled.connect (on_no_confirm_build_checkbutton_toggled);
transaction.daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished); transaction.daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
@ -181,6 +186,12 @@ namespace Pamac {
return true; return true;
} }
void on_search_aur_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("SearchInAURByDefault", new Variant.boolean (search_aur_checkbutton.active));
transaction.start_write_pamac_config (new_pamac_conf);
}
void on_check_aur_updates_checkbutton_toggled () { void on_check_aur_updates_checkbutton_toggled () {
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 ("CheckAURUpdates", new Variant.boolean (check_aur_updates_checkbutton.active)); new_pamac_conf.insert ("CheckAURUpdates", new Variant.boolean (check_aur_updates_checkbutton.active));
@ -193,8 +204,8 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf); transaction.start_write_pamac_config (new_pamac_conf);
} }
void on_write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse, void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool no_update_hide_icon, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) { bool no_confirm_build) {
remove_unrequired_deps_button.state = recurse; remove_unrequired_deps_button.state = recurse;
if (refresh_period == 0) { if (refresh_period == 0) {
@ -219,11 +230,13 @@ 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 = aur_enabled; enable_aur_button.state = enable_aur;
search_aur_checkbutton.active = search_aur;
search_aur_checkbutton.sensitive = enable_aur;
check_aur_updates_checkbutton.active = check_aur_updates; check_aur_updates_checkbutton.active = check_aur_updates;
check_aur_updates_checkbutton.sensitive = aur_enabled; check_aur_updates_checkbutton.sensitive = enable_aur;
no_confirm_build_checkbutton.active = no_confirm_build; no_confirm_build_checkbutton.active = no_confirm_build;
no_confirm_build_checkbutton.sensitive = aur_enabled; no_confirm_build_checkbutton.sensitive = enable_aur;
} }
bool on_check_space_button_state_set (bool new_state) { bool on_check_space_button_state_set (bool new_state) {

View File

@ -74,8 +74,8 @@ namespace Pamac {
public signal void trans_prepare_finished (ErrorInfos error); public signal void trans_prepare_finished (ErrorInfos error);
public signal void trans_commit_finished (ErrorInfos error); public signal void trans_commit_finished (ErrorInfos error);
public signal void get_authorization_finished (bool authorized); public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse, public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool no_update_hide_icon, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build); bool no_confirm_build);
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);
@ -121,7 +121,7 @@ namespace Pamac {
Gtk.ApplicationWindow? window; Gtk.ApplicationWindow? window;
public signal void finished (bool with_error); public signal void finished (bool with_error);
public signal void enable_aur (bool enable); public signal void support_aur (bool enable_aur, bool search_aur);
public Transaction (Gtk.ApplicationWindow? window) { public Transaction (Gtk.ApplicationWindow? window) {
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
@ -1285,14 +1285,16 @@ namespace Pamac {
}); });
} }
void on_write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse) { void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) {
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
if (recurse) { if (recurse) {
flags |= Alpm.TransFlag.RECURSE; flags |= Alpm.TransFlag.RECURSE;
} }
Pamac.Package pkg = find_local_satisfier ("yaourt"); Pamac.Package pkg = find_local_satisfier ("yaourt");
if (pkg.name != "") { if (pkg.name != "") {
enable_aur (aur_enabled); support_aur (enable_aur, search_aur);
} }
} }

View File

@ -28,13 +28,13 @@ namespace Pamac {
[DBus (name = "org.manjaro.pamac")] [DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object { public interface Daemon : Object {
public abstract void start_refresh (int force) throws IOError; public abstract void start_refresh (int force) throws IOError;
public abstract async Updates get_updates (bool enable_aur) throws IOError; public abstract async Updates get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)] [DBus (no_reply = true)]
public abstract void quit () throws IOError; public abstract void quit () throws IOError;
public signal void refresh_finished (ErrorInfos error); public signal void refresh_finished (ErrorInfos error);
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse, public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool no_update_hide_icon, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build); bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace); public signal void write_alpm_config_finished (bool checkspace);
} }
@ -136,7 +136,9 @@ namespace Pamac {
return true; return true;
} }
void on_write_pamac_config_finished (int refresh_period) { void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) {
launch_refresh_timeout ((uint) refresh_period); launch_refresh_timeout ((uint) refresh_period);
if (refresh_period == 0) { if (refresh_period == 0) {
status_icon.visible = false; status_icon.visible = false;