now transaction functions are a library, see pamac.vapi

This commit is contained in:
guinux 2016-02-26 10:37:26 +01:00
parent 6b4a935da1
commit dd71fd3ecc
33 changed files with 698 additions and 704 deletions

3
.gitignore vendored
View File

@ -2,6 +2,9 @@ pkgbuild
resources/*~
resources/*.c
src/*.c
src/pamac.h
src/pamac.vapi
src/libpamac.so
src/pamac-daemon
src/pamac-tray
src/pamac-manager

View File

@ -16,6 +16,9 @@ install:
cp -r po/locale /usr/share
install -Dm744 src/pamac-daemon /usr/bin/pamac-daemon
install -Dm755 src/pamac-tray /usr/bin/pamac-tray
install -Dm644 src/pamac.h /usr/include/pamac.h
install -Dm644 src/pamac.vapi /usr/share/vala/vapi/pamac.vapi
install -Dm755 src/libpamac.so /usr/lib/libpamac.so
install -Dm755 src/pamac-manager /usr/bin/pamac-manager
install -Dm755 src/pamac-updater /usr/bin/pamac-updater
install -Dm755 src/pamac-install /usr/bin/pamac-install
@ -39,6 +42,9 @@ uninstall:
rm -f /usr/share/icons/24x24/status/pamac-tray-update.png
rm -f /usr/share/icons/32x32/apps/system-software-install.png
rm -f /usr/share/locale/*/LC_MESSAGES/pamac.mo
rm -f /usr/include/pamac.h
rm -f /usr/share/vala/vapi/pamac.vapi
rm -f /usr/lib/libpamac.so
rm -f /usr/bin/pamac-daemon /usr/bin/pamac-updater /usr/bin/pamac-tray /usr/bin/pamac-manager /usr/bin/pamac-install
rm -f /etc/xdg/autostart/pamac-tray.desktop
rm -f /usr/share/applications/pamac-manager.desktop /usr/share/applications/pamac-updater.desktop /usr/share/applications/pamac-install.desktop

View File

@ -4,12 +4,6 @@
../src/tray.vala
../src/manager.vala
../src/updater.vala
../src/choose_provider_dialog.vala
../src/progress_dialog.vala
../src/history_dialog.vala
../src/transaction_info_dialog.vala
../src/transaction_sum_dialog.vala
../src/choose_dep_dialog.vala
../src/manager_window.vala
../src/aur_model.vala
../src/packages_model.vala

View File

@ -21,7 +21,7 @@ msgstr ""
msgid "Authentication is required"
msgstr ""
#: ../src/daemon.vala ../src/manager_window.vala ../src/preferences_dialog.vala
#: ../src/daemon.vala ../src/transaction.vala
msgid "Failed to initialize alpm library"
msgstr ""
@ -85,6 +85,16 @@ msgstr ""
msgid "Authentication failed"
msgstr ""
#: ../src/daemon.vala
#, c-format
msgid "%s appears to be truncated: %jd/%jd bytes\n"
msgstr ""
#: ../src/daemon.vala
#, c-format
msgid "failed retrieving file '%s' from %s : %s\n"
msgstr ""
#: ../src/transaction.vala
msgid "Refreshing mirrors list"
msgstr ""
@ -287,8 +297,7 @@ msgstr[1] ""
msgid "Warning"
msgstr ""
#: ../src/transaction.vala ../src/installer.vala ../src/manager.vala
#: ../src/updater.vala
#: ../src/transaction.vala
msgid "Error"
msgstr ""
@ -407,6 +416,14 @@ msgstr ""
msgid "Conflicts With"
msgstr ""
#: ../src/manager_window.vala
msgid "Make Dependencies"
msgstr ""
#: ../src/manager_window.vala
msgid "Check Dependencies"
msgstr ""
#: ../src/manager_window.vala ../resources/manager_window.ui
msgid "Repository"
msgstr ""
@ -455,6 +472,10 @@ msgstr ""
msgid "Backup files"
msgstr ""
#: ../src/manager_window.vala
msgid "Package Base"
msgstr ""
#: ../src/manager_window.vala
msgid "Maintainer"
msgstr ""

View File

@ -14,27 +14,26 @@ UPDATER_RESOURCES_FILES = updater_window.ui
TRANSACTION_RESOURCES_FILES = progress_dialog.ui \
choose_provider_dialog.ui \
transaction_sum_dialog.ui \
transaction_info_dialog.ui
PREFERENCES_RESOURCES_FILES = preferences_dialog.ui \
transaction_info_dialog.ui \
preferences_dialog.ui \
choose_ignorepkgs_dialog.ui
TRANSACTION_GRESOURCE_FILE = pamac.transaction.gresource.xml
MANAGER_GRESOURCE_FILE = pamac.manager.gresource.xml
UPDATER_GRESOURCE_FILE = pamac.updater.gresource.xml
INSTALLER_GRESOURCE_FILE = pamac.installer.gresource.xml
resources: manager_resources.c updater_resources.c installer_resources.c
resources: transaction_resources.c manager_resources.c updater_resources.c
clean:
rm -f *.c
manager_resources.c: $(MANAGER_GRESOURCE_FILE) $(MANAGER_RESOURCES_FILES) $(TRANSACTION_RESOURCES_FILES) $(PREFERENCES_RESOURCES_FILES)
transaction_resources.c: $(TRANSACTION_GRESOURCE_FILE) $(TRANSACTION_RESOURCES_FILES)
glib-compile-resources $(TRANSACTION_GRESOURCE_FILE) --target=transaction_resources.c --generate-source
manager_resources.c: $(MANAGER_GRESOURCE_FILE) $(MANAGER_RESOURCES_FILES)
glib-compile-resources $(MANAGER_GRESOURCE_FILE) --target=manager_resources.c --generate-source
updater_resources.c: $(UPDATER_GRESOURCE_FILE) $(UPDATER_RESOURCES_FILES) $(TRANSACTION_RESOURCES_FILES) $(PREFERENCES_RESOURCES_FILES)
updater_resources.c: $(UPDATER_GRESOURCE_FILE) $(UPDATER_RESOURCES_FILES)
glib-compile-resources $(UPDATER_GRESOURCE_FILE) --target=updater_resources.c --generate-source
installer_resources.c: $(INSTALLER_GRESOURCE_FILE) $(TRANSACTION_RESOURCES_FILES)
glib-compile-resources $(INSTALLER_GRESOURCE_FILE) --target=installer_resources.c --generate-source

View File

@ -11,14 +11,4 @@
<file preprocess="to-pixdata">package-reinstall.png</file>
<file preprocess="to-pixdata">package-remove.png</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_provider_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_info_dialog.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/preferences">
<file preprocess="xml-stripblanks">preferences_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_ignorepkgs_dialog.ui</file>
</gresource>
</gresources>

View File

@ -6,4 +6,8 @@
<file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_info_dialog.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/preferences">
<file preprocess="xml-stripblanks">preferences_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_ignorepkgs_dialog.ui</file>
</gresource>
</gresources>

View File

@ -3,14 +3,4 @@
<gresource prefix="/org/manjaro/pamac/updater">
<file preprocess="xml-stripblanks">updater_window.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_provider_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_info_dialog.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/preferences">
<file preprocess="xml-stripblanks">preferences_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_ignorepkgs_dialog.ui</file>
</gresource>
</gresources>

View File

@ -3,16 +3,16 @@ COMMON_VALA_FLAGS = -X -w \
--pkg=libalpm \
--pkg=gio-2.0 \
--pkg=posix \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--vapidir=./ \
--vapidir=../vapi \
--Xcc=-I../util \
-X -I../util \
-X -D_FILE_OFFSET_BITS=64 \
-X -DGETTEXT_PACKAGE="pamac" \
--target-glib=2.38
TRANSACTION_VALA_FLAGS = --pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \
TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--pkg=vte-2.91 \
-X -lm
@ -21,10 +21,9 @@ COMMON_SOURCES = ../util/alpm-util.c \
common.vala \
pamac_config.vala \
alpm_config.vala \
alpm_utils.vala \
aur.vala \
TRANSACTION_SOURCES = transaction.vala \
aur.vala \
choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
@ -34,16 +33,18 @@ PREFERENCES_SOURCES = preferences_dialog.vala \
choose_ignorepkgs_dialog.vala \
mirrors_config.vala
TRANSACTION_GRESOURCE_FILE = ../resources/pamac.transaction.gresource.xml
MANAGER_GRESOURCE_FILE = ../resources/pamac.manager.gresource.xml
UPDATER_GRESOURCE_FILE = ../resources/pamac.updater.gresource.xml
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
binaries: pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
binaries: pamac-refresh pamac-daemon pamac-tray libpamac.so pamac-updater pamac-manager pamac-install
clean:
rm -f *.c pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
rm -f *.c pamac.h pamac.vapi libpamac.so pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
pamac-refresh: pamac_config.vala refresh.vala
valac -o pamac-refresh \
@ -61,50 +62,77 @@ pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
$(COMMON_SOURCES) \
tray.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi ../vapi/libcurl.vapi $(COMMON_SOURCES) mirrors_config.vala daemon.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi ../vapi/libcurl.vapi $(COMMON_SOURCES) aur.vala mirrors_config.vala daemon.vala
valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \
--pkg=polkit-gobject-1 \
--pkg=libcurl \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--thread \
$(COMMON_SOURCES) \
aur.vala \
mirrors_config.vala \
daemon.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 aur_model.vala manager_window.vala manager.vala
valac -o pamac-manager \
libpamac.so: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/manager_resources.c
valac -o libpamac.so \
-X -fPIC \
-X --shared \
-H pamac.h \
--vapi=pamac.vapi \
--library=libpamac \
$(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
--gresources=$(TRANSACTION_GRESOURCE_FILE) \
../resources/transaction_resources.c \
$(COMMON_SOURCES) \
$(TRANSACTION_SOURCES) \
$(PREFERENCES_SOURCES) \
$(PREFERENCES_SOURCES)
pamac-manager: libpamac.so choose_dep_dialog.vala history_dialog.vala transaction_info_dialog.vala ../resources/manager_resources.c ../util/alpm-util.c alpm_utils.vala packages_model.vala aur_model.vala manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
../util/alpm-util.c \
choose_dep_dialog.vala \
history_dialog.vala \
alpm_utils.vala \
packages_model.vala \
aur_model.vala \
manager_window.vala \
manager.vala
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/updater_resources.c updater_window.vala updater.vala
pamac-updater: libpamac.so ../resources/updater_resources.c updater_window.vala updater.vala
valac -o pamac-updater \
$(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--gresources=$(UPDATER_GRESOURCE_FILE) \
../resources/updater_resources.c \
$(COMMON_SOURCES) \
$(TRANSACTION_SOURCES) \
$(PREFERENCES_SOURCES) \
updater_window.vala \
updater.vala
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) ../resources/installer_resources.c installer.vala
pamac-install: libpamac.so installer.vala
valac -o pamac-install \
$(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \
--gresources=$(INSTALLER_GRESOURCE_FILE) \
../resources/installer_resources.c \
$(COMMON_SOURCES) \
$(TRANSACTION_SOURCES) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
installer.vala

View File

@ -17,18 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Alpm {
namespace Pamac {
[Compact]
public class Repo {
public string name;
public Signature.Level siglevel;
public Signature.Level siglevel_mask;
public DB.Usage usage;
public Alpm.Signature.Level siglevel;
public Alpm.Signature.Level siglevel_mask;
public Alpm.DB.Usage usage;
public GLib.List<string> urls;
public Repo (string name) {
this.name = name;
siglevel = Signature.Level.USE_DEFAULT;
siglevel = Alpm.Signature.Level.USE_DEFAULT;
usage = 0;
urls = new GLib.List<string> ();
}
@ -44,7 +44,7 @@ namespace Alpm {
}
[Compact]
public class Config {
public class AlpmConfig {
public string conf_path;
public string? rootdir;
public string? dbpath;
@ -62,16 +62,16 @@ namespace Alpm {
public Alpm.List<string>? noupgrades;
public GLib.List<string>? holdpkgs;
public GLib.List<string>? syncfirsts;
public Signature.Level siglevel;
public Signature.Level localfilesiglevel;
public Signature.Level remotefilesiglevel;
public Signature.Level siglevel_mask;
public Signature.Level localfilesiglevel_mask;
public Signature.Level remotefilesiglevel_mask;
public Alpm.Signature.Level siglevel;
public Alpm.Signature.Level localfilesiglevel;
public Alpm.Signature.Level remotefilesiglevel;
public Alpm.Signature.Level siglevel_mask;
public Alpm.Signature.Level localfilesiglevel_mask;
public Alpm.Signature.Level remotefilesiglevel_mask;
public GLib.List<Repo> repo_order;
public Handle? handle;
public Alpm.Handle? handle;
public Config (string path) {
public AlpmConfig (string path) {
conf_path = path;
reload ();
}
@ -108,9 +108,9 @@ namespace Alpm {
usesyslog = 0;
checkspace = 0;
deltaratio = 0.7;
siglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = Signature.Level.USE_DEFAULT;
remotefilesiglevel = Signature.Level.USE_DEFAULT;
siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = Alpm.Signature.Level.USE_DEFAULT;
remotefilesiglevel = Alpm.Signature.Level.USE_DEFAULT;
repo_order = new GLib.List<Repo> ();
// parse conf file
parse_file (conf_path);
@ -150,7 +150,7 @@ namespace Alpm {
public void get_handle () {
Alpm.Errno error;
handle = Handle.new (rootdir, dbpath, out error);
handle = Alpm.Handle.new (rootdir, dbpath, out error);
if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return;
@ -179,12 +179,12 @@ namespace Alpm {
// register dbs
foreach (unowned Repo repo in repo_order) {
repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (unowned string url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
}
if (repo.usage == 0) {
db.usage = DB.Usage.ALL;
db.usage = Alpm.DB.Usage.ALL;
} else {
db.usage = repo.usage;
}
@ -373,25 +373,25 @@ namespace Alpm {
}
}
public DB.Usage define_usage (string conf_string) {
DB.Usage usage = 0;
public Alpm.DB.Usage define_usage (string conf_string) {
Alpm.DB.Usage usage = 0;
foreach (unowned string directive in conf_string.split(" ")) {
if (directive == "Sync") {
usage |= DB.Usage.SYNC;
usage |= Alpm.DB.Usage.SYNC;
} else if (directive == "Search") {
usage |= DB.Usage.SEARCH;
usage |= Alpm.DB.Usage.SEARCH;
} else if (directive == "Install") {
usage |= DB.Usage.INSTALL;
usage |= Alpm.DB.Usage.INSTALL;
} else if (directive == "Upgrade") {
usage |= DB.Usage.UPGRADE;
usage |= Alpm.DB.Usage.UPGRADE;
} else if (directive == "All") {
usage |= DB.Usage.ALL;
usage |= Alpm.DB.Usage.ALL;
}
}
return usage;
}
public void process_siglevel (string conf_string, ref Signature.Level siglevel, ref Signature.Level siglevel_mask) {
public void process_siglevel (string conf_string, ref Alpm.Signature.Level siglevel, ref Alpm.Signature.Level siglevel_mask) {
foreach (unowned string directive in conf_string.split(" ")) {
bool affect_package = false;
bool affect_database = false;
@ -405,61 +405,61 @@ namespace Alpm {
}
if ("Never" in directive) {
if (affect_package) {
siglevel &= ~Signature.Level.PACKAGE;
siglevel_mask |= Signature.Level.PACKAGE;
siglevel &= ~Alpm.Signature.Level.PACKAGE;
siglevel_mask |= Alpm.Signature.Level.PACKAGE;
}
if (affect_database) {
siglevel &= ~Signature.Level.DATABASE;
siglevel_mask |= Signature.Level.DATABASE;
siglevel &= ~Alpm.Signature.Level.DATABASE;
siglevel_mask |= Alpm.Signature.Level.DATABASE;
}
} else if ("Optional" in directive) {
if (affect_package) {
siglevel |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
siglevel_mask |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
siglevel |= (Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL);
siglevel_mask |= (Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL);
}
if (affect_database) {
siglevel |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
siglevel_mask |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
siglevel |= (Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL);
siglevel_mask |= (Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL);
}
} else if ("Required" in directive) {
if (affect_package) {
siglevel |= Signature.Level.PACKAGE;
siglevel_mask |= Signature.Level.PACKAGE;
siglevel &= ~Signature.Level.PACKAGE_OPTIONAL;
siglevel_mask |= Signature.Level.PACKAGE_OPTIONAL;
siglevel |= Alpm.Signature.Level.PACKAGE;
siglevel_mask |= Alpm.Signature.Level.PACKAGE;
siglevel &= ~Alpm.Signature.Level.PACKAGE_OPTIONAL;
siglevel_mask |= Alpm.Signature.Level.PACKAGE_OPTIONAL;
}
if (affect_database) {
siglevel |= Signature.Level.DATABASE;
siglevel_mask |= Signature.Level.DATABASE;
siglevel &= ~Signature.Level.DATABASE_OPTIONAL;
siglevel_mask |= Signature.Level.DATABASE_OPTIONAL;
siglevel |= Alpm.Signature.Level.DATABASE;
siglevel_mask |= Alpm.Signature.Level.DATABASE;
siglevel &= ~Alpm.Signature.Level.DATABASE_OPTIONAL;
siglevel_mask |= Alpm.Signature.Level.DATABASE_OPTIONAL;
}
} else if ("TrustedOnly" in directive) {
if (affect_package) {
siglevel &= ~(Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel &= ~(Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
siglevel &= ~(Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel &= ~(Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK);
}
} else if ("TrustAll" in directive) {
if (affect_package) {
siglevel |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
siglevel |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK);
}
} else {
GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
}
}
siglevel &= ~Signature.Level.USE_DEFAULT;
siglevel &= ~Alpm.Signature.Level.USE_DEFAULT;
}
public Signature.Level merge_siglevel(Signature.Level sigbase, Signature.Level sigover, Signature.Level sigmask) {
public Alpm.Signature.Level merge_siglevel(Alpm.Signature.Level sigbase, Alpm.Signature.Level sigover, Alpm.Signature.Level sigmask) {
return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover;
}
}

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2015-2016 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
@ -17,22 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public int compare_name (Alpm.Package pkg_a, Alpm.Package pkg_b) {
int compare_name (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return strcmp (pkg_a.name, pkg_b.name);
}
public int compare_state (Alpm.Package pkg_a, Alpm.Package pkg_b) {
int compare_state (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return (int) (pkg_a.origin > pkg_b.origin) - (int) (pkg_a.origin < pkg_b.origin);
}
public int compare_version (Alpm.Package pkg_a, Alpm.Package pkg_b) {
int compare_version (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
}
public int compare_repo (Alpm.Package pkg_a, Alpm.Package pkg_b) {
int compare_repo (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return strcmp (pkg_a.db.name, pkg_b.db.name);
}
public int compare_size (Alpm.Package pkg_a, Alpm.Package pkg_b) {
int compare_size (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return (int) (pkg_a.isize > pkg_b.isize) - (int) (pkg_a.isize < pkg_b.isize);
}

View File

@ -20,13 +20,13 @@
Pamac.ManagerWindow manager_window;
// custom sort functions
public int aur_compare_name (Json.Object pkg_a, Json.Object pkg_b) {
int aur_compare_name (Json.Object pkg_a, Json.Object pkg_b) {
return strcmp (pkg_a.get_string_member ("Name"), pkg_b.get_string_member ("Name"));
}
public int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) {
unowned Alpm.Package? alpm_pkg_a = manager_window.alpm_config.handle.localdb.get_pkg (pkg_a.get_string_member ("Name"));
unowned Alpm.Package? alpm_pkg_b = manager_window.alpm_config.handle.localdb.get_pkg (pkg_b.get_string_member ("Name"));
int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) {
unowned Alpm.Package? alpm_pkg_a = manager_window.transaction.alpm_config.handle.localdb.get_pkg (pkg_a.get_string_member ("Name"));
unowned Alpm.Package? alpm_pkg_b = manager_window.transaction.alpm_config.handle.localdb.get_pkg (pkg_b.get_string_member ("Name"));
if (pkg_a != null) {
if (pkg_b != null) {
return (int) (alpm_pkg_a.origin > alpm_pkg_b.origin) - (int) (alpm_pkg_a.origin < alpm_pkg_b.origin);
@ -42,17 +42,17 @@ public int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) {
}
}
public int aur_compare_version (Json.Object pkg_a, Json.Object pkg_b) {
int aur_compare_version (Json.Object pkg_a, Json.Object pkg_b) {
return Alpm.pkg_vercmp (pkg_a.get_string_member ("Version"), pkg_b.get_string_member ("Version"));
}
public int aur_compare_votes (Json.Object pkg_a, Json.Object pkg_b) {
int aur_compare_votes (Json.Object pkg_a, Json.Object pkg_b) {
return (int) (pkg_a.get_int_member ("NumVotes") > pkg_b.get_int_member ("NumVotes")) - (int) (pkg_a.get_int_member ("NumVotes") < pkg_b.get_int_member ("NumVotes"));
}
namespace Pamac {
public class AURModel : Object, Gtk.TreeModel {
class AURModel : Object, Gtk.TreeModel {
private Json.Array pkgs_infos;
private GLib.List<Json.Object?> pkgs;
@ -68,7 +68,7 @@ namespace Pamac {
}
// TreeModel interface
public Type get_column_type (int index) {
Type get_column_type (int index) {
switch (index) {
case 0: // name
case 2: // version
@ -82,11 +82,11 @@ namespace Pamac {
}
}
public Gtk.TreeModelFlags get_flags () {
Gtk.TreeModelFlags get_flags () {
return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST;
}
public void get_value (Gtk.TreeIter iter, int column, out Value val) {
void get_value (Gtk.TreeIter iter, int column, out Value val) {
unowned Json.Object? pkg_info = pkgs.nth_data (iter.stamp);
switch (column) {
case 0:
@ -100,9 +100,9 @@ namespace Pamac {
case 1:
val = Value (typeof (Object));
if (pkg_info != null) {
unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
unowned Alpm.Package? pkg = manager_window.transaction.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) {
if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
if (manager_window.transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon);
@ -121,7 +121,7 @@ namespace Pamac {
case 2:
val = Value (typeof (string));
if (pkg_info != null) {
unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
unowned Alpm.Package? pkg = manager_window.transaction.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) {
val.set_string (pkg.version);
} else {
@ -144,7 +144,7 @@ namespace Pamac {
}
}
public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
if (path.get_depth () != 1) {
return invalid_iter (out iter);
}
@ -154,20 +154,20 @@ namespace Pamac {
return true;
}
public int get_n_columns () {
int get_n_columns () {
// name, icon, version, votes
return 4;
}
public Gtk.TreePath? get_path (Gtk.TreeIter iter) {
Gtk.TreePath? get_path (Gtk.TreeIter iter) {
return new Gtk.TreePath.from_indices (iter.stamp);
}
public int iter_n_children (Gtk.TreeIter? iter) {
int iter_n_children (Gtk.TreeIter? iter) {
return 0;
}
public bool iter_next (ref Gtk.TreeIter iter) {
bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1;
if (pos >= pkgs.length ()) {
return false;
@ -176,7 +176,7 @@ namespace Pamac {
return true;
}
public bool iter_previous (ref Gtk.TreeIter iter) {
bool iter_previous (ref Gtk.TreeIter iter) {
int pos = iter.stamp;
if (pos >= 0) {
return false;
@ -185,23 +185,23 @@ namespace Pamac {
return true;
}
public bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
return invalid_iter (out iter);
}
public bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
return invalid_iter (out iter);
}
public bool iter_has_child (Gtk.TreeIter iter) {
bool iter_has_child (Gtk.TreeIter iter) {
return false;
}
public bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
return invalid_iter (out iter);
}
private bool invalid_iter (out Gtk.TreeIter iter) {
bool invalid_iter (out Gtk.TreeIter iter) {
iter = Gtk.TreeIter ();
iter.stamp = -1;
return false;

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,14 +20,12 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/choose_dep_dialog.ui")]
public class ChooseDependenciesDialog : Gtk.Dialog {
class ChooseDependenciesDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.TreeView treeview;
[GtkChild]
public Gtk.CellRendererToggle renderertoggle;
public Gtk.ListStore deps_list;

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2015-2016 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
@ -20,14 +20,12 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/choose_ignorepkgs_dialog.ui")]
public class ChooseIgnorepkgsDialog : Gtk.Dialog {
class ChooseIgnorepkgsDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.TreeView treeview;
[GtkChild]
public Gtk.CellRendererToggle renderertoggle;
public Gtk.ListStore pkgs_list;

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,7 +20,7 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/choose_provider_dialog.ui")]
public class ChooseProviderDialog : Gtk.Dialog {
class ChooseProviderDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;

View File

@ -38,8 +38,8 @@ public class AlpmAction {
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public class Daemon : Object {
private Alpm.Config alpm_config;
public class Daemon: Object {
private AlpmConfig alpm_config;
public Cond provider_cond;
public Mutex provider_mutex;
public int? choosen_provider;
@ -76,7 +76,7 @@ namespace Pamac {
public signal void generate_mirrors_list_finished ();
public Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
alpm_config = new AlpmConfig ("/etc/pacman.conf");
databases_lock_mutex = Mutex ();
aur_updates_results = new Json.Array ();
timer = new Timer ();
@ -283,7 +283,7 @@ namespace Pamac {
}
public void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf, GLib.BusName sender) {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
check_authorization.begin (sender, (obj, res) => {
bool authorized = check_authorization.end (res);
if (authorized) {
@ -1159,7 +1159,7 @@ private int cb_fetch (string fileurl, string localpath, int force) {
// as actually being transferred during curl_easy_perform ()
else if (remote_size != -1 && bytes_dl != -1 && bytes_dl != remote_size) {
pamac_daemon.emit_log ((uint) Alpm.LogLevel.ERROR,
dgettext ("libalpm", "%s appears to be truncated: %jd/%jd bytes\n").printf (
_("%s appears to be truncated: %jd/%jd bytes\n").printf (
fileurl, bytes_dl, remote_size));
if (remove_partial_download) {
try {
@ -1214,7 +1214,7 @@ private int cb_fetch (string fileurl, string localpath, int force) {
if (!fileurl.has_suffix ("db.sig")) {
string hostname = url.get_uri ().split("/")[2];
pamac_daemon.emit_log ((uint) Alpm.LogLevel.ERROR,
dgettext ("libalpm", "failed retrieving file '%s' from %s : %s\n").printf (
_("failed retrieving file '%s' from %s : %s\n").printf (
url.get_basename (), hostname, error_buffer));
}
ret = -1;

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,7 +20,7 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/history_dialog.ui")]
public class HistoryDialog : Gtk.Dialog {
class HistoryDialog : Gtk.Dialog {
[GtkChild]
public Gtk.TextView textview;

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -37,13 +37,13 @@ namespace Pamac {
pamac_run = check_pamac_running ();
if (pamac_run) {
var transaction_info_dialog = new TransactionInfoDialog (null);
transaction_info_dialog.set_title (dgettext (null, "Error"));
transaction_info_dialog.label.set_visible (true);
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
transaction_info_dialog.expander.set_visible (false);
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
var msg = new Gtk.MessageDialog (null,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
dgettext (null, "Pamac is already running"));
msg.run ();
msg.destroy ();
} else {
transaction = new Pamac.Transaction (null);
transaction.finished.connect (on_transaction_finished);
@ -91,7 +91,7 @@ namespace Pamac {
return run;
}
public void on_transaction_finished () {
void on_transaction_finished () {
transaction.stop_daemon ();
this.release ();
}

View File

@ -37,13 +37,13 @@ namespace Pamac {
pamac_run = check_pamac_running ();
if (pamac_run) {
var transaction_info_dialog = new TransactionInfoDialog (null);
transaction_info_dialog.set_title (dgettext (null, "Error"));
transaction_info_dialog.label.set_visible (true);
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
transaction_info_dialog.expander.set_visible (false);
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
var msg = new Gtk.MessageDialog (null,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
dgettext (null, "Pamac is already running"));
msg.run ();
msg.destroy ();
} else {
manager_window = new ManagerWindow (this);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -17,9 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Alpm {
namespace Pamac {
[Compact]
public class MirrorsConfig: Object {
public class MirrorsConfig {
public string conf_path;
public string mirrorlists_dir;
public string choosen_generation_method;

View File

@ -1,95 +0,0 @@
/*
* pamac-vala
*
* Copyright (C) 2014-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 {
public struct Package {
public string name;
public string version;
public string desc;
public string repo;
public uint64 size;
public string size_string;
public string url;
public string licenses;
public int reason;
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) {
name = alpm_pkg.name;
version = alpm_pkg.version;
desc = alpm_pkg.desc;
repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize);
// alpm pkg url can be null
url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) {
if (licenses_build.len != 0) {
licenses_build.append (" ");
}
licenses_build.append (license);
}
licenses = licenses_build.str;
reason = alpm_pkg.reason;
} else if (aur_json != null ) {
name = aur_json.get_string_member ("Name");
version = aur_json.get_string_member ("Version");
desc = aur_json.get_string_member ("Description");
repo = "AUR";
size = 0;
size_string = "";
url = aur_json.get_string_member ("URL") ?? "";
licenses = aur_json.get_string_member ("License") ?? dgettext (null, "Unknown");
reason = 0;
} else {
name = "";
version = "";
desc = "";
repo = "";
size = 0;
size_string = "";
url = "";
licenses= "";
reason = 0;
}
}
}
public struct PackageDetails {
string repo;
string has_signature;
int reason;
string packager;
string install_date;
string[] groups;
string[] backups;
}
public struct PackageDeps {
string repo;
string[] depends;
string[] optdepends;
string[] requiredby;
string[] optionalfor;
string[] provides;
string[] replaces;
string[] conflicts;
}
}

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -19,7 +19,7 @@
namespace Pamac {
public class PackagesModel : Object, Gtk.TreeModel {
class PackagesModel : Object, Gtk.TreeModel {
private Alpm.List<unowned Alpm.Package?>? pkgs;
private ManagerWindow manager_window;
@ -43,11 +43,11 @@ namespace Pamac {
}
}
public Gtk.TreeModelFlags get_flags () {
Gtk.TreeModelFlags get_flags () {
return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST;
}
public void get_value (Gtk.TreeIter iter, int column, out Value val) {
void get_value (Gtk.TreeIter iter, int column, out Value val) {
unowned Alpm.Package? pkg = pkgs.nth (iter.stamp).data;
switch (column) {
case 0:
@ -62,7 +62,7 @@ namespace Pamac {
val = Value (typeof (Object));
if (pkg != null) {
if (pkg.origin == Alpm.Package.From.LOCALDB) {
if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
if (manager_window.transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon);
@ -102,30 +102,38 @@ namespace Pamac {
}
}
public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
if (path.get_depth () != 1) {
return invalid_iter (out iter);
bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {
if (path.get_depth () == 1) {
int pos = path.get_indices ()[0];
// return a valid iter for pos == 0 to display "No package found"
if (pos < pkgs.length || pos == 0) {
iter = Gtk.TreeIter ();
iter.stamp = pos;
return true;
}
}
iter = Gtk.TreeIter ();
int pos = path.get_indices ()[0];
iter.stamp = pos;
return true;
return invalid_iter (out iter);
}
public int get_n_columns () {
int get_n_columns () {
// name, icon, version, repo, isize
return 5;
}
public Gtk.TreePath? get_path (Gtk.TreeIter iter) {
return new Gtk.TreePath.from_indices (iter.stamp);
Gtk.TreePath? get_path (Gtk.TreeIter iter) {
int pos = iter.stamp;
// return a valid path for pos == 0 to display "No package found"
if (pos < pkgs.length || pos == 0) {
return new Gtk.TreePath.from_indices (pos);
}
return null;
}
public int iter_n_children (Gtk.TreeIter? iter) {
int iter_n_children (Gtk.TreeIter? iter) {
return 0;
}
public bool iter_next (ref Gtk.TreeIter iter) {
bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1;
if (pos >= pkgs.length) {
return false;
@ -134,7 +142,7 @@ namespace Pamac {
return true;
}
public bool iter_previous (ref Gtk.TreeIter iter) {
bool iter_previous (ref Gtk.TreeIter iter) {
int pos = iter.stamp;
if (pos >= 0) {
return false;
@ -143,23 +151,23 @@ namespace Pamac {
return true;
}
public bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
return invalid_iter (out iter);
}
public bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
return invalid_iter (out iter);
}
public bool iter_has_child (Gtk.TreeIter iter) {
bool iter_has_child (Gtk.TreeIter iter) {
return false;
}
public bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
return invalid_iter (out iter);
}
private bool invalid_iter (out Gtk.TreeIter iter) {
bool invalid_iter (out Gtk.TreeIter iter) {
iter = Gtk.TreeIter ();
iter.stamp = -1;
return false;
@ -167,7 +175,11 @@ namespace Pamac {
// custom get pkg function
public unowned Alpm.Package? get_pkg_at_path (Gtk.TreePath path) {
return pkgs.nth (path.get_indices ()[0]).data;
int pos = path.get_indices ()[0];
if (pos < pkgs.length) {
return pkgs.nth (pos).data;
}
return null;
}
// custom sort functions

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -17,8 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const string VERSION = "3.1.0";
namespace Pamac {
[Compact]
public class Config {
@ -37,7 +35,7 @@ namespace Pamac {
//get environment variables
environment_variables = new HashTable<string,string> (str_hash, str_equal);
var utsname = Posix.utsname();
environment_variables.insert ("HTTP_USER_AGENT", "pamac/%s (%s %s)".printf (VERSION, utsname.sysname, utsname.machine));
environment_variables.insert ("HTTP_USER_AGENT", "pamac (%s %s)".printf (utsname.sysname, utsname.machine));
unowned string? variable = Environment.get_variable ("http_proxy");
if (variable != null) {
environment_variables.insert ("http_proxy", variable);

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2015-2016 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
@ -20,61 +20,55 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/preferences_dialog.ui")]
public class PreferencesDialog : Gtk.Dialog {
class PreferencesDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Switch remove_unrequired_deps_button;
Gtk.Switch remove_unrequired_deps_button;
[GtkChild]
public Gtk.Switch check_space_button;
Gtk.Switch check_space_button;
[GtkChild]
public Gtk.Switch check_updates_button;
Gtk.Switch check_updates_button;
[GtkChild]
public Gtk.Label refresh_period_label;
Gtk.Label refresh_period_label;
[GtkChild]
public Gtk.SpinButton refresh_period_spin_button;
Gtk.SpinButton refresh_period_spin_button;
[GtkChild]
public Gtk.CheckButton no_update_hide_icon_checkbutton;
Gtk.CheckButton no_update_hide_icon_checkbutton;
[GtkChild]
public Gtk.Box ignorepkgs_box;
Gtk.Box ignorepkgs_box;
[GtkChild]
public Gtk.ListStore ignorepkgs_liststore;
Gtk.ListStore ignorepkgs_liststore;
[GtkChild]
public Gtk.TreeView ignorepkgs_treeview;
Gtk.TreeView ignorepkgs_treeview;
[GtkChild]
public Gtk.Box mirrors_config_box;
Gtk.Box mirrors_config_box;
[GtkChild]
public Gtk.ComboBoxText mirrors_country_comboboxtext;
Gtk.ComboBoxText mirrors_country_comboboxtext;
[GtkChild]
public Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext;
Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext;
[GtkChild]
public Gtk.Button generate_mirrors_list_button;
Gtk.Button generate_mirrors_list_button;
[GtkChild]
public Gtk.Box aur_config_box;
Gtk.Box aur_config_box;
[GtkChild]
public Gtk.Switch enable_aur_button;
Gtk.Switch enable_aur_button;
[GtkChild]
public Gtk.CheckButton search_aur_checkbutton;
Gtk.CheckButton search_aur_checkbutton;
[GtkChild]
public Gtk.CheckButton check_aur_updates_checkbutton;
Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild]
public Gtk.CheckButton no_confirm_build_checkbutton;
Gtk.CheckButton no_confirm_build_checkbutton;
Transaction transaction;
Alpm.Config alpm_config;
uint64 previous_refresh_period;
public PreferencesDialog (Gtk.ApplicationWindow? window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0);
public PreferencesDialog (Transaction transaction) {
Object (transient_for: transaction.application_window, use_header_bar: 0);
this.transaction = transaction;
alpm_config = new Alpm.Config ("/etc/pacman.conf");
alpm_config.get_handle ();
if (alpm_config.handle == null) {
stderr.printf (dgettext (null, "Failed to initialize alpm library"));
}
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
remove_unrequired_deps_button.active = transaction.pamac_config.recurse;
check_space_button.active = (alpm_config.checkspace == 1);
check_space_button.active = (transaction.alpm_config.checkspace == 1);
if (transaction.pamac_config.refresh_period == 0) {
check_updates_button.active = false;
refresh_period_label.sensitive = false;
@ -93,22 +87,22 @@ namespace Pamac {
// populate ignorepkgs_liststore
Gtk.TreeIter iter;
for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
for (unowned Alpm.List<string> list = transaction.alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
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);
transaction.daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
transaction.write_alpm_config_finished.connect (on_write_alpm_config_finished);
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);
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "pacman-mirrorlist");
unowned Alpm.Package? pkg = Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, "pacman-mirrorlist");
if (pkg == null) {
mirrors_config_box.visible = false;
} else {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
mirrors_country_comboboxtext.active = 0;
int index = 1;
@ -129,10 +123,10 @@ namespace Pamac {
}
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);
transaction.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
}
pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
pkg = Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, "yaourt");
if (pkg == null) {
aur_config_box.visible = false;
} else {
@ -254,9 +248,9 @@ namespace Pamac {
[GtkCallback]
void on_add_ignorepkgs_button_clicked () {
var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this);
foreach (var pkg in alpm_config.handle.localdb.pkgcache) {
foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
Gtk.TreeIter iter;
if (alpm_config.ignorepkgs.find_str (pkg.name) == null) {
if (transaction.alpm_config.ignorepkgs.find_str (pkg.name) == null) {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
} else {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
@ -317,8 +311,7 @@ namespace Pamac {
// re-populate ignorepkgs_liststore
Gtk.TreeIter iter;
ignorepkgs_liststore.clear ();
alpm_config.reload ();
for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
for (unowned Alpm.List<string> list = transaction.alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
}

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,7 +20,7 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")]
public class ProgressDialog : Gtk.Dialog {
class ProgressDialog : Gtk.Dialog {
[GtkChild]
public Gtk.ProgressBar progressbar;
@ -63,7 +63,7 @@ namespace Pamac {
}
[GtkCallback]
public void on_close_button_clicked () {
void on_close_button_clicked () {
this.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();

View File

@ -18,12 +18,8 @@
*/
namespace Pamac {
public struct ErrorInfos {
public string message;
public string[] details;
}
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
interface Daemon : Object {
public abstract void start_refresh (bool force) throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;

View File

@ -19,7 +19,7 @@
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
interface Daemon : Object {
public abstract void set_environment_variables (HashTable<string,string> variables) throws IOError;
public abstract ErrorInfos get_current_error () throws IOError;
public abstract void start_get_authorization () throws IOError;
@ -74,15 +74,17 @@ namespace Pamac {
UPDATER
}
public enum TransactionType {
STANDARD = (1 << 0),
UPDATE = (1 << 1),
BUILD = (1 << 2)
}
public class Transaction: Object {
public Daemon daemon;
enum Type {
STANDARD = (1 << 0),
UPDATE = (1 << 1),
BUILD = (1 << 2)
}
Daemon daemon;
public AlpmConfig alpm_config;
public Pamac.Config pamac_config;
public Alpm.TransFlag flags;
@ -91,7 +93,9 @@ namespace Pamac {
public GenericSet<string?> to_remove;
public GenericSet<string?> to_load;
public GenericSet<string?> to_build;
public GenericSet<string?> special_ignorepkgs;
public GenericSet<string?> temporary_ignorepkgs;
HashTable<string,Json.Object> aur_infos;
public Mode mode;
@ -114,21 +118,32 @@ namespace Pamac {
TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog;
//parent window
Gtk.ApplicationWindow? application_window;
public Gtk.ApplicationWindow? application_window;
public signal void finished (bool database_modified);
public signal void set_pkgreason_finished ();
public signal void get_updates_finished (Updates updates);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool 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 Transaction (Gtk.ApplicationWindow? application_window) {
alpm_config = new AlpmConfig ("/etc/pacman.conf");
refresh_handle ();
pamac_config = new Pamac.Config ("/etc/pamac.conf");
flags = Alpm.TransFlag.CASCADE;
if (pamac_config.recurse) {
flags |= Alpm.TransFlag.RECURSE;
}
to_add = new GenericSet<string?> (str_hash, str_equal);
to_remove = new GenericSet<string?> (str_hash, str_equal);
to_load = new GenericSet<string?> (str_hash, str_equal);
to_build = new GenericSet<string?> (str_hash, str_equal);
special_ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
temporary_ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
aur_infos = new HashTable<string,Json.Object> (str_hash, str_equal);
connecting_dbus_signals ();
//creating dialogs
this.application_window = application_window;
@ -146,6 +161,31 @@ namespace Pamac {
timer = new Timer ();
}
public async void run_preferences_dialog () {
SourceFunc callback = run_preferences_dialog.callback;
ulong handler_id = daemon.get_authorization_finished.connect ((authorized) => {
if (authorized) {
var preferences_dialog = new PreferencesDialog (this);
preferences_dialog.run ();
preferences_dialog.destroy ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
Idle.add((owned) callback);
});
start_get_authorization ();
yield;
daemon.disconnect (handler_id);
}
public void refresh_handle () {
alpm_config.get_handle ();
if (alpm_config.handle == null) {
stderr.printf (dgettext (null, "Failed to initialize alpm library"));
}
}
public ErrorInfos get_current_error () {
try {
return daemon.get_current_error ();
@ -236,6 +276,7 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
daemon.refresh_finished.disconnect (on_refresh_finished);
refresh_handle ();
finished (true);
}
}
@ -252,7 +293,7 @@ namespace Pamac {
public void add_ignorepkg (string pkgname) {
try {
daemon.add_ignorepkg (pkgname);
//special_ignorepkgs.add (pkgname);
//temporary_ignorepkgs.add (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@ -267,7 +308,7 @@ namespace Pamac {
}
public bool init (Alpm.TransFlag flags) {
foreach (unowned string pkgname in special_ignorepkgs) {
foreach (unowned string pkgname in temporary_ignorepkgs) {
add_ignorepkg (pkgname);
}
try {
@ -278,7 +319,7 @@ namespace Pamac {
}
}
public void sysupgrade_simple (bool enable_downgrade) {
void sysupgrade_simple (bool enable_downgrade) {
progress_dialog.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (true);
bool success = init (0);
@ -328,7 +369,7 @@ namespace Pamac {
start_get_updates ();
}
public void on_get_updates_finished (Updates updates) {
void on_get_updates_finished (Updates updates) {
// get syncfirst updates
if (updates.is_syncfirst) {
clear_lists ();
@ -344,7 +385,7 @@ namespace Pamac {
if (updates.aur_updates.length != 0) {
clear_lists ();
foreach (unowned PackageInfos infos in updates.aur_updates) {
if (!(infos.name in special_ignorepkgs)) {
if (!(infos.name in temporary_ignorepkgs)) {
to_build.add (infos.name);
}
}
@ -360,6 +401,7 @@ namespace Pamac {
}
}
daemon.get_updates_finished.disconnect (on_get_updates_finished);
get_updates_finished (updates);
}
public void clear_lists () {
@ -369,7 +411,7 @@ namespace Pamac {
}
public void run () {
string action = dgettext (null,"Preparing") + "...";
string action = dgettext (null, "Preparing") + "...";
progress_dialog.spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
@ -445,7 +487,7 @@ namespace Pamac {
}
}
public void choose_provider (string depend, string[] providers) {
void choose_provider (string depend, string[] providers) {
var choose_provider_dialog = new ChooseProviderDialog (application_window);
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
foreach (unowned string provider in providers) {
@ -464,9 +506,9 @@ namespace Pamac {
}
}
public TransactionType set_transaction_sum () {
Type set_transaction_sum () {
// return 0 if transaction_sum is empty, 2, if there are only aur updates, 1 otherwise
TransactionType type = 0;
Type type = 0;
uint64 dsize = 0;
PackageInfos[] prepared_to_add = {};
PackageInfos[] prepared_to_remove = {};
@ -510,7 +552,7 @@ namespace Pamac {
int len = prepared_to_remove.length;
int i;
if (len != 0) {
type |= TransactionType.STANDARD;
type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To remove") + ":",
1, "%s %s".printf (prepared_to_remove[0].name, prepared_to_remove[0].version));
@ -523,7 +565,7 @@ namespace Pamac {
}
len = to_downgrade.length;
if (len != 0) {
type |= TransactionType.STANDARD;
type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To downgrade") + ":",
1, to_downgrade[0]);
@ -536,7 +578,7 @@ namespace Pamac {
}
len = _to_build.length;
if (len != 0) {
type |= TransactionType.BUILD;
type |= Type.BUILD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To build") + ":",
1, _to_build[0]);
@ -549,7 +591,7 @@ namespace Pamac {
}
len = to_install.length;
if (len != 0) {
type |= TransactionType.STANDARD;
type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To install") + ":",
1, to_install[0]);
@ -562,7 +604,7 @@ namespace Pamac {
}
len = to_reinstall.length;
if (len != 0) {
type |= TransactionType.STANDARD;
type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To reinstall") + ":",
1, to_reinstall[0]);
@ -575,7 +617,7 @@ namespace Pamac {
}
len = to_update.length;
if (len != 0) {
type |= TransactionType.UPDATE;
type |= Type.UPDATE;
if (mode != Mode.UPDATER) {
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To update") + ":",
@ -603,12 +645,13 @@ namespace Pamac {
daemon.start_trans_commit ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
refresh_handle ();
finished (true);
}
}
public void build_aur_packages () {
string action = dgettext (null,"Building packages") + "...";
string action = dgettext (null, "Building packages") + "...";
progress_dialog.spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
@ -632,6 +675,14 @@ namespace Pamac {
progress_dialog.term.watch_child (child_pid);
}
public async Json.Object get_aur_infos (string aur_name) {
if (!aur_infos.contains (aur_name)) {
Json.Array results = AUR.multiinfo ({aur_name});
aur_infos.insert (aur_name, results.get_object_element (0));
}
return aur_infos.lookup (aur_name);
}
public void cancel () {
try {
daemon.trans_cancel ();
@ -652,7 +703,7 @@ namespace Pamac {
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
foreach (unowned string pkgname in special_ignorepkgs) {
foreach (unowned string pkgname in temporary_ignorepkgs) {
remove_ignorepkg (pkgname);
}
}
@ -1037,7 +1088,7 @@ namespace Pamac {
}
}
public void show_warnings () {
void show_warnings () {
if (transaction_info_dialog.textbuffer.text != "") {
transaction_info_dialog.set_title (dgettext (null, "Warning"));
transaction_info_dialog.label.set_visible (false);
@ -1056,7 +1107,7 @@ namespace Pamac {
}
}
public void handle_error (ErrorInfos error) {
void handle_error (ErrorInfos error) {
if (error.message != null && error.message != "") {
progress_dialog.expander.set_expanded (true);
progress_dialog.spawn_in_term ({"echo", "-n", error.message});
@ -1097,7 +1148,8 @@ namespace Pamac {
}
}
public void on_refresh_finished (bool success) {
void on_refresh_finished (bool success) {
refresh_handle ();
if (success) {
if (mode == Mode.UPDATER) {
finished (true);
@ -1117,7 +1169,7 @@ namespace Pamac {
daemon.refresh_finished.disconnect (on_refresh_finished);
}
public void on_cancel_button_clicked () {
void on_cancel_button_clicked () {
cancel ();
clear_lists ();
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
@ -1127,11 +1179,11 @@ namespace Pamac {
}
}
public void on_trans_prepare_finished (bool success) {
void on_trans_prepare_finished (bool success) {
if (success) {
show_warnings ();
TransactionType type = set_transaction_sum ();
if (type == TransactionType.UPDATE && mode == Mode.UPDATER) {
Type type = set_transaction_sum ();
if (type == Type.UPDATE && mode == Mode.UPDATER) {
// there only updates
start_commit ();
} else if (type != 0) {
@ -1140,7 +1192,7 @@ namespace Pamac {
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
if (type == TransactionType.BUILD) {
if (type == Type.BUILD) {
// there only AUR packages to build
release ();
on_trans_commit_finished (true);
@ -1178,7 +1230,7 @@ namespace Pamac {
}
}
public void on_trans_commit_finished (bool success) {
void on_trans_commit_finished (bool success) {
if (success) {
if (to_build.length != 0) {
if (to_add.length != 0
@ -1194,6 +1246,7 @@ namespace Pamac {
sysupgrade_after_trans = false;
sysupgrade (false);
} else {
refresh_handle ();
finished (true);
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
if (progress_dialog.expander.get_expanded ()) {
@ -1215,6 +1268,7 @@ namespace Pamac {
finished (false);
} else {
clear_lists ();
refresh_handle ();
finished (true);
}
handle_error (err);
@ -1229,6 +1283,7 @@ namespace Pamac {
clear_lists ();
// let the time to the daemon to update databases
Timeout.add (1000, () => {
refresh_handle ();
finished (true);
if (status == 0) {
string action = dgettext (null, "Transaction successfully finished");
@ -1247,8 +1302,27 @@ namespace Pamac {
});
}
void on_write_pamac_config_finished () {
void on_set_pkgreason_finished () {
refresh_handle ();
set_pkgreason_finished ();
}
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) {
pamac_config.reload ();
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon,
enable_aur, search_aur, check_aur_updates,
no_confirm_build);
}
void on_write_alpm_config_finished (bool checkspace) {
alpm_config.reload ();
write_alpm_config_finished (checkspace);
}
void on_write_mirrors_config_finished (string choosen_country, string choosen_generation_method) {
write_mirrors_config_finished (choosen_country, choosen_generation_method);
}
void on_generate_mirrors_list_data (string line) {
@ -1276,6 +1350,9 @@ namespace Pamac {
daemon.emit_log.connect (on_emit_log);
daemon.trans_prepare_finished.connect (on_trans_prepare_finished);
daemon.trans_commit_finished.connect (on_trans_commit_finished);
daemon.set_pkgreason_finished.connect (on_set_pkgreason_finished);
daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
daemon.generate_mirrors_list_data.connect (on_generate_mirrors_list_data);
daemon.generate_mirrors_list_finished.connect (on_generate_mirrors_list_finished);

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,15 +20,15 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_info_dialog.ui")]
public class TransactionInfoDialog : Gtk.Dialog {
class TransactionInfoDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label label;
[GtkChild]
public Gtk.Expander expander;
[GtkChild]
public Gtk.TextView textview;
Gtk.TextView textview;
public Gtk.TextBuffer textbuffer;
public TransactionInfoDialog (Gtk.ApplicationWindow? window) {

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -20,14 +20,14 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_sum_dialog.ui")]
public class TransactionSumDialog : Gtk.Dialog {
class TransactionSumDialog : Gtk.Dialog {
[GtkChild]
public Gtk.Label top_label;
[GtkChild]
public Gtk.Label bottom_label;
[GtkChild]
public Gtk.TreeView treeview;
Gtk.TreeView treeview;
public Gtk.ListStore sum_list;

View File

@ -26,7 +26,7 @@ const string noupdate_info = _("Your system is up-to-date");
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
interface Daemon : Object {
public abstract void start_refresh (bool force) throws IOError;
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)]
@ -38,7 +38,7 @@ namespace Pamac {
public signal void write_alpm_config_finished (bool checkspace);
}
public class TrayIcon: Gtk.Application {
class TrayIcon: Gtk.Application {
Notify.Notification notification;
//~ Notification notification;
Daemon daemon;
@ -313,14 +313,14 @@ namespace Pamac {
status_icon = new Gtk.StatusIcon ();
status_icon.visible = !(pamac_config.no_update_hide_icon);
this.update_icon (noupdate_icon_name, noupdate_info);
update_icon (noupdate_icon_name, noupdate_info);
status_icon.activate.connect (left_clicked);
create_menu ();
status_icon.popup_menu.connect (menu_popup);
Notify.init (_("Update Manager"));
var alpm_config = new Alpm.Config ("/etc/pacman.conf");
var alpm_config = new AlpmConfig ("/etc/pacman.conf");
alpm_config.get_handle ();
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
start_daemon ();
@ -335,7 +335,7 @@ namespace Pamac {
// nothing to do
}
public static int main (string[] args) {
static int main (string[] args) {
var tray_icon = new TrayIcon();
return tray_icon.run (args);
}

View File

@ -1,7 +1,7 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
* Copyright (C) 2014-2016 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
@ -19,7 +19,7 @@
namespace Pamac {
public class Updater : Gtk.Application {
class Updater : Gtk.Application {
UpdaterWindow updater_window;
bool pamac_run;
@ -37,13 +37,13 @@ namespace Pamac {
pamac_run = check_pamac_running ();
if (pamac_run) {
var transaction_info_dialog = new TransactionInfoDialog (null);
transaction_info_dialog.set_title (dgettext (null, "Error"));
transaction_info_dialog.label.set_visible (true);
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running"));
transaction_info_dialog.expander.set_visible (false);
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
var msg = new Gtk.MessageDialog (null,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
dgettext (null, "Pamac is already running"));
msg.run ();
msg.destroy ();
} else {
updater_window = new UpdaterWindow (this);
}
@ -86,7 +86,7 @@ namespace Pamac {
}
}
public static int main (string[] args) {
static int main (string[] args) {
var updater = new Updater ();
return updater.run (args);
}

View File

@ -20,31 +20,31 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/updater/updater_window.ui")]
public class UpdaterWindow : Gtk.ApplicationWindow {
class UpdaterWindow : Gtk.ApplicationWindow {
[GtkChild]
public Gtk.Label top_label;
Gtk.Label top_label;
[GtkChild]
public Gtk.Notebook notebook;
Gtk.Notebook notebook;
[GtkChild]
public Gtk.ScrolledWindow repos_scrolledwindow;
Gtk.ScrolledWindow repos_scrolledwindow;
[GtkChild]
public Gtk.ScrolledWindow aur_scrolledwindow;
Gtk.ScrolledWindow aur_scrolledwindow;
[GtkChild]
public Gtk.TreeView repos_updates_treeview;
Gtk.TreeView repos_updates_treeview;
[GtkChild]
public Gtk.CellRendererToggle repos_select_update;
Gtk.CellRendererToggle repos_select_update;
[GtkChild]
public Gtk.TreeView aur_updates_treeview;
Gtk.TreeView aur_updates_treeview;
[GtkChild]
public Gtk.CellRendererToggle aur_select_update;
Gtk.CellRendererToggle aur_select_update;
[GtkChild]
public Gtk.Label bottom_label;
Gtk.Label bottom_label;
[GtkChild]
public Gtk.Button apply_button;
Gtk.Button apply_button;
public Gtk.ListStore repos_updates_list;
public Gtk.ListStore aur_updates_list;
Gtk.ListStore repos_updates_list;
Gtk.ListStore aur_updates_list;
public Pamac.Transaction transaction;
@ -59,7 +59,7 @@ namespace Pamac {
Timeout.add (100, populate_window);
}
public bool populate_window () {
bool populate_window () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
repos_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
@ -71,14 +71,14 @@ namespace Pamac {
transaction.mode = Mode.UPDATER;
transaction.finished.connect (on_transaction_finished);
transaction.daemon.get_updates_finished.connect (on_get_updates_finished);
transaction.get_updates_finished.connect (on_get_updates_finished);
on_refresh_button_clicked ();
return false;
}
public void set_apply_button_sensitive () {
void set_apply_button_sensitive () {
bool sensitive = false;
repos_updates_list.foreach ((model, path, iter) => {
GLib.Value selected;
@ -98,7 +98,7 @@ namespace Pamac {
}
[GtkCallback]
public void on_repos_select_update_toggled (string path) {
void on_repos_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
GLib.Value name_string;
@ -108,16 +108,16 @@ namespace Pamac {
string pkgname = name_string.get_string ().split (" ", 2)[0];
if (repos_select_update.active) {
repos_updates_list.set (iter, 0, false);
transaction.special_ignorepkgs.add (pkgname);
transaction.temporary_ignorepkgs.add (pkgname);
} else {
repos_updates_list.set (iter, 0, true);
transaction.special_ignorepkgs.remove (pkgname);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_apply_button_sensitive ();
}
[GtkCallback]
public void on_aur_select_update_toggled (string path) {
void on_aur_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
GLib.Value name_string;
@ -127,57 +127,39 @@ namespace Pamac {
string pkgname = name_string.get_string ().split (" ", 2)[0];
if (aur_select_update.active) {
aur_updates_list.set (iter, 0, false);
transaction.special_ignorepkgs.add (pkgname);
transaction.temporary_ignorepkgs.add (pkgname);
} else {
aur_updates_list.set (iter, 0, true);
transaction.special_ignorepkgs.remove (pkgname);
transaction.temporary_ignorepkgs.remove (pkgname);
}
set_apply_button_sensitive ();
}
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 (this, transaction);
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 () {
run_preferences_dialog.begin (() => {
void on_preferences_button_clicked () {
transaction.run_preferences_dialog.begin (() => {
populate_updates_list ();
});
}
[GtkCallback]
public void on_apply_button_clicked () {
void on_apply_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.sysupgrade (false);
}
[GtkCallback]
public void on_refresh_button_clicked () {
void on_refresh_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.start_refresh (false);
}
[GtkCallback]
public void on_close_button_clicked () {
void on_close_button_clicked () {
this.application.quit ();
}
public void on_transaction_finished (bool database_modified) {
void on_transaction_finished (bool database_modified) {
if (database_modified) {
populate_updates_list ();
} else {
@ -185,12 +167,12 @@ namespace Pamac {
}
}
public void populate_updates_list () {
void populate_updates_list () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.start_get_updates ();
}
public void on_get_updates_finished (Updates updates) {
void on_get_updates_finished (Updates updates) {
top_label.set_markup ("");
repos_updates_list.clear ();
notebook.set_show_tabs (false);
@ -207,7 +189,7 @@ namespace Pamac {
string size = infos.download_size != 0 ? format_size (infos.download_size) : "";
dsize += infos.download_size;
repos_updates_nb++;
if (infos.name in transaction.special_ignorepkgs) {
if (infos.name in transaction.temporary_ignorepkgs) {
repos_updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
} else {
repos_updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
@ -216,7 +198,7 @@ namespace Pamac {
foreach (unowned PackageInfos infos in updates.aur_updates) {
string name = infos.name + " " + infos.version;
aur_updates_nb++;
if (infos.name in transaction.special_ignorepkgs) {
if (infos.name in transaction.temporary_ignorepkgs) {
aur_updates_list.insert_with_values (out iter, -1, 0, false, 1, name);
} else {
aur_updates_list.insert_with_values (out iter, -1, 0, true, 1, name);