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/*~
resources/*.c resources/*.c
src/*.c src/*.c
src/pamac.h
src/pamac.vapi
src/libpamac.so
src/pamac-daemon src/pamac-daemon
src/pamac-tray src/pamac-tray
src/pamac-manager src/pamac-manager

View File

@ -16,6 +16,9 @@ install:
cp -r po/locale /usr/share cp -r po/locale /usr/share
install -Dm744 src/pamac-daemon /usr/bin/pamac-daemon install -Dm744 src/pamac-daemon /usr/bin/pamac-daemon
install -Dm755 src/pamac-tray /usr/bin/pamac-tray 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-manager /usr/bin/pamac-manager
install -Dm755 src/pamac-updater /usr/bin/pamac-updater install -Dm755 src/pamac-updater /usr/bin/pamac-updater
install -Dm755 src/pamac-install /usr/bin/pamac-install 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/24x24/status/pamac-tray-update.png
rm -f /usr/share/icons/32x32/apps/system-software-install.png rm -f /usr/share/icons/32x32/apps/system-software-install.png
rm -f /usr/share/locale/*/LC_MESSAGES/pamac.mo 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 /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 /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 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/tray.vala
../src/manager.vala ../src/manager.vala
../src/updater.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/manager_window.vala
../src/aur_model.vala ../src/aur_model.vala
../src/packages_model.vala ../src/packages_model.vala

View File

@ -21,7 +21,7 @@ msgstr ""
msgid "Authentication is required" msgid "Authentication is required"
msgstr "" msgstr ""
#: ../src/daemon.vala ../src/manager_window.vala ../src/preferences_dialog.vala #: ../src/daemon.vala ../src/transaction.vala
msgid "Failed to initialize alpm library" msgid "Failed to initialize alpm library"
msgstr "" msgstr ""
@ -85,6 +85,16 @@ msgstr ""
msgid "Authentication failed" msgid "Authentication failed"
msgstr "" 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 #: ../src/transaction.vala
msgid "Refreshing mirrors list" msgid "Refreshing mirrors list"
msgstr "" msgstr ""
@ -287,8 +297,7 @@ msgstr[1] ""
msgid "Warning" msgid "Warning"
msgstr "" msgstr ""
#: ../src/transaction.vala ../src/installer.vala ../src/manager.vala #: ../src/transaction.vala
#: ../src/updater.vala
msgid "Error" msgid "Error"
msgstr "" msgstr ""
@ -407,6 +416,14 @@ msgstr ""
msgid "Conflicts With" msgid "Conflicts With"
msgstr "" 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 #: ../src/manager_window.vala ../resources/manager_window.ui
msgid "Repository" msgid "Repository"
msgstr "" msgstr ""
@ -455,6 +472,10 @@ msgstr ""
msgid "Backup files" msgid "Backup files"
msgstr "" msgstr ""
#: ../src/manager_window.vala
msgid "Package Base"
msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Maintainer" msgid "Maintainer"
msgstr "" msgstr ""

View File

@ -14,27 +14,26 @@ UPDATER_RESOURCES_FILES = updater_window.ui
TRANSACTION_RESOURCES_FILES = progress_dialog.ui \ TRANSACTION_RESOURCES_FILES = progress_dialog.ui \
choose_provider_dialog.ui \ choose_provider_dialog.ui \
transaction_sum_dialog.ui \ transaction_sum_dialog.ui \
transaction_info_dialog.ui transaction_info_dialog.ui \
preferences_dialog.ui \
PREFERENCES_RESOURCES_FILES = preferences_dialog.ui \
choose_ignorepkgs_dialog.ui choose_ignorepkgs_dialog.ui
TRANSACTION_GRESOURCE_FILE = pamac.transaction.gresource.xml
MANAGER_GRESOURCE_FILE = pamac.manager.gresource.xml MANAGER_GRESOURCE_FILE = pamac.manager.gresource.xml
UPDATER_GRESOURCE_FILE = pamac.updater.gresource.xml UPDATER_GRESOURCE_FILE = pamac.updater.gresource.xml
INSTALLER_GRESOURCE_FILE = pamac.installer.gresource.xml resources: transaction_resources.c manager_resources.c updater_resources.c
resources: manager_resources.c updater_resources.c installer_resources.c
clean: clean:
rm -f *.c 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 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 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-reinstall.png</file>
<file preprocess="to-pixdata">package-remove.png</file> <file preprocess="to-pixdata">package-remove.png</file>
</gresource> </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> </gresources>

View File

@ -6,4 +6,8 @@
<file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file> <file preprocess="xml-stripblanks">transaction_sum_dialog.ui</file>
<file preprocess="xml-stripblanks">transaction_info_dialog.ui</file> <file preprocess="xml-stripblanks">transaction_info_dialog.ui</file>
</gresource> </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> </gresources>

View File

@ -3,14 +3,4 @@
<gresource prefix="/org/manjaro/pamac/updater"> <gresource prefix="/org/manjaro/pamac/updater">
<file preprocess="xml-stripblanks">updater_window.ui</file> <file preprocess="xml-stripblanks">updater_window.ui</file>
</gresource> </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> </gresources>

View File

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

View File

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

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * 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/>. * 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); 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); 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); 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); 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); 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; Pamac.ManagerWindow manager_window;
// custom sort functions // 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")); 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) { 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_a = manager_window.transaction.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")); 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_a != null) {
if (pkg_b != null) { if (pkg_b != null) {
return (int) (alpm_pkg_a.origin > alpm_pkg_b.origin) - (int) (alpm_pkg_a.origin < alpm_pkg_b.origin); 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")); 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")); 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 { namespace Pamac {
public class AURModel : Object, Gtk.TreeModel { class AURModel : Object, Gtk.TreeModel {
private Json.Array pkgs_infos; private Json.Array pkgs_infos;
private GLib.List<Json.Object?> pkgs; private GLib.List<Json.Object?> pkgs;
@ -68,7 +68,7 @@ namespace Pamac {
} }
// TreeModel interface // TreeModel interface
public Type get_column_type (int index) { Type get_column_type (int index) {
switch (index) { switch (index) {
case 0: // name case 0: // name
case 2: // version 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; 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); unowned Json.Object? pkg_info = pkgs.nth_data (iter.stamp);
switch (column) { switch (column) {
case 0: case 0:
@ -100,9 +100,9 @@ namespace Pamac {
case 1: case 1:
val = Value (typeof (Object)); val = Value (typeof (Object));
if (pkg_info != null) { 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 (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); val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) { } else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon); val.set_object (manager_window.to_reinstall_icon);
@ -121,7 +121,7 @@ namespace Pamac {
case 2: case 2:
val = Value (typeof (string)); val = Value (typeof (string));
if (pkg_info != null) { 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 (pkg != null) {
val.set_string (pkg.version); val.set_string (pkg.version);
} else { } 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) { if (path.get_depth () != 1) {
return invalid_iter (out iter); return invalid_iter (out iter);
} }
@ -154,20 +154,20 @@ namespace Pamac {
return true; return true;
} }
public int get_n_columns () { int get_n_columns () {
// name, icon, version, votes // name, icon, version, votes
return 4; 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); 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; return 0;
} }
public bool iter_next (ref Gtk.TreeIter iter) { bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1; int pos = (iter.stamp) + 1;
if (pos >= pkgs.length ()) { if (pos >= pkgs.length ()) {
return false; return false;
@ -176,7 +176,7 @@ namespace Pamac {
return true; return true;
} }
public bool iter_previous (ref Gtk.TreeIter iter) { bool iter_previous (ref Gtk.TreeIter iter) {
int pos = iter.stamp; int pos = iter.stamp;
if (pos >= 0) { if (pos >= 0) {
return false; return false;
@ -185,23 +185,23 @@ namespace Pamac {
return true; 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); 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); return invalid_iter (out iter);
} }
public bool iter_has_child (Gtk.TreeIter iter) { bool iter_has_child (Gtk.TreeIter iter) {
return false; 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); return invalid_iter (out iter);
} }
private bool invalid_iter (out Gtk.TreeIter iter) { bool invalid_iter (out Gtk.TreeIter iter) {
iter = Gtk.TreeIter (); iter = Gtk.TreeIter ();
iter.stamp = -1; iter.stamp = -1;
return false; return false;

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,14 +20,12 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/choose_dep_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/manager/choose_dep_dialog.ui")]
public class ChooseDependenciesDialog : Gtk.Dialog { class ChooseDependenciesDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label label; public Gtk.Label label;
[GtkChild] [GtkChild]
public Gtk.TreeView treeview; public Gtk.TreeView treeview;
[GtkChild]
public Gtk.CellRendererToggle renderertoggle;
public Gtk.ListStore deps_list; public Gtk.ListStore deps_list;

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,14 +20,12 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/choose_ignorepkgs_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/preferences/choose_ignorepkgs_dialog.ui")]
public class ChooseIgnorepkgsDialog : Gtk.Dialog { class ChooseIgnorepkgsDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label label; public Gtk.Label label;
[GtkChild] [GtkChild]
public Gtk.TreeView treeview; public Gtk.TreeView treeview;
[GtkChild]
public Gtk.CellRendererToggle renderertoggle;
public Gtk.ListStore pkgs_list; public Gtk.ListStore pkgs_list;

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/choose_provider_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/transaction/choose_provider_dialog.ui")]
public class ChooseProviderDialog : Gtk.Dialog { class ChooseProviderDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label label; public Gtk.Label label;

View File

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

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/history_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/manager/history_dialog.ui")]
public class HistoryDialog : Gtk.Dialog { class HistoryDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.TextView textview; public Gtk.TextView textview;

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -37,13 +37,13 @@ namespace Pamac {
pamac_run = check_pamac_running (); pamac_run = check_pamac_running ();
if (pamac_run) { if (pamac_run) {
var transaction_info_dialog = new TransactionInfoDialog (null); var msg = new Gtk.MessageDialog (null,
transaction_info_dialog.set_title (dgettext (null, "Error")); Gtk.DialogFlags.MODAL,
transaction_info_dialog.label.set_visible (true); Gtk.MessageType.ERROR,
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running")); Gtk.ButtonsType.OK,
transaction_info_dialog.expander.set_visible (false); dgettext (null, "Pamac is already running"));
transaction_info_dialog.run (); msg.run ();
transaction_info_dialog.hide (); msg.destroy ();
} else { } else {
transaction = new Pamac.Transaction (null); transaction = new Pamac.Transaction (null);
transaction.finished.connect (on_transaction_finished); transaction.finished.connect (on_transaction_finished);
@ -91,7 +91,7 @@ namespace Pamac {
return run; return run;
} }
public void on_transaction_finished () { void on_transaction_finished () {
transaction.stop_daemon (); transaction.stop_daemon ();
this.release (); this.release ();
} }

View File

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

View File

@ -17,15 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
const string VERSION = "3.2.0";
namespace Pamac { namespace Pamac {
public struct SortInfo { struct SortInfo {
public int column_number; public int column_number;
public Gtk.SortType sort_type; public Gtk.SortType sort_type;
} }
[GtkTemplate (ui = "/org/manjaro/pamac/manager/manager_window.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/manager/manager_window.ui")]
public class ManagerWindow : Gtk.ApplicationWindow { class ManagerWindow : Gtk.ApplicationWindow {
// icons // icons
public Gdk.Pixbuf? installed_icon; public Gdk.Pixbuf? installed_icon;
public Gdk.Pixbuf? uninstalled_icon; public Gdk.Pixbuf? uninstalled_icon;
@ -36,7 +38,7 @@ namespace Pamac {
// manager objects // manager objects
[GtkChild] [GtkChild]
public Gtk.TreeView packages_treeview; Gtk.TreeView packages_treeview;
[GtkChild] [GtkChild]
public Gtk.TreeViewColumn packages_state_column; public Gtk.TreeViewColumn packages_state_column;
[GtkChild] [GtkChild]
@ -48,9 +50,9 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.TreeViewColumn packages_size_column; public Gtk.TreeViewColumn packages_size_column;
[GtkChild] [GtkChild]
public Gtk.TreeView aur_treeview; Gtk.TreeView aur_treeview;
[GtkChild] [GtkChild]
public Gtk.ScrolledWindow aur_scrolledwindow; Gtk.ScrolledWindow aur_scrolledwindow;
[GtkChild] [GtkChild]
public Gtk.TreeViewColumn aur_state_column; public Gtk.TreeViewColumn aur_state_column;
[GtkChild] [GtkChild]
@ -60,49 +62,45 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.TreeViewColumn aur_votes_column; public Gtk.TreeViewColumn aur_votes_column;
[GtkChild] [GtkChild]
public Gtk.Notebook filters_notebook; Gtk.Notebook filters_notebook;
[GtkChild] [GtkChild]
public Gtk.SearchEntry search_entry; Gtk.SearchEntry search_entry;
[GtkChild] [GtkChild]
public Gtk.TreeView search_treeview; Gtk.TreeView search_treeview;
[GtkChild] [GtkChild]
public Gtk.TreeView groups_treeview; Gtk.TreeView groups_treeview;
[GtkChild] [GtkChild]
public Gtk.TreeView states_treeview; Gtk.TreeView states_treeview;
[GtkChild] [GtkChild]
public Gtk.TreeView repos_treeview; Gtk.TreeView repos_treeview;
[GtkChild] [GtkChild]
public Gtk.Notebook packages_notebook; Gtk.Notebook packages_notebook;
[GtkChild] [GtkChild]
public Gtk.Notebook properties_notebook; Gtk.Notebook properties_notebook;
[GtkChild] [GtkChild]
public Gtk.TreeView deps_treeview; Gtk.TreeView deps_treeview;
[GtkChild] [GtkChild]
public Gtk.TreeView details_treeview; Gtk.TreeView details_treeview;
[GtkChild] [GtkChild]
public Gtk.ScrolledWindow deps_scrolledwindow; Gtk.ScrolledWindow files_scrolledwindow;
[GtkChild] [GtkChild]
public Gtk.ScrolledWindow details_scrolledwindow; Gtk.Label name_label;
[GtkChild] [GtkChild]
public Gtk.ScrolledWindow files_scrolledwindow; Gtk.Label desc_label;
[GtkChild] [GtkChild]
public Gtk.Label name_label; Gtk.Label link_label;
[GtkChild] [GtkChild]
public Gtk.Label desc_label; Gtk.Label licenses_label;
[GtkChild] [GtkChild]
public Gtk.Label link_label; Gtk.TextView files_textview;
[GtkChild] [GtkChild]
public Gtk.Label licenses_label; Gtk.Box search_aur_box;
[GtkChild] [GtkChild]
public Gtk.TextView files_textview; Gtk.Switch search_aur_button;
[GtkChild] [GtkChild]
public Gtk.Box search_aur_box; Gtk.Button valid_button;
[GtkChild] [GtkChild]
public Gtk.Switch search_aur_button; Gtk.Button cancel_button;
[GtkChild]
public Gtk.Button valid_button;
[GtkChild]
public Gtk.Button cancel_button;
// menu // menu
Gtk.Menu right_click_menu; Gtk.Menu right_click_menu;
@ -126,10 +124,9 @@ namespace Pamac {
PackagesModel packages_list; PackagesModel packages_list;
AURModel aur_list; AURModel aur_list;
public HashTable<string,Json.Array> aur_search_results; HashTable<string,Json.Array> aur_search_results;
public HashTable<string,Json.Object> aur_infos; string current_package_path;
string current_aur_path;
public Alpm.Config alpm_config;
public Transaction transaction; public Transaction transaction;
@ -143,7 +140,7 @@ namespace Pamac {
Timeout.add (100, populate_window); 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)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
right_click_menu = new Gtk.Menu (); right_click_menu = new Gtk.Menu ();
@ -196,13 +193,10 @@ namespace Pamac {
transaction = new Transaction (this as Gtk.ApplicationWindow); transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.MANAGER; transaction.mode = Mode.MANAGER;
transaction.finished.connect (on_transaction_finished); transaction.finished.connect (on_transaction_finished);
transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
transaction.daemon.set_pkgreason_finished.connect (display_package_properties); transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished);
alpm_config = new Alpm.Config ("/etc/pacman.conf"); unowned Alpm.Package? pkg = Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, "yaourt");
refresh_handle ();
unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
if (pkg != null) { if (pkg != null) {
support_aur (transaction.pamac_config.enable_aur, transaction.pamac_config.search_aur); support_aur (transaction.pamac_config.enable_aur, transaction.pamac_config.search_aur);
} }
@ -213,7 +207,6 @@ namespace Pamac {
sortinfo = {0, Gtk.SortType.ASCENDING}; sortinfo = {0, Gtk.SortType.ASCENDING};
aur_search_results = new HashTable<string,Json.Array> (str_hash, str_equal); aur_search_results = new HashTable<string,Json.Array> (str_hash, str_equal);
aur_infos = new HashTable<string,Json.Object> (str_hash, str_equal);
update_lists (); update_lists ();
show_default_pkgs (); show_default_pkgs ();
@ -226,13 +219,17 @@ namespace Pamac {
if (recurse) { if (recurse) {
transaction.flags |= Alpm.TransFlag.RECURSE; transaction.flags |= Alpm.TransFlag.RECURSE;
} }
unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt"); unowned Alpm.Package? pkg = Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, "yaourt");
if (pkg != null) { if (pkg != null) {
support_aur (enable_aur, search_aur); support_aur (enable_aur, search_aur);
} }
} }
public void support_aur (bool enable_aur, bool search_aur) { void on_set_pkgreason_finished () {
refresh_packages_list ();
}
void support_aur (bool enable_aur, bool search_aur) {
if (enable_aur) { if (enable_aur) {
search_aur_button.set_active (search_aur); search_aur_button.set_active (search_aur);
search_aur_box.set_visible (true); search_aur_box.set_visible (true);
@ -244,27 +241,20 @@ namespace Pamac {
} }
} }
public void set_buttons_sensitive (bool sensitive) { void set_buttons_sensitive (bool sensitive) {
valid_button.set_sensitive (sensitive); valid_button.set_sensitive (sensitive);
cancel_button.set_sensitive (sensitive); cancel_button.set_sensitive (sensitive);
} }
public void refresh_handle () { async Alpm.List<unowned Alpm.Package?> search_all_dbs (string search_string) {
alpm_config.get_handle ();
if (alpm_config.handle == null) {
stderr.printf (dgettext (null, "Failed to initialize alpm library"));
}
}
public async Alpm.List<unowned Alpm.Package?> search_all_dbs (string search_string) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> (); var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var needles = new Alpm.List<unowned string> (); var needles = new Alpm.List<unowned string> ();
string[] splitted = search_string.split (" "); string[] splitted = search_string.split (" ");
foreach (unowned string part in splitted) { foreach (unowned string part in splitted) {
needles.add (part); needles.add (part);
} }
var result = alpm_config.handle.localdb.search (needles); var result = transaction.alpm_config.handle.localdb.search (needles);
foreach (var db in alpm_config.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (syncpkgs.length == 0) { if (syncpkgs.length == 0) {
syncpkgs = db.search (needles); syncpkgs = db.search (needles);
} else { } else {
@ -276,26 +266,26 @@ namespace Pamac {
return result; return result;
} }
public async Alpm.List<unowned Alpm.Package?> get_group_pkgs (string grp_name) { async Alpm.List<unowned Alpm.Package?> get_group_pkgs (string grp_name) {
var result = new Alpm.List<unowned Alpm.Package?> (); var result = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Group? grp = alpm_config.handle.localdb.get_group (grp_name); unowned Alpm.Group? grp = transaction.alpm_config.handle.localdb.get_group (grp_name);
if (grp != null) { if (grp != null) {
foreach (var pkg in grp.packages) { foreach (var pkg in grp.packages) {
result.add (pkg); result.add (pkg);
} }
} }
result.join (Alpm.find_group_pkgs (alpm_config.handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) compare_name)); result.join (Alpm.find_group_pkgs (transaction.alpm_config.handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) compare_name));
//result.sort ((Alpm.List.CompareFunc) compare_name); //result.sort ((Alpm.List.CompareFunc) compare_name);
return result; return result;
} }
public async Alpm.List<unowned Alpm.Package?> get_installed_pkgs () { async Alpm.List<unowned Alpm.Package?> get_installed_pkgs () {
return alpm_config.handle.localdb.pkgcache.copy (); return transaction.alpm_config.handle.localdb.pkgcache.copy ();
} }
public async Alpm.List<unowned Alpm.Package?> get_orphans () { async Alpm.List<unowned Alpm.Package?> get_orphans () {
var result = new Alpm.List<unowned Alpm.Package?> (); var result = new Alpm.List<unowned Alpm.Package?> ();
foreach (var pkg in alpm_config.handle.localdb.pkgcache) { foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
if (pkg.reason == Alpm.Package.Reason.DEPEND) { if (pkg.reason == Alpm.Package.Reason.DEPEND) {
Alpm.List<string?> requiredby = pkg.compute_requiredby (); Alpm.List<string?> requiredby = pkg.compute_requiredby ();
if (requiredby.length == 0) { if (requiredby.length == 0) {
@ -311,9 +301,9 @@ namespace Pamac {
return result; return result;
} }
public async Alpm.List<unowned Alpm.Package?> get_local_pkgs () { async Alpm.List<unowned Alpm.Package?> get_local_pkgs () {
var result = new Alpm.List<unowned Alpm.Package?> (); var result = new Alpm.List<unowned Alpm.Package?> ();
foreach (var pkg in alpm_config.handle.localdb.pkgcache) { foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
if (get_sync_pkg (pkg.name) == null) { if (get_sync_pkg (pkg.name) == null) {
result.add (pkg); result.add (pkg);
} }
@ -321,12 +311,12 @@ namespace Pamac {
return result; return result;
} }
public async Alpm.List<unowned Alpm.Package?> get_repo_pkgs (string reponame) { async Alpm.List<unowned Alpm.Package?> get_repo_pkgs (string reponame) {
var result = new Alpm.List<unowned Alpm.Package?> (); var result = new Alpm.List<unowned Alpm.Package?> ();
foreach (var db in alpm_config.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (db.name == reponame) { if (db.name == reponame) {
foreach (var sync_pkg in db.pkgcache) { foreach (var sync_pkg in db.pkgcache) {
unowned Alpm.Package?local_pkg = alpm_config.handle.localdb.get_pkg (sync_pkg.name); unowned Alpm.Package?local_pkg = transaction.alpm_config.handle.localdb.get_pkg (sync_pkg.name);
if (local_pkg != null) { if (local_pkg != null) {
result.add (local_pkg); result.add (local_pkg);
} else { } else {
@ -338,11 +328,11 @@ namespace Pamac {
return result; return result;
} }
//~ public async Alpm.List<unowned Alpm.Package?> get_all_pkgs () { //~ async Alpm.List<unowned Alpm.Package?> get_all_pkgs () {
//~ var syncpkgs = new Alpm.List<unowned Alpm.Package?> (); //~ var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
//~ var result = new Alpm.List<unowned Alpm.Package?> (); //~ var result = new Alpm.List<unowned Alpm.Package?> ();
//~ result = alpm_config.handle.localdb.pkgcache.copy (); //~ result = transaction.alpm_config.handle.localdb.pkgcache.copy ();
//~ foreach (var db in alpm_config.handle.syncdbs) { //~ foreach (var db in transaction.alpm_config.handle.syncdbs) {
//~ if (syncpkgs.length == 0) //~ if (syncpkgs.length == 0)
//~ syncpkgs = db.pkgcache.copy (); //~ syncpkgs = db.pkgcache.copy ();
//~ else { //~ else {
@ -354,9 +344,9 @@ namespace Pamac {
//~ return result; //~ return result;
//~ } //~ }
public unowned Alpm.Package? get_sync_pkg (string pkgname) { unowned Alpm.Package? get_sync_pkg (string pkgname) {
unowned Alpm.Package? pkg = null; unowned Alpm.Package? pkg = null;
foreach (var db in alpm_config.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
pkg = db.get_pkg (pkgname); pkg = db.get_pkg (pkgname);
if (pkg != null) { if (pkg != null) {
break; break;
@ -365,7 +355,7 @@ namespace Pamac {
return pkg; return pkg;
} }
public void show_default_pkgs () { void show_default_pkgs () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
get_installed_pkgs.begin ((obj, res) => { get_installed_pkgs.begin ((obj, res) => {
var pkgs = get_installed_pkgs.end (res); var pkgs = get_installed_pkgs.end (res);
@ -373,13 +363,13 @@ namespace Pamac {
}); });
} }
public void update_lists () { void update_lists () {
Gtk.TreeIter iter; Gtk.TreeIter iter;
Gtk.TreeSelection selection; Gtk.TreeSelection selection;
selection = repos_treeview.get_selection (); selection = repos_treeview.get_selection ();
selection.changed.disconnect (on_repos_treeview_selection_changed); selection.changed.disconnect (on_repos_treeview_selection_changed);
var groups_names = new GLib.List<string> (); var groups_names = new GLib.List<string> ();
foreach (var db in alpm_config.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
repos_list.insert_with_values (out iter, -1, 0, db.name); repos_list.insert_with_values (out iter, -1, 0, db.name);
foreach (var group in db.groupcache) { foreach (var group in db.groupcache) {
if (groups_names.find_custom (group.name, strcmp) == null) { if (groups_names.find_custom (group.name, strcmp) == null) {
@ -394,7 +384,7 @@ namespace Pamac {
selection = groups_treeview.get_selection (); selection = groups_treeview.get_selection ();
selection.changed.disconnect (on_groups_treeview_selection_changed); selection.changed.disconnect (on_groups_treeview_selection_changed);
foreach (var group in alpm_config.handle.localdb.groupcache) { foreach (var group in transaction.alpm_config.handle.localdb.groupcache) {
if (groups_names.find_custom (group.name, strcmp) == null) { if (groups_names.find_custom (group.name, strcmp) == null) {
groups_names.append (group.name); groups_names.append (group.name);
} }
@ -419,7 +409,7 @@ namespace Pamac {
selection.changed.connect_after (on_states_treeview_selection_changed); selection.changed.connect_after (on_states_treeview_selection_changed);
} }
public void set_package_infos_list (Alpm.Package pkg) { void set_package_infos_list (Alpm.Package pkg) {
name_label.set_markup ("<big><b>%s %s</b></big>".printf (pkg.name, pkg.version)); name_label.set_markup ("<big><b>%s %s</b></big>".printf (pkg.name, pkg.version));
desc_label.set_markup (Markup.escape_text (pkg.desc)); desc_label.set_markup (Markup.escape_text (pkg.desc));
string url = Markup.escape_text (pkg.url); string url = Markup.escape_text (pkg.url);
@ -434,21 +424,13 @@ namespace Pamac {
licenses_label.set_markup (licenses.str); licenses_label.set_markup (licenses.str);
} }
public async Json.Object get_aur_infos (string aur_name) { async void set_aur_infos_list (Json.Object pkg_info) {
if (!aur_infos.contains (aur_name)) {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
Json.Array results = AUR.multiinfo ({aur_name});
aur_infos.insert (aur_name, results.get_object_element (0));
this.get_window ().set_cursor (null);
}
return aur_infos.lookup (aur_name);
}
public async void set_aur_infos_list (Json.Object pkg_info) {
unowned Json.Node? node; unowned Json.Node? node;
node = pkg_info.get_member ("Name"); node = pkg_info.get_member ("Name");
unowned string name = node.get_string (); unowned string name = node.get_string ();
Json.Object all_infos = yield get_aur_infos (name); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
Json.Object all_infos = yield transaction.get_aur_infos (name);
this.get_window ().set_cursor (null);
node = all_infos.get_member ("Version"); node = all_infos.get_member ("Version");
name_label.set_markup ("<big><b>%s %s</b></big>".printf (name, node.get_string ())); name_label.set_markup ("<big><b>%s %s</b></big>".printf (name, node.get_string ()));
node = all_infos.get_member ("Description"); node = all_infos.get_member ("Description");
@ -479,7 +461,7 @@ namespace Pamac {
licenses_label.set_markup (licenses.str); licenses_label.set_markup (licenses.str);
} }
public void set_package_deps_list (Alpm.Package pkg) { void set_package_deps_list (Alpm.Package pkg) {
deps_list.clear (); deps_list.clear ();
Gtk.TreeIter iter; Gtk.TreeIter iter;
unowned Alpm.List<unowned Alpm.Depend> deps = pkg.depends; unowned Alpm.List<unowned Alpm.Depend> deps = pkg.depends;
@ -499,7 +481,7 @@ namespace Pamac {
list = deps; list = deps;
string optdep_str = list.data.compute_string (); string optdep_str = list.data.compute_string ();
var optdep = new StringBuilder (optdep_str); var optdep = new StringBuilder (optdep_str);
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str) != null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep_str) != null) {
optdep.append (" ["); optdep.append (" [");
optdep.append (dgettext (null, "Installed")); optdep.append (dgettext (null, "Installed"));
optdep.append ("]"); optdep.append ("]");
@ -510,7 +492,7 @@ namespace Pamac {
for (list = list.next (); list != null; list = list.next ()) { for (list = list.next (); list != null; list = list.next ()) {
optdep_str = list.data.compute_string (); optdep_str = list.data.compute_string ();
optdep = new StringBuilder (optdep_str); optdep = new StringBuilder (optdep_str);
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str) != null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep_str) != null) {
optdep.append (" ["); optdep.append (" [");
optdep.append (dgettext (null, "Installed")); optdep.append (dgettext (null, "Installed"));
optdep.append ("]"); optdep.append ("]");
@ -580,12 +562,14 @@ namespace Pamac {
} }
} }
public async void set_aur_deps_list (Json.Object pkg_info) { async void set_aur_deps_list (Json.Object pkg_info) {
deps_list.clear (); deps_list.clear ();
Gtk.TreeIter iter; Gtk.TreeIter iter;
unowned Json.Node? node; unowned Json.Node? node;
node = pkg_info.get_member ("Name"); node = pkg_info.get_member ("Name");
Json.Object all_infos = yield get_aur_infos (node.get_string ()); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
Json.Object all_infos = yield transaction.get_aur_infos (node.get_string ());
this.get_window ().set_cursor (null);
unowned Json.Array deps; unowned Json.Array deps;
uint i; uint i;
uint length; uint length;
@ -636,7 +620,7 @@ namespace Pamac {
deps = node.get_array (); deps = node.get_array ();
string optdep_str = deps.get_string_element (0); string optdep_str = deps.get_string_element (0);
var optdep = new StringBuilder (optdep_str); var optdep = new StringBuilder (optdep_str);
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str) != null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep_str) != null) {
optdep.append (" ["); optdep.append (" [");
optdep.append (dgettext (null, "Installed")); optdep.append (dgettext (null, "Installed"));
optdep.append ("]"); optdep.append ("]");
@ -649,7 +633,7 @@ namespace Pamac {
while (i < length) { while (i < length) {
optdep_str = deps.get_string_element (i); optdep_str = deps.get_string_element (i);
optdep = new StringBuilder (optdep_str); optdep = new StringBuilder (optdep_str);
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep_str.split (": ", 2)[0]) != null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep_str.split (": ", 2)[0]) != null) {
optdep.append (" ["); optdep.append (" [");
optdep.append (dgettext (null, "Installed")); optdep.append (dgettext (null, "Installed"));
optdep.append ("]"); optdep.append ("]");
@ -702,7 +686,7 @@ namespace Pamac {
} }
} }
public void set_package_details_list (Alpm.Package pkg) { void set_package_details_list (Alpm.Package pkg) {
details_list.clear (); details_list.clear ();
Gtk.TreeIter iter; Gtk.TreeIter iter;
if (pkg.origin == Alpm.Package.From.SYNCDB) { if (pkg.origin == Alpm.Package.From.SYNCDB) {
@ -768,7 +752,7 @@ namespace Pamac {
} }
} }
public void set_aur_details_list (Json.Object pkg_info) { void set_aur_details_list (Json.Object pkg_info) {
details_list.clear (); details_list.clear ();
Gtk.TreeIter iter; Gtk.TreeIter iter;
unowned Json.Node? node; unowned Json.Node? node;
@ -807,7 +791,7 @@ namespace Pamac {
} }
} }
public void set_package_files_list (Alpm.Package pkg) { void set_package_files_list (Alpm.Package pkg) {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
foreach (var file in pkg.files) { foreach (var file in pkg.files) {
if (text.len != 0) { if (text.len != 0) {
@ -819,9 +803,9 @@ namespace Pamac {
files_textview.buffer.set_text (text.str, (int) text.len); files_textview.buffer.set_text (text.str, (int) text.len);
} }
public void populate_packages_list (owned Alpm.List<unowned Alpm.Package?>? pkgs) { void populate_packages_list (owned Alpm.List<unowned Alpm.Package?>? pkgs) {
packages_treeview.freeze_child_notify (); Gtk.TreeSelection selection = packages_treeview.get_selection ();
packages_treeview.set_model (null); selection.changed.disconnect (on_packages_treeview_selection_changed);
// populate liststore // populate liststore
packages_list = new PackagesModel ((owned) pkgs, this); packages_list = new PackagesModel ((owned) pkgs, this);
@ -849,14 +833,15 @@ namespace Pamac {
} }
packages_treeview.set_model (packages_list); packages_treeview.set_model (packages_list);
packages_treeview.thaw_child_notify (); selection.changed.connect (on_packages_treeview_selection_changed);
display_package_properties ();
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
} }
public void populate_aur_list (Json.Array? pkgs_infos) { void populate_aur_list (Json.Array? pkgs_infos) {
aur_treeview.freeze_child_notify (); Gtk.TreeSelection selection = aur_treeview.get_selection ();
aur_treeview.set_model (null); selection.changed.disconnect (on_aur_treeview_selection_changed);
// populate liststore // populate liststore
aur_list = new AURModel (pkgs_infos, this); aur_list = new AURModel (pkgs_infos, this);
@ -881,12 +866,13 @@ namespace Pamac {
} }
aur_treeview.set_model (aur_list); aur_treeview.set_model (aur_list);
aur_treeview.thaw_child_notify (); selection.changed.connect (on_aur_treeview_selection_changed);
display_package_properties();
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
} }
public void refresh_packages_list () { void refresh_packages_list () {
switch (filters_notebook.get_current_page ()) { switch (filters_notebook.get_current_page ()) {
case 0: case 0:
if (search_aur_button.get_active ()) { if (search_aur_button.get_active ()) {
@ -916,14 +902,33 @@ namespace Pamac {
} }
} }
public void display_package_properties () { void display_package_properties () {
switch (packages_notebook.get_current_page ()) { switch (packages_notebook.get_current_page ()) {
case 0: case 0:
Gtk.TreeSelection selection = packages_treeview.get_selection (); Gtk.TreeSelection selection = packages_treeview.get_selection ();
GLib.List<Gtk.TreePath> selected = selection.get_selected_rows (null); GLib.List<Gtk.TreePath> selected = selection.get_selected_rows (null);
if (selected.length () > 0) { unowned GLib.List<Gtk.TreePath>? first_element = selected.nth (0);
if (first_element == null) {
Gtk.TreeIter? iter;
if (current_package_path == null) {
packages_list.get_iter_first (out iter);
selection.select_iter (iter);
current_package_path = packages_list.get_path (iter).to_string ();
} else {
// check if current_package_path is valid else select first iter
if (packages_list.get_iter_from_string (out iter, current_package_path)) {
selection.select_iter (iter);
} else {
packages_list.get_iter_first (out iter);
selection.select_iter (iter);
current_package_path = packages_list.get_path (iter).to_string ();
}
}
} else {
// display info for the first package of the selection // display info for the first package of the selection
unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (selected.nth_data (0)); current_package_path = first_element.data.to_string ();
}
unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (new Gtk.TreePath.from_string (current_package_path));
if (pkg == null) { if (pkg == null) {
return; return;
} }
@ -950,19 +955,54 @@ namespace Pamac {
default: default:
break; break;
} }
}
break; break;
case 1: case 1:
Gtk.TreeSelection selection = aur_treeview.get_selection (); Gtk.TreeSelection selection = aur_treeview.get_selection ();
GLib.List<Gtk.TreePath> selected = selection.get_selected_rows (null); GLib.List<Gtk.TreePath> selected = selection.get_selected_rows (null);
if (selected.length () > 0) { unowned GLib.List<Gtk.TreePath>? first_element = selected.nth (0);
if (first_element == null) {
Gtk.TreeIter? iter;
if (current_aur_path == null) {
aur_list.get_iter_first (out iter);
selection.select_iter (iter);
current_aur_path = aur_list.get_path (iter).to_string ();
} else {
// check if current_package_path is valid else select first iter
if (aur_list.get_iter_from_string (out iter, current_aur_path)) {
selection.select_iter (iter);
} else {
aur_list.get_iter_first (out iter);
selection.select_iter (iter);
current_aur_path = aur_list.get_path (iter).to_string ();
}
}
} else {
// display info for the first package of the selection // display info for the first package of the selection
unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (selected.nth_data (0)); current_aur_path = first_element.data.to_string ();
}
unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (new Gtk.TreePath.from_string (current_aur_path));
if (pkg_info == null) { if (pkg_info == null) {
return; return;
} }
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name")); unowned Alpm.Package? pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) { if (pkg == null) {
files_scrolledwindow.visible = false;
switch (properties_notebook.get_current_page ()) {
case 0:
set_aur_infos_list.begin (pkg_info);
break;
case 1:
set_aur_deps_list.begin (pkg_info);
break;
case 2:
set_aur_details_list (pkg_info);
break;
case 3:
break;
default:
break;
}
} else {
files_scrolledwindow.visible = true; files_scrolledwindow.visible = true;
switch (properties_notebook.get_current_page ()) { switch (properties_notebook.get_current_page ()) {
case 0: case 0:
@ -980,25 +1020,6 @@ namespace Pamac {
default: default:
break; break;
} }
} else {
files_scrolledwindow.visible = false;
switch (properties_notebook.get_current_page ()) {
case 0:
set_aur_infos_list.begin (pkg_info);
break;
case 1:
set_aur_deps_list.begin (pkg_info);
break;
case 2:
set_aur_details_list (pkg_info);
break;
case 3:
break;
default:
break;
}
break;
}
} }
break; break;
default: default:
@ -1007,29 +1028,29 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_treeview_selection_changed () { void on_packages_treeview_selection_changed () {
display_package_properties (); display_package_properties ();
} }
[GtkCallback] [GtkCallback]
public void on_aur_treeview_selection_changed () { void on_aur_treeview_selection_changed () {
display_package_properties (); display_package_properties ();
} }
[GtkCallback] [GtkCallback]
public void on_properties_notebook_switch_page (Gtk.Widget page, uint page_num) { void on_properties_notebook_switch_page (Gtk.Widget page, uint page_num) {
display_package_properties (); display_package_properties ();
} }
[GtkCallback] [GtkCallback]
public void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) { void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (path); unowned Alpm.Package? pkg = packages_list.get_pkg_at_path (path);
if (pkg != null) { if (pkg != null) {
if (transaction.to_add.remove (pkg.name)) { if (transaction.to_add.remove (pkg.name)) {
} else if (transaction.to_remove.remove (pkg.name)) { } else if (transaction.to_remove.remove (pkg.name)) {
} else { } else {
if (pkg.origin == Alpm.Package.From.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) { if (transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
transaction.to_remove.add (pkg.name); transaction.to_remove.add (pkg.name);
} }
} else { } else {
@ -1047,13 +1068,13 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_aur_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) { void on_aur_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (path); unowned Json.Object? pkg_info = aur_list.get_pkg_at_path (path);
if (pkg_info != null) { if (pkg_info != null) {
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name")); unowned Alpm.Package? pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) { if (pkg != null) {
if (pkg.origin == Alpm.Package.From.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) { if (transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
transaction.to_remove.add (pkg.name); transaction.to_remove.add (pkg.name);
} }
} }
@ -1100,7 +1121,7 @@ namespace Pamac {
void on_remove_item_activate () { void on_remove_item_activate () {
foreach (var pkg in selected_pkgs) { foreach (var pkg in selected_pkgs) {
transaction.to_add.remove (pkg.name); transaction.to_add.remove (pkg.name);
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) { if (transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
if (pkg.origin == Alpm.Package.From.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
transaction.to_remove.add (pkg.name); transaction.to_remove.add (pkg.name);
} }
@ -1129,13 +1150,13 @@ namespace Pamac {
} }
} }
public void choose_opt_dep (Alpm.List<unowned Alpm.Package?> pkgs) { void choose_opt_dep (Alpm.List<unowned Alpm.Package?> pkgs) {
foreach (var pkg in pkgs) { foreach (var pkg in pkgs) {
var choose_dep_dialog = new ChooseDependenciesDialog (this); var choose_dep_dialog = new ChooseDependenciesDialog (this);
Gtk.TreeIter iter; Gtk.TreeIter iter;
int length = 0; int length = 0;
foreach (var optdep in pkg.optdepends) { foreach (var optdep in pkg.optdepends) {
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep.name) == null) {
length++; length++;
choose_dep_dialog.deps_list.insert_with_values (out iter, -1, choose_dep_dialog.deps_list.insert_with_values (out iter, -1,
0, false, 0, false,
@ -1144,7 +1165,7 @@ namespace Pamac {
} }
} }
choose_dep_dialog.label.set_markup ("<b>%s</b>".printf ( 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", ngettext ("%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", length).printf (pkg.name, length))); "%s has %u uninstalled optional dependencies.\nChoose those you would like to install", length).printf (pkg.name, length)));
if (choose_dep_dialog.run () == Gtk.ResponseType.OK) { if (choose_dep_dialog.run () == Gtk.ResponseType.OK) {
choose_dep_dialog.deps_list.foreach ((model, path, iter) => { choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
@ -1180,10 +1201,9 @@ namespace Pamac {
foreach (var pkg in selected_pkgs) { foreach (var pkg in selected_pkgs) {
transaction.start_set_pkgreason (pkg.name, Alpm.Package.Reason.EXPLICIT); transaction.start_set_pkgreason (pkg.name, Alpm.Package.Reason.EXPLICIT);
} }
refresh_packages_list ();
} }
public async void search_in_aur (string search_string) { async void search_in_aur (string search_string) {
if (!aur_search_results.contains (search_string)) { if (!aur_search_results.contains (search_string)) {
Json.Array results = AUR.search (search_string.split (" ")); Json.Array results = AUR.search (search_string.split (" "));
aur_search_results.insert (search_string, results); aur_search_results.insert (search_string, results);
@ -1191,7 +1211,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_notebook_switch_page (Gtk.Widget page, uint page_num) { void on_packages_notebook_switch_page (Gtk.Widget page, uint page_num) {
Gtk.TreeModel model; Gtk.TreeModel model;
Gtk.TreeIter? iter; Gtk.TreeIter? iter;
Gtk.TreeSelection selection = search_treeview.get_selection (); Gtk.TreeSelection selection = search_treeview.get_selection ();
@ -1219,7 +1239,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public bool on_packages_treeview_button_press_event (Gdk.EventButton event) { bool on_packages_treeview_button_press_event (Gdk.EventButton event) {
packages_treeview.grab_focus (); packages_treeview.grab_focus ();
// Check if right mouse button was clicked // Check if right mouse button was clicked
if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) { if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
@ -1269,7 +1289,7 @@ namespace Pamac {
clicked_pkg = selected_pkgs.data; clicked_pkg = selected_pkgs.data;
if (clicked_pkg.origin == Alpm.Package.From.LOCALDB) { if (clicked_pkg.origin == Alpm.Package.From.LOCALDB) {
foreach (var optdep in clicked_pkg.optdepends) { foreach (var optdep in clicked_pkg.optdepends) {
if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) { if (Alpm.find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, optdep.name) == null) {
install_optional_deps_item.set_sensitive (true); install_optional_deps_item.set_sensitive (true);
break; break;
} }
@ -1293,7 +1313,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public bool on_aur_treeview_button_press_event (Gdk.EventButton event) { bool on_aur_treeview_button_press_event (Gdk.EventButton event) {
aur_treeview.grab_focus (); aur_treeview.grab_focus ();
// Check if right mouse button was clicked // Check if right mouse button was clicked
if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) { if (event.type == Gdk.EventType.BUTTON_PRESS && event.button == 3) {
@ -1319,7 +1339,7 @@ namespace Pamac {
selected_pkgs = new Alpm.List<unowned Alpm.Package?> (); selected_pkgs = new Alpm.List<unowned Alpm.Package?> ();
selected_aur = new GLib.List<unowned Json.Object> (); selected_aur = new GLib.List<unowned Json.Object> ();
foreach (unowned Gtk.TreePath path in selected_paths) { foreach (unowned Gtk.TreePath path in selected_paths) {
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (clicked_pkg_info.get_string_member ("Name")); unowned Alpm.Package? pkg = transaction.alpm_config.handle.localdb.get_pkg (clicked_pkg_info.get_string_member ("Name"));
if (pkg != null) { if (pkg != null) {
selected_pkgs.add (pkg); selected_pkgs.add (pkg);
// there is for sure a pkg to remove // there is for sure a pkg to remove
@ -1354,7 +1374,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_name_column_clicked () { void on_packages_name_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!packages_name_column.sort_indicator) { if (!packages_name_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1371,7 +1391,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_aur_name_column_clicked () { void on_aur_name_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!aur_name_column.sort_indicator) { if (!aur_name_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1388,7 +1408,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_state_column_clicked () { void on_packages_state_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!packages_state_column.sort_indicator) { if (!packages_state_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1405,7 +1425,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_aur_state_column_clicked () { void on_aur_state_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!aur_state_column.sort_indicator) { if (!aur_state_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1422,7 +1442,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_version_column_clicked () { void on_packages_version_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!packages_version_column.sort_indicator) { if (!packages_version_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1439,7 +1459,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_aur_version_column_clicked () { void on_aur_version_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!aur_version_column.sort_indicator) { if (!aur_version_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1456,7 +1476,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_repo_column_clicked () { void on_packages_repo_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!packages_repo_column.sort_indicator) { if (!packages_repo_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1473,7 +1493,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_packages_size_column_clicked () { void on_packages_size_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!packages_size_column.sort_indicator) { if (!packages_size_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1490,7 +1510,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_aur_votes_column_clicked () { void on_aur_votes_column_clicked () {
Gtk.SortType new_order; Gtk.SortType new_order;
if (!aur_votes_column.sort_indicator) { if (!aur_votes_column.sort_indicator) {
new_order = Gtk.SortType.ASCENDING; new_order = Gtk.SortType.ASCENDING;
@ -1507,7 +1527,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_search_entry_activate () { void on_search_entry_activate () {
unowned string search_string = search_entry.get_text (); unowned string search_string = search_entry.get_text ();
if (search_string != "") { if (search_string != "") {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
@ -1540,7 +1560,6 @@ namespace Pamac {
}); });
} }
if (!found) { if (!found) {
search_list.insert_with_values (out iter, -1, 0, search_string); search_list.insert_with_values (out iter, -1, 0, search_string);
// we select the iter in search_list // we select the iter in search_list
// it will populate the list with the selection changed signal // it will populate the list with the selection changed signal
@ -1550,12 +1569,12 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_search_entry_icon_press () { void on_search_entry_icon_press () {
on_search_entry_activate (); on_search_entry_activate ();
} }
[GtkCallback] [GtkCallback]
public void on_search_treeview_selection_changed () { void on_search_treeview_selection_changed () {
Gtk.TreeModel model; Gtk.TreeModel model;
Gtk.TreeIter? iter; Gtk.TreeIter? iter;
Gtk.TreeSelection selection = search_treeview.get_selection (); Gtk.TreeSelection selection = search_treeview.get_selection ();
@ -1597,7 +1616,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_groups_treeview_selection_changed () { void on_groups_treeview_selection_changed () {
Gtk.TreeModel model; Gtk.TreeModel model;
Gtk.TreeIter? iter; Gtk.TreeIter? iter;
Gtk.TreeSelection selection = groups_treeview.get_selection (); Gtk.TreeSelection selection = groups_treeview.get_selection ();
@ -1613,7 +1632,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_states_treeview_selection_changed () { void on_states_treeview_selection_changed () {
Gtk.TreeModel model; Gtk.TreeModel model;
Gtk.TreeIter? treeiter; Gtk.TreeIter? treeiter;
Gtk.TreeSelection selection = states_treeview.get_selection (); Gtk.TreeSelection selection = states_treeview.get_selection ();
@ -1625,7 +1644,7 @@ namespace Pamac {
if (state == dgettext (null, "To install")) { if (state == dgettext (null, "To install")) {
var pkgs = new Alpm.List<unowned Alpm.Package?> (); var pkgs = new Alpm.List<unowned Alpm.Package?> ();
foreach (unowned string pkgname in transaction.to_add) { foreach (unowned string pkgname in transaction.to_add) {
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname); unowned Alpm.Package? pkg = transaction.alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg == null) { if (pkg == null) {
pkg = get_sync_pkg (pkgname); pkg = get_sync_pkg (pkgname);
} }
@ -1637,7 +1656,7 @@ namespace Pamac {
} else if (state == dgettext (null, "To remove")) { } else if (state == dgettext (null, "To remove")) {
var pkgs = new Alpm.List<unowned Alpm.Package?> (); var pkgs = new Alpm.List<unowned Alpm.Package?> ();
foreach (unowned string pkgname in transaction.to_remove) { foreach (unowned string pkgname in transaction.to_remove) {
unowned Alpm.Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname); unowned Alpm.Package? pkg = transaction.alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg != null) { if (pkg != null) {
pkgs.add (pkg); pkgs.add (pkg);
} }
@ -1663,7 +1682,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_repos_treeview_selection_changed () { void on_repos_treeview_selection_changed () {
Gtk.TreeModel model; Gtk.TreeModel model;
Gtk.TreeIter? iter; Gtk.TreeIter? iter;
Gtk.TreeSelection selection = repos_treeview.get_selection (); Gtk.TreeSelection selection = repos_treeview.get_selection ();
@ -1687,12 +1706,12 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_filters_notebook_switch_page (Gtk.Widget page, uint page_num) { void on_filters_notebook_switch_page (Gtk.Widget page, uint page_num) {
refresh_packages_list (); refresh_packages_list ();
} }
[GtkCallback] [GtkCallback]
public void on_history_item_activate () { void on_history_item_activate () {
var file = GLib.File.new_for_path ("/var/log/pamac.log"); var file = GLib.File.new_for_path ("/var/log/pamac.log");
if (!file.query_exists ()) { if (!file.query_exists ()) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ()); GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
@ -1724,7 +1743,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_local_item_activate () { void on_local_item_activate () {
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog ( 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, "_Cancel"), Gtk.ResponseType.CANCEL,
@ -1760,31 +1779,13 @@ namespace Pamac {
} }
} }
public async void run_preferences_dialog () { [GtkCallback]
SourceFunc callback = run_preferences_dialog.callback; void on_preferences_item_activate () {
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => { transaction.run_preferences_dialog.begin ();
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] [GtkCallback]
public void on_preferences_item_activate () { void on_about_item_activate () {
run_preferences_dialog.begin ();
}
[GtkCallback]
public void on_about_item_activate () {
Gtk.show_about_dialog ( Gtk.show_about_dialog (
this, this,
"program_name", "Pamac", "program_name", "Pamac",
@ -1797,13 +1798,13 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_valid_button_clicked () { void on_valid_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.run (); transaction.run ();
} }
[GtkCallback] [GtkCallback]
public void on_cancel_button_clicked () { void on_cancel_button_clicked () {
transaction.clear_lists (); transaction.clear_lists ();
set_buttons_sensitive (false); set_buttons_sensitive (false);
// force a display refresh // force a display refresh
@ -1812,15 +1813,14 @@ namespace Pamac {
} }
[GtkCallback] [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)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.start_refresh (false); transaction.start_refresh (false);
} }
public void on_transaction_finished (bool database_modified) { void on_transaction_finished (bool database_modified) {
if (database_modified) { if (database_modified) {
set_buttons_sensitive (false); set_buttons_sensitive (false);
refresh_handle ();
refresh_packages_list (); refresh_packages_list ();
} else { } else {
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace Alpm { namespace Pamac {
[Compact] [Compact]
public class MirrorsConfig: Object { public class MirrorsConfig {
public string conf_path; public string conf_path;
public string mirrorlists_dir; public string mirrorlists_dir;
public string choosen_generation_method; 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 * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
namespace Pamac { namespace Pamac {
public class PackagesModel : Object, Gtk.TreeModel { class PackagesModel : Object, Gtk.TreeModel {
private Alpm.List<unowned Alpm.Package?>? pkgs; private Alpm.List<unowned Alpm.Package?>? pkgs;
private ManagerWindow manager_window; 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; 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; unowned Alpm.Package? pkg = pkgs.nth (iter.stamp).data;
switch (column) { switch (column) {
case 0: case 0:
@ -62,7 +62,7 @@ namespace Pamac {
val = Value (typeof (Object)); val = Value (typeof (Object));
if (pkg != null) { if (pkg != null) {
if (pkg.origin == Alpm.Package.From.LOCALDB) { 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); val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) { } else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon); 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) {; bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {
if (path.get_depth () != 1) { if (path.get_depth () == 1) {
return invalid_iter (out iter);
}
iter = Gtk.TreeIter ();
int pos = path.get_indices ()[0]; 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; iter.stamp = pos;
return true; return true;
} }
}
return invalid_iter (out iter);
}
public int get_n_columns () { int get_n_columns () {
// name, icon, version, repo, isize // name, icon, version, repo, isize
return 5; return 5;
} }
public Gtk.TreePath? get_path (Gtk.TreeIter iter) { Gtk.TreePath? get_path (Gtk.TreeIter iter) {
return new Gtk.TreePath.from_indices (iter.stamp); 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; return 0;
} }
public bool iter_next (ref Gtk.TreeIter iter) { bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1; int pos = (iter.stamp) + 1;
if (pos >= pkgs.length) { if (pos >= pkgs.length) {
return false; return false;
@ -134,7 +142,7 @@ namespace Pamac {
return true; return true;
} }
public bool iter_previous (ref Gtk.TreeIter iter) { bool iter_previous (ref Gtk.TreeIter iter) {
int pos = iter.stamp; int pos = iter.stamp;
if (pos >= 0) { if (pos >= 0) {
return false; return false;
@ -143,23 +151,23 @@ namespace Pamac {
return true; 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); 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); return invalid_iter (out iter);
} }
public bool iter_has_child (Gtk.TreeIter iter) { bool iter_has_child (Gtk.TreeIter iter) {
return false; 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); return invalid_iter (out iter);
} }
private bool invalid_iter (out Gtk.TreeIter iter) { bool invalid_iter (out Gtk.TreeIter iter) {
iter = Gtk.TreeIter (); iter = Gtk.TreeIter ();
iter.stamp = -1; iter.stamp = -1;
return false; return false;
@ -167,7 +175,11 @@ namespace Pamac {
// custom get pkg function // custom get pkg function
public unowned Alpm.Package? get_pkg_at_path (Gtk.TreePath path) { 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 // custom sort functions

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
const string VERSION = "3.1.0";
namespace Pamac { namespace Pamac {
[Compact] [Compact]
public class Config { public class Config {
@ -37,7 +35,7 @@ namespace Pamac {
//get environment variables //get environment variables
environment_variables = new HashTable<string,string> (str_hash, str_equal); environment_variables = new HashTable<string,string> (str_hash, str_equal);
var utsname = Posix.utsname(); 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"); unowned string? variable = Environment.get_variable ("http_proxy");
if (variable != null) { if (variable != null) {
environment_variables.insert ("http_proxy", variable); environment_variables.insert ("http_proxy", variable);

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,61 +20,55 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/preferences_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/preferences/preferences_dialog.ui")]
public class PreferencesDialog : Gtk.Dialog { class PreferencesDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Switch remove_unrequired_deps_button; Gtk.Switch remove_unrequired_deps_button;
[GtkChild] [GtkChild]
public Gtk.Switch check_space_button; Gtk.Switch check_space_button;
[GtkChild] [GtkChild]
public Gtk.Switch check_updates_button; Gtk.Switch check_updates_button;
[GtkChild] [GtkChild]
public Gtk.Label refresh_period_label; Gtk.Label refresh_period_label;
[GtkChild] [GtkChild]
public Gtk.SpinButton refresh_period_spin_button; Gtk.SpinButton refresh_period_spin_button;
[GtkChild] [GtkChild]
public Gtk.CheckButton no_update_hide_icon_checkbutton; Gtk.CheckButton no_update_hide_icon_checkbutton;
[GtkChild] [GtkChild]
public Gtk.Box ignorepkgs_box; Gtk.Box ignorepkgs_box;
[GtkChild] [GtkChild]
public Gtk.ListStore ignorepkgs_liststore; Gtk.ListStore ignorepkgs_liststore;
[GtkChild] [GtkChild]
public Gtk.TreeView ignorepkgs_treeview; Gtk.TreeView ignorepkgs_treeview;
[GtkChild] [GtkChild]
public Gtk.Box mirrors_config_box; Gtk.Box mirrors_config_box;
[GtkChild] [GtkChild]
public Gtk.ComboBoxText mirrors_country_comboboxtext; Gtk.ComboBoxText mirrors_country_comboboxtext;
[GtkChild] [GtkChild]
public Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext; Gtk.ComboBoxText mirrors_list_generation_method_comboboxtext;
[GtkChild] [GtkChild]
public Gtk.Button generate_mirrors_list_button; Gtk.Button generate_mirrors_list_button;
[GtkChild] [GtkChild]
public Gtk.Box aur_config_box; Gtk.Box aur_config_box;
[GtkChild] [GtkChild]
public Gtk.Switch enable_aur_button; Gtk.Switch enable_aur_button;
[GtkChild] [GtkChild]
public Gtk.CheckButton search_aur_checkbutton; Gtk.CheckButton search_aur_checkbutton;
[GtkChild] [GtkChild]
public Gtk.CheckButton check_aur_updates_checkbutton; Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild] [GtkChild]
public Gtk.CheckButton no_confirm_build_checkbutton; Gtk.CheckButton no_confirm_build_checkbutton;
Transaction transaction; Transaction transaction;
Alpm.Config alpm_config;
uint64 previous_refresh_period; uint64 previous_refresh_period;
public PreferencesDialog (Gtk.ApplicationWindow? window, Transaction transaction) { public PreferencesDialog (Transaction transaction) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: transaction.application_window, use_header_bar: 0);
this.transaction = transaction; 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") +":"); 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; 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) { if (transaction.pamac_config.refresh_period == 0) {
check_updates_button.active = false; check_updates_button.active = false;
refresh_period_label.sensitive = false; refresh_period_label.sensitive = false;
@ -93,22 +87,22 @@ namespace Pamac {
// populate ignorepkgs_liststore // populate ignorepkgs_liststore
Gtk.TreeIter iter; 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); 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); 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_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); 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); 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); 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) { if (pkg == null) {
mirrors_config_box.visible = false; mirrors_config_box.visible = false;
} else { } 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.append_text (dgettext (null, "Worldwide"));
mirrors_country_comboboxtext.active = 0; mirrors_country_comboboxtext.active = 0;
int index = 1; int index = 1;
@ -129,10 +123,10 @@ namespace Pamac {
} }
mirrors_country_comboboxtext.changed.connect (on_mirrors_country_comboboxtext_changed); mirrors_country_comboboxtext.changed.connect (on_mirrors_country_comboboxtext_changed);
mirrors_list_generation_method_comboboxtext.changed.connect (on_mirrors_list_generation_method_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) { if (pkg == null) {
aur_config_box.visible = false; aur_config_box.visible = false;
} else { } else {
@ -254,9 +248,9 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_add_ignorepkgs_button_clicked () { void on_add_ignorepkgs_button_clicked () {
var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this); 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; 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); choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
} else { } else {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name); 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 // re-populate ignorepkgs_liststore
Gtk.TreeIter iter; Gtk.TreeIter iter;
ignorepkgs_liststore.clear (); ignorepkgs_liststore.clear ();
alpm_config.reload (); for (unowned Alpm.List<string> list = transaction.alpm_config.ignorepkgs; list != null; list = list.next ()) {
for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data); ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")]
public class ProgressDialog : Gtk.Dialog { class ProgressDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.ProgressBar progressbar; public Gtk.ProgressBar progressbar;
@ -63,7 +63,7 @@ namespace Pamac {
} }
[GtkCallback] [GtkCallback]
public void on_close_button_clicked () { void on_close_button_clicked () {
this.hide (); this.hide ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();

View File

@ -18,12 +18,8 @@
*/ */
namespace Pamac { namespace Pamac {
public struct ErrorInfos {
public string message;
public string[] details;
}
[DBus (name = "org.manjaro.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_refresh (bool force) throws IOError;
[DBus (no_reply = true)] [DBus (no_reply = true)]
public abstract void quit () throws IOError; public abstract void quit () throws IOError;

View File

@ -19,7 +19,7 @@
namespace Pamac { namespace Pamac {
[DBus (name = "org.manjaro.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 void set_environment_variables (HashTable<string,string> variables) throws IOError;
public abstract ErrorInfos get_current_error () throws IOError; public abstract ErrorInfos get_current_error () throws IOError;
public abstract void start_get_authorization () throws IOError; public abstract void start_get_authorization () throws IOError;
@ -74,15 +74,17 @@ namespace Pamac {
UPDATER UPDATER
} }
public enum TransactionType { public class Transaction: Object {
enum Type {
STANDARD = (1 << 0), STANDARD = (1 << 0),
UPDATE = (1 << 1), UPDATE = (1 << 1),
BUILD = (1 << 2) BUILD = (1 << 2)
} }
public class Transaction: Object { Daemon daemon;
public Daemon daemon;
public AlpmConfig alpm_config;
public Pamac.Config pamac_config; public Pamac.Config pamac_config;
public Alpm.TransFlag flags; public Alpm.TransFlag flags;
@ -91,7 +93,9 @@ namespace Pamac {
public GenericSet<string?> to_remove; public GenericSet<string?> to_remove;
public GenericSet<string?> to_load; public GenericSet<string?> to_load;
public GenericSet<string?> to_build; public GenericSet<string?> to_build;
public GenericSet<string?> special_ignorepkgs; public GenericSet<string?> temporary_ignorepkgs;
HashTable<string,Json.Object> aur_infos;
public Mode mode; public Mode mode;
@ -114,21 +118,32 @@ namespace Pamac {
TransactionInfoDialog transaction_info_dialog; TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog; ProgressDialog progress_dialog;
//parent window //parent window
Gtk.ApplicationWindow? application_window; public Gtk.ApplicationWindow? application_window;
public signal void finished (bool database_modified); 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) { public Transaction (Gtk.ApplicationWindow? application_window) {
alpm_config = new AlpmConfig ("/etc/pacman.conf");
refresh_handle ();
pamac_config = new Pamac.Config ("/etc/pamac.conf"); pamac_config = new Pamac.Config ("/etc/pamac.conf");
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
if (pamac_config.recurse) { if (pamac_config.recurse) {
flags |= Alpm.TransFlag.RECURSE; flags |= Alpm.TransFlag.RECURSE;
} }
to_add = new GenericSet<string?> (str_hash, str_equal); to_add = new GenericSet<string?> (str_hash, str_equal);
to_remove = 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_load = new GenericSet<string?> (str_hash, str_equal);
to_build = 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 (); connecting_dbus_signals ();
//creating dialogs //creating dialogs
this.application_window = application_window; this.application_window = application_window;
@ -146,6 +161,31 @@ namespace Pamac {
timer = new Timer (); 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 () { public ErrorInfos get_current_error () {
try { try {
return daemon.get_current_error (); return daemon.get_current_error ();
@ -236,6 +276,7 @@ namespace Pamac {
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
daemon.refresh_finished.disconnect (on_refresh_finished); daemon.refresh_finished.disconnect (on_refresh_finished);
refresh_handle ();
finished (true); finished (true);
} }
} }
@ -252,7 +293,7 @@ namespace Pamac {
public void add_ignorepkg (string pkgname) { public void add_ignorepkg (string pkgname) {
try { try {
daemon.add_ignorepkg (pkgname); daemon.add_ignorepkg (pkgname);
//special_ignorepkgs.add (pkgname); //temporary_ignorepkgs.add (pkgname);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
@ -267,7 +308,7 @@ namespace Pamac {
} }
public bool init (Alpm.TransFlag flags) { public bool init (Alpm.TransFlag flags) {
foreach (unowned string pkgname in special_ignorepkgs) { foreach (unowned string pkgname in temporary_ignorepkgs) {
add_ignorepkg (pkgname); add_ignorepkg (pkgname);
} }
try { 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.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (true); progress_dialog.cancel_button.set_visible (true);
bool success = init (0); bool success = init (0);
@ -328,7 +369,7 @@ namespace Pamac {
start_get_updates (); start_get_updates ();
} }
public void on_get_updates_finished (Updates updates) { void on_get_updates_finished (Updates updates) {
// get syncfirst updates // get syncfirst updates
if (updates.is_syncfirst) { if (updates.is_syncfirst) {
clear_lists (); clear_lists ();
@ -344,7 +385,7 @@ namespace Pamac {
if (updates.aur_updates.length != 0) { if (updates.aur_updates.length != 0) {
clear_lists (); clear_lists ();
foreach (unowned PackageInfos infos in updates.aur_updates) { 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); to_build.add (infos.name);
} }
} }
@ -360,6 +401,7 @@ namespace Pamac {
} }
} }
daemon.get_updates_finished.disconnect (on_get_updates_finished); daemon.get_updates_finished.disconnect (on_get_updates_finished);
get_updates_finished (updates);
} }
public void clear_lists () { public void clear_lists () {
@ -369,7 +411,7 @@ namespace Pamac {
} }
public void run () { public void run () {
string action = dgettext (null,"Preparing") + "..."; string action = dgettext (null, "Preparing") + "...";
progress_dialog.spawn_in_term ({"echo", action}); progress_dialog.spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action); progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0); 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); 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))); 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) { 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 // 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; uint64 dsize = 0;
PackageInfos[] prepared_to_add = {}; PackageInfos[] prepared_to_add = {};
PackageInfos[] prepared_to_remove = {}; PackageInfos[] prepared_to_remove = {};
@ -510,7 +552,7 @@ namespace Pamac {
int len = prepared_to_remove.length; int len = prepared_to_remove.length;
int i; int i;
if (len != 0) { if (len != 0) {
type |= TransactionType.STANDARD; type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To remove") + ":", 0, dgettext (null, "To remove") + ":",
1, "%s %s".printf (prepared_to_remove[0].name, prepared_to_remove[0].version)); 1, "%s %s".printf (prepared_to_remove[0].name, prepared_to_remove[0].version));
@ -523,7 +565,7 @@ namespace Pamac {
} }
len = to_downgrade.length; len = to_downgrade.length;
if (len != 0) { if (len != 0) {
type |= TransactionType.STANDARD; type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To downgrade") + ":", 0, dgettext (null, "To downgrade") + ":",
1, to_downgrade[0]); 1, to_downgrade[0]);
@ -536,7 +578,7 @@ namespace Pamac {
} }
len = _to_build.length; len = _to_build.length;
if (len != 0) { if (len != 0) {
type |= TransactionType.BUILD; type |= Type.BUILD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To build") + ":", 0, dgettext (null, "To build") + ":",
1, _to_build[0]); 1, _to_build[0]);
@ -549,7 +591,7 @@ namespace Pamac {
} }
len = to_install.length; len = to_install.length;
if (len != 0) { if (len != 0) {
type |= TransactionType.STANDARD; type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To install") + ":", 0, dgettext (null, "To install") + ":",
1, to_install[0]); 1, to_install[0]);
@ -562,7 +604,7 @@ namespace Pamac {
} }
len = to_reinstall.length; len = to_reinstall.length;
if (len != 0) { if (len != 0) {
type |= TransactionType.STANDARD; type |= Type.STANDARD;
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To reinstall") + ":", 0, dgettext (null, "To reinstall") + ":",
1, to_reinstall[0]); 1, to_reinstall[0]);
@ -575,7 +617,7 @@ namespace Pamac {
} }
len = to_update.length; len = to_update.length;
if (len != 0) { if (len != 0) {
type |= TransactionType.UPDATE; type |= Type.UPDATE;
if (mode != Mode.UPDATER) { if (mode != Mode.UPDATER) {
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1, transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
0, dgettext (null, "To update") + ":", 0, dgettext (null, "To update") + ":",
@ -603,12 +645,13 @@ namespace Pamac {
daemon.start_trans_commit (); daemon.start_trans_commit ();
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
refresh_handle ();
finished (true); finished (true);
} }
} }
public void build_aur_packages () { 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.spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action); progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0); progress_dialog.progressbar.set_fraction (0);
@ -632,6 +675,14 @@ namespace Pamac {
progress_dialog.term.watch_child (child_pid); 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 () { public void cancel () {
try { try {
daemon.trans_cancel (); daemon.trans_cancel ();
@ -652,7 +703,7 @@ namespace Pamac {
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
foreach (unowned string pkgname in special_ignorepkgs) { foreach (unowned string pkgname in temporary_ignorepkgs) {
remove_ignorepkg (pkgname); remove_ignorepkg (pkgname);
} }
} }
@ -1037,7 +1088,7 @@ namespace Pamac {
} }
} }
public void show_warnings () { void show_warnings () {
if (transaction_info_dialog.textbuffer.text != "") { if (transaction_info_dialog.textbuffer.text != "") {
transaction_info_dialog.set_title (dgettext (null, "Warning")); transaction_info_dialog.set_title (dgettext (null, "Warning"));
transaction_info_dialog.label.set_visible (false); 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 != "") { if (error.message != null && error.message != "") {
progress_dialog.expander.set_expanded (true); progress_dialog.expander.set_expanded (true);
progress_dialog.spawn_in_term ({"echo", "-n", error.message}); 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 (success) {
if (mode == Mode.UPDATER) { if (mode == Mode.UPDATER) {
finished (true); finished (true);
@ -1117,7 +1169,7 @@ namespace Pamac {
daemon.refresh_finished.disconnect (on_refresh_finished); daemon.refresh_finished.disconnect (on_refresh_finished);
} }
public void on_cancel_button_clicked () { void on_cancel_button_clicked () {
cancel (); cancel ();
clear_lists (); clear_lists ();
progress_dialog.spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"}); 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) { if (success) {
show_warnings (); show_warnings ();
TransactionType type = set_transaction_sum (); Type type = set_transaction_sum ();
if (type == TransactionType.UPDATE && mode == Mode.UPDATER) { if (type == Type.UPDATE && mode == Mode.UPDATER) {
// there only updates // there only updates
start_commit (); start_commit ();
} else if (type != 0) { } else if (type != 0) {
@ -1140,7 +1192,7 @@ namespace Pamac {
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
if (type == TransactionType.BUILD) { if (type == Type.BUILD) {
// there only AUR packages to build // there only AUR packages to build
release (); release ();
on_trans_commit_finished (true); 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 (success) {
if (to_build.length != 0) { if (to_build.length != 0) {
if (to_add.length != 0 if (to_add.length != 0
@ -1194,6 +1246,7 @@ namespace Pamac {
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
sysupgrade (false); sysupgrade (false);
} else { } else {
refresh_handle ();
finished (true); finished (true);
progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"}); progress_dialog.spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
if (progress_dialog.expander.get_expanded ()) { if (progress_dialog.expander.get_expanded ()) {
@ -1215,6 +1268,7 @@ namespace Pamac {
finished (false); finished (false);
} else { } else {
clear_lists (); clear_lists ();
refresh_handle ();
finished (true); finished (true);
} }
handle_error (err); handle_error (err);
@ -1229,6 +1283,7 @@ namespace Pamac {
clear_lists (); clear_lists ();
// let the time to the daemon to update databases // let the time to the daemon to update databases
Timeout.add (1000, () => { Timeout.add (1000, () => {
refresh_handle ();
finished (true); finished (true);
if (status == 0) { if (status == 0) {
string action = dgettext (null, "Transaction successfully finished"); 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 (); 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) { void on_generate_mirrors_list_data (string line) {
@ -1276,6 +1350,9 @@ namespace Pamac {
daemon.emit_log.connect (on_emit_log); daemon.emit_log.connect (on_emit_log);
daemon.trans_prepare_finished.connect (on_trans_prepare_finished); daemon.trans_prepare_finished.connect (on_trans_prepare_finished);
daemon.trans_commit_finished.connect (on_trans_commit_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.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_data.connect (on_generate_mirrors_list_data);
daemon.generate_mirrors_list_finished.connect (on_generate_mirrors_list_finished); daemon.generate_mirrors_list_finished.connect (on_generate_mirrors_list_finished);

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,14 +20,14 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_info_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_info_dialog.ui")]
public class TransactionInfoDialog : Gtk.Dialog { class TransactionInfoDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label label; public Gtk.Label label;
[GtkChild] [GtkChild]
public Gtk.Expander expander; public Gtk.Expander expander;
[GtkChild] [GtkChild]
public Gtk.TextView textview; Gtk.TextView textview;
public Gtk.TextBuffer textbuffer; public Gtk.TextBuffer textbuffer;

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -20,14 +20,14 @@
namespace Pamac { namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_sum_dialog.ui")] [GtkTemplate (ui = "/org/manjaro/pamac/transaction/transaction_sum_dialog.ui")]
public class TransactionSumDialog : Gtk.Dialog { class TransactionSumDialog : Gtk.Dialog {
[GtkChild] [GtkChild]
public Gtk.Label top_label; public Gtk.Label top_label;
[GtkChild] [GtkChild]
public Gtk.Label bottom_label; public Gtk.Label bottom_label;
[GtkChild] [GtkChild]
public Gtk.TreeView treeview; Gtk.TreeView treeview;
public Gtk.ListStore sum_list; public Gtk.ListStore sum_list;

View File

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

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
namespace Pamac { namespace Pamac {
public class Updater : Gtk.Application { class Updater : Gtk.Application {
UpdaterWindow updater_window; UpdaterWindow updater_window;
bool pamac_run; bool pamac_run;
@ -37,13 +37,13 @@ namespace Pamac {
pamac_run = check_pamac_running (); pamac_run = check_pamac_running ();
if (pamac_run) { if (pamac_run) {
var transaction_info_dialog = new TransactionInfoDialog (null); var msg = new Gtk.MessageDialog (null,
transaction_info_dialog.set_title (dgettext (null, "Error")); Gtk.DialogFlags.MODAL,
transaction_info_dialog.label.set_visible (true); Gtk.MessageType.ERROR,
transaction_info_dialog.label.set_markup (dgettext (null, "Pamac is already running")); Gtk.ButtonsType.OK,
transaction_info_dialog.expander.set_visible (false); dgettext (null, "Pamac is already running"));
transaction_info_dialog.run (); msg.run ();
transaction_info_dialog.hide (); msg.destroy ();
} else { } else {
updater_window = new UpdaterWindow (this); 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 (); var updater = new Updater ();
return updater.run (args); return updater.run (args);
} }

View File

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