add to possibility to change syncfirst, ignorepkg and mirrors into preferences

This commit is contained in:
guinux 2014-12-30 15:04:40 +01:00
parent 6f417e4f33
commit 430b514f37
17 changed files with 950 additions and 415 deletions

View File

@ -158,32 +158,56 @@ msgstr ""
msgid "Preferences"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Enable AUR support"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Allow Pamac to search and install packages from AUR"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Remove unrequired dependencies"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid ""
"When removing a package, also remove its dependencies that are not required "
"by other packages"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Check available disk space"
msgstr ""
#: ../resources/preferences_dialog.ui ../src/preferences_dialog.vala
msgid "How often to check for updates, value in hours"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Remove unrequired dependencies"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Upgrade first:"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Ignore upgrades for:"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Enable AUR support"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Options"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Sort mirrors by:"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Use mirrors from:"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "Official repositories"
msgstr ""
#: ../src/packages_chooser_dialog.vala
msgid "Alpm Package"
msgstr ""
@ -301,6 +325,18 @@ msgstr ""
msgid "Building packages"
msgstr ""
#: ../src/transaction.vala
msgid "Worldwide"
msgstr ""
#: ../src/transaction.vala
msgid "speed"
msgstr ""
#: ../src/transaction.vala
msgid "random"
msgstr ""
#: ../src/transaction.vala
msgid "Checking dependencies"
msgstr ""
@ -402,6 +438,21 @@ msgstr ""
msgid "Database file for %s does not exist"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "%s installed as %s.pacnew"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "%s installed as %s.pacsave"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "%s installed as %s.pacorig"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "Refreshing %s"
@ -433,6 +484,10 @@ msgstr ""
msgid "Transaction successfully finished"
msgstr ""
#: ../src/transaction.vala
msgid "Generating mirrorlist"
msgstr ""
#: ../src/installer.vala ../src/manager.vala ../src/updater.vala
msgid "Pamac is already running"
msgstr ""

View File

@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">preferences_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>

View File

@ -12,11 +12,9 @@
<file preprocess="to-pixdata">package-reinstall.png</file>
<file preprocess="to-pixdata">package-remove.png</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/preferences">
<file preprocess="xml-stripblanks">preferences_dialog.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">preferences_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>

View File

@ -3,11 +3,9 @@
<gresource prefix="/org/manjaro/pamac/updater">
<file preprocess="xml-stripblanks">updater_window.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/preferences">
<file preprocess="xml-stripblanks">preferences_dialog.ui</file>
</gresource>
<gresource prefix="/org/manjaro/pamac/transaction">
<file preprocess="xml-stripblanks">progress_dialog.ui</file>
<file preprocess="xml-stripblanks">preferences_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>

View File

@ -1,13 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="adjustment">
<property name="lower">1</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<template class="PamacPreferencesDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Preferences</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">300</property>
<property name="default_width">600</property>
<property name="default_height">250</property>
<property name="icon_name">system-software-install</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox">
<property name="can_focus">False</property>
@ -29,19 +38,21 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="close_button">
<property name="label" translatable="yes">_Close</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
@ -49,6 +60,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -56,112 +68,159 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox" id="box1">
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="enable_aur_label">
<property name="label" translatable="yes">Enable AUR support</property>
<property name="visible">True</property>
<property name="halign">1</property>
<property name="margin">6</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkSwitch" id="enable_aur_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Allow Pamac to search and install packages from AUR</property>
<property name="halign">2</property>
<property name="margin">3</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="remove_unrequired_deps_label">
<property name="label" translatable="yes">Remove unrequired dependencies</property>
<property name="visible">True</property>
<property name="halign">1</property>
<property name="margin">6</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="remove_unrequired_deps_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">When removing a package, also remove its dependencies that are not required by other packages</property>
<property name="halign">2</property>
<property name="margin">3</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="box4">
<object class="GtkSwitch" id="check_space_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="refresh_period_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">1</property>
<property name="margin">6</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Check available disk space</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="syncfirst_entry">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ignore_upgrade_entry">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="refresh_period_spin_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">2</property>
<property name="margin">3</property>
<property name="tooltip_text" translatable="yes">How often to check for updates, value in hours</property>
<property name="halign">start</property>
<property name="caps_lock_warning">False</property>
<property name="input_purpose">number</property>
<property name="adjustment">adjustment</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
<property name="value">1</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="remove_unrequired_deps_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Remove unrequired dependencies</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="check_space_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Check available disk space</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="syncfirst_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Upgrade first:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ignore_upgrade_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Ignore upgrades for:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="refresh_period_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="enable_aur_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Enable AUR support</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
@ -176,10 +235,80 @@
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkComboBoxText" id="mirrors_country_comboboxtext">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="mirrorlist_generation_method_comboboxtext">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mirrorlist_generation_method_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Sort mirrors by:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="mirrorlist_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Use mirrors from:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="tab_label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Official repositories</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
@ -189,10 +318,4 @@
<action-widget response="-7">close_button</action-widget>
</action-widgets>
</template>
<object class="GtkAdjustment" id="adjustment">
<property name="lower">1</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
</interface>

View File

@ -1,5 +1,6 @@
COMMON_VALA_FLAGS = --pkg=libalpm \
COMMON_VALA_FLAGS = --fatal-warnings \
--pkg=libalpm \
--pkg=gio-2.0 \
--pkg=posix \
--pkg=json-glib-1.0 \
@ -25,6 +26,7 @@ INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
DIALOGS_FILES = choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
preferences_dialog.vala \
progress_dialog.vala
pamac-refresh: refresh.vala
@ -32,12 +34,13 @@ pamac-refresh: refresh.vala
--pkg=gio-2.0 \
refresh.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) daemon.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala daemon.vala
valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \
--pkg=polkit-gobject-1 \
--thread \
$(COMMON_SOURCES) \
mirrors_config.vala \
daemon.vala
pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
@ -48,7 +51,7 @@ pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
$(COMMON_SOURCES) \
tray.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) choose_dep_dialog.vala preferences_dialog.vala history_dialog.vala packages_chooser_dialog.vala ../resources/manager_resources.c package.vala transaction.vala packages_model.vala manager_window.vala manager.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) choose_dep_dialog.vala history_dialog.vala packages_chooser_dialog.vala ../resources/manager_resources.c package.vala mirrors_config.vala transaction.vala packages_model.vala manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
@ -59,17 +62,17 @@ pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) choose_de
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
choose_dep_dialog.vala \
preferences_dialog.vala \
history_dialog.vala \
packages_chooser_dialog.vala \
../resources/manager_resources.c \
package.vala \
mirrors_config.vala \
transaction.vala \
packages_model.vala \
manager_window.vala \
manager.vala
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala ../resources/updater_resources.c transaction.vala updater_window.vala updater.vala
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resources/updater_resources.c mirrors_config.vala transaction.vala updater_window.vala updater.vala
valac -o pamac-updater \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
@ -78,13 +81,13 @@ pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) preferenc
--gresources=$(UPDATER_GRESOURCE_FILE) \
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
preferences_dialog.vala \
../resources/updater_resources.c \
mirrors_config.vala \
transaction.vala \
updater_window.vala \
updater.vala
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resources/installer_resources.c transaction.vala installer.vala
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resources/installer_resources.c mirrors_config.vala transaction.vala installer.vala
valac -o pamac-install \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
@ -94,6 +97,7 @@ pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) ../resour
$(COMMON_SOURCES) \
$(DIALOGS_FILES) \
../resources/installer_resources.c \
mirrors_config.vala \
transaction.vala \
installer.vala

View File

@ -40,23 +40,21 @@ namespace Alpm {
string arch;
double deltaratio;
int usesyslog;
int checkspace;
string[] cachedir;
string[] ignoregroup;
string[] ignorepkg;
string[] noextract;
string[] noupgrade;
string[] priv_holdpkg;
string[] priv_syncfirst;
public string[] holdpkg;
public string[] syncfirst;
public int checkspace;
Alpm.List<string> cachedirs;
Alpm.List<string> ignoregrps;
public string ignorepkg;
Alpm.List<string> ignorepkgs;
Alpm.List<string> noextracts;
Alpm.List<string> noupgrades;
public GLib.List<string> holdpkgs;
public GLib.List<string> syncfirsts;
public string syncfirst;
Signature.Level defaultsiglevel;
Signature.Level localfilesiglevel;
Signature.Level remotefilesiglevel;
Repo[] repo_order;
public unowned Handle? handle;
string[] priv_ignore_pkgs;
public string[] ignore_pkgs;
public Config (string path) {
conf_path = path;
@ -65,18 +63,22 @@ namespace Alpm {
}
public void reload () {
// set default options
rootdir = "/";
dbpath = "/var/lib/pacman";
gpgdir = "/etc/pacman.d/gnupg/";
logfile = "/var/log/pacman.log";
arch = Posix.utsname().machine;
cachedir = {"/var/cache/pacman/pkg/"};
priv_holdpkg = {};
priv_syncfirst = {};
ignoregroup = {};
ignorepkg = {};
noextract = {};
noupgrade = {};
holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> ();
syncfirst = "";
cachedirs = new Alpm.List<string> ();
cachedirs.add ("/var/cache/pacman/pkg/");
ignoregrps = new Alpm.List<string> ();
ignorepkgs = new Alpm.List<string> ();
ignorepkg = "";
noextracts = new Alpm.List<string> ();
noupgrades = new Alpm.List<string> ();
usesyslog = 0;
checkspace = 0;
deltaratio = 0.7;
@ -87,24 +89,6 @@ namespace Alpm {
// parse conf file
parse_file (conf_path);
get_handle ();
get_ignore_pkgs ();
}
public void get_ignore_pkgs () {
priv_ignore_pkgs = {};
unowned Group? group = null;
if (handle != null) {
foreach (string name in ignorepkg)
priv_ignore_pkgs += name;
foreach (string grp_name in ignoregroup) {
group = handle.localdb.get_group (grp_name);
if (group != null) {
foreach (unowned Package found_pkg in group.packages)
priv_ignore_pkgs += found_pkg.name;
}
}
}
ignore_pkgs = priv_ignore_pkgs;
}
public void get_handle () {
@ -126,20 +110,15 @@ namespace Alpm {
handle.defaultsiglevel = defaultsiglevel;
handle.localfilesiglevel = localfilesiglevel;
handle.remotefilesiglevel = remotefilesiglevel;
foreach (string dir in cachedir)
handle.add_cachedir (dir);
foreach (string name in ignoregroup)
handle.add_ignoregroup (name);
foreach (string name in ignorepkg)
handle.add_ignorepkg (name);
foreach (string name in noextract)
handle.add_noextract (name);
foreach (string name in noupgrade)
handle.add_noupgrade (name);
handle.cachedirs = cachedirs;
handle.ignoregroups = ignoregrps;
handle.ignorepkgs = ignorepkgs;
handle.noextracts = noextracts;
handle.noupgrades = noupgrades;
// register dbs
foreach (Repo repo in repo_order) {
foreach (var repo in repo_order) {
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (string url in repo.urls)
foreach (var url in repo.urls)
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
if (repo.usage == 0)
db.usage = DB.Usage.ALL;
@ -149,11 +128,11 @@ namespace Alpm {
}
public void parse_file (string path, string? section = null) {
string current_section = section;
string? current_section = section;
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
else {
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
} else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@ -161,21 +140,23 @@ namespace Alpm {
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
line = line.strip ();
if (line.length == 0) continue;
if (line[0] == '#') continue;
// ignore whole line and end of line comments
string[] splitted = line.split ("#", 2);
line = splitted[0].strip ();
if (line.length == 0) continue;
if (line[0] == '[' && line[line.length-1] == ']') {
current_section = line[1:-1];
if (current_section != "options") {
Repo repo = new Repo (current_section);
var repo = new Repo (current_section);
repo.siglevel = defaultsiglevel;
repo_order += repo;
}
continue;
}
string[] splitted = line.split ("=");
splitted = line.split ("=", 2);
string _key = splitted[0].strip ();
string _value = null;
string? _value = null;
if (splitted[1] != null)
_value = splitted[1].strip ();
if (_key == "Include")
@ -203,43 +184,38 @@ namespace Alpm {
else if (_key == "RemoteSigLevel")
remotefilesiglevel = merge_siglevel (defaultsiglevel, define_siglevel (remotefilesiglevel, _value));
else if (_key == "HoldPkg") {
foreach (string name in _value.split (" ")) {
priv_holdpkg += name;
}
foreach (string name in _value.split (" "))
holdpkgs.append (name);
} else if (_key == "SyncFirst") {
foreach (string name in _value.split (" ")) {
priv_syncfirst += name;
}
syncfirst = _value;
foreach (string name in _value.split (" "))
syncfirsts.append (name);
} else if (_key == "CacheDir") {
foreach (string dir in _value.split (" ")) {
cachedir += dir;
}
foreach (string dir in _value.split (" "))
cachedirs.add (dir);
} else if (_key == "IgnoreGroup") {
foreach (string name in _value.split (" ")) {
ignoregroup += name;
}
foreach (string name in _value.split (" "))
ignoregrps.add (name);
} else if (_key == "IgnorePkg") {
foreach (string name in _value.split (" ")) {
ignorepkg += name;
}
ignorepkg = _value;
foreach (string name in _value.split (" "))
ignorepkgs.add (name);
} else if (_key == "Noextract") {
foreach (string name in _value.split (" ")) {
noextract += name;
}
foreach (string name in _value.split (" "))
noextracts.add (name);
} else if (_key == "NoUpgrade") {
foreach (string name in _value.split (" ")) {
noupgrade += name;
}
foreach (string name in _value.split (" "))
noupgrades.add (name);
}
} else {
foreach (Repo _repo in repo_order) {
if (_repo.name == current_section) {
foreach (var repo in repo_order) {
if (repo.name == current_section) {
if (_key == "Server")
_repo.urls += _value;
repo.urls += _value;
else if (_key == "SigLevel")
_repo.siglevel = define_siglevel (defaultsiglevel, _value);
repo.siglevel = define_siglevel (defaultsiglevel, _value);
else if (_key == "Usage")
_repo.usage = define_usage (_value);
repo.usage = define_usage (_value);
}
}
}
@ -247,8 +223,64 @@ namespace Alpm {
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
holdpkg = priv_holdpkg;
syncfirst = priv_syncfirst;
}
}
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
string[] data = {};
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
if (line.length == 0) continue;
if (line.contains ("IgnorePkg")) {
if (new_conf.contains ("IgnorePkg")) {
string _value = new_conf.get ("IgnorePkg").get_string ();
if (_value == "")
data += "#IgnorePkg =\n";
else
data += "IgnorePkg = %s\n".printf (_value);
} else
data += line + "\n";
} else if (line.contains ("SyncFirst")) {
if (new_conf.contains ("SyncFirst")) {
string _value = new_conf.get ("SyncFirst").get_string ();
if (_value == "")
data += "#SyncFirst =\n";
else
data += "SyncFirst = %s\n".printf (_value);
} else
data += line + "\n";
} else if (line.contains ("CheckSpace")) {
if (new_conf.contains ("CheckSpace")) {
int _value = new_conf.get ("CheckSpace").get_int32 ();
if (_value == 1)
data += "CheckSpace\n";
else
data += "#CheckSpace\n";
} else
data += line + "\n";
} else
data += line + "\n";
}
// delete the file before rewrite it
file.delete ();
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
}
}

View File

@ -119,12 +119,12 @@ public unowned Alpm.Package? get_syncpkg (Alpm.Handle handle, string name) {
return pkg;
}
public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, string[] syncfirst) {
public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, GLib.List<string> syncfirsts) {
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] syncfirst_infos = {};
unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null;
foreach (var name in syncfirst) {
foreach (var name in syncfirsts) {
pkg = Alpm.find_satisfier (handle.localdb.pkgcache, name);
if (pkg != null) {
candidate = pkg.sync_newversion (handle.syncdbs);
@ -141,13 +141,13 @@ public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, string[]
return syncfirst_infos;
}
public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle, string[] ignore_pkgs) {
public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle) {
unowned Alpm.Package? candidate = null;
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] updates = {};
foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if ((local_pkg.name in ignore_pkgs) == false) {
if (handle.should_ignore (local_pkg) == 0) {
candidate = local_pkg.sync_newversion (handle.syncdbs);
if (candidate != null) {
infos.name = candidate.name;
@ -162,7 +162,7 @@ public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle, string[] igno
return updates;
}
public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle, string[] ignore_pkgs) {
public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle) {
unowned Alpm.Package? sync_pkg = null;
unowned Alpm.Package? candidate = null;
string[] local_pkgs = {};
@ -171,7 +171,7 @@ public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle, string[] ignore
// get local pkgs
foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if ((local_pkg.name in ignore_pkgs) == false) {
if (handle.should_ignore (local_pkg) == 0) {
// check updates from AUR only for local packages
foreach (var db in handle.syncdbs) {
sync_pkg = Alpm.find_satisfier (db.pkgcache, local_pkg.name);

View File

@ -46,6 +46,9 @@ namespace Pamac {
public signal void emit_refreshed (ErrorInfos error);
public signal void emit_trans_prepared (ErrorInfos error);
public signal void emit_trans_committed (ErrorInfos error);
public signal void emit_generate_mirrorlist_start ();
public signal void emit_generate_mirrorlist_data (string line);
public signal void emit_generate_mirrorlist_finished ();
public Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
@ -68,7 +71,7 @@ namespace Pamac {
previous_percent = 0;
}
public void write_config (HashTable<string,string> new_conf, GLib.BusName sender) {
public void write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
try {
Polkit.Authority authority = Polkit.Authority.get_sync (null);
@ -81,7 +84,108 @@ namespace Pamac {
null
);
if (result.get_is_authorized ()) {
pamac_config.write (new_conf);
pamac_config.write (new_pamac_conf);
}
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
}
public void write_alpm_config (HashTable<string,Variant> new_alpm_conf, GLib.BusName sender) {
try {
Polkit.Authority authority = Polkit.Authority.get_sync (null);
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
Polkit.AuthorizationResult result = authority.check_authorization_sync (
subject,
"org.manjaro.pamac.commit",
null,
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
null
);
if (result.get_is_authorized ()) {
alpm_config.write (new_alpm_conf);
}
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
}
private bool process_line (IOChannel channel, IOCondition condition, string stream_name) {
if (condition == IOCondition.HUP) {
stdout.printf ("%s: The fd has been closed.\n", stream_name);
return false;
}
try {
string line;
channel.read_line (out line, null, null);
emit_generate_mirrorlist_data (line);
} catch (IOChannelError e) {
stdout.printf ("%s: IOChannelError: %s\n", stream_name, e.message);
return false;
} catch (ConvertError e) {
stdout.printf ("%s: ConvertError: %s\n", stream_name, e.message);
return false;
}
return true;
}
private void generate_mirrorlist () {
emit_generate_mirrorlist_start ();
int standard_output;
int standard_error;
Pid child_pid;
try {
Process.spawn_async_with_pipes (null,
{"pacman-mirrors", "-g"},
null,
SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
null,
out child_pid,
null,
out standard_output,
out standard_error);
} catch (SpawnError e) {
stdout.printf ("SpawnError: %s\n", e.message);
}
// stdout:
IOChannel output = new IOChannel.unix_new (standard_output);
output.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
return process_line (channel, condition, "stdout");
});
// stderr:
IOChannel error = new IOChannel.unix_new (standard_error);
error.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
return process_line (channel, condition, "stderr");
});
ChildWatch.add (child_pid, (pid, status) => {
// Triggered when the child indicated by child_pid exits
Process.close_pid (pid);
alpm_config.reload ();
refresh_handle ();
emit_generate_mirrorlist_finished ();
});
}
public void write_mirrors_config (HashTable<string,Variant> new_mirrors_conf, GLib.BusName sender) {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
try {
Polkit.Authority authority = Polkit.Authority.get_sync (null);
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
Polkit.AuthorizationResult result = authority.check_authorization_sync (
subject,
"org.manjaro.pamac.commit",
null,
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
null
);
if (result.get_is_authorized ()) {
mirrors_config.write (new_mirrors_conf);
generate_mirrorlist ();
}
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
@ -148,13 +252,13 @@ namespace Pamac {
refresh_handle ();
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
UpdatesInfos[] updates = {};
updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirst);
updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirsts);
if (updates.length != 0) {
return updates;
} else {
updates = get_repos_updates (alpm_config.handle, alpm_config.ignore_pkgs);
updates = get_repos_updates (alpm_config.handle);
if (pamac_config.enable_aur) {
UpdatesInfos[] aur_updates = get_aur_updates (alpm_config.handle, alpm_config.ignore_pkgs);
UpdatesInfos[] aur_updates = get_aur_updates (alpm_config.handle);
foreach (var infos in aur_updates)
updates += infos;
}
@ -320,7 +424,7 @@ namespace Pamac {
// Search for holdpkg in target list
bool found_locked_pkg = false;
foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
if (pkg.name in alpm_config.holdpkg) {
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
found_locked_pkg = true;
break;

View File

@ -121,7 +121,6 @@ namespace Pamac {
//dialogs
HistoryDialog history_dialog;
PackagesChooserDialog packages_chooser_dialog;
PreferencesDialog preferences_dialog;
public ManagerWindow (Gtk.Application application) {
Object (application: application);
@ -183,7 +182,6 @@ namespace Pamac {
history_dialog = new HistoryDialog (this);
packages_chooser_dialog = new PackagesChooserDialog (this, transaction);
preferences_dialog = new PreferencesDialog (this as ApplicationWindow);
set_buttons_sensitive (false);
search_aur_button.set_active (pamac_config.enable_aur);
@ -411,7 +409,7 @@ namespace Pamac {
string reason;
if (pkg.reason == Alpm.Package.Reason.EXPLICIT)
reason = dgettext (null, "Explicitly installed");
else if (pkg.reason == Alpm.Package.Reason.EXPLICIT)
else if (pkg.reason == Alpm.Package.Reason.DEPEND)
reason = dgettext (null, "Installed as a dependency for another package");
else
reason = dgettext (null, "Unknown");
@ -562,7 +560,7 @@ namespace Pamac {
packages_list.get_value (iter, 3, out val);
string db_name = val.get_string ();
if (db_name == "local") {
if ((name in transaction.alpm_config.holdpkg) == false) {
if (transaction.alpm_config.holdpkgs.find_custom (name, strcmp) == null) {
transaction.to_remove.insert (name, name);
}
} else if (db_name == "AUR") {
@ -609,7 +607,7 @@ namespace Pamac {
void on_remove_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) {
if ((pkg.name in transaction.alpm_config.holdpkg) == false) {
if (transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) == null) {
if (pkg.repo == "local")
transaction.to_remove.insert (pkg.name, pkg.name);
}
@ -1091,38 +1089,10 @@ namespace Pamac {
[GtkCallback]
public void on_preferences_item_activate () {
bool enable_aur = pamac_config.enable_aur;
bool recurse = pamac_config.recurse;
uint64 refresh_period = pamac_config.refresh_period;
preferences_dialog.enable_aur_button.set_active (enable_aur);
preferences_dialog.remove_unrequired_deps_button.set_active (recurse);
preferences_dialog.refresh_period_spin_button.set_value (refresh_period);
int response = preferences_dialog.run ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
if (response == ResponseType.OK) {
HashTable<string,string> new_conf = new HashTable<string,string> (str_hash, str_equal);
enable_aur = preferences_dialog.enable_aur_button.get_active ();
recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
refresh_period = (uint64) preferences_dialog.refresh_period_spin_button.get_value ();
if (enable_aur != pamac_config.enable_aur) {
search_aur_button.set_active (enable_aur);
new_conf.insert ("EnableAUR", enable_aur.to_string ());
}
if (recurse != pamac_config.recurse)
new_conf.insert ("RemoveUnrequiredDeps", recurse.to_string ());
if (refresh_period != pamac_config.refresh_period)
new_conf.insert ("RefreshPeriod", refresh_period.to_string ());
if (new_conf.size () != 0) {
transaction.write_config (new_conf);
pamac_config.reload ();
bool changes = transaction.run_preferences_dialog (pamac_config);
if (changes)
search_aur_button.set_active (pamac_config.enable_aur);
}
}
preferences_dialog.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
}
[GtkCallback]
public void on_about_item_activate () {

136
src/mirrors_config.vala Normal file
View File

@ -0,0 +1,136 @@
/*
* pamac-vala
*
* Copyright (C) 2014 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 Alpm {
public class MirrorsConfig: Object {
string conf_path;
string mirrorlists_dir;
public string choosen_generation_method;
public string choosen_country;
public GLib.List<string> countrys;
public MirrorsConfig (string path) {
conf_path = path;
reload ();
}
public void reload () {
// set default options
choosen_generation_method = "rank";
choosen_country = dgettext (null, "Worldwide");
mirrorlists_dir = "/etc/pacman.d/mirrors";
parse_file (conf_path);
}
public void get_countrys () {
try {
var directory = GLib.File.new_for_path (mirrorlists_dir);
var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
FileInfo file_info;
countrys = new GLib.List<string> ();
while ((file_info = enumerator.next_file ()) != null) {
countrys.append(file_info.get_name ());
}
countrys.sort ((a, b) => {
return strcmp (a, b);
});
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
}
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
line = line.strip ();
if (line.length == 0) continue;
if (line[0] == '#') continue;
string[] splitted = line.split ("=");
string _key = splitted[0].strip ();
string _value = null;
if (splitted[1] != null)
_value = splitted[1].strip ();
if (_key == "Method")
choosen_generation_method = _value;
else if (_key == "OnlyCountry")
choosen_country = _value;
else if (_key == "MirrorlistsDir")
mirrorlists_dir = _value.replace ("\"", "");
}
} catch (Error e) {
GLib.stderr.printf("%s\n", e.message);
}
}
}
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
else {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string line;
string[] data = {};
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
if (line.contains ("Method")) {
if (new_conf.contains ("Method")) {
string _value = new_conf.get ("Method").get_string ();
data += "Method=%s\n".printf (_value);
} else
data += line + "\n";
} else if (line.contains ("OnlyCountry")) {
if (new_conf.contains ("OnlyCountry")) {
string _value = new_conf.get ("OnlyCountry").get_string ();
if (_value == dgettext (null, "Worldwide"))
data += "#%s\n".printf (line);
else
data += "OnlyCountry=%s\n".printf (_value);
} else
data += line + "\n";
} else
data += line + "\n";
}
// delete the file before rewrite it
file.delete ();
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
}
}
}
}

View File

@ -84,7 +84,7 @@ namespace Pamac {
case 1:
val = Value (typeof (Object));
if (pkg.alpm_pkg != null) {
if (pkg.name in manager_window.transaction.alpm_config.holdpkg)
if (manager_window.transaction.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null)
val.set_object (manager_window.locked_icon);
else if (pkg.repo == "local") {
if (manager_window.transaction.to_add.contains (pkg.name))

Binary file not shown.

View File

@ -20,24 +20,28 @@
namespace Pamac {
public class Config: Object {
string conf_path;
public uint64 refresh_period;
public int refresh_period;
public bool enable_aur;
public bool recurse;
public Config (string path) {
conf_path = path;
// set default options
// set default option
refresh_period = 4;
enable_aur = false;
recurse = false;
// parse conf file
parse_include_file (conf_path);
reload ();
}
public void parse_include_file (string path) {
public void reload () {
// set default options
enable_aur = false;
recurse = false;
parse_file (conf_path);
}
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
else {
try {
// Open file for reading and wrap returned FileInputStream into a
@ -55,7 +59,7 @@ namespace Pamac {
if (splitted[1] != null)
_value = splitted[1].strip ();
if (_key == "RefreshPeriod")
refresh_period = uint64.parse (_value);
refresh_period = int.parse (_value);
else if (_key == "EnableAUR")
enable_aur = true;
else if (_key == "RemoveUnrequiredDeps")
@ -67,10 +71,10 @@ namespace Pamac {
}
}
public void write (HashTable<string,string> new_conf) {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
else {
try {
// Open file for reading and wrap returned FileInputStream into a
@ -80,31 +84,29 @@ namespace Pamac {
string[] data = {};
// Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) {
if (line.length == 0) continue;
if (line.contains ("RefreshPeriod")) {
if (new_conf.contains ("RefreshPeriod")) {
string _value = new_conf.get ("RefreshPeriod");
data += "RefreshPeriod = %s\n".printf (_value);
refresh_period = uint64.parse (_value);
int _value = new_conf.get ("RefreshPeriod").get_int32 ();
data += "RefreshPeriod = %u\n".printf (_value);
} else
data += line + "\n";
} else if (line.contains ("EnableAUR")) {
if (new_conf.contains ("EnableAUR")) {
bool _value = bool.parse (new_conf.get ("EnableAUR"));
bool _value = new_conf.get ("EnableAUR").get_boolean ();
if (_value == true)
data += "EnableAUR\n";
else
data += "#EnableAUR\n";
enable_aur = _value;
} else
data += line + "\n";
} else if (line.contains ("RemoveUnrequiredDeps")) {
if (new_conf.contains ("RemoveUnrequiredDeps")) {
bool _value = bool.parse (new_conf.get ("RemoveUnrequiredDeps"));
bool _value = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
if (_value == true)
data += "RemoveUnrequiredDeps\n";
else
data += "#RemoveUnrequiredDeps\n";
enable_aur = _value;
} else
data += line + "\n";
} else
@ -123,11 +125,5 @@ namespace Pamac {
}
}
}
public void reload () {
enable_aur = false;
recurse = false;
parse_include_file (conf_path);
}
}
}

View File

@ -19,7 +19,7 @@
namespace Pamac {
[GtkTemplate (ui = "/org/manjaro/pamac/preferences/preferences_dialog.ui")]
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/preferences_dialog.ui")]
public class PreferencesDialog : Gtk.Dialog {
[GtkChild]
@ -27,11 +27,21 @@ namespace Pamac {
[GtkChild]
public Gtk.Switch remove_unrequired_deps_button;
[GtkChild]
public Gtk.Switch check_space_button;
[GtkChild]
public Gtk.Entry syncfirst_entry;
[GtkChild]
public Gtk.Entry ignore_upgrade_entry;
[GtkChild]
public Gtk.SpinButton refresh_period_spin_button;
[GtkChild]
public Gtk.Label refresh_period_label;
[GtkChild]
public Gtk.ComboBoxText mirrors_country_comboboxtext;
[GtkChild]
public Gtk.ComboBoxText mirrorlist_generation_method_comboboxtext;
public PreferencesDialog (Gtk.ApplicationWindow window) {
public PreferencesDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");

View File

@ -24,7 +24,9 @@ using Alpm;
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
public abstract void write_config (HashTable<string,string> new_conf) throws IOError;
public abstract void write_pamac_config (HashTable<string,Variant> new_pamac_conf) throws IOError;
public abstract void write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
public abstract void write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
public abstract void set_pkgreason (string pkgname, uint reason) throws IOError;
public abstract void refresh (int force, bool emit_signal) throws IOError;
public abstract ErrorInfos trans_init (TransFlag transflags) throws IOError;
@ -50,19 +52,23 @@ namespace Pamac {
public signal void emit_refreshed (ErrorInfos error);
public signal void emit_trans_prepared (ErrorInfos error);
public signal void emit_trans_committed (ErrorInfos error);
public signal void emit_generate_mirrorlist_start ();
public signal void emit_generate_mirrorlist_data (string line);
public signal void emit_generate_mirrorlist_finished ();
}
public class Transaction: Object {
public Daemon daemon;
public Alpm.Config alpm_config;
public Alpm.MirrorsConfig mirrors_config;
public Alpm.TransFlag flags;
// those hashtables will be used as set
public HashTable<string, string> to_add;
public HashTable<string, string> to_remove;
public HashTable<string, string> to_load;
public HashTable<string, string> to_build;
public HashTable<string,string> to_add;
public HashTable<string,string> to_remove;
public HashTable<string,string> to_load;
public HashTable<string,string> to_build;
public Mode mode;
@ -72,7 +78,7 @@ namespace Pamac {
string previous_textbar;
double previous_percent;
string previous_filename;
uint build_timeout_id;
uint pulse_timeout_id;
bool sysupgrade_after_trans;
bool sysupgrade_after_build;
int build_status;
@ -88,6 +94,7 @@ namespace Pamac {
TransactionSumDialog transaction_sum_dialog;
TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog;
PreferencesDialog preferences_dialog;
//parent window
ApplicationWindow? window;
@ -95,18 +102,20 @@ namespace Pamac {
public Transaction (ApplicationWindow? window) {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
mode = Mode.MANAGER;
flags = Alpm.TransFlag.CASCADE;
to_add = new HashTable<string, string> (str_hash, str_equal);
to_remove = new HashTable<string, string> (str_hash, str_equal);
to_load = new HashTable<string, string> (str_hash, str_equal);
to_build = new HashTable<string, string> (str_hash, str_equal);
to_add = new HashTable<string,string> (str_hash, str_equal);
to_remove = new HashTable<string,string> (str_hash, str_equal);
to_load = new HashTable<string,string> (str_hash, str_equal);
to_build = new HashTable<string,string> (str_hash, str_equal);
connecting_dbus_signals ();
//creating dialogs
this.window = window;
transaction_sum_dialog = new TransactionSumDialog (window);
transaction_info_dialog = new TransactionInfoDialog (window);
progress_dialog = new ProgressDialog (this, window);
preferences_dialog = new PreferencesDialog (window);
//creating terminal
term = new Terminal ();
term.scroll_on_output = false;
@ -145,9 +154,25 @@ namespace Pamac {
aur_checked = false;
}
public void write_config (HashTable<string,string> new_conf) {
public void write_pamac_config (HashTable<string,Variant> new_pamac_conf) {
try {
daemon.write_config (new_conf);
daemon.write_pamac_config (new_pamac_conf);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
public void write_alpm_config (HashTable<string,Variant> new_alpm_conf) {
try {
daemon.write_alpm_config (new_alpm_conf);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
public void write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) {
try {
daemon.write_mirrors_config (new_mirrors_conf);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@ -168,7 +193,7 @@ namespace Pamac {
public void refresh (int force) {
string action = dgettext (null, "Synchronizing package databases") + "...";
spawn_in_term ({"/usr/bin/echo", action});
spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
progress_dialog.progressbar.set_text ("");
@ -222,7 +247,7 @@ namespace Pamac {
public void sysupgrade (int enable_downgrade) {
this.enable_downgrade = enable_downgrade;
string action = dgettext (null, "Starting full system upgrade") + "...";
spawn_in_term ({"/usr/bin/echo", action});
spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
progress_dialog.progressbar.set_text ("");
@ -232,7 +257,7 @@ namespace Pamac {
Gtk.main_iteration ();
// sysupgrade
// get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirst);
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirsts);
if (syncfirst_updates.length != 0) {
clear_lists ();
if (mode == Mode.MANAGER)
@ -242,11 +267,11 @@ namespace Pamac {
// run as a standard transaction
run ();
} else {
UpdatesInfos[] repos_updates = get_repos_updates (alpm_config.handle, alpm_config.ignore_pkgs);
UpdatesInfos[] repos_updates = get_repos_updates (alpm_config.handle);
int repos_updates_len = repos_updates.length;
if (check_aur) {
if (aur_checked == false) {
aur_updates = get_aur_updates (alpm_config.handle, alpm_config.ignore_pkgs);
aur_updates = get_aur_updates (alpm_config.handle);
aur_checked = true;
}
if (aur_updates.length != 0) {
@ -277,7 +302,7 @@ namespace Pamac {
public void run () {
string action = dgettext (null,"Preparing") + "...";
spawn_in_term ({"/usr/bin/echo", action});
spawn_in_term ({"echo", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
progress_dialog.progressbar.set_text ("");
@ -504,7 +529,7 @@ namespace Pamac {
public void build_aur_packages () {
print ("building packages\n");
string action = dgettext (null,"Building packages") + "...";
spawn_in_term ({"/usr/bin/echo", "-n", action});
spawn_in_term ({"echo", "-n", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
progress_dialog.progressbar.set_text ("");
@ -513,8 +538,8 @@ namespace Pamac {
progress_dialog.expander.set_expanded (true);
progress_dialog.width_request = 700;
term.grab_focus ();
build_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
string[] cmds = {"/usr/bin/yaourt", "-S"};
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
string[] cmds = {"yaourt", "-S"};
foreach (string name in to_build.get_keys ())
cmds += name;
Pid child_pid;
@ -550,11 +575,7 @@ namespace Pamac {
public void spawn_in_term (string[] args, out Pid child_pid = null) {
Pid intern_pid;
try {
Process.spawn_async (null, args, null, SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid);
ChildWatch.add (intern_pid, (pid, status) => {
// triggered when the child indicated by intern_pid exits
Process.close_pid (pid);
});
Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH, pty.child_setup, out intern_pid);
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
@ -562,28 +583,127 @@ namespace Pamac {
term.set_pty (pty);
}
public bool run_preferences_dialog (Pamac.Config pamac_config) {
bool enable_aur = pamac_config.enable_aur;
bool recurse = pamac_config.recurse;
int refresh_period = pamac_config.refresh_period;
int checkspace = alpm_config.checkspace;
string syncfirst = alpm_config.syncfirst;
string ignorepkg = alpm_config.ignorepkg;
string choosen_generation_method = mirrors_config.choosen_generation_method;
string choosen_country = mirrors_config.choosen_country;
preferences_dialog.enable_aur_button.set_active (enable_aur);
preferences_dialog.remove_unrequired_deps_button.set_active (recurse);
preferences_dialog.refresh_period_spin_button.set_value (refresh_period);
if (checkspace == 1)
preferences_dialog.check_space_button.set_active (true);
else
preferences_dialog.check_space_button.set_active (false);
preferences_dialog.syncfirst_entry.set_text (syncfirst);
preferences_dialog.ignore_upgrade_entry.set_text (ignorepkg);
preferences_dialog.mirrors_country_comboboxtext.remove_all ();
preferences_dialog.mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
preferences_dialog.mirrors_country_comboboxtext.active = 0;
int index = 1;
mirrors_config.get_countrys ();
foreach (string country in mirrors_config.countrys) {
preferences_dialog.mirrors_country_comboboxtext.append_text (country);
if (country == choosen_country)
preferences_dialog.mirrors_country_comboboxtext.active = index;
index += 1;
}
preferences_dialog.mirrorlist_generation_method_comboboxtext.remove_all ();
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "speed"));
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "random"));
if (choosen_generation_method == "rank")
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 0;
else
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 1;
int response = preferences_dialog.run ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
if (response == ResponseType.OK) {
enable_aur = preferences_dialog.enable_aur_button.get_active ();
recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
refresh_period = preferences_dialog.refresh_period_spin_button.get_value_as_int ();
if (preferences_dialog.check_space_button.get_active () == true)
checkspace = 1;
else
checkspace = 0;
syncfirst = preferences_dialog.syncfirst_entry.get_text ();
ignorepkg = preferences_dialog.ignore_upgrade_entry.get_text ();
choosen_country = preferences_dialog.mirrors_country_comboboxtext.get_active_text ();
if (preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed"))
choosen_generation_method = "rank";
else
choosen_generation_method = "random";
if (enable_aur != pamac_config.enable_aur)
new_pamac_conf.insert ("EnableAUR", new Variant.boolean (enable_aur));
if (recurse != pamac_config.recurse)
new_pamac_conf.insert ("RemoveUnrequiredDeps", new Variant.boolean (recurse));
if (refresh_period != pamac_config.refresh_period)
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (refresh_period));
if (checkspace != alpm_config.checkspace)
new_alpm_conf.insert ("CheckSpace", new Variant.int32 (checkspace));
if (syncfirst != alpm_config.syncfirst)
new_alpm_conf.insert ("SyncFirst", new Variant.string (syncfirst));
if (ignorepkg != alpm_config.ignorepkg)
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg));
if (choosen_country != mirrors_config.choosen_country)
new_mirrors_conf.insert ("OnlyCountry", new Variant.string (choosen_country));
if (choosen_generation_method == "rank"
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "random"))
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "random")));
if (choosen_generation_method == "random"
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed"))
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "speed")));
}
bool pamac_changes = (new_pamac_conf.size () != 0);
if (pamac_changes) {
write_pamac_config (new_pamac_conf);
pamac_config.reload ();
}
bool alpm_changes = (new_alpm_conf.size () != 0);
if (alpm_changes) {
write_alpm_config (new_alpm_conf);
alpm_config.reload ();
}
bool mirrors_changes = (new_mirrors_conf.size () != 0);
if (mirrors_changes) {
write_mirrors_config (new_mirrors_conf);
mirrors_config.reload ();
}
preferences_dialog.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
return (pamac_changes || alpm_changes || mirrors_changes);
}
void on_emit_event (uint primary_event, uint secondary_event, string[] details) {
string msg;
switch (primary_event) {
case Event.Type.CHECKDEPS_START:
msg = dgettext (null, "Checking dependencies") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.FILECONFLICTS_START:
msg = dgettext (null, "Checking file conflicts") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.RESOLVEDEPS_START:
msg = dgettext (null, "Resolving dependencies") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.INTERCONFLICTS_START:
msg = dgettext (null, "Checking inter-conflicts") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.PACKAGE_OPERATION_START:
switch (secondary_event) {
@ -593,7 +713,7 @@ namespace Pamac {
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.REINSTALL:
progress_dialog.cancel_button.set_visible (false);
@ -601,7 +721,7 @@ namespace Pamac {
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.REMOVE:
progress_dialog.cancel_button.set_visible (false);
@ -609,7 +729,7 @@ namespace Pamac {
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.UPGRADE:
progress_dialog.cancel_button.set_visible (false);
@ -617,7 +737,7 @@ namespace Pamac {
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Alpm.Package.Operation.DOWNGRADE:
progress_dialog.cancel_button.set_visible (false);
@ -625,96 +745,86 @@ namespace Pamac {
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
}
break;
case Event.Type.INTEGRITY_START:
msg = dgettext (null, "Checking integrity") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.KEYRING_START:
progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Checking keyring") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.KEY_DOWNLOAD_START:
msg = dgettext (null, "Downloading required keys") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.LOAD_START:
msg = dgettext (null, "Loading packages files") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DELTA_INTEGRITY_START:
msg = dgettext (null, "Checking delta integrity") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DELTA_PATCHES_START:
msg = dgettext (null, "Applying deltas") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DELTA_PATCH_START:
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DELTA_PATCH_DONE:
msg = dgettext (null, "Generation succeeded") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DELTA_PATCH_FAILED:
msg = dgettext (null, "Generation failed") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.SCRIPTLET_INFO:
progress_dialog.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
progress_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", details[0]});
spawn_in_term ({"echo", "-n", details[0]});
break;
case Event.Type.RETRIEVE_START:
progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Downloading") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.Type.PKGDOWNLOAD_START:
string label;
if (details[0].has_suffix (".db")) {
label = dgettext (null, "Refreshing %s").printf (details[0].replace (".db", "")) + "...";
} else {
label = dgettext (null, "Downloading %s").printf (details[0].replace (".pkg.tar.xz", "")) + "...";
}
progress_dialog.action_label.set_text (label);
spawn_in_term ({"/usr/bin/echo", label});
spawn_in_term ({"echo", msg});
break;
case Event.Type.DISKSPACE_START:
msg = dgettext (null, "Checking available disk space") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
spawn_in_term ({"echo", msg});
break;
case Event.Type.OPTDEP_REMOVAL:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
spawn_in_term ({"echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
break;
case Event.Type.DATABASE_MISSING:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
spawn_in_term ({"echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
break;
case Event.Type.PACNEW_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
break;
case Event.Type.PACSAVE_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
break;
case Event.Type.PACORIG_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
break;
default:
break;
@ -760,22 +870,22 @@ namespace Pamac {
}
void on_emit_download (string filename, uint64 xfered, uint64 total) {
//~ string label;
string label;
string textbar;
double fraction;
//~ if (filename != previous_filename) {
//~ previous_filename = filename;
//~ if (filename.has_suffix (".db")) {
//~ label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
//~ } else {
//~ label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
//~ }
//~ if (label != previous_label) {
//~ previous_label = label;
//~ progress_dialog.action_label.set_text (label);
//~ spawn_in_term ({"/usr/bin/echo", label});
//~ }
//~ }
if (filename != previous_filename) {
previous_filename = filename;
if (filename.has_suffix (".db")) {
label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
} else {
label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
}
if (label != previous_label) {
previous_label = label;
progress_dialog.action_label.set_text (label);
spawn_in_term ({"echo", label});
}
}
if (total_download > 0) {
fraction = (float) (xfered + already_downloaded) / total_download;
if (fraction > 0)
@ -829,7 +939,7 @@ namespace Pamac {
}
if (line != null) {
progress_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", line});
spawn_in_term ({"echo", "-n", line});
}
}
@ -853,7 +963,7 @@ namespace Pamac {
public void handle_error (ErrorInfos error) {
progress_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", error.str});
spawn_in_term ({"echo", "-n", error.str});
TextIter start_iter;
TextIter end_iter;
transaction_info_dialog.set_title (dgettext (null, "Error"));
@ -865,16 +975,16 @@ namespace Pamac {
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
transaction_info_dialog.expander.set_visible (true);
transaction_info_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", ":"});
spawn_in_term ({"echo", ":"});
foreach (string detail in error.details) {
spawn_in_term ({"/usr/bin/echo", detail});
spawn_in_term ({"echo", detail});
string str = detail + "\n";
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
}
} else
transaction_info_dialog.expander.set_visible (false);
spawn_in_term ({"/usr/bin/echo"});
spawn_in_term ({"echo"});
transaction_info_dialog.run ();
transaction_info_dialog.hide ();
progress_dialog.hide ();
@ -895,6 +1005,8 @@ namespace Pamac {
Gtk.main_iteration ();
finished (false);
} else {
clear_lists ();
finished (false);
sysupgrade (0);
}
} else {
@ -923,7 +1035,7 @@ namespace Pamac {
ErrorInfos err = ErrorInfos ();
on_emit_trans_committed (err);
} else {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_dialog.hide ();
transaction_sum_dialog.hide ();
while (Gtk.events_pending ())
@ -943,7 +1055,7 @@ namespace Pamac {
Gtk.main_iteration ();
commit ();
} else {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
progress_dialog.hide ();
transaction_sum_dialog.hide ();
while (Gtk.events_pending ())
@ -961,7 +1073,7 @@ namespace Pamac {
} else {
//ErrorInfos err = ErrorInfos ();
//err.str = dgettext (null, "Nothing to do") + "\n";
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Nothing to do") + ".\n"});
spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"});
progress_dialog.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
@ -983,7 +1095,7 @@ namespace Pamac {
if (to_add.size () != 0
|| to_remove.size () != 0
|| to_load.size () != 0) {
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
}
build_aur_packages ();
} else {
@ -999,9 +1111,9 @@ namespace Pamac {
sysupgrade_simple (enable_downgrade);
} else {
if (build_status == 0)
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
else
spawn_in_term ({"/usr/bin/echo"});
spawn_in_term ({"echo"});
progress_dialog.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
@ -1021,13 +1133,37 @@ namespace Pamac {
}
void on_term_child_exited (int status) {
Source.remove (build_timeout_id);
Source.remove (pulse_timeout_id);
to_build.steal_all ();
build_status = status;
ErrorInfos err = ErrorInfos ();
on_emit_trans_committed (err);
}
void on_emit_generate_mirrorlist_start () {
string action = dgettext (null, "Generating mirrorlist") + "...";
spawn_in_term ({"echo", "-n", action});
progress_dialog.action_label.set_text (action);
progress_dialog.progressbar.set_fraction (0);
progress_dialog.progressbar.set_text ("");
progress_dialog.cancel_button.set_visible (false);
progress_dialog.close_button.set_visible (false);
progress_dialog.expander.set_expanded (true);
progress_dialog.width_request = 700;
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
progress_dialog.show ();
}
void on_emit_generate_mirrorlist_data (string line) {
spawn_in_term ({"echo", "-n", line});
}
void on_emit_generate_mirrorlist_finished () {
Source.remove (pulse_timeout_id);
spawn_in_term ({"echo"});
refresh (0);
}
void connecting_dbus_signals () {
try {
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
@ -1042,6 +1178,9 @@ namespace Pamac {
daemon.emit_refreshed.connect (on_emit_refreshed);
daemon.emit_trans_prepared.connect (on_emit_trans_prepared);
daemon.emit_trans_committed.connect (on_emit_trans_committed);
daemon.emit_generate_mirrorlist_start.connect (on_emit_generate_mirrorlist_start);
daemon.emit_generate_mirrorlist_data.connect (on_emit_generate_mirrorlist_data);
daemon.emit_generate_mirrorlist_finished.connect (on_emit_generate_mirrorlist_finished);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}

View File

@ -37,8 +37,6 @@ namespace Pamac {
public Pamac.Config pamac_config;
public Pamac.Transaction transaction;
PreferencesDialog preferences_dialog;
public UpdaterWindow (Gtk.Application application) {
Object (application: application);
@ -52,8 +50,6 @@ namespace Pamac {
transaction.check_aur = pamac_config.enable_aur;
transaction.finished.connect (on_emit_trans_finished);
preferences_dialog = new PreferencesDialog (this as ApplicationWindow);
bottom_label.set_visible (false);
apply_button.set_sensitive (false);
@ -62,37 +58,10 @@ namespace Pamac {
[GtkCallback]
public void on_preferences_button_clicked () {
bool enable_aur = pamac_config.enable_aur;
bool recurse = pamac_config.recurse;
uint64 refresh_period = pamac_config.refresh_period;
preferences_dialog.enable_aur_button.set_active (enable_aur);
preferences_dialog.remove_unrequired_deps_button.set_active (recurse);
preferences_dialog.refresh_period_spin_button.set_value (refresh_period);
int response = preferences_dialog.run ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
if (response == ResponseType.OK) {
HashTable<string,string> new_conf = new HashTable<string,string> (str_hash, str_equal);
enable_aur = preferences_dialog.enable_aur_button.get_active ();
recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
refresh_period = (uint64) preferences_dialog.refresh_period_spin_button.get_value ();
if (enable_aur != pamac_config.enable_aur) {
new_conf.insert ("EnableAUR", enable_aur.to_string ());
}
if (recurse != pamac_config.recurse)
new_conf.insert ("RemoveUnrequiredDeps", recurse.to_string ());
if (refresh_period != pamac_config.refresh_period)
new_conf.insert ("RefreshPeriod", refresh_period.to_string ());
if (new_conf.size () != 0) {
transaction.write_config (new_conf);
pamac_config.reload ();
bool changes = transaction.run_preferences_dialog (pamac_config);
if (changes)
set_updates_list.begin ();
}
}
preferences_dialog.hide ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
}
[GtkCallback]
public void on_apply_button_clicked () {
@ -131,7 +100,7 @@ namespace Pamac {
top_label.set_markup ("");
updates_list.clear ();
// get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.alpm_config.handle, transaction.alpm_config.syncfirst);
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.alpm_config.handle, transaction.alpm_config.syncfirsts);
if (syncfirst_updates.length != 0) {
updates_nb = syncfirst_updates.length;
foreach (UpdatesInfos infos in syncfirst_updates) {
@ -146,7 +115,7 @@ namespace Pamac {
} else {
while (Gtk.events_pending ())
Gtk.main_iteration ();
UpdatesInfos[] updates = get_repos_updates (transaction.alpm_config.handle, transaction.alpm_config.ignore_pkgs);
UpdatesInfos[] updates = get_repos_updates (transaction.alpm_config.handle);
foreach (UpdatesInfos infos in updates) {
name = infos.name + " " + infos.version;
if (infos.download_size != 0)
@ -158,7 +127,7 @@ namespace Pamac {
}
updates_nb += updates.length;
if (pamac_config.enable_aur) {
UpdatesInfos[] aur_updates = get_aur_updates (transaction.alpm_config.handle, transaction.alpm_config.ignore_pkgs);
UpdatesInfos[] aur_updates = get_aur_updates (transaction.alpm_config.handle);
updates_nb += aur_updates.length;
foreach (UpdatesInfos infos in aur_updates) {
name = infos.name + " " + infos.version;