v2.4, new preferences dialog
This commit is contained in:
33
src/Makefile
33
src/Makefile
@@ -17,22 +17,24 @@ TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \
|
||||
COMMON_SOURCES = ../util/alpm-util.c \
|
||||
common.vala \
|
||||
pamac_config.vala \
|
||||
mirrors_config.vala \
|
||||
package.vala \
|
||||
|
||||
TRANSACTION_SOURCES = transaction.vala \
|
||||
choose_provider_dialog.vala \
|
||||
transaction_sum_dialog.vala \
|
||||
transaction_info_dialog.vala \
|
||||
progress_dialog.vala
|
||||
|
||||
PREFERENCES_SOURCES = preferences_dialog.vala \
|
||||
choose_ignorepkgs_dialog.vala \
|
||||
mirrors_config.vala
|
||||
|
||||
MANAGER_GRESOURCE_FILE = ../resources/pamac.manager.gresource.xml
|
||||
|
||||
UPDATER_GRESOURCE_FILE = ../resources/pamac.updater.gresource.xml
|
||||
|
||||
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
|
||||
|
||||
TRANSACTION_SOURCES = transaction.vala \
|
||||
choose_provider_dialog.vala \
|
||||
transaction_sum_dialog.vala \
|
||||
transaction_info_dialog.vala \
|
||||
preferences_dialog.vala \
|
||||
progress_dialog.vala
|
||||
|
||||
binaries: pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
|
||||
|
||||
clean:
|
||||
@@ -55,7 +57,7 @@ pamac-tray: ../vapi/libalpm.vapi ../util/alpm-util.c common.vala alpm_config.val
|
||||
pamac_config.vala \
|
||||
tray.vala
|
||||
|
||||
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) alpm_config.vala alpm_utils.vala aur.vala daemon.vala
|
||||
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala alpm_config.vala alpm_utils.vala aur.vala daemon.vala
|
||||
valac -o pamac-daemon \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=posix \
|
||||
@@ -64,33 +66,36 @@ pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCE
|
||||
--pkg=polkit-gobject-1 \
|
||||
--thread \
|
||||
$(COMMON_SOURCES) \
|
||||
mirrors_config.vala \
|
||||
alpm_config.vala \
|
||||
aur.vala \
|
||||
alpm_utils.vala \
|
||||
daemon.vala
|
||||
|
||||
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala
|
||||
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala
|
||||
valac -o pamac-manager \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
$(TRANSACTION_VALA_FLAGS) \
|
||||
--gresources=$(MANAGER_GRESOURCE_FILE) \
|
||||
../resources/manager_resources.c \
|
||||
$(COMMON_SOURCES) \
|
||||
$(TRANSACTION_SOURCES) \
|
||||
$(PREFERENCES_SOURCES) \
|
||||
choose_dep_dialog.vala \
|
||||
history_dialog.vala \
|
||||
../resources/manager_resources.c \
|
||||
packages_model.vala \
|
||||
manager_window.vala \
|
||||
manager.vala
|
||||
|
||||
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) ../resources/updater_resources.c updater_window.vala updater.vala
|
||||
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/updater_resources.c updater_window.vala updater.vala
|
||||
valac -o pamac-updater \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
$(TRANSACTION_VALA_FLAGS) \
|
||||
--gresources=$(UPDATER_GRESOURCE_FILE) \
|
||||
../resources/updater_resources.c \
|
||||
$(COMMON_SOURCES) \
|
||||
$(TRANSACTION_SOURCES) \
|
||||
../resources/updater_resources.c \
|
||||
$(PREFERENCES_SOURCES) \
|
||||
updater_window.vala \
|
||||
updater.vala
|
||||
|
||||
@@ -99,7 +104,7 @@ pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) ../
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
$(TRANSACTION_VALA_FLAGS) \
|
||||
--gresources=$(INSTALLER_GRESOURCE_FILE) \
|
||||
../resources/installer_resources.c \
|
||||
$(COMMON_SOURCES) \
|
||||
$(TRANSACTION_SOURCES) \
|
||||
../resources/installer_resources.c \
|
||||
installer.vala
|
||||
|
@@ -44,13 +44,11 @@ namespace Alpm {
|
||||
public int checkspace;
|
||||
Alpm.List<string> *cachedirs;
|
||||
Alpm.List<string> *ignoregroups;
|
||||
public string ignorepkg;
|
||||
Alpm.List<string> *ignorepkgs;
|
||||
public Alpm.List<string> *ignorepkgs;
|
||||
Alpm.List<string> *noextracts;
|
||||
Alpm.List<string> *noupgrades;
|
||||
public GLib.List<string> holdpkgs;
|
||||
public GLib.List<string> syncfirsts;
|
||||
public string syncfirst;
|
||||
Signature.Level defaultsiglevel;
|
||||
Signature.Level localfilesiglevel;
|
||||
Signature.Level remotefilesiglevel;
|
||||
@@ -73,7 +71,6 @@ namespace Alpm {
|
||||
arch = Posix.utsname().machine;
|
||||
holdpkgs = new GLib.List<string> ();
|
||||
syncfirsts = new GLib.List<string> ();
|
||||
syncfirst = "";
|
||||
Alpm.List.free_all (cachedirs);
|
||||
Alpm.List.free_all (ignoregroups);
|
||||
Alpm.List.free_all (ignorepkgs);
|
||||
@@ -83,7 +80,6 @@ namespace Alpm {
|
||||
cachedirs->add_str (default_cachedir);
|
||||
ignoregroups = new Alpm.List<string> ();
|
||||
ignorepkgs = new Alpm.List<string> ();
|
||||
ignorepkg = "";
|
||||
noextracts = new Alpm.List<string> ();
|
||||
noupgrades = new Alpm.List<string> ();
|
||||
usesyslog = 0;
|
||||
@@ -141,16 +137,14 @@ namespace Alpm {
|
||||
public void parse_file (string path, string? section = null) {
|
||||
string? current_section = section;
|
||||
var file = GLib.File.new_for_path (path);
|
||||
if (file.query_exists () == false) {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
|
||||
} else {
|
||||
if (file.query_exists ()) {
|
||||
try {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string? line;
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -169,80 +163,78 @@ namespace Alpm {
|
||||
continue;
|
||||
}
|
||||
splitted = line.split ("=", 2);
|
||||
string _key = splitted[0].strip ();
|
||||
string? _value = null;
|
||||
string key = splitted[0].strip ();
|
||||
string? val = null;
|
||||
if (splitted[1] != null) {
|
||||
_value = splitted[1].strip ();
|
||||
val = splitted[1].strip ();
|
||||
}
|
||||
if (_key == "Include") {
|
||||
parse_file (_value, current_section);
|
||||
if (key == "Include") {
|
||||
parse_file (val, current_section);
|
||||
}
|
||||
if (current_section == "options") {
|
||||
if (_key == "GPGDir") {
|
||||
gpgdir = _value;
|
||||
} else if (_key == "LogFile") {
|
||||
logfile = _value;
|
||||
} else if (_key == "Architecture") {
|
||||
if (_value == "auto") {
|
||||
if (key == "GPGDir") {
|
||||
gpgdir = val;
|
||||
} else if (key == "LogFile") {
|
||||
logfile = val;
|
||||
} else if (key == "Architecture") {
|
||||
if (val == "auto") {
|
||||
arch = Posix.utsname ().machine;
|
||||
} else {
|
||||
arch = _value;
|
||||
arch = val;
|
||||
}
|
||||
} else if (_key == "UseDelta") {
|
||||
deltaratio = double.parse (_value);
|
||||
} else if (_key == "UseSysLog") {
|
||||
} else if (key == "UseDelta") {
|
||||
deltaratio = double.parse (val);
|
||||
} else if (key == "UseSysLog") {
|
||||
usesyslog = 1;
|
||||
} else if (_key == "CheckSpace") {
|
||||
} else if (key == "CheckSpace") {
|
||||
checkspace = 1;
|
||||
} else if (_key == "SigLevel") {
|
||||
defaultsiglevel = define_siglevel (defaultsiglevel, _value);
|
||||
} else if (_key == "LocalFileSigLevel") {
|
||||
localfilesiglevel = define_siglevel (localfilesiglevel, _value);
|
||||
} else if (_key == "RemoteFileSigLevel") {
|
||||
remotefilesiglevel = define_siglevel (remotefilesiglevel, _value);
|
||||
} else if (_key == "HoldPkg") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "SigLevel") {
|
||||
defaultsiglevel = define_siglevel (defaultsiglevel, val);
|
||||
} else if (key == "LocalFileSigLevel") {
|
||||
localfilesiglevel = define_siglevel (localfilesiglevel, val);
|
||||
} else if (key == "RemoteFileSigLevel") {
|
||||
remotefilesiglevel = define_siglevel (remotefilesiglevel, val);
|
||||
} else if (key == "HoldPkg") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
holdpkgs.append (name);
|
||||
}
|
||||
} else if (_key == "SyncFirst") {
|
||||
syncfirst = _value;
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "SyncFirst") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
syncfirsts.append (name);
|
||||
}
|
||||
} else if (_key == "CacheDir") {
|
||||
foreach (string dir in _value.split (" ")) {
|
||||
} else if (key == "CacheDir") {
|
||||
foreach (string dir in val.split (" ")) {
|
||||
cachedirs->add_str (dir);
|
||||
}
|
||||
} else if (_key == "IgnoreGroup") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "IgnoreGroup") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
ignoregroups->add_str (name);
|
||||
}
|
||||
} else if (_key == "IgnorePkg") {
|
||||
ignorepkg = _value;
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "IgnorePkg") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
ignorepkgs->add_str (name);
|
||||
}
|
||||
} else if (_key == "Noextract") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "Noextract") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
noextracts->add_str (name);
|
||||
}
|
||||
} else if (_key == "NoUpgrade") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
} else if (key == "NoUpgrade") {
|
||||
foreach (string name in val.split (" ")) {
|
||||
noupgrades->add_str (name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (var repo in repo_order) {
|
||||
if (repo.name == current_section) {
|
||||
if (_key == "Server") {
|
||||
repo.urls += _value;
|
||||
} else if (_key == "SigLevel") {
|
||||
if (key == "Server") {
|
||||
repo.urls += val;
|
||||
} else if (key == "SigLevel") {
|
||||
if (repo.siglevel == Signature.Level.USE_DEFAULT) {
|
||||
repo.siglevel = defaultsiglevel;
|
||||
}
|
||||
repo.siglevel = define_siglevel (repo.siglevel, _value);
|
||||
} else if (_key == "Usage") {
|
||||
repo.usage = define_usage (_value);
|
||||
repo.siglevel = define_siglevel (repo.siglevel, val);
|
||||
} else if (key == "Usage") {
|
||||
repo.usage = define_usage (val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,56 +243,47 @@ namespace Alpm {
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
public void write (HashTable<string,Variant> new_conf) {
|
||||
var file = GLib.File.new_for_path (conf_path);
|
||||
if (file.query_exists () == false) {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
|
||||
} else {
|
||||
if (file.query_exists ()) {
|
||||
try {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string? line;
|
||||
string[] data = {};
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
data += "\n";
|
||||
continue;
|
||||
}
|
||||
if (line.contains ("IgnorePkg")) {
|
||||
if (new_conf.contains ("IgnorePkg")) {
|
||||
string _value = new_conf.get ("IgnorePkg").get_string ();
|
||||
if (_value == "") {
|
||||
string val = new_conf.get ("IgnorePkg").get_string ();
|
||||
if (val == "") {
|
||||
data += "#IgnorePkg =\n";
|
||||
} else {
|
||||
data += "IgnorePkg = %s\n".printf (_value);
|
||||
}
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("SyncFirst")) {
|
||||
if (new_conf.contains ("SyncFirst")) {
|
||||
string _value = new_conf.get ("SyncFirst").get_string ();
|
||||
if (_value == "") {
|
||||
data += "#SyncFirst =\n";
|
||||
} else {
|
||||
data += "SyncFirst = %s\n".printf (_value);
|
||||
data += "IgnorePkg = %s\n".printf (val);
|
||||
}
|
||||
new_conf.remove ("IgnorePkg");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("CheckSpace")) {
|
||||
if (new_conf.contains ("CheckSpace")) {
|
||||
bool _value = new_conf.get ("CheckSpace").get_boolean ();
|
||||
if (_value == true) {
|
||||
bool val = new_conf.get ("CheckSpace").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "CheckSpace\n";
|
||||
} else {
|
||||
data += "#CheckSpace\n";
|
||||
}
|
||||
new_conf.remove ("CheckSpace");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
@@ -319,6 +302,8 @@ namespace Alpm {
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,11 +31,27 @@ namespace Pamac {
|
||||
|
||||
public Gtk.ListStore deps_list;
|
||||
|
||||
public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
|
||||
Transaction transaction;
|
||||
|
||||
public ChooseDependenciesDialog (Transaction transaction, string pkgname, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
this.transaction = transaction;
|
||||
|
||||
string[] optdeps = transaction.get_pkg_uninstalled_optdeps (pkgname);
|
||||
label.set_markup ("<b>%s</b>".printf (
|
||||
dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it",
|
||||
"%s has %u uninstalled optional dependencies.\nChoose those you would like to install", optdeps.length).printf (pkgname, optdeps.length)));
|
||||
deps_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
|
||||
treeview.set_model (deps_list);
|
||||
Gtk.TreeIter iter;
|
||||
foreach (var optdep in optdeps) {
|
||||
string[] split = optdep.split (":", 2);
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
0, false,
|
||||
1, split[0],
|
||||
2, split[1]);
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
|
70
src/choose_ignorepkgs_dialog.vala
Normal file
70
src/choose_ignorepkgs_dialog.vala
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* pamac-vala
|
||||
*
|
||||
* Copyright (C) 2015 Guillaume Benoit <guillaume@manjaro.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Pamac {
|
||||
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/choose_ignorepkgs_dialog.ui")]
|
||||
public class ChooseIgnorepkgsDialog : Gtk.Dialog {
|
||||
|
||||
[GtkChild]
|
||||
public Gtk.Label label;
|
||||
[GtkChild]
|
||||
public Gtk.TreeView treeview;
|
||||
[GtkChild]
|
||||
public Gtk.CellRendererToggle renderertoggle;
|
||||
|
||||
public Gtk.ListStore pkgs_list;
|
||||
|
||||
Transaction transaction;
|
||||
|
||||
public ChooseIgnorepkgsDialog (Gtk.Window window, Transaction transaction) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
this.transaction = transaction;
|
||||
|
||||
label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose the packages you do not want to upgrade")));
|
||||
pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
|
||||
treeview.set_model (pkgs_list);
|
||||
transaction.get_installed_pkgs.begin ((obj, res) => {
|
||||
Pamac.Package[] pkgs = transaction.get_installed_pkgs.end (res);
|
||||
Gtk.TreeIter iter;
|
||||
string[] already_ignorepkgs = transaction.get_ignorepkgs ();
|
||||
foreach (var pkg in pkgs) {
|
||||
if (pkg.name in already_ignorepkgs) {
|
||||
pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
|
||||
} else {
|
||||
pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
void on_renderertoggle_toggled (string path) {
|
||||
Gtk.TreeIter iter;
|
||||
GLib.Value val;
|
||||
bool selected;
|
||||
if (pkgs_list.get_iter_from_string (out iter, path)) {;
|
||||
pkgs_list.get_value (iter, 0, out val);
|
||||
selected = val.get_boolean ();
|
||||
pkgs_list.set_value (iter, 0, !selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -27,8 +27,14 @@ namespace Pamac {
|
||||
[GtkChild]
|
||||
public Gtk.ComboBoxText comboboxtext;
|
||||
|
||||
public ChooseProviderDialog (Gtk.ApplicationWindow? window) {
|
||||
public ChooseProviderDialog (string depend, string[] providers, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
|
||||
foreach (string provider in providers) {
|
||||
comboboxtext.append_text (provider);
|
||||
}
|
||||
comboboxtext.active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
482
src/daemon.vala
482
src/daemon.vala
@@ -26,6 +26,18 @@ const string GETTEXT_PACKAGE = "pamac";
|
||||
Pamac.Daemon pamac_daemon;
|
||||
MainLoop loop;
|
||||
|
||||
public delegate void AlpmActionDelegate ();
|
||||
|
||||
public class AlpmAction: Object {
|
||||
unowned AlpmActionDelegate action_delegate;
|
||||
public AlpmAction (AlpmActionDelegate action_delegate) {
|
||||
this.action_delegate = action_delegate;
|
||||
}
|
||||
public void run () {
|
||||
action_delegate ();
|
||||
}
|
||||
}
|
||||
|
||||
namespace Pamac {
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public class Daemon : Object {
|
||||
@@ -34,6 +46,8 @@ namespace Pamac {
|
||||
public Cond provider_cond;
|
||||
public Mutex provider_mutex;
|
||||
public int? choosen_provider;
|
||||
private int force_refresh;
|
||||
private ThreadPool<AlpmAction> thread_pool;
|
||||
private Mutex databases_lock_mutex;
|
||||
private HashTable<string, Json.Array> aur_search_results;
|
||||
private Json.Array aur_updates_results;
|
||||
@@ -51,12 +65,14 @@ namespace Pamac {
|
||||
public signal void refresh_finished (ErrorInfos error);
|
||||
public signal void trans_prepare_finished (ErrorInfos error);
|
||||
public signal void trans_commit_finished (ErrorInfos error);
|
||||
public signal void write_pamac_config_finished (int refresh_period, bool enable_aur, bool recurse);
|
||||
public signal void write_alpm_config_finished ();
|
||||
public signal void write_mirrors_config_finished ();
|
||||
public signal void generate_mirrorlist_start ();
|
||||
public signal void generate_mirrorlist_data (string line);
|
||||
public signal void generate_mirrorlist_finished ();
|
||||
public signal void get_authorization_finished (bool authorized);
|
||||
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse,
|
||||
bool no_update_hide_icon, bool check_aur_updates,
|
||||
bool no_confirm_build);
|
||||
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);
|
||||
public signal void generate_mirrors_list_finished ();
|
||||
|
||||
public Daemon () {
|
||||
alpm_config = new Alpm.Config ("/etc/pacman.conf");
|
||||
@@ -65,8 +81,28 @@ namespace Pamac {
|
||||
aur_updates_results = new Json.Array ();
|
||||
intern_lock = false;
|
||||
extern_lock = false;
|
||||
force_refresh = 0;
|
||||
refresh_handle ();
|
||||
Timeout.add (500, check_pacman_running);
|
||||
create_thread_pool ();
|
||||
}
|
||||
|
||||
private void create_thread_pool () {
|
||||
// create a thread pool which will run alpm action one after one
|
||||
try {
|
||||
thread_pool = new ThreadPool<AlpmAction>.with_owned_data (
|
||||
// call alpm_action.run () on thread start
|
||||
(alpm_action) => {
|
||||
alpm_action.run ();
|
||||
},
|
||||
// only one thread created so alpm action will run one after one
|
||||
1,
|
||||
// exclusive thread
|
||||
true
|
||||
);
|
||||
} catch (ThreadError e) {
|
||||
stderr.printf ("Thread Error %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
private void refresh_handle () {
|
||||
@@ -103,6 +139,34 @@ namespace Pamac {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start_get_authorization (GLib.BusName sender) {
|
||||
bool authorized = false;
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync ();
|
||||
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
|
||||
authority.check_authorization.begin (
|
||||
subject,
|
||||
"org.manjaro.pamac.commit",
|
||||
null,
|
||||
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
|
||||
null,
|
||||
(obj, res) => {
|
||||
try {
|
||||
var result = authority.check_authorization.end (res);
|
||||
authorized = result.get_is_authorized ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
} finally {
|
||||
get_authorization_finished (authorized);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (GLib.Error e) {
|
||||
get_authorization_finished (authorized);
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) {
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
try {
|
||||
@@ -124,12 +188,16 @@ namespace Pamac {
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
} finally {
|
||||
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, pamac_config.recurse);
|
||||
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur,
|
||||
pamac_config.recurse, pamac_config.no_update_hide_icon,
|
||||
pamac_config.check_aur_updates, pamac_config.no_confirm_build);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (GLib.Error e) {
|
||||
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, pamac_config.recurse);
|
||||
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur,
|
||||
pamac_config.recurse, pamac_config.no_update_hide_icon,
|
||||
pamac_config.check_aur_updates, pamac_config.no_confirm_build);
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
@@ -155,12 +223,12 @@ namespace Pamac {
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
} finally {
|
||||
write_alpm_config_finished ();
|
||||
write_alpm_config_finished (get_checkspace ());
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (GLib.Error e) {
|
||||
write_alpm_config_finished ();
|
||||
write_alpm_config_finished (get_checkspace ());
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +240,7 @@ namespace Pamac {
|
||||
try {
|
||||
string line;
|
||||
channel.read_line (out line, null, null);
|
||||
generate_mirrorlist_data (line);
|
||||
generate_mirrors_list_data (line);
|
||||
} catch (IOChannelError e) {
|
||||
stderr.printf ("%s: IOChannelError: %s\n", stream_name, e.message);
|
||||
return false;
|
||||
@@ -183,8 +251,7 @@ namespace Pamac {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generate_mirrorlist () {
|
||||
generate_mirrorlist_start ();
|
||||
public void start_generate_mirrors_list () {
|
||||
int standard_output;
|
||||
int standard_error;
|
||||
Pid child_pid;
|
||||
@@ -213,10 +280,10 @@ namespace Pamac {
|
||||
Process.close_pid (pid);
|
||||
alpm_config.reload ();
|
||||
refresh_handle ();
|
||||
generate_mirrorlist_finished ();
|
||||
generate_mirrors_list_finished ();
|
||||
});
|
||||
} catch (SpawnError e) {
|
||||
generate_mirrorlist_finished ();
|
||||
generate_mirrors_list_finished ();
|
||||
stdout.printf ("SpawnError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
@@ -237,17 +304,17 @@ namespace Pamac {
|
||||
var result = authority.check_authorization.end (res);
|
||||
if (result.get_is_authorized ()) {
|
||||
mirrors_config.write (new_mirrors_conf);
|
||||
generate_mirrorlist ();
|
||||
mirrors_config.reload ();
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
} finally {
|
||||
write_mirrors_config_finished ();
|
||||
write_mirrors_config_finished (mirrors_config.choosen_country, mirrors_config.choosen_generation_method);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (GLib.Error e) {
|
||||
write_mirrors_config_finished ();
|
||||
write_mirrors_config_finished (mirrors_config.choosen_country, mirrors_config.choosen_generation_method);
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
@@ -285,62 +352,50 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
|
||||
private async ErrorInfos refresh (int force) {
|
||||
SourceFunc callback = refresh.callback;
|
||||
private void refresh () {
|
||||
intern_lock = true;
|
||||
var err = ErrorInfos ();
|
||||
try {
|
||||
new Thread<int>.try ("refresh thread", () => {
|
||||
databases_lock_mutex.lock ();
|
||||
string[] details = {};
|
||||
int success = 0;
|
||||
int ret;
|
||||
foreach (var db in alpm_config.handle.syncdbs) {
|
||||
ret = db.update (force);
|
||||
if (ret >= 0) {
|
||||
success++;
|
||||
}
|
||||
}
|
||||
// We should always succeed if at least one DB was upgraded - we may possibly
|
||||
// fail later with unresolved deps, but that should be rare, and would be expected
|
||||
if (success == 0) {
|
||||
err.message = _("Failed to synchronize any databases");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
databases_lock_mutex.unlock ();
|
||||
Idle.add ((owned) callback);
|
||||
return success;
|
||||
});
|
||||
yield;
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
string[] details = {};
|
||||
int success = 0;
|
||||
int ret;
|
||||
foreach (var db in alpm_config.handle.syncdbs) {
|
||||
ret = db.update (force_refresh);
|
||||
if (ret >= 0) {
|
||||
success++;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
// We should always succeed if at least one DB was upgraded - we may possibly
|
||||
// fail later with unresolved deps, but that should be rare, and would be expected
|
||||
if (success == 0) {
|
||||
err.message = _("Failed to synchronize any databases");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
refresh_handle ();
|
||||
refresh_finished (err);
|
||||
force_refresh = 0;
|
||||
intern_lock = false;
|
||||
}
|
||||
|
||||
public void start_refresh (int force) {
|
||||
intern_lock = true;
|
||||
refresh.begin (force, (obj, res) => {
|
||||
var err = refresh.end (res);
|
||||
intern_lock = false;
|
||||
refresh_handle ();
|
||||
refresh_finished (err);
|
||||
});
|
||||
force_refresh = force;
|
||||
try {
|
||||
thread_pool.add (new AlpmAction (refresh));
|
||||
} catch (ThreadError e) {
|
||||
stderr.printf ("Thread Error %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public bool get_checkspace () {
|
||||
if (alpm_config.checkspace == 1) {
|
||||
return true;
|
||||
return alpm_config.checkspace == 1 ? true : false;
|
||||
}
|
||||
|
||||
public string[] get_ignorepkgs () {
|
||||
string[] ignorepkgs = {};
|
||||
for (size_t i = 0; i < alpm_config.ignorepkgs->length; i++) {
|
||||
ignorepkgs += alpm_config.ignorepkgs->nth_data (i);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string get_syncfirst (){
|
||||
return alpm_config.syncfirst;
|
||||
}
|
||||
|
||||
public string get_ignorepkg () {
|
||||
return alpm_config.ignorepkg;
|
||||
return ignorepkgs;
|
||||
}
|
||||
|
||||
public void add_ignorepkg (string pkgname) {
|
||||
@@ -627,7 +682,7 @@ namespace Pamac {
|
||||
return deps;
|
||||
}
|
||||
|
||||
public async Updates get_updates (bool enable_aur) {
|
||||
public async Updates get_updates (bool check_aur_updates) {
|
||||
var infos = UpdateInfos ();
|
||||
UpdateInfos[] updates_infos = {};
|
||||
var updates = Updates ();
|
||||
@@ -665,7 +720,7 @@ namespace Pamac {
|
||||
infos.download_size = candidate.download_size;
|
||||
updates_infos += infos;
|
||||
} else {
|
||||
if (enable_aur) {
|
||||
if (check_aur_updates) {
|
||||
// check if installed_pkg is a local pkg
|
||||
foreach (var db in alpm_config.handle.syncdbs) {
|
||||
pkg = Alpm.find_satisfier (db.pkgcache, installed_pkg.name);
|
||||
@@ -681,7 +736,7 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
updates.repos_updates = updates_infos;
|
||||
if (enable_aur) {
|
||||
if (check_aur_updates) {
|
||||
// get aur updates
|
||||
if (aur_updates_results.get_length () == 0) {
|
||||
aur_updates_results = AUR.multiinfo (local_pkgs);
|
||||
@@ -860,91 +915,80 @@ namespace Pamac {
|
||||
return err;
|
||||
}
|
||||
|
||||
private async ErrorInfos trans_prepare () {
|
||||
SourceFunc callback = trans_prepare.callback;
|
||||
private void trans_prepare () {
|
||||
var err = ErrorInfos ();
|
||||
try {
|
||||
new Thread<int>.try ("prepare thread", () => {
|
||||
databases_lock_mutex.lock ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_prepare (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.message = _("Failed to prepare transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Errno.PKG_INVALID_ARCH:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
string *pkgname = i;
|
||||
details += _("package %s does not have a valid architecture").printf (pkgname);
|
||||
delete pkgname;
|
||||
}
|
||||
break;
|
||||
case Errno.UNSATISFIED_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
DepMissing *miss = i;
|
||||
string depstring = miss->depend.compute_string ();
|
||||
details += _("%s: requires %s").printf (miss->target, depstring);
|
||||
delete miss;
|
||||
}
|
||||
break;
|
||||
case Errno.CONFLICTING_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
Conflict *conflict = i;
|
||||
detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
|
||||
// only print reason if it contains new information
|
||||
if (conflict->reason.mod != Depend.Mode.ANY) {
|
||||
detail += " (%s)".printf (conflict->reason.compute_string ());
|
||||
}
|
||||
details += detail;
|
||||
delete conflict;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_prepare (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.message = _("Failed to prepare transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Errno.PKG_INVALID_ARCH:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
string *pkgname = i;
|
||||
details += _("package %s does not have a valid architecture").printf (pkgname);
|
||||
delete pkgname;
|
||||
}
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
} else {
|
||||
// Search for holdpkg in target list
|
||||
bool found_locked_pkg = false;
|
||||
foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
|
||||
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
|
||||
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
|
||||
found_locked_pkg = true;
|
||||
break;
|
||||
break;
|
||||
case Errno.UNSATISFIED_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
DepMissing *miss = i;
|
||||
string depstring = miss->depend.compute_string ();
|
||||
details += _("%s: requires %s").printf (miss->target, depstring);
|
||||
delete miss;
|
||||
}
|
||||
break;
|
||||
case Errno.CONFLICTING_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
Conflict *conflict = i;
|
||||
detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
|
||||
// only print reason if it contains new information
|
||||
if (conflict->reason.mod != Depend.Mode.ANY) {
|
||||
detail += " (%s)".printf (conflict->reason.compute_string ());
|
||||
}
|
||||
details += detail;
|
||||
delete conflict;
|
||||
}
|
||||
if (found_locked_pkg) {
|
||||
err.message = _("Failed to prepare transaction");
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
} else {
|
||||
// Search for holdpkg in target list
|
||||
bool found_locked_pkg = false;
|
||||
foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
|
||||
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
|
||||
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
|
||||
found_locked_pkg = true;
|
||||
break;
|
||||
}
|
||||
databases_lock_mutex.unlock ();
|
||||
Idle.add ((owned) callback);
|
||||
return ret;
|
||||
});
|
||||
yield;
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
if (found_locked_pkg) {
|
||||
err.message = _("Failed to prepare transaction");
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
}
|
||||
}
|
||||
return err;
|
||||
trans_prepare_finished (err);
|
||||
}
|
||||
|
||||
public void start_trans_prepare () {
|
||||
trans_prepare.begin ((obj, res) => {
|
||||
var err = trans_prepare.end (res);
|
||||
trans_prepare_finished (err);
|
||||
});
|
||||
try {
|
||||
thread_pool.add (new AlpmAction (trans_prepare));
|
||||
} catch (ThreadError e) {
|
||||
stderr.printf ("Thread Error %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void choose_provider (int provider) {
|
||||
@@ -987,8 +1031,61 @@ namespace Pamac {
|
||||
return infos;
|
||||
}
|
||||
|
||||
private async ErrorInfos trans_commit (GLib.BusName sender) {
|
||||
SourceFunc callback = trans_commit.callback;
|
||||
private void trans_commit () {
|
||||
var err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_commit (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.message = _("Failed to commit transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Alpm.Errno.FILE_CONFLICTS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
//TransFlag flags = alpm_config.handle.trans_get_flags ();
|
||||
//if ((flags & TransFlag.FORCE) != 0) {
|
||||
//details += _("unable to %s directory-file conflicts").printf ("--force");
|
||||
//}
|
||||
foreach (void *i in err_data) {
|
||||
FileConflict *conflict = i;
|
||||
switch (conflict->type) {
|
||||
case FileConflict.Type.TARGET:
|
||||
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
|
||||
break;
|
||||
case FileConflict.Type.FILESYSTEM:
|
||||
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
|
||||
break;
|
||||
}
|
||||
delete conflict;
|
||||
}
|
||||
break;
|
||||
case Alpm.Errno.PKG_INVALID:
|
||||
case Alpm.Errno.PKG_INVALID_CHECKSUM:
|
||||
case Alpm.Errno.PKG_INVALID_SIG:
|
||||
case Alpm.Errno.DLT_INVALID:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
string *filename = i;
|
||||
details += _("%s is invalid or corrupted").printf (filename);
|
||||
delete filename;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
refresh_handle ();
|
||||
trans_commit_finished (err);
|
||||
intern_lock = false;
|
||||
}
|
||||
|
||||
public void start_trans_commit (GLib.BusName sender) {
|
||||
var err = ErrorInfos ();
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync ();
|
||||
@@ -1003,84 +1100,30 @@ namespace Pamac {
|
||||
try {
|
||||
var result = authority.check_authorization.end (res);
|
||||
if (result.get_is_authorized ()) {
|
||||
new Thread<int>.try ("commit thread", () => {
|
||||
databases_lock_mutex.lock ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_commit (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.message = _("Failed to commit transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Alpm.Errno.FILE_CONFLICTS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
//TransFlag flags = alpm_config.handle.trans_get_flags ();
|
||||
//if ((flags & TransFlag.FORCE) != 0) {
|
||||
//details += _("unable to %s directory-file conflicts").printf ("--force");
|
||||
//}
|
||||
foreach (void *i in err_data) {
|
||||
FileConflict *conflict = i;
|
||||
switch (conflict->type) {
|
||||
case FileConflict.Type.TARGET:
|
||||
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
|
||||
break;
|
||||
case FileConflict.Type.FILESYSTEM:
|
||||
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
|
||||
break;
|
||||
}
|
||||
delete conflict;
|
||||
}
|
||||
break;
|
||||
case Alpm.Errno.PKG_INVALID:
|
||||
case Alpm.Errno.PKG_INVALID_CHECKSUM:
|
||||
case Alpm.Errno.PKG_INVALID_SIG:
|
||||
case Alpm.Errno.DLT_INVALID:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
string *filename = i;
|
||||
details += _("%s is invalid or corrupted").printf (filename);
|
||||
delete filename;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
databases_lock_mutex.unlock ();
|
||||
Idle.add ((owned) callback);
|
||||
return ret;
|
||||
});
|
||||
thread_pool.add (new AlpmAction (trans_commit));
|
||||
} else {
|
||||
err.message = _("Authentication failed");
|
||||
trans_release ();
|
||||
Idle.add ((owned) callback);
|
||||
refresh_handle ();
|
||||
trans_commit_finished (err);
|
||||
intern_lock = false;
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
Idle.add ((owned) callback);
|
||||
stderr.printf ("%s\n", e.message);
|
||||
trans_release ();
|
||||
refresh_handle ();
|
||||
trans_commit_finished (err);
|
||||
intern_lock = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
yield;
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public void start_trans_commit (GLib.BusName sender) {
|
||||
trans_commit.begin (sender, (obj, res) => {
|
||||
var err = trans_commit.end (res);
|
||||
intern_lock = false;
|
||||
trans_release ();
|
||||
refresh_handle ();
|
||||
trans_commit_finished (err);
|
||||
});
|
||||
intern_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int trans_release () {
|
||||
@@ -1092,22 +1135,15 @@ namespace Pamac {
|
||||
// a transaction is being interrupted
|
||||
return;
|
||||
}
|
||||
// explicitly quit to avoid a crash
|
||||
// this daemon should be auto-restarted
|
||||
quit ();
|
||||
trans_release ();
|
||||
}
|
||||
|
||||
[DBus (no_reply = true)]
|
||||
public void quit () {
|
||||
// be sure to not quit with locked databases
|
||||
alpm_config.handle.trans_release ();
|
||||
if (lockfile.query_exists () == true) {
|
||||
try {
|
||||
lockfile.delete ();
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
// to be sure to not quit with locked databases,
|
||||
// the above function will wait for all task in queue
|
||||
// to be processed before return;
|
||||
ThreadPool.free ((owned) thread_pool, false, true);
|
||||
loop.quit ();
|
||||
}
|
||||
// End of Daemon Object
|
||||
|
@@ -20,7 +20,7 @@
|
||||
using Gtk;
|
||||
using Alpm;
|
||||
|
||||
const string VERSION = "2.3.3";
|
||||
const string VERSION = "2.4.0";
|
||||
|
||||
namespace Pamac {
|
||||
|
||||
@@ -180,7 +180,12 @@ namespace Pamac {
|
||||
if (pamac_config.recurse) {
|
||||
transaction.flags |= Alpm.TransFlag.RECURSE;
|
||||
}
|
||||
enable_aur (pamac_config.enable_aur);
|
||||
Pamac.Package pkg = transaction.find_local_pkg ("yaourt");
|
||||
if (pkg.name == "") {
|
||||
enable_aur (false);
|
||||
} else {
|
||||
enable_aur (pamac_config.enable_aur);
|
||||
}
|
||||
|
||||
set_buttons_sensitive (false);
|
||||
|
||||
@@ -620,32 +625,21 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void choose_opt_dep (Pamac.Package[] pkgs) {
|
||||
Gtk.TreeIter iter;
|
||||
foreach (Pamac.Package pkg in pkgs) {
|
||||
var choose_dep_dialog = new ChooseDependenciesDialog (this);
|
||||
string[] optdeps = transaction.get_pkg_uninstalled_optdeps (pkg.name);
|
||||
foreach (var optdep in optdeps) {
|
||||
string[] split = optdep.split (":", 2);
|
||||
choose_dep_dialog.deps_list.insert_with_values (out iter, -1,
|
||||
0, false,
|
||||
1, split[0],
|
||||
2, split[1]);
|
||||
var choose_dep_dialog = new ChooseDependenciesDialog (transaction, pkg.name, this);
|
||||
if (choose_dep_dialog.run () == Gtk.ResponseType.OK) {
|
||||
choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
choose_dep_dialog.deps_list.get_value (iter, 0, out val);
|
||||
bool selected = val.get_boolean ();
|
||||
if (selected) {
|
||||
choose_dep_dialog.deps_list.get_value (iter, 1, out val);
|
||||
string name = val.get_string ();
|
||||
transaction.to_add.add ((owned) name);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
choose_dep_dialog.label.set_markup ("<b>%s</b>".printf (
|
||||
dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it:",
|
||||
"%s has %u uninstalled optional dependencies.\nChoose those you would like to install:", optdeps.length).printf (pkg.name, optdeps.length)));
|
||||
choose_dep_dialog.run ();
|
||||
choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
choose_dep_dialog.deps_list.get_value (iter, 0, out val);
|
||||
bool selected = val.get_boolean ();
|
||||
if (selected) {
|
||||
choose_dep_dialog.deps_list.get_value (iter, 1, out val);
|
||||
string name = val.get_string ();
|
||||
transaction.to_add.add ((owned) name);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
choose_dep_dialog.destroy ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
@@ -829,9 +823,6 @@ namespace Pamac {
|
||||
string search_string = search_entry.get_text ();
|
||||
if (search_string != "") {
|
||||
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.search_pkgs.begin (search_string, search_aur_button.get_active (), (obj, res) => {
|
||||
var pkgs = transaction.search_pkgs.end (res);
|
||||
if (pkgs.length != 0) {
|
||||
@@ -893,9 +884,6 @@ namespace Pamac {
|
||||
Gtk.TreeSelection selection = search_treeview.get_selection ();
|
||||
if (selection.get_selected (out model, 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 ();
|
||||
}
|
||||
GLib.Value val;
|
||||
model.get_value (iter, 0, out val);
|
||||
string search_string = val.get_string ();
|
||||
@@ -913,9 +901,6 @@ namespace Pamac {
|
||||
Gtk.TreeSelection selection = groups_treeview.get_selection ();
|
||||
if (selection.get_selected (out model, 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 ();
|
||||
}
|
||||
GLib.Value val;
|
||||
model.get_value (iter, 0, out val);
|
||||
string grp_name = val.get_string ();
|
||||
@@ -933,9 +918,6 @@ namespace Pamac {
|
||||
Gtk.TreeSelection selection = states_treeview.get_selection ();
|
||||
if (selection.get_selected (out model, 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 ();
|
||||
}
|
||||
GLib.Value val;
|
||||
model.get_value (iter, 0, out val);
|
||||
string state = val.get_string ();
|
||||
@@ -988,9 +970,6 @@ namespace Pamac {
|
||||
Gtk.TreeSelection selection = repos_treeview.get_selection ();
|
||||
if (selection.get_selected (out model, 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 ();
|
||||
}
|
||||
GLib.Value val;
|
||||
model.get_value (iter, 0, out val);
|
||||
string repo = val.get_string ();
|
||||
@@ -1046,7 +1025,7 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
public void on_local_item_activate () {
|
||||
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
|
||||
dgettext (null, "Install local packages"), this, Gtk.FileChooserAction.OPEN,
|
||||
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;
|
||||
@@ -1078,12 +1057,29 @@ namespace Pamac {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void run_preferences_dialog () {
|
||||
SourceFunc callback = run_preferences_dialog.callback;
|
||||
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
|
||||
if (authorized) {
|
||||
var preferences_dialog = new PreferencesDialog (transaction, this);
|
||||
preferences_dialog.run ();
|
||||
preferences_dialog.destroy ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
Idle.add((owned) callback);
|
||||
});
|
||||
transaction.start_get_authorization ();
|
||||
yield;
|
||||
transaction.daemon.disconnect (handler_id);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
public void on_preferences_item_activate () {
|
||||
transaction.run_preferences_dialog.begin ();
|
||||
run_preferences_dialog.begin ();
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
@@ -1102,9 +1098,6 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
public void on_valid_button_clicked () {
|
||||
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.run ();
|
||||
}
|
||||
|
||||
@@ -1119,9 +1112,6 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
public void on_refresh_button_clicked () {
|
||||
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.start_refresh (0);
|
||||
}
|
||||
|
||||
|
@@ -64,28 +64,30 @@ namespace Alpm {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string? line;
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
line = line.strip ();
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (line[0] == '#') {
|
||||
// ignore whole line and end of line comments
|
||||
string[] splitted = line.split ("#", 2);
|
||||
line = splitted[0].strip ();
|
||||
if (line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
string[] splitted = line.split ("=");
|
||||
string _key = splitted[0].strip ();
|
||||
string _value = null;
|
||||
splitted = line.split ("=");
|
||||
string key = splitted[0].strip ();
|
||||
string? val = null;
|
||||
if (splitted[1] != null) {
|
||||
_value = splitted[1].strip ();
|
||||
val = splitted[1].strip ();
|
||||
}
|
||||
if (_key == "Method") {
|
||||
choosen_generation_method = _value;
|
||||
} else if (_key == "OnlyCountry") {
|
||||
choosen_country = _value;
|
||||
} else if (_key == "MirrorlistsDir") {
|
||||
mirrorlists_dir = _value.replace ("\"", "");
|
||||
if (key == "Method") {
|
||||
choosen_generation_method = val;
|
||||
} else if (key == "OnlyCountry") {
|
||||
choosen_country = val;
|
||||
} else if (key == "MirrorlistsDir") {
|
||||
mirrorlists_dir = val.replace ("\"", "");
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
@@ -103,24 +105,28 @@ namespace Alpm {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string? line;
|
||||
string[] data = {};
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
data += "\n";
|
||||
continue;
|
||||
}
|
||||
if (line.contains ("Method")) {
|
||||
if (new_conf.contains ("Method")) {
|
||||
string _value = new_conf.get ("Method").get_string ();
|
||||
data += "Method=%s\n".printf (_value);
|
||||
string val = new_conf.get ("Method").get_string ();
|
||||
data += "Method=%s\n".printf (val);
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("OnlyCountry")) {
|
||||
if (new_conf.contains ("OnlyCountry")) {
|
||||
string _value = new_conf.get ("OnlyCountry").get_string ();
|
||||
if (_value == dgettext (null, "Worldwide")) {
|
||||
string val = new_conf.get ("OnlyCountry").get_string ();
|
||||
if (val == dgettext (null, "Worldwide")) {
|
||||
data += "#%s\n".printf (line);
|
||||
} else {
|
||||
data += "OnlyCountry=%s\n".printf (_value);
|
||||
data += "OnlyCountry=%s\n".printf (val);
|
||||
}
|
||||
} else {
|
||||
data += line + "\n";
|
||||
|
@@ -23,11 +23,14 @@ namespace Pamac {
|
||||
public int refresh_period;
|
||||
public bool enable_aur;
|
||||
public bool recurse;
|
||||
public bool no_update_hide_icon;
|
||||
public bool check_aur_updates;
|
||||
public bool no_confirm_build;
|
||||
|
||||
public Config (string path) {
|
||||
conf_path = path;
|
||||
// set default option
|
||||
refresh_period = 4;
|
||||
refresh_period = 6;
|
||||
reload ();
|
||||
}
|
||||
|
||||
@@ -35,90 +38,139 @@ namespace Pamac {
|
||||
// set default options
|
||||
enable_aur = false;
|
||||
recurse = false;
|
||||
no_update_hide_icon = false;
|
||||
check_aur_updates = false;
|
||||
no_confirm_build = false;
|
||||
parse_file (conf_path);
|
||||
}
|
||||
|
||||
public void parse_file (string path) {
|
||||
var file = GLib.File.new_for_path (path);
|
||||
if (file.query_exists () == false) {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
|
||||
} else {
|
||||
if (file.query_exists ()) {
|
||||
try {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string? line;
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
line = line.strip ();
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if (line[0] == '#') {
|
||||
// ignore whole line and end of line comments
|
||||
string[] splitted = line.split ("#", 2);
|
||||
line = splitted[0].strip ();
|
||||
if (line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
string[] splitted = line.split ("=");
|
||||
string _key = splitted[0].strip ();
|
||||
string _value = null;
|
||||
splitted = line.split ("=");
|
||||
string key = splitted[0].strip ();
|
||||
string? val = null;
|
||||
if (splitted[1] != null) {
|
||||
_value = splitted[1].strip ();
|
||||
val = splitted[1].strip ();
|
||||
}
|
||||
if (_key == "RefreshPeriod") {
|
||||
refresh_period = int.parse (_value);
|
||||
} else if (_key == "EnableAUR") {
|
||||
enable_aur = true;
|
||||
} else if (_key == "RemoveUnrequiredDeps") {
|
||||
if (key == "RemoveUnrequiredDeps") {
|
||||
recurse = true;
|
||||
} else if (key == "RefreshPeriod") {
|
||||
refresh_period = int.parse (val);
|
||||
} else if (key == "NoUpdateHideIcon") {
|
||||
no_update_hide_icon = true;
|
||||
} else if (key == "EnableAUR") {
|
||||
enable_aur = true;
|
||||
} else if (key == "CheckAURUpdates") {
|
||||
check_aur_updates = true;
|
||||
} else if (key == "NoConfirmBuild") {
|
||||
no_confirm_build = true;
|
||||
}
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
public void write (HashTable<string,Variant> new_conf) {
|
||||
var file = GLib.File.new_for_path (conf_path);
|
||||
if (file.query_exists () == false) {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
|
||||
} else {
|
||||
string[] data = {};
|
||||
if (file.query_exists ()) {
|
||||
try {
|
||||
// Open file for reading and wrap returned FileInputStream into a
|
||||
// DataInputStream, so we can read line by line
|
||||
var dis = new DataInputStream (file.read ());
|
||||
string line;
|
||||
string[] data = {};
|
||||
string? line;
|
||||
// Read lines until end of file (null) is reached
|
||||
while ((line = dis.read_line (null)) != null) {
|
||||
while ((line = dis.read_line ()) != null) {
|
||||
if (line.length == 0) {
|
||||
data += "\n";
|
||||
continue;
|
||||
}
|
||||
if (line.contains ("RefreshPeriod")) {
|
||||
if (line.contains ("RemoveUnrequiredDeps")) {
|
||||
if (new_conf.contains ("RemoveUnrequiredDeps")) {
|
||||
bool val = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "RemoveUnrequiredDeps\n";
|
||||
} else {
|
||||
data += "#RemoveUnrequiredDeps\n";
|
||||
}
|
||||
new_conf.remove ("RemoveUnrequiredDeps");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("RefreshPeriod")) {
|
||||
if (new_conf.contains ("RefreshPeriod")) {
|
||||
int _value = new_conf.get ("RefreshPeriod").get_int32 ();
|
||||
data += "RefreshPeriod = %u\n".printf (_value);
|
||||
int val = new_conf.get ("RefreshPeriod").get_int32 ();
|
||||
data += "RefreshPeriod = %u\n".printf (val);
|
||||
new_conf.remove ("RefreshPeriod");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("NoUpdateHideIcon")) {
|
||||
if (new_conf.contains ("NoUpdateHideIcon")) {
|
||||
bool val = new_conf.get ("NoUpdateHideIcon").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "NoUpdateHideIcon\n";
|
||||
} else {
|
||||
data += "#NoUpdateHideIcon\n";
|
||||
}
|
||||
new_conf.remove ("NoUpdateHideIcon");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("EnableAUR")) {
|
||||
if (new_conf.contains ("EnableAUR")) {
|
||||
bool _value = new_conf.get ("EnableAUR").get_boolean ();
|
||||
if (_value == true) {
|
||||
bool val = new_conf.get ("EnableAUR").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "EnableAUR\n";
|
||||
} else {
|
||||
data += "#EnableAUR\n";
|
||||
}
|
||||
new_conf.remove ("EnableAUR");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("RemoveUnrequiredDeps")) {
|
||||
if (new_conf.contains ("RemoveUnrequiredDeps")) {
|
||||
bool _value = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
|
||||
if (_value == true) {
|
||||
data += "RemoveUnrequiredDeps\n";
|
||||
} else if (line.contains ("CheckAURUpdates")) {
|
||||
if (new_conf.contains ("CheckAURUpdates")) {
|
||||
bool val = new_conf.get ("CheckAURUpdates").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "CheckAURUpdates\n";
|
||||
} else {
|
||||
data += "#RemoveUnrequiredDeps\n";
|
||||
data += "#CheckAURUpdates\n";
|
||||
}
|
||||
new_conf.remove ("CheckAURUpdates");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
} else if (line.contains ("NoConfirmBuild")) {
|
||||
if (new_conf.contains ("NoConfirmBuild")) {
|
||||
bool val = new_conf.get ("NoConfirmBuild").get_boolean ();
|
||||
if (val == true) {
|
||||
data += "NoConfirmBuild\n";
|
||||
} else {
|
||||
data += "#NoConfirmBuild\n";
|
||||
}
|
||||
new_conf.remove ("NoConfirmBuild");
|
||||
} else {
|
||||
data += line + "\n";
|
||||
}
|
||||
@@ -128,15 +180,61 @@ namespace Pamac {
|
||||
}
|
||||
// delete the file before rewrite it
|
||||
file.delete ();
|
||||
// creating a DataOutputStream to the file
|
||||
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
|
||||
foreach (string new_line in data) {
|
||||
// writing a short string to the stream
|
||||
dos.put_string (new_line);
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
|
||||
}
|
||||
// create lines for unexisted options
|
||||
if (new_conf.size () != 0) {
|
||||
data += "\n";
|
||||
new_conf.foreach ((key, val) => {
|
||||
if (key == "RemoveUnrequiredDeps") {
|
||||
if (val.get_boolean () == true) {
|
||||
data += "RemoveUnrequiredDeps\n";
|
||||
} else {
|
||||
data += "#RemoveUnrequiredDeps\n";
|
||||
}
|
||||
} else if (key == "RefreshPeriod") {
|
||||
data += "RefreshPeriod = %u\n".printf (val.get_int32 ());
|
||||
} else if (key =="NoUpdateHideIcon") {
|
||||
if (val.get_boolean () == true) {
|
||||
data += "NoUpdateHideIcon\n";
|
||||
} else {
|
||||
data += "#NoUpdateHideIcon\n";
|
||||
}
|
||||
} else if (key == "EnableAUR") {
|
||||
if (val.get_boolean () == true) {
|
||||
data += "EnableAUR\n";
|
||||
} else {
|
||||
data += "#EnableAUR\n";
|
||||
}
|
||||
} else if (key == "CheckAURUpdates") {
|
||||
if (val.get_boolean () == true) {
|
||||
data += "CheckAURUpdates\n";
|
||||
} else {
|
||||
data += "#CheckAURUpdates\n";
|
||||
}
|
||||
} else if (key == "NoConfirmBuild") {
|
||||
if (val.get_boolean () == true) {
|
||||
data += "NoConfirmBuild\n";
|
||||
} else {
|
||||
data += "#NoConfirmBuild\n";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// write the file
|
||||
try {
|
||||
// creating a DataOutputStream to the file
|
||||
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
|
||||
foreach (string new_line in data) {
|
||||
// writing a short string to the stream
|
||||
dos.put_string (new_line);
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,32 +19,325 @@
|
||||
|
||||
namespace Pamac {
|
||||
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/preferences_dialog.ui")]
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/preferences_dialog.ui")]
|
||||
public class PreferencesDialog : Gtk.Dialog {
|
||||
|
||||
[GtkChild]
|
||||
public Gtk.Switch enable_aur_button;
|
||||
[GtkChild]
|
||||
public Gtk.Switch remove_unrequired_deps_button;
|
||||
[GtkChild]
|
||||
public Gtk.Switch check_space_button;
|
||||
[GtkChild]
|
||||
public Gtk.Entry syncfirst_entry;
|
||||
[GtkChild]
|
||||
public Gtk.Entry ignore_upgrade_entry;
|
||||
[GtkChild]
|
||||
public Gtk.SpinButton refresh_period_spin_button;
|
||||
public Gtk.Switch check_updates_button;
|
||||
[GtkChild]
|
||||
public Gtk.Label refresh_period_label;
|
||||
[GtkChild]
|
||||
public Gtk.SpinButton refresh_period_spin_button;
|
||||
[GtkChild]
|
||||
public Gtk.CheckButton no_update_hide_icon_checkbutton;
|
||||
[GtkChild]
|
||||
public Gtk.Box ignorepkgs_box;
|
||||
[GtkChild]
|
||||
public Gtk.ListStore ignorepkgs_liststore;
|
||||
[GtkChild]
|
||||
public Gtk.TreeView ignorepkgs_treeview;
|
||||
[GtkChild]
|
||||
public Gtk.Box mirrors_config_box;
|
||||
[GtkChild]
|
||||
public Gtk.ComboBoxText mirrors_country_comboboxtext;
|
||||
[GtkChild]
|
||||
public Gtk.ComboBoxText mirrorlist_generation_method_comboboxtext;
|
||||
public Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext;
|
||||
[GtkChild]
|
||||
public Gtk.Button generate_mirrors_list_button;
|
||||
[GtkChild]
|
||||
public Gtk.Box aur_config_box;
|
||||
[GtkChild]
|
||||
public Gtk.Switch enable_aur_button;
|
||||
[GtkChild]
|
||||
public Gtk.CheckButton check_aur_updates_checkbutton;
|
||||
[GtkChild]
|
||||
public Gtk.CheckButton no_confirm_build_checkbutton;
|
||||
|
||||
public PreferencesDialog (Gtk.ApplicationWindow? window) {
|
||||
Transaction transaction;
|
||||
int previous_refresh_period;
|
||||
|
||||
public PreferencesDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
this.transaction = transaction;
|
||||
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
remove_unrequired_deps_button.active = pamac_config.recurse;
|
||||
check_space_button.active = transaction.get_checkspace ();
|
||||
if (pamac_config.refresh_period == 0) {
|
||||
check_updates_button.active = false;
|
||||
refresh_period_label.sensitive = false;
|
||||
// set default value
|
||||
refresh_period_spin_button.value = 6;
|
||||
previous_refresh_period = 6;
|
||||
refresh_period_spin_button.sensitive = false;
|
||||
no_update_hide_icon_checkbutton.sensitive = false;
|
||||
ignorepkgs_box.sensitive = false;
|
||||
} else {
|
||||
check_updates_button.active = true;
|
||||
refresh_period_spin_button.value = pamac_config.refresh_period;
|
||||
previous_refresh_period = pamac_config.refresh_period;
|
||||
}
|
||||
no_update_hide_icon_checkbutton.active = pamac_config.no_update_hide_icon;
|
||||
|
||||
// populate ignorepkgs_liststore
|
||||
Gtk.TreeIter iter;
|
||||
foreach (var name in transaction.get_ignorepkgs ()) {
|
||||
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
|
||||
}
|
||||
remove_unrequired_deps_button.state_set.connect (on_remove_unrequired_deps_button_state_set);
|
||||
check_space_button.state_set.connect (on_check_space_button_state_set);
|
||||
check_updates_button.state_set.connect (on_check_updates_button_state_set);
|
||||
refresh_period_spin_button.value_changed.connect (on_refresh_period_spin_button_value_changed);
|
||||
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
|
||||
transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||
|
||||
Pamac.Package pkg = this.transaction.find_local_pkg ("pacman-mirrorlist");
|
||||
if (pkg.name == "") {
|
||||
mirrors_config_box.visible = false;
|
||||
} else {
|
||||
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
|
||||
mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
|
||||
mirrors_country_comboboxtext.active = 0;
|
||||
int index = 1;
|
||||
mirrors_config.get_countrys ();
|
||||
foreach (string country in mirrors_config.countrys) {
|
||||
mirrors_country_comboboxtext.append_text (country);
|
||||
if (country == mirrors_config.choosen_country) {
|
||||
mirrors_country_comboboxtext.active = index;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
mirrors_list_generation_method_comboboxtext.append_text (dgettext (null, "Speed"));
|
||||
mirrors_list_generation_method_comboboxtext.append_text (dgettext (null, "Random"));
|
||||
if (mirrors_config.choosen_generation_method == "rank") {
|
||||
mirrors_list_generation_method_comboboxtext.active = 0;
|
||||
} else {
|
||||
mirrors_list_generation_method_comboboxtext.active = 1;
|
||||
}
|
||||
mirrors_country_comboboxtext.changed.connect (on_mirrors_country_comboboxtext_changed);
|
||||
mirrors_list_generation_method_comboboxtext.changed.connect (on_mirrors_list_generation_method_comboboxtext_changed);
|
||||
transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
|
||||
}
|
||||
|
||||
pkg = this.transaction.find_local_pkg ("yaourt");
|
||||
if (pkg.name == "") {
|
||||
aur_config_box.visible = false;
|
||||
} else {
|
||||
enable_aur_button.active = pamac_config.enable_aur;
|
||||
check_aur_updates_checkbutton.active = pamac_config.check_aur_updates;
|
||||
check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur;
|
||||
no_confirm_build_checkbutton.active = pamac_config.no_confirm_build;
|
||||
no_confirm_build_checkbutton.sensitive = pamac_config.enable_aur;
|
||||
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
|
||||
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_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);
|
||||
}
|
||||
}
|
||||
|
||||
bool on_remove_unrequired_deps_button_state_set (bool new_state) {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_pamac_conf.insert ("RemoveUnrequiredDeps", new Variant.boolean (new_state));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool on_check_updates_button_state_set (bool new_state) {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
refresh_period_label.sensitive = new_state;
|
||||
refresh_period_spin_button.sensitive = new_state;
|
||||
no_update_hide_icon_checkbutton.sensitive = new_state;
|
||||
ignorepkgs_box.sensitive = new_state;
|
||||
if (new_state == true) {
|
||||
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (previous_refresh_period));
|
||||
} else {
|
||||
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (0));
|
||||
}
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
return true;
|
||||
}
|
||||
|
||||
void on_refresh_period_spin_button_value_changed () {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (refresh_period_spin_button.get_value_as_int ()));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
}
|
||||
|
||||
void on_no_update_hide_icon_checkbutton_toggled () {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
}
|
||||
|
||||
bool on_enable_aur_button_state_set (bool new_state) {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_pamac_conf.insert ("EnableAUR", new Variant.boolean (new_state));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
return true;
|
||||
}
|
||||
|
||||
void on_check_aur_updates_checkbutton_toggled () {
|
||||
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));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
}
|
||||
|
||||
void on_no_confirm_build_checkbutton_toggled () {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_pamac_conf.insert ("NoConfirmBuild", new Variant.boolean (no_confirm_build_checkbutton.active));
|
||||
transaction.start_write_pamac_config (new_pamac_conf);
|
||||
}
|
||||
|
||||
void on_write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse,
|
||||
bool no_update_hide_icon, bool check_aur_updates,
|
||||
bool no_confirm_build) {
|
||||
remove_unrequired_deps_button.state = recurse;
|
||||
if (refresh_period == 0) {
|
||||
check_updates_button.state = false;
|
||||
refresh_period_label.sensitive = false;
|
||||
refresh_period_spin_button.sensitive = false;
|
||||
no_update_hide_icon_checkbutton.sensitive = false;
|
||||
ignorepkgs_box.sensitive = false;
|
||||
} else {
|
||||
check_updates_button.state = true;
|
||||
refresh_period_label.sensitive = true;
|
||||
refresh_period_spin_button.value = refresh_period;
|
||||
previous_refresh_period = refresh_period;
|
||||
refresh_period_spin_button.sensitive = true;
|
||||
no_update_hide_icon_checkbutton.sensitive = true;
|
||||
ignorepkgs_box.sensitive = true;
|
||||
// launch pamac-tray if needed
|
||||
try {
|
||||
Process.spawn_command_line_async ("pamac-tray");
|
||||
} catch (SpawnError e) {
|
||||
stderr.printf ("SpawnError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
no_update_hide_icon_checkbutton.active = no_update_hide_icon;
|
||||
enable_aur_button.state = aur_enabled;
|
||||
check_aur_updates_checkbutton.active = check_aur_updates;
|
||||
check_aur_updates_checkbutton.sensitive = aur_enabled;
|
||||
no_confirm_build_checkbutton.active = no_confirm_build;
|
||||
no_confirm_build_checkbutton.sensitive = aur_enabled;
|
||||
}
|
||||
|
||||
bool on_check_space_button_state_set (bool new_state) {
|
||||
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_alpm_conf.insert ("CheckSpace", new Variant.boolean (new_state));
|
||||
transaction.start_write_alpm_config (new_alpm_conf);
|
||||
return true;
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
void on_add_ignorepkgs_button_clicked () {
|
||||
var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this, transaction);
|
||||
if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) {
|
||||
var ignorepkg_string = new StringBuilder ();
|
||||
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 0, out val);
|
||||
bool selected = val.get_boolean ();
|
||||
if (selected) {
|
||||
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 1, out val);
|
||||
string name = val.get_string ();
|
||||
if (ignorepkg_string.len != 0) {
|
||||
ignorepkg_string.append (" ");
|
||||
}
|
||||
ignorepkg_string.append (name);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (ignorepkg_string.len != 0) {
|
||||
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
|
||||
transaction.start_write_alpm_config (new_alpm_conf);
|
||||
}
|
||||
}
|
||||
choose_ignorepkgs_dialog.destroy ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
void on_remove_ignorepkgs_button_clicked () {
|
||||
Gtk.TreeIter? iter;
|
||||
Gtk.TreeSelection selection = ignorepkgs_treeview.get_selection ();
|
||||
if (selection.get_selected (null, out iter)) {
|
||||
ignorepkgs_liststore.remove (iter);
|
||||
var ignorepkg_string = new StringBuilder ();
|
||||
ignorepkgs_liststore.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
ignorepkgs_liststore.get_value (iter, 0, out val);
|
||||
string name = val.get_string ();
|
||||
if (ignorepkg_string.len != 0) {
|
||||
ignorepkg_string.append (" ");
|
||||
}
|
||||
ignorepkg_string.append (name);
|
||||
return false;
|
||||
});
|
||||
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
|
||||
transaction.start_write_alpm_config (new_alpm_conf);
|
||||
}
|
||||
}
|
||||
|
||||
void on_write_alpm_config_finished (bool checkspace) {
|
||||
check_space_button.state = checkspace;
|
||||
// re-populate ignorepkgs_liststore
|
||||
Gtk.TreeIter iter;
|
||||
ignorepkgs_liststore.clear ();
|
||||
foreach (var name in transaction.get_ignorepkgs ()) {
|
||||
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
|
||||
}
|
||||
}
|
||||
|
||||
void on_mirrors_country_comboboxtext_changed () {
|
||||
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
new_mirrors_conf.insert ("OnlyCountry", new Variant.string (mirrors_country_comboboxtext.get_active_text ()));
|
||||
transaction.start_write_mirrors_config (new_mirrors_conf);
|
||||
}
|
||||
|
||||
void on_mirrors_list_generation_method_comboboxtext_changed () {
|
||||
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
if (mirrors_list_generation_method_comboboxtext.get_active_text () == dgettext (null, "Speed")){
|
||||
new_mirrors_conf.insert ("Method", new Variant.string ("rank"));
|
||||
} else {
|
||||
new_mirrors_conf.insert ("Method", new Variant.string ("random"));
|
||||
}
|
||||
transaction.start_write_mirrors_config (new_mirrors_conf);
|
||||
}
|
||||
|
||||
void on_write_mirrors_config_finished (string choosen_country, string choosen_generation_method) {
|
||||
int index = 0;
|
||||
mirrors_country_comboboxtext.model.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
model.get_value (iter, 0, out val);
|
||||
string country = val.get_string ();
|
||||
if (choosen_country == country) {
|
||||
return true;
|
||||
}
|
||||
index += 1;
|
||||
return false;
|
||||
});
|
||||
mirrors_country_comboboxtext.active = index;
|
||||
if (choosen_generation_method == "rank") {
|
||||
mirrors_list_generation_method_comboboxtext.active = 0;
|
||||
} else {
|
||||
mirrors_list_generation_method_comboboxtext.active = 1;
|
||||
}
|
||||
generate_mirrors_list_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
void on_generate_mirrors_list_button_clicked () {
|
||||
transaction.start_generate_mirrors_list ();
|
||||
generate_mirrors_list_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,11 +34,34 @@ namespace Pamac {
|
||||
public Gtk.Expander expander;
|
||||
|
||||
Transaction transaction;
|
||||
public Vte.Terminal term;
|
||||
Vte.Pty pty;
|
||||
|
||||
public ProgressDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
this.transaction = transaction;
|
||||
//creating terminal
|
||||
term = new Vte.Terminal ();
|
||||
term.scroll_on_output = false;
|
||||
term.expand = true;
|
||||
term.height_request = 200;
|
||||
term.visible = true;
|
||||
// creating pty for term
|
||||
try {
|
||||
pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER);
|
||||
} catch (Error e) {
|
||||
stderr.printf ("Error: %s\n", e.message);
|
||||
}
|
||||
// add term in a grid with a scrollbar
|
||||
var grid = new Gtk.Grid ();
|
||||
grid.expand = true;
|
||||
grid.visible = true;
|
||||
var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment);
|
||||
sb.visible = true;
|
||||
grid.attach (term, 0, 0, 1, 1);
|
||||
grid.attach (sb, 1, 0, 1, 1);
|
||||
this.expander.add (grid);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
@@ -53,12 +76,23 @@ namespace Pamac {
|
||||
public void on_cancel_button_clicked () {
|
||||
transaction.cancel ();
|
||||
transaction.clear_lists ();
|
||||
transaction.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
this.hide ();
|
||||
transaction.finished (false);
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn_in_term (string[] args, out Pid child_pid = null) {
|
||||
Pid intern_pid;
|
||||
try {
|
||||
Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid);
|
||||
} catch (SpawnError e) {
|
||||
stderr.printf ("SpawnError: %s\n", e.message);
|
||||
}
|
||||
child_pid = intern_pid;
|
||||
term.set_pty (pty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,10 +68,12 @@ bool check_pamac_running () {
|
||||
}
|
||||
|
||||
void on_refresh_finished () {
|
||||
try {
|
||||
pamac_daemon.quit ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
if (check_pamac_running () == false) {
|
||||
try {
|
||||
pamac_daemon.quit ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
loop.quit ();
|
||||
}
|
||||
@@ -83,11 +85,11 @@ int main () {
|
||||
"/org/manjaro/pamac");
|
||||
pamac_daemon.refresh_finished.connect (on_refresh_finished);
|
||||
pamac_daemon.start_refresh (0);
|
||||
loop = new MainLoop ();
|
||||
loop.run ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
loop = new MainLoop ();
|
||||
loop.run ();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -20,14 +20,15 @@
|
||||
namespace Pamac {
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public interface Daemon : Object {
|
||||
public abstract void start_get_authorization () throws IOError;
|
||||
public abstract void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) throws IOError;
|
||||
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
|
||||
public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
|
||||
public abstract void start_generate_mirrors_list () throws IOError;
|
||||
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
|
||||
public abstract void start_refresh (int force) throws IOError;
|
||||
public abstract bool get_checkspace () throws IOError;
|
||||
public abstract string get_syncfirst () throws IOError;
|
||||
public abstract string get_ignorepkg () throws IOError;
|
||||
public abstract string[] get_ignorepkgs () throws IOError;
|
||||
public abstract void add_ignorepkg (string pkgname) throws IOError;
|
||||
public abstract void remove_ignorepkg (string pkgname) throws IOError;
|
||||
public abstract bool should_hold (string pkgname) throws IOError;
|
||||
@@ -46,7 +47,7 @@ namespace Pamac {
|
||||
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
|
||||
public abstract PackageDeps get_pkg_deps (string pkgname) throws IOError;
|
||||
public abstract PackageDetails get_pkg_details (string pkgname) 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;
|
||||
public abstract ErrorInfos trans_init (Alpm.TransFlag transflags) throws IOError;
|
||||
public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
|
||||
public abstract ErrorInfos trans_add_pkg (string pkgname) throws IOError;
|
||||
@@ -71,12 +72,14 @@ namespace Pamac {
|
||||
public signal void refresh_finished (ErrorInfos error);
|
||||
public signal void trans_prepare_finished (ErrorInfos error);
|
||||
public signal void trans_commit_finished (ErrorInfos error);
|
||||
public signal void write_pamac_config_finished (int refresh_period, bool enable_aur, bool recurse);
|
||||
public signal void write_alpm_config_finished ();
|
||||
public signal void write_mirrors_config_finished ();
|
||||
public signal void generate_mirrorlist_start ();
|
||||
public signal void generate_mirrorlist_data (string line);
|
||||
public signal void generate_mirrorlist_finished ();
|
||||
public signal void get_authorization_finished (bool authorized);
|
||||
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse,
|
||||
bool no_update_hide_icon, bool check_aur_updates,
|
||||
bool no_confirm_build);
|
||||
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);
|
||||
public signal void generate_mirrors_list_finished ();
|
||||
}
|
||||
|
||||
public enum TransactionType {
|
||||
@@ -109,9 +112,6 @@ namespace Pamac {
|
||||
int build_status;
|
||||
int enable_downgrade;
|
||||
|
||||
Vte.Terminal term;
|
||||
Vte.Pty pty;
|
||||
|
||||
//dialogs
|
||||
TransactionSumDialog transaction_sum_dialog;
|
||||
TransactionInfoDialog transaction_info_dialog;
|
||||
@@ -135,29 +135,8 @@ namespace Pamac {
|
||||
transaction_sum_dialog = new TransactionSumDialog (window);
|
||||
transaction_info_dialog = new TransactionInfoDialog (window);
|
||||
progress_dialog = new ProgressDialog (this, window);
|
||||
//creating terminal
|
||||
term = new Vte.Terminal ();
|
||||
term.scroll_on_output = false;
|
||||
term.expand = true;
|
||||
term.height_request = 200;
|
||||
term.set_visible (true);
|
||||
// creating pty for term
|
||||
try {
|
||||
pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER);
|
||||
} catch (Error e) {
|
||||
stderr.printf ("Error: %s\n", e.message);
|
||||
}
|
||||
// connect to child_exited signal which will only be emit after a call to watch_child
|
||||
term.child_exited.connect (on_term_child_exited);
|
||||
// add term in a grid with a scrollbar
|
||||
var grid = new Gtk.Grid ();
|
||||
grid.expand = true;
|
||||
grid.set_visible (true);
|
||||
var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment);
|
||||
sb.set_visible (true);
|
||||
grid.attach (term, 0, 0, 1, 1);
|
||||
grid.attach (sb, 1, 0, 1, 1);
|
||||
progress_dialog.expander.add (grid);
|
||||
progress_dialog.term.child_exited.connect (on_term_child_exited);
|
||||
// progress data
|
||||
total_download = 0;
|
||||
already_downloaded = 0;
|
||||
@@ -169,6 +148,14 @@ namespace Pamac {
|
||||
build_status = 0;
|
||||
}
|
||||
|
||||
public void start_get_authorization () {
|
||||
try {
|
||||
daemon.start_get_authorization ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) {
|
||||
try {
|
||||
daemon.start_write_pamac_config (new_pamac_conf);
|
||||
@@ -193,6 +180,28 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
|
||||
public void start_generate_mirrors_list () {
|
||||
string action = dgettext (null, "Refreshing mirrors list") + "...";
|
||||
progress_dialog.spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
progress_dialog.width_request = 700;
|
||||
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
||||
progress_dialog.show ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
try {
|
||||
daemon.start_generate_mirrors_list ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void start_set_pkgreason (string pkgname, Alpm.Package.Reason reason) {
|
||||
try {
|
||||
daemon.start_set_pkgreason (pkgname, (uint) reason);
|
||||
@@ -203,7 +212,7 @@ namespace Pamac {
|
||||
|
||||
public void start_refresh (int force) {
|
||||
string action = dgettext (null, "Synchronizing package databases") + "...";
|
||||
spawn_in_term ({"echo", action});
|
||||
progress_dialog.spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
@@ -214,9 +223,11 @@ namespace Pamac {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
try {
|
||||
daemon.refresh_finished.connect (on_refresh_finished);
|
||||
daemon.start_refresh (force);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,24 +241,14 @@ namespace Pamac {
|
||||
return checkspace;
|
||||
}
|
||||
|
||||
public string get_syncfirst () {
|
||||
string syncfirst = "";
|
||||
public string[] get_ignorepkgs () {
|
||||
string[] ignorepkgs = {};
|
||||
try {
|
||||
syncfirst = daemon.get_syncfirst ();
|
||||
ignorepkgs = daemon.get_ignorepkgs ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
return syncfirst;
|
||||
}
|
||||
|
||||
public string get_ignorepkg () {
|
||||
string ignorepkg = "";
|
||||
try {
|
||||
ignorepkg = daemon.get_ignorepkg ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
return ignorepkg;
|
||||
return ignorepkgs;
|
||||
}
|
||||
|
||||
public void add_ignorepkg (string pkgname) {
|
||||
@@ -431,7 +432,7 @@ namespace Pamac {
|
||||
var updates = Updates ();
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
try {
|
||||
updates = yield daemon.get_updates (pamac_config.enable_aur);
|
||||
updates = yield daemon.get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
@@ -485,7 +486,7 @@ namespace Pamac {
|
||||
public void sysupgrade (int enable_downgrade) {
|
||||
this.enable_downgrade = enable_downgrade;
|
||||
string action = dgettext (null, "Starting full system upgrade") + "...";
|
||||
spawn_in_term ({"echo", action});
|
||||
progress_dialog.spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
@@ -539,7 +540,7 @@ namespace Pamac {
|
||||
|
||||
public void run () {
|
||||
string action = dgettext (null,"Preparing") + "...";
|
||||
spawn_in_term ({"echo", action});
|
||||
progress_dialog.spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
@@ -613,14 +614,7 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void choose_provider (string depend, string[] providers) {
|
||||
int len = providers.length;
|
||||
var choose_provider_dialog = new ChooseProviderDialog (window);
|
||||
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend, len)));
|
||||
choose_provider_dialog.comboboxtext.remove_all ();
|
||||
foreach (string provider in providers) {
|
||||
choose_provider_dialog.comboboxtext.append_text (provider);
|
||||
}
|
||||
choose_provider_dialog.comboboxtext.active = 0;
|
||||
var choose_provider_dialog = new ChooseProviderDialog (depend, providers, window);
|
||||
choose_provider_dialog.run ();
|
||||
try {
|
||||
daemon.choose_provider (choose_provider_dialog.comboboxtext.active);
|
||||
@@ -773,7 +767,7 @@ namespace Pamac {
|
||||
|
||||
public void build_aur_packages () {
|
||||
string action = dgettext (null,"Building packages") + "...";
|
||||
spawn_in_term ({"echo", action});
|
||||
progress_dialog.spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
@@ -781,16 +775,20 @@ namespace Pamac {
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
progress_dialog.width_request = 700;
|
||||
term.grab_focus ();
|
||||
progress_dialog.term.grab_focus ();
|
||||
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
||||
string[] cmds = {"yaourt", "-S"};
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
if (pamac_config.no_confirm_build) {
|
||||
cmds += "--noconfirm";
|
||||
}
|
||||
foreach (string name in to_build) {
|
||||
cmds += name;
|
||||
}
|
||||
Pid child_pid;
|
||||
spawn_in_term (cmds, out child_pid);
|
||||
progress_dialog.spawn_in_term (cmds, out child_pid);
|
||||
// watch_child is needed in order to have the child_exited signal emitted
|
||||
term.watch_child (child_pid);
|
||||
progress_dialog.term.watch_child (child_pid);
|
||||
}
|
||||
|
||||
public void cancel () {
|
||||
@@ -820,156 +818,28 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn_in_term (string[] args, out Pid child_pid = null) {
|
||||
Pid intern_pid;
|
||||
try {
|
||||
Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid);
|
||||
} catch (SpawnError e) {
|
||||
stderr.printf ("SpawnError: %s\n", e.message);
|
||||
}
|
||||
child_pid = intern_pid;
|
||||
term.set_pty (pty);
|
||||
}
|
||||
|
||||
public async void run_preferences_dialog () {
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
|
||||
var preferences_dialog = new PreferencesDialog (window);
|
||||
bool enable_aur = pamac_config.enable_aur;
|
||||
bool recurse = pamac_config.recurse;
|
||||
int refresh_period = pamac_config.refresh_period;
|
||||
bool checkspace = get_checkspace ();
|
||||
string syncfirst = get_syncfirst ();
|
||||
string ignorepkg = get_ignorepkg ();
|
||||
string choosen_generation_method = mirrors_config.choosen_generation_method;
|
||||
string choosen_country = mirrors_config.choosen_country;
|
||||
preferences_dialog.enable_aur_button.set_active (enable_aur);
|
||||
preferences_dialog.remove_unrequired_deps_button.set_active (recurse);
|
||||
preferences_dialog.refresh_period_spin_button.set_value (refresh_period);
|
||||
preferences_dialog.check_space_button.set_active (checkspace);
|
||||
preferences_dialog.syncfirst_entry.set_text (syncfirst);
|
||||
preferences_dialog.ignore_upgrade_entry.set_text (ignorepkg);
|
||||
preferences_dialog.mirrors_country_comboboxtext.remove_all ();
|
||||
preferences_dialog.mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
|
||||
preferences_dialog.mirrors_country_comboboxtext.active = 0;
|
||||
int index = 1;
|
||||
mirrors_config.get_countrys ();
|
||||
foreach (string country in mirrors_config.countrys) {
|
||||
preferences_dialog.mirrors_country_comboboxtext.append_text (country);
|
||||
if (country == choosen_country) {
|
||||
preferences_dialog.mirrors_country_comboboxtext.active = index;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
preferences_dialog.mirrorlist_generation_method_comboboxtext.remove_all ();
|
||||
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "speed"));
|
||||
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "random"));
|
||||
if (choosen_generation_method == "rank") {
|
||||
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 0;
|
||||
} else {
|
||||
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 1;
|
||||
}
|
||||
if (preferences_dialog.run () == Gtk.ResponseType.OK) {
|
||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||
enable_aur = preferences_dialog.enable_aur_button.get_active ();
|
||||
recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
|
||||
refresh_period = preferences_dialog.refresh_period_spin_button.get_value_as_int ();
|
||||
checkspace = preferences_dialog.check_space_button.get_active ();
|
||||
syncfirst = preferences_dialog.syncfirst_entry.get_text ();
|
||||
ignorepkg = preferences_dialog.ignore_upgrade_entry.get_text ();
|
||||
choosen_country = preferences_dialog.mirrors_country_comboboxtext.get_active_text ();
|
||||
if (preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) {
|
||||
choosen_generation_method = "rank";
|
||||
} else {
|
||||
choosen_generation_method = "random";
|
||||
}
|
||||
if (enable_aur != pamac_config.enable_aur) {
|
||||
new_pamac_conf.insert ("EnableAUR", new Variant.boolean (enable_aur));
|
||||
}
|
||||
if (recurse != pamac_config.recurse) {
|
||||
new_pamac_conf.insert ("RemoveUnrequiredDeps", new Variant.boolean (recurse));
|
||||
}
|
||||
if (refresh_period != pamac_config.refresh_period) {
|
||||
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (refresh_period));
|
||||
}
|
||||
if (checkspace != get_checkspace ()) {
|
||||
new_alpm_conf.insert ("CheckSpace", new Variant.boolean (checkspace));
|
||||
}
|
||||
if (syncfirst != get_syncfirst ()) {
|
||||
new_alpm_conf.insert ("SyncFirst", new Variant.string (syncfirst));
|
||||
}
|
||||
if (ignorepkg != get_ignorepkg ()) {
|
||||
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg));
|
||||
}
|
||||
if (choosen_country != mirrors_config.choosen_country) {
|
||||
new_mirrors_conf.insert ("OnlyCountry", new Variant.string (choosen_country));
|
||||
}
|
||||
if (choosen_generation_method == "rank"
|
||||
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "random")) {
|
||||
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "random")));
|
||||
}
|
||||
if (choosen_generation_method == "random"
|
||||
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) {
|
||||
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "speed")));
|
||||
}
|
||||
if (new_pamac_conf.size () != 0) {
|
||||
start_write_pamac_config (new_pamac_conf);
|
||||
SourceFunc callback = run_preferences_dialog.callback;
|
||||
ulong handler_id = daemon.write_pamac_config_finished.connect (() => {
|
||||
Idle.add((owned) callback);
|
||||
});
|
||||
yield;
|
||||
daemon.disconnect (handler_id);
|
||||
}
|
||||
if (new_alpm_conf.size () != 0) {
|
||||
start_write_alpm_config (new_alpm_conf);
|
||||
SourceFunc callback = run_preferences_dialog.callback;
|
||||
ulong handler_id = daemon.write_alpm_config_finished.connect (() => {
|
||||
Idle.add((owned) callback);
|
||||
});
|
||||
yield;
|
||||
daemon.disconnect (handler_id);
|
||||
}
|
||||
if (new_mirrors_conf.size () != 0) {
|
||||
start_write_mirrors_config (new_mirrors_conf);
|
||||
SourceFunc callback = run_preferences_dialog.callback;
|
||||
ulong handler_id = daemon.write_mirrors_config_finished.connect (() => {
|
||||
Idle.add((owned) callback);
|
||||
});
|
||||
yield;
|
||||
daemon.disconnect (handler_id);
|
||||
}
|
||||
}
|
||||
preferences_dialog.destroy ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
|
||||
void on_emit_event (uint primary_event, uint secondary_event, string[] details) {
|
||||
string msg;
|
||||
switch (primary_event) {
|
||||
case Alpm.Event.Type.CHECKDEPS_START:
|
||||
msg = dgettext (null, "Checking dependencies") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.FILECONFLICTS_START:
|
||||
msg = dgettext (null, "Checking file conflicts") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.RESOLVEDEPS_START:
|
||||
msg = dgettext (null, "Resolving dependencies") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.INTERCONFLICTS_START:
|
||||
msg = dgettext (null, "Checking inter-conflicts") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.PACKAGE_OPERATION_START:
|
||||
switch (secondary_event) {
|
||||
@@ -979,7 +849,7 @@ namespace Pamac {
|
||||
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Package.Operation.REINSTALL:
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
@@ -987,7 +857,7 @@ namespace Pamac {
|
||||
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
msg = dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Package.Operation.REMOVE:
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
@@ -995,7 +865,7 @@ namespace Pamac {
|
||||
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
msg = dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Package.Operation.UPGRADE:
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
@@ -1003,7 +873,7 @@ namespace Pamac {
|
||||
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
msg = dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Package.Operation.DOWNGRADE:
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
@@ -1011,86 +881,86 @@ namespace Pamac {
|
||||
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
msg = dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Alpm.Event.Type.INTEGRITY_START:
|
||||
msg = dgettext (null, "Checking integrity") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.KEYRING_START:
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
msg = dgettext (null, "Checking keyring") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.KEY_DOWNLOAD_START:
|
||||
msg = dgettext (null, "Downloading required keys") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.LOAD_START:
|
||||
msg = dgettext (null, "Loading packages files") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DELTA_INTEGRITY_START:
|
||||
msg = dgettext (null, "Checking delta integrity") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DELTA_PATCHES_START:
|
||||
msg = dgettext (null, "Applying deltas") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DELTA_PATCH_START:
|
||||
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DELTA_PATCH_DONE:
|
||||
msg = dgettext (null, "Generation succeeded") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DELTA_PATCH_FAILED:
|
||||
msg = dgettext (null, "Generation failed") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.SCRIPTLET_INFO:
|
||||
progress_dialog.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"echo", "-n", details[0]});
|
||||
progress_dialog.spawn_in_term ({"echo", "-n", details[0]});
|
||||
break;
|
||||
case Alpm.Event.Type.RETRIEVE_START:
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
msg = dgettext (null, "Downloading") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.DISKSPACE_START:
|
||||
msg = dgettext (null, "Checking available disk space") + "...";
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"echo", msg});
|
||||
progress_dialog.spawn_in_term ({"echo", msg});
|
||||
break;
|
||||
case Alpm.Event.Type.OPTDEP_REMOVAL:
|
||||
spawn_in_term ({"echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
|
||||
break;
|
||||
case Alpm.Event.Type.DATABASE_MISSING:
|
||||
spawn_in_term ({"echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
|
||||
break;
|
||||
case Alpm.Event.Type.PACNEW_CREATED:
|
||||
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
|
||||
break;
|
||||
case Alpm.Event.Type.PACSAVE_CREATED:
|
||||
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
|
||||
break;
|
||||
case Alpm.Event.Type.PACORIG_CREATED:
|
||||
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1151,7 +1021,7 @@ namespace Pamac {
|
||||
if (label != previous_label) {
|
||||
previous_label = label;
|
||||
progress_dialog.action_label.set_text (label);
|
||||
spawn_in_term ({"echo", label});
|
||||
progress_dialog.spawn_in_term ({"echo", label});
|
||||
}
|
||||
}
|
||||
if (total_download > 0) {
|
||||
@@ -1215,7 +1085,7 @@ namespace Pamac {
|
||||
}
|
||||
if (line != null) {
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"echo", "-n", line});
|
||||
progress_dialog.spawn_in_term ({"echo", "-n", line});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1240,7 +1110,7 @@ namespace Pamac {
|
||||
|
||||
public void handle_error (ErrorInfos error) {
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"echo", "-n", error.message});
|
||||
progress_dialog.spawn_in_term ({"echo", "-n", error.message});
|
||||
Gtk.TextIter start_iter;
|
||||
Gtk.TextIter end_iter;
|
||||
transaction_info_dialog.set_title (dgettext (null, "Error"));
|
||||
@@ -1252,9 +1122,9 @@ namespace Pamac {
|
||||
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
||||
transaction_info_dialog.expander.set_visible (true);
|
||||
transaction_info_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"echo", ":"});
|
||||
progress_dialog.spawn_in_term ({"echo", ":"});
|
||||
foreach (string detail in error.details) {
|
||||
spawn_in_term ({"echo", detail});
|
||||
progress_dialog.spawn_in_term ({"echo", detail});
|
||||
string str = detail + "\n";
|
||||
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
||||
transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
|
||||
@@ -1262,7 +1132,7 @@ namespace Pamac {
|
||||
} else {
|
||||
transaction_info_dialog.expander.set_visible (false);
|
||||
}
|
||||
spawn_in_term ({"echo"});
|
||||
progress_dialog.spawn_in_term ({"echo"});
|
||||
transaction_info_dialog.run ();
|
||||
transaction_info_dialog.hide ();
|
||||
progress_dialog.hide ();
|
||||
@@ -1291,6 +1161,7 @@ namespace Pamac {
|
||||
handle_error (error);
|
||||
}
|
||||
previous_filename = "";
|
||||
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||
}
|
||||
|
||||
public void on_trans_prepare_finished (ErrorInfos error) {
|
||||
@@ -1314,7 +1185,7 @@ namespace Pamac {
|
||||
start_commit ();
|
||||
}
|
||||
} else {
|
||||
spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
progress_dialog.hide ();
|
||||
transaction_sum_dialog.hide ();
|
||||
while (Gtk.events_pending ()) {
|
||||
@@ -1328,7 +1199,7 @@ namespace Pamac {
|
||||
} else {
|
||||
//var err = ErrorInfos ();
|
||||
//err.message = dgettext (null, "Nothing to do") + "\n";
|
||||
spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"});
|
||||
progress_dialog.hide ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
@@ -1350,7 +1221,7 @@ namespace Pamac {
|
||||
if (to_add.length != 0
|
||||
|| to_remove.length != 0
|
||||
|| to_load.length != 0) {
|
||||
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
}
|
||||
build_aur_packages ();
|
||||
} else {
|
||||
@@ -1362,7 +1233,7 @@ namespace Pamac {
|
||||
sysupgrade (0);
|
||||
} else {
|
||||
if (build_status == 0) {
|
||||
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
progress_dialog.hide ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
@@ -1371,7 +1242,7 @@ namespace Pamac {
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
progress_dialog.close_button.set_visible (true);
|
||||
spawn_in_term ({"echo"});
|
||||
progress_dialog.spawn_in_term ({"echo"});
|
||||
}
|
||||
finished (false);
|
||||
}
|
||||
@@ -1403,30 +1274,19 @@ namespace Pamac {
|
||||
if (recurse) {
|
||||
flags |= Alpm.TransFlag.RECURSE;
|
||||
}
|
||||
enable_aur (aur_enabled);
|
||||
Pamac.Package pkg = find_local_pkg ("yaourt");
|
||||
if (pkg.name != "") {
|
||||
enable_aur (aur_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void on_generate_mirrorlist_start () {
|
||||
string action = dgettext (null, "Generating mirrorlist") + "...";
|
||||
spawn_in_term ({"echo", action});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
progress_dialog.width_request = 700;
|
||||
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
||||
progress_dialog.show ();
|
||||
void on_generate_mirrors_list_data (string line) {
|
||||
progress_dialog.spawn_in_term ({"echo", "-n", line});
|
||||
}
|
||||
|
||||
void on_generate_mirrorlist_data (string line) {
|
||||
spawn_in_term ({"echo", "-n", line});
|
||||
}
|
||||
|
||||
void on_generate_mirrorlist_finished () {
|
||||
void on_generate_mirrors_list_finished () {
|
||||
Source.remove (pulse_timeout_id);
|
||||
spawn_in_term ({"echo"});
|
||||
progress_dialog.spawn_in_term ({"echo"});
|
||||
// force a dbs refresh
|
||||
start_refresh (1);
|
||||
}
|
||||
@@ -1442,13 +1302,11 @@ namespace Pamac {
|
||||
daemon.emit_download.connect (on_emit_download);
|
||||
daemon.emit_totaldownload.connect (on_emit_totaldownload);
|
||||
daemon.emit_log.connect (on_emit_log);
|
||||
daemon.refresh_finished.connect (on_refresh_finished);
|
||||
daemon.trans_prepare_finished.connect (on_trans_prepare_finished);
|
||||
daemon.trans_commit_finished.connect (on_trans_commit_finished);
|
||||
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||
daemon.generate_mirrorlist_start.connect (on_generate_mirrorlist_start);
|
||||
daemon.generate_mirrorlist_data.connect (on_generate_mirrorlist_data);
|
||||
daemon.generate_mirrorlist_finished.connect (on_generate_mirrorlist_finished);
|
||||
daemon.generate_mirrors_list_data.connect (on_generate_mirrors_list_data);
|
||||
daemon.generate_mirrors_list_finished.connect (on_generate_mirrors_list_finished);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
|
@@ -32,12 +32,15 @@ namespace Pamac {
|
||||
[DBus (no_reply = true)]
|
||||
public abstract void quit () throws IOError;
|
||||
public signal void refresh_finished (ErrorInfos error);
|
||||
public signal void write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse,
|
||||
bool no_update_hide_icon, bool check_aur_updates,
|
||||
bool no_confirm_build);
|
||||
public signal void write_alpm_config_finished (bool checkspace);
|
||||
}
|
||||
|
||||
public class TrayIcon: Gtk.Application {
|
||||
Notify.Notification notification;
|
||||
Daemon daemon;
|
||||
bool intern_lock;
|
||||
bool extern_lock;
|
||||
uint refresh_timeout_id;
|
||||
Gtk.StatusIcon status_icon;
|
||||
@@ -53,8 +56,9 @@ namespace Pamac {
|
||||
try {
|
||||
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
||||
"/org/manjaro/pamac");
|
||||
// Connecting to signal
|
||||
daemon.refresh_finished.connect (on_refresh_finished);
|
||||
// Connecting to signals
|
||||
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||
daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
@@ -62,7 +66,6 @@ namespace Pamac {
|
||||
|
||||
void stop_daemon () {
|
||||
if (check_pamac_running () == false) {
|
||||
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||
try {
|
||||
daemon.quit ();
|
||||
} catch (IOError e) {
|
||||
@@ -120,11 +123,12 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
bool start_refresh () {
|
||||
if (check_pamac_running () == false) {
|
||||
start_daemon ();
|
||||
// if pamac is not running start refresh else just check updates
|
||||
if (check_pamac_running ()) {
|
||||
check_updates ();
|
||||
} else {
|
||||
try {
|
||||
daemon.start_refresh (0);
|
||||
intern_lock = true;
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
@@ -132,14 +136,25 @@ namespace Pamac {
|
||||
return true;
|
||||
}
|
||||
|
||||
void on_refresh_finished () {
|
||||
intern_lock = false;
|
||||
void on_write_pamac_config_finished (int refresh_period) {
|
||||
launch_refresh_timeout ((uint) refresh_period);
|
||||
if (refresh_period == 0) {
|
||||
status_icon.visible = false;
|
||||
} else {
|
||||
check_updates ();
|
||||
}
|
||||
}
|
||||
|
||||
void on_write_alpm_config_finished (bool checkspace) {
|
||||
check_updates ();
|
||||
}
|
||||
|
||||
void check_updates () {
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
daemon.get_updates.begin (pamac_config.enable_aur, (obj, res) => {
|
||||
if (pamac_config.refresh_period == 0) {
|
||||
return;
|
||||
}
|
||||
daemon.get_updates.begin ((pamac_config.enable_aur && pamac_config.check_aur_updates), (obj, res) => {
|
||||
var updates = Updates ();
|
||||
try {
|
||||
updates = daemon.get_updates.end (res);
|
||||
@@ -149,9 +164,15 @@ namespace Pamac {
|
||||
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
|
||||
if (updates_nb == 0) {
|
||||
this.update_icon (noupdate_icon_name, noupdate_info);
|
||||
if (pamac_config.no_update_hide_icon) {
|
||||
status_icon.visible = false;
|
||||
} else {
|
||||
status_icon.visible = true;
|
||||
}
|
||||
} else {
|
||||
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
|
||||
this.update_icon (update_icon_name, info);
|
||||
status_icon.visible = true;
|
||||
if (check_pamac_running () == false) {
|
||||
show_notification (info);
|
||||
}
|
||||
@@ -225,9 +246,7 @@ namespace Pamac {
|
||||
}
|
||||
} else {
|
||||
if (lockfile.query_exists () == true) {
|
||||
if (intern_lock == false) {
|
||||
extern_lock = true;
|
||||
}
|
||||
extern_lock = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -236,8 +255,11 @@ namespace Pamac {
|
||||
void launch_refresh_timeout (uint refresh_period_in_hours) {
|
||||
if (refresh_timeout_id != 0) {
|
||||
Source.remove (refresh_timeout_id);
|
||||
refresh_timeout_id = 0;
|
||||
}
|
||||
if (refresh_period_in_hours != 0) {
|
||||
refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, start_refresh);
|
||||
}
|
||||
refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, start_refresh);
|
||||
}
|
||||
|
||||
public override void startup () {
|
||||
@@ -245,14 +267,19 @@ namespace Pamac {
|
||||
Intl.textdomain ("pamac");
|
||||
Intl.setlocale (LocaleCategory.ALL, "");
|
||||
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
// if refresh period is 0, just return so tray will exit
|
||||
if (pamac_config.refresh_period == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
base.startup ();
|
||||
|
||||
intern_lock = false;
|
||||
extern_lock = false;
|
||||
refresh_timeout_id = 0;
|
||||
|
||||
status_icon = new Gtk.StatusIcon ();
|
||||
status_icon.set_visible (true);
|
||||
status_icon.visible = !(pamac_config.no_update_hide_icon);
|
||||
this.update_icon (noupdate_icon_name, noupdate_info);
|
||||
status_icon.activate.connect (left_clicked);
|
||||
create_menu ();
|
||||
@@ -263,9 +290,9 @@ namespace Pamac {
|
||||
var alpm_config = new Alpm.Config ("/etc/pacman.conf");
|
||||
alpm_config.get_handle ();
|
||||
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
|
||||
start_daemon ();
|
||||
Timeout.add (500, check_pacman_running);
|
||||
start_refresh ();
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
launch_refresh_timeout ((uint) pamac_config.refresh_period);
|
||||
|
||||
this.hold ();
|
||||
|
@@ -72,9 +72,27 @@ namespace Pamac {
|
||||
});
|
||||
}
|
||||
|
||||
public async void run_preferences_dialog () {
|
||||
SourceFunc callback = run_preferences_dialog.callback;
|
||||
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
|
||||
if (authorized) {
|
||||
var preferences_dialog = new PreferencesDialog (transaction, this);
|
||||
preferences_dialog.run ();
|
||||
preferences_dialog.destroy ();
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
Idle.add((owned) callback);
|
||||
});
|
||||
transaction.start_get_authorization ();
|
||||
yield;
|
||||
transaction.daemon.disconnect (handler_id);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
public void on_preferences_button_clicked () {
|
||||
transaction.run_preferences_dialog.begin (() => {
|
||||
run_preferences_dialog.begin (() => {
|
||||
set_updates_list.begin ();
|
||||
});
|
||||
}
|
||||
@@ -82,9 +100,6 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
public void on_apply_button_clicked () {
|
||||
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
updates_list.foreach ((model, path, iter) => {
|
||||
GLib.Value val;
|
||||
updates_list.get_value (iter, 0, out val);
|
||||
@@ -108,9 +123,6 @@ namespace Pamac {
|
||||
[GtkCallback]
|
||||
public void on_refresh_button_clicked () {
|
||||
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.start_refresh (0);
|
||||
}
|
||||
|
||||
@@ -125,9 +137,6 @@ namespace Pamac {
|
||||
|
||||
public async void set_updates_list () {
|
||||
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
top_label.set_markup ("");
|
||||
updates_list.clear ();
|
||||
bottom_label.set_visible (false);
|
||||
@@ -172,9 +181,6 @@ namespace Pamac {
|
||||
bottom_label.set_visible (false);
|
||||
}
|
||||
this.get_window ().set_cursor (null);
|
||||
while (Gtk.events_pending ()) {
|
||||
Gtk.main_iteration ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user