possibility to ignore some updates in pamac-updater, do not close progress window when yaourt failed and other improvements

This commit is contained in:
guinux 2015-04-11 18:00:49 +02:00
parent 65e5756807
commit 22af5edc77
18 changed files with 403 additions and 374 deletions

View File

@ -2,7 +2,6 @@
MANAGER_GRESOURCE_FILE = pamac.manager.gresource.xml MANAGER_GRESOURCE_FILE = pamac.manager.gresource.xml
MANAGER_RESOURCES_FILES = manager_window.ui \ MANAGER_RESOURCES_FILES = manager_window.ui \
packages_chooser_dialog.ui \
choose_dep_dialog.ui \ choose_dep_dialog.ui \
history_dialog.ui \ history_dialog.ui \
preferences_dialog.ui \ preferences_dialog.ui \

View File

@ -52,7 +52,6 @@
<property name="pixels_below_lines">2</property> <property name="pixels_below_lines">2</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="cursor_visible">False</property> <property name="cursor_visible">False</property>
<signal name="size-allocate" handler="on_textview_size_allocate" swapped="no"/>
</object> </object>
</child> </child>
</object> </object>

View File

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.12"/>
<template class="PamacPackagesChooserDialog" parent="GtkFileChooserDialog">
<property name="border_width">6</property>
<property name="title" translatable="yes">Install local packages</property>
<property name="role">GtkFileChooserDialog</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">900</property>
<property name="icon_name">system-software-install</property>
<property name="type_hint">dialog</property>
<property name="create_folders">False</property>
<property name="local_only">False</property>
<property name="select_multiple">True</property>
<signal name="file-activated" handler="on_file_activated" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="filechooserdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="filechooserdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="package_cancel_button">
<property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="package_open_button">
<property name="label" translatable="yes">_Open</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">package_cancel_button</action-widget>
<action-widget response="-3">package_open_button</action-widget>
</action-widgets>
</template>
</interface>

View File

@ -3,7 +3,6 @@
<gresource prefix="/org/manjaro/pamac/manager"> <gresource prefix="/org/manjaro/pamac/manager">
<file preprocess="xml-stripblanks">manager_window.ui</file> <file preprocess="xml-stripblanks">manager_window.ui</file>
<file preprocess="xml-stripblanks">history_dialog.ui</file> <file preprocess="xml-stripblanks">history_dialog.ui</file>
<file preprocess="xml-stripblanks">packages_chooser_dialog.ui</file>
<file preprocess="xml-stripblanks">choose_dep_dialog.ui</file> <file preprocess="xml-stripblanks">choose_dep_dialog.ui</file>
<file preprocess="to-pixdata">package-available.png</file> <file preprocess="to-pixdata">package-available.png</file>
<file preprocess="to-pixdata">package-install.png</file> <file preprocess="to-pixdata">package-install.png</file>

View File

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.12"/>
<template class="PamacUpdaterWindow" parent="GtkApplicationWindow"> <template class="PamacUpdaterWindow" parent="GtkApplicationWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Update Manager</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes">Update Manager</property>
<property name="window_position">center</property> <property name="window_position">center</property>
<property name="default_width">500</property> <property name="default_width">500</property>
<property name="icon_name">system-software-update</property> <property name="icon_name">system-software-update</property>
<property name="show_menubar">True</property>
<child> <child>
<object class="GtkBox" id="box1"> <object class="GtkBox" id="box1">
<property name="visible">True</property> <property name="visible">True</property>
@ -25,6 +26,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -48,16 +50,28 @@
<property name="mode">none</property> <property name="mode">none</property>
</object> </object>
</child> </child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<child>
<object class="GtkCellRendererToggle" id="select_update">
<signal name="toggled" handler="on_select_update_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child> <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1"> <object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="expand">True</property> <property name="expand">True</property>
<child> <child>
<object class="GtkCellRendererText" id="_name"> <object class="GtkCellRendererText" id="update_name">
<property name="width">200</property> <property name="width">200</property>
<property name="height">22</property> <property name="height">22</property>
</object> </object>
<attributes> <attributes>
<attribute name="text">0</attribute> <attribute name="text">1</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
@ -65,12 +79,12 @@
<child> <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2"> <object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child> <child>
<object class="GtkCellRendererText" id="_size"> <object class="GtkCellRendererText" id="download_size">
<property name="width">80</property> <property name="width">80</property>
<property name="height">22</property> <property name="height">22</property>
</object> </object>
<attributes> <attributes>
<attribute name="text">1</attribute> <attribute name="text">2</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
@ -81,6 +95,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -91,6 +106,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -108,18 +124,21 @@
<property name="label" translatable="yes">_Preferences</property> <property name="label" translatable="yes">_Preferences</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_preferences_button_clicked" swapped="no"/> <signal name="clicked" handler="on_preferences_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -133,12 +152,14 @@
<property name="label" translatable="yes">_Refresh</property> <property name="label" translatable="yes">_Refresh</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_refresh_button_clicked" swapped="no"/> <signal name="clicked" handler="on_refresh_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -147,12 +168,14 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_focus">True</property> <property name="has_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_apply_button_clicked" swapped="no"/> <signal name="clicked" handler="on_apply_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -160,12 +183,14 @@
<property name="label" translatable="yes">_Close</property> <property name="label" translatable="yes">_Close</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_close_button_clicked" swapped="no"/> <signal name="clicked" handler="on_close_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -173,12 +198,14 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="pack_type">end</property> <property name="pack_type">end</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -74,7 +74,7 @@ pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCE
alpm_utils.vala \ alpm_utils.vala \
daemon.vala daemon.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) choose_dep_dialog.vala history_dialog.vala packages_chooser_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala
valac -o pamac-manager \ valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \ $(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \ $(TRANSACTION_VALA_FLAGS) \
@ -83,7 +83,6 @@ pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) cho
$(TRANSACTION_SOURCES) \ $(TRANSACTION_SOURCES) \
choose_dep_dialog.vala \ choose_dep_dialog.vala \
history_dialog.vala \ history_dialog.vala \
packages_chooser_dialog.vala \
../resources/manager_resources.c \ ../resources/manager_resources.c \
packages_model.vala \ packages_model.vala \
manager_window.vala \ manager_window.vala \

View File

@ -95,7 +95,6 @@ namespace Alpm {
repo_order = {}; repo_order = {};
// parse conf file // parse conf file
parse_file (conf_path); parse_file (conf_path);
get_handle ();
} }
public void get_handle () { public void get_handle () {

View File

@ -114,6 +114,9 @@ namespace AUR {
public Json.Array multiinfo (string[] pkgnames) { public Json.Array multiinfo (string[] pkgnames) {
Json.Array results = new Json.Array (); Json.Array results = new Json.Array ();
if (pkgnames.length == 0) {
return results;
}
var builder = new StringBuilder (); var builder = new StringBuilder ();
builder.append (rpc_url); builder.append (rpc_url);
builder.append (rpc_multiinfo); builder.append (rpc_multiinfo);

View File

@ -46,8 +46,7 @@ namespace Pamac {
if (deps_list.get_iter_from_string (out iter, path)) {; if (deps_list.get_iter_from_string (out iter, path)) {;
deps_list.get_value (iter, 0, out val); deps_list.get_value (iter, 0, out val);
selected = val.get_boolean (); selected = val.get_boolean ();
selected = (!selected); deps_list.set_value (iter, 0, !selected);
deps_list.set_value (iter, 0, selected);
} }
} }
} }

View File

@ -106,7 +106,7 @@ namespace Pamac {
public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) { public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf, GLib.BusName sender) {
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
try { try {
Polkit.Authority authority = Polkit.Authority.get_sync (null); Polkit.Authority authority = Polkit.Authority.get_sync ();
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
authority.check_authorization.begin ( authority.check_authorization.begin (
subject, subject,
@ -120,21 +120,23 @@ namespace Pamac {
if (result.get_is_authorized ()) { if (result.get_is_authorized ()) {
pamac_config.write (new_pamac_conf); pamac_config.write (new_pamac_conf);
pamac_config.reload (); pamac_config.reload ();
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, pamac_config.recurse);
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} finally {
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, pamac_config.recurse);
} }
} }
); );
} catch (GLib.Error e) { } catch (GLib.Error e) {
write_pamac_config_finished (pamac_config.refresh_period, pamac_config.enable_aur, pamac_config.recurse);
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
} }
public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf, GLib.BusName sender) { public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf, GLib.BusName sender) {
try { try {
Polkit.Authority authority = Polkit.Authority.get_sync (null); Polkit.Authority authority = Polkit.Authority.get_sync ();
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
authority.check_authorization.begin ( authority.check_authorization.begin (
subject, subject,
@ -148,14 +150,17 @@ namespace Pamac {
if (result.get_is_authorized ()) { if (result.get_is_authorized ()) {
alpm_config.write (new_alpm_conf); alpm_config.write (new_alpm_conf);
alpm_config.reload (); alpm_config.reload ();
write_alpm_config_finished (); refresh_handle ();
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} finally {
write_alpm_config_finished ();
} }
} }
); );
} catch (GLib.Error e) { } catch (GLib.Error e) {
write_alpm_config_finished ();
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
} }
@ -193,15 +198,12 @@ namespace Pamac {
null, null,
out standard_output, out standard_output,
out standard_error); out standard_error);
} catch (SpawnError e) { // stdout
stdout.printf ("SpawnError: %s\n", e.message);
}
// stdout:
IOChannel output = new IOChannel.unix_new (standard_output); IOChannel output = new IOChannel.unix_new (standard_output);
output.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => { output.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
return process_line (channel, condition, "stdout"); return process_line (channel, condition, "stdout");
}); });
// stderr: // stderr
IOChannel error = new IOChannel.unix_new (standard_error); IOChannel error = new IOChannel.unix_new (standard_error);
error.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => { error.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
return process_line (channel, condition, "stderr"); return process_line (channel, condition, "stderr");
@ -213,12 +215,16 @@ namespace Pamac {
refresh_handle (); refresh_handle ();
generate_mirrorlist_finished (); generate_mirrorlist_finished ();
}); });
} catch (SpawnError e) {
generate_mirrorlist_finished ();
stdout.printf ("SpawnError: %s\n", e.message);
}
} }
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 Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
try { try {
Polkit.Authority authority = Polkit.Authority.get_sync (null); Polkit.Authority authority = Polkit.Authority.get_sync ();
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
authority.check_authorization.begin ( authority.check_authorization.begin (
subject, subject,
@ -231,22 +237,24 @@ namespace Pamac {
var result = authority.check_authorization.end (res); var result = authority.check_authorization.end (res);
if (result.get_is_authorized ()) { if (result.get_is_authorized ()) {
mirrors_config.write (new_mirrors_conf); mirrors_config.write (new_mirrors_conf);
write_mirrors_config_finished ();
generate_mirrorlist (); generate_mirrorlist ();
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} finally {
write_mirrors_config_finished ();
} }
} }
); );
} catch (GLib.Error e) { } catch (GLib.Error e) {
write_mirrors_config_finished ();
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
} }
public void start_set_pkgreason (string pkgname, uint reason, GLib.BusName sender) { public void start_set_pkgreason (string pkgname, uint reason, GLib.BusName sender) {
try { try {
Polkit.Authority authority = Polkit.Authority.get_sync (null); Polkit.Authority authority = Polkit.Authority.get_sync ();
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
authority.check_authorization.begin ( authority.check_authorization.begin (
subject, subject,
@ -262,15 +270,17 @@ namespace Pamac {
if (pkg != null) { if (pkg != null) {
pkg.reason = (Alpm.Package.Reason) reason; pkg.reason = (Alpm.Package.Reason) reason;
refresh_handle (); refresh_handle ();
set_pkgreason_finished ();
} }
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} finally {
set_pkgreason_finished ();
} }
} }
); );
} catch (GLib.Error e) { } catch (GLib.Error e) {
set_pkgreason_finished ();
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
} }
@ -298,25 +308,23 @@ namespace Pamac {
err.details = details; err.details = details;
} }
databases_lock_mutex.unlock (); databases_lock_mutex.unlock ();
Idle.add((owned) callback); Idle.add ((owned) callback);
return success; return success;
}); });
yield;
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
yield;
return err; return err;
} }
public void start_refresh (int force, bool emit_finish_signal) { public void start_refresh (int force) {
intern_lock = true; intern_lock = true;
refresh.begin (force, (obj, res) => { refresh.begin (force, (obj, res) => {
var err = refresh.end (res); var err = refresh.end (res);
intern_lock = false; intern_lock = false;
refresh_handle (); refresh_handle ();
if (emit_finish_signal) {
refresh_finished (err); refresh_finished (err);
}
}); });
} }
@ -335,6 +343,14 @@ namespace Pamac {
return alpm_config.ignorepkg; return alpm_config.ignorepkg;
} }
public void add_ignorepkg (string pkgname) {
alpm_config.handle.add_ignorepkg (pkgname);
}
public void remove_ignorepkg (string pkgname) {
alpm_config.handle.remove_ignorepkg (pkgname);
}
public bool should_hold (string pkgname) { public bool should_hold (string pkgname) {
if (alpm_config.holdpkgs.find_custom (pkgname, strcmp) != null) { if (alpm_config.holdpkgs.find_custom (pkgname, strcmp) != null) {
return true; return true;
@ -634,10 +650,10 @@ namespace Pamac {
return updates; return updates;
} else { } else {
string[] local_pkgs = {}; string[] local_pkgs = {};
foreach (var local_pkg in alpm_config.handle.localdb.pkgcache) { foreach (var installed_pkg in alpm_config.handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup // check if installed_pkg is in IgnorePkg or IgnoreGroup
if (alpm_config.handle.should_ignore (local_pkg) == 0) { if (alpm_config.handle.should_ignore (installed_pkg) == 0) {
candidate = local_pkg.sync_newversion (alpm_config.handle.syncdbs); candidate = installed_pkg.sync_newversion (alpm_config.handle.syncdbs);
if (candidate != null) { if (candidate != null) {
infos.name = candidate.name; infos.name = candidate.name;
infos.version = candidate.version; infos.version = candidate.version;
@ -647,15 +663,15 @@ namespace Pamac {
updates_infos += infos; updates_infos += infos;
} else { } else {
if (enable_aur) { if (enable_aur) {
// check if it is a local pkg // check if installed_pkg is a local pkg
foreach (var db in alpm_config.handle.syncdbs) { foreach (var db in alpm_config.handle.syncdbs) {
pkg = Alpm.find_satisfier (db.pkgcache, local_pkg.name); pkg = Alpm.find_satisfier (db.pkgcache, installed_pkg.name);
if (pkg != null) { if (pkg != null) {
break; break;
} }
} }
if (pkg == null) { if (pkg == null) {
local_pkgs += local_pkg.name; local_pkgs += installed_pkg.name;
} }
} }
} }
@ -911,13 +927,13 @@ namespace Pamac {
} }
} }
databases_lock_mutex.unlock (); databases_lock_mutex.unlock ();
Idle.add((owned) callback); Idle.add ((owned) callback);
return ret; return ret;
}); });
yield;
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
yield;
return err; return err;
} }
@ -972,7 +988,7 @@ namespace Pamac {
SourceFunc callback = trans_commit.callback; SourceFunc callback = trans_commit.callback;
var err = ErrorInfos (); var err = ErrorInfos ();
try { try {
Polkit.Authority authority = Polkit.Authority.get_sync (null); Polkit.Authority authority = Polkit.Authority.get_sync ();
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
authority.check_authorization.begin ( authority.check_authorization.begin (
subject, subject,
@ -1034,22 +1050,24 @@ namespace Pamac {
} }
trans_release (); trans_release ();
databases_lock_mutex.unlock (); databases_lock_mutex.unlock ();
Idle.add((owned) callback); Idle.add ((owned) callback);
return ret; return ret;
}); });
} else { } else {
err.message = _("Authentication failed"); err.message = _("Authentication failed");
trans_release (); trans_release ();
Idle.add ((owned) callback);
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
Idle.add ((owned) callback);
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
} }
); );
yield;
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
yield;
return err; return err;
} }
@ -1067,6 +1085,10 @@ namespace Pamac {
} }
public void trans_cancel () { public void trans_cancel () {
if (alpm_config.handle.trans_interrupt () == 0) {
// a transaction is being interrupted
return;
}
// explicitly quit to avoid a crash // explicitly quit to avoid a crash
// this daemon should be auto-restarted // this daemon should be auto-restarted
quit (); quit ();
@ -1074,12 +1096,20 @@ namespace Pamac {
[DBus (no_reply = true)] [DBus (no_reply = true)]
public void quit () { public void quit () {
try {
new Thread<int>.try ("quit thread", () => {
databases_lock_mutex.lock ();
// be sure to not quit with locked databases // be sure to not quit with locked databases
alpm_config.handle.trans_interrupt ();
alpm_config.handle.trans_release (); alpm_config.handle.trans_release ();
if (lockfile.query_exists () == false) { if (lockfile.query_exists () == false) {
loop.quit (); loop.quit ();
} }
databases_lock_mutex.unlock ();
return 0;
});
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
} }
// End of Daemon Object // End of Daemon Object
} }
@ -1280,6 +1310,7 @@ void on_bus_acquired (DBusConnection conn) {
} }
catch (IOError e) { catch (IOError e) {
stderr.printf ("Could not register service\n"); stderr.printf ("Could not register service\n");
loop.quit ();
} }
} }
@ -1290,8 +1321,11 @@ void main () {
Bus.own_name (BusType.SYSTEM, "org.manjaro.pamac", BusNameOwnerFlags.NONE, Bus.own_name (BusType.SYSTEM, "org.manjaro.pamac", BusNameOwnerFlags.NONE,
on_bus_acquired, on_bus_acquired,
() => {}, null,
() => stderr.printf ("Could not acquire name\n")); () => {
stderr.printf ("Could not acquire name\n");
loop.quit ();
});
loop = new MainLoop (); loop = new MainLoop ();
loop.run (); loop.run ();

View File

@ -28,13 +28,5 @@ namespace Pamac {
public HistoryDialog (ManagerWindow window) { public HistoryDialog (ManagerWindow window) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
} }
[GtkCallback]
public void on_textview_size_allocate () {
// auto-scrolling method
var scrollable = textview as Gtk.Scrollable;
var adj = scrollable.get_vadjustment ();
adj.set_value (adj.get_upper () - adj.get_page_size ());
}
} }
} }

View File

@ -63,7 +63,7 @@ namespace Pamac {
if (pamac_run == false) { if (pamac_run == false) {
foreach (File file in files) { foreach (File file in files) {
string? path = file.get_path (); string? path = file.get_path ();
transaction.to_load.insert (path, path); transaction.to_load.add ((owned) path);
} }
transaction.run (); transaction.run ();
} }

View File

@ -20,7 +20,7 @@
using Gtk; using Gtk;
using Alpm; using Alpm;
const string VERSION = "2.2.2"; const string VERSION = "2.3";
namespace Pamac { namespace Pamac {
@ -118,10 +118,6 @@ namespace Pamac {
public SortInfo sortinfo; public SortInfo sortinfo;
//dialogs
HistoryDialog history_dialog;
PackagesChooserDialog packages_chooser_dialog;
public ManagerWindow (Gtk.Application application) { public ManagerWindow (Gtk.Application application) {
Object (application: application); Object (application: application);
@ -184,9 +180,6 @@ namespace Pamac {
} }
enable_aur (pamac_config.enable_aur); enable_aur (pamac_config.enable_aur);
history_dialog = new HistoryDialog (this);
packages_chooser_dialog = new PackagesChooserDialog (this, transaction);
set_buttons_sensitive (false); set_buttons_sensitive (false);
// sort by name by default // sort by name by default
@ -544,25 +537,25 @@ namespace Pamac {
packages_list.get_value (iter, 0, out val); packages_list.get_value (iter, 0, out val);
string name = val.get_string (); string name = val.get_string ();
if (name != dgettext (null, "No package found")) { if (name != dgettext (null, "No package found")) {
if (transaction.to_add.steal (name)) { if (transaction.to_add.remove (name)) {
} else if (transaction.to_remove.steal (name)) { } else if (transaction.to_remove.remove (name)) {
} else if (transaction.to_build.steal (name)) { } else if (transaction.to_build.remove (name)) {
} else { } else {
packages_list.get_value (iter, 3, out val); packages_list.get_value (iter, 3, out val);
string db_name = val.get_string (); string db_name = val.get_string ();
if (db_name == "local") { if (db_name == "local") {
if (transaction.should_hold (name) == false) { if (transaction.should_hold (name) == false) {
transaction.to_remove.insert (name, name); transaction.to_remove.add ((owned) name);
} }
} else if (db_name == "AUR") { } else if (db_name == "AUR") {
transaction.to_build.insert (name, name); transaction.to_build.add ((owned) name);
} else { } else {
transaction.to_add.insert (name, name); transaction.to_add.add ((owned) name);
} }
} }
} }
} }
if (transaction.to_add.size () + transaction.to_remove.size () + transaction.to_build.size () == 0) { if (transaction.to_add.length + transaction.to_remove.length + transaction.to_build.length == 0) {
set_buttons_sensitive (false); set_buttons_sensitive (false);
} else { } else {
set_buttons_sensitive (true); set_buttons_sensitive (true);
@ -575,54 +568,54 @@ namespace Pamac {
Pamac.Package find_pkg; Pamac.Package find_pkg;
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
if (pkg.repo == "AUR") { if (pkg.repo == "AUR") {
transaction.to_build.insert (pkg.name, pkg.name); transaction.to_build.add (pkg.name);
} else { } else {
find_pkg = transaction.find_local_pkg (pkg.name); find_pkg = transaction.find_local_pkg (pkg.name);
if (find_pkg.name == "") { if (find_pkg.name == "") {
transaction.to_add.insert (pkg.name, pkg.name); transaction.to_add.add (pkg.name);
} }
} }
} }
if (transaction.to_add.size () != 0 || transaction.to_build.size () != 0) { if (transaction.to_add.length != 0 || transaction.to_build.length != 0) {
set_buttons_sensitive (true); set_buttons_sensitive (true);
} }
} }
void on_reinstall_item_activate () { void on_reinstall_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
transaction.to_remove.steal (pkg.name); transaction.to_remove.remove (pkg.name);
if (pkg.repo == "local") { if (pkg.repo == "local") {
transaction.to_add.insert (pkg.name, pkg.name); transaction.to_add.add (pkg.name);
} }
} }
if (transaction.to_add.size () != 0) { if (transaction.to_add.length != 0) {
set_buttons_sensitive (true); set_buttons_sensitive (true);
} }
} }
void on_remove_item_activate () { void on_remove_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
transaction.to_add.steal (pkg.name); transaction.to_add.remove (pkg.name);
if (transaction.should_hold (pkg.name) == false) { if (transaction.should_hold (pkg.name) == false) {
if (pkg.repo == "local") { if (pkg.repo == "local") {
transaction.to_remove.insert (pkg.name, pkg.name); transaction.to_remove.add (pkg.name);
} }
} }
} }
if (transaction.to_remove.size () != 0) { if (transaction.to_remove.length != 0) {
set_buttons_sensitive (true); set_buttons_sensitive (true);
} }
} }
void on_deselect_item_activate () { void on_deselect_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
if (transaction.to_add.steal (pkg.name)) { if (transaction.to_add.remove (pkg.name)) {
} else if (transaction.to_remove.steal (pkg.name)) { } else if (transaction.to_remove.remove (pkg.name)) {
} else if (transaction.to_build.steal (pkg.name)) { } else if (transaction.to_build.remove (pkg.name)) {
} }
} }
if (transaction.to_add.size () == 0 && transaction.to_remove.size () == 0 if (transaction.to_add.length == 0 && transaction.to_remove.length == 0
&& transaction.to_load.size () == 0 && transaction.to_build.size () == 0) { && transaction.to_load.length == 0 && transaction.to_build.length == 0) {
set_buttons_sensitive (false); set_buttons_sensitive (false);
} }
} }
@ -643,29 +636,27 @@ namespace Pamac {
dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it:", dngettext (null, "%s has %u uninstalled optional dependency.\nChoose if you would like to install it:",
"%s has %u uninstalled optional dependencies.\nChoose those you would like to install:", optdeps.length).printf (pkg.name, optdeps.length))); "%s has %u uninstalled optional dependencies.\nChoose those you would like to install:", optdeps.length).printf (pkg.name, optdeps.length)));
choose_dep_dialog.run (); choose_dep_dialog.run ();
choose_dep_dialog.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
choose_dep_dialog.deps_list.foreach ((model, path, iter) => { choose_dep_dialog.deps_list.foreach ((model, path, iter) => {
GLib.Value val; GLib.Value val;
bool selected;
string name;
choose_dep_dialog.deps_list.get_value (iter, 0, out val); choose_dep_dialog.deps_list.get_value (iter, 0, out val);
selected = val.get_boolean (); bool selected = val.get_boolean ();
if (selected) { if (selected) {
choose_dep_dialog.deps_list.get_value (iter, 1, out val); choose_dep_dialog.deps_list.get_value (iter, 1, out val);
name = val.get_string (); string name = val.get_string ();
transaction.to_add.insert (name, name); transaction.to_add.add ((owned) name);
} }
return false; return false;
}); });
choose_dep_dialog.destroy ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
} }
} }
void on_install_optional_deps_item_activate () { void on_install_optional_deps_item_activate () {
choose_opt_dep (selected_pkgs); choose_opt_dep (selected_pkgs);
if (transaction.to_add.size () != 0) { if (transaction.to_add.length != 0) {
set_buttons_sensitive (true); set_buttons_sensitive (true);
} }
} }
@ -952,7 +943,7 @@ namespace Pamac {
Pamac.Package[] pkgs = {}; Pamac.Package[] pkgs = {};
Pamac.Package find_pkg; Pamac.Package find_pkg;
if (state == dgettext (null, "To install")) { if (state == dgettext (null, "To install")) {
foreach (string name in transaction.to_add.get_keys ()) { foreach (string name in transaction.to_add) {
find_pkg = transaction.find_local_pkg (name); find_pkg = transaction.find_local_pkg (name);
if (find_pkg.name != "") { if (find_pkg.name != "") {
pkgs += find_pkg; pkgs += find_pkg;
@ -965,7 +956,7 @@ namespace Pamac {
} }
populate_packages_list (pkgs); populate_packages_list (pkgs);
} else if (state == dgettext (null, "To remove")) { } else if (state == dgettext (null, "To remove")) {
foreach (string name in transaction.to_remove.get_keys ()) { foreach (string name in transaction.to_remove) {
find_pkg = transaction.find_local_pkg (name); find_pkg = transaction.find_local_pkg (name);
if (find_pkg.name != "") { if (find_pkg.name != "") {
pkgs += find_pkg; pkgs += find_pkg;
@ -1036,16 +1027,17 @@ namespace Pamac {
var dis = new DataInputStream (file.read ()); var dis = new DataInputStream (file.read ());
string line; string line;
// Read lines until end of file (null) is reached // Read lines until end of file (null) is reached
while ((line = dis.read_line (null)) != null) { while ((line = dis.read_line ()) != null) {
text.append (line); // construct text in reverse order
text.append ("\n"); text.prepend (line + "\n");
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
GLib.stderr.printf ("%s\n", e.message); GLib.stderr.printf ("%s\n", e.message);
} }
var history_dialog = new HistoryDialog (this);
history_dialog.textview.buffer.set_text (text.str, (int) text.len); history_dialog.textview.buffer.set_text (text.str, (int) text.len);
history_dialog.run (); history_dialog.run ();
history_dialog.hide (); history_dialog.destroy ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
@ -1054,26 +1046,40 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
public void on_local_item_activate () { public void on_local_item_activate () {
int response = packages_chooser_dialog.run (); Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
if (response== Gtk.ResponseType.ACCEPT) { dgettext (null, "Install local packages"), this, Gtk.FileChooserAction.OPEN,
SList<string> packages_paths = packages_chooser_dialog.get_filenames (); dgettext (null, "_Cancel"), Gtk.ResponseType.CANCEL,
dgettext (null, "_Open"),Gtk.ResponseType.ACCEPT);
chooser.window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
chooser.icon_name = "system-software-install";
chooser.default_width = 900;
chooser.select_multiple = true;
chooser.local_only = false;
chooser.create_folders = false;
Gtk.FileFilter package_filter = new Gtk.FileFilter ();
package_filter.set_filter_name (dgettext (null, "Alpm Package"));
package_filter.add_pattern ("*.pkg.tar.xz");
chooser.add_filter (package_filter);
if (chooser.run () == Gtk.ResponseType.ACCEPT) {
SList<string> packages_paths = chooser.get_filenames ();
if (packages_paths.length () != 0) { if (packages_paths.length () != 0) {
foreach (string path in packages_paths) { foreach (string path in packages_paths) {
transaction.to_load.insert (path, path); transaction.to_load.add (path);
} }
this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
packages_chooser_dialog.hide (); chooser.destroy ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
transaction.run (); transaction.run ();
} }
} else { } else {
packages_chooser_dialog.hide (); chooser.destroy ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
} }
} }
[GtkCallback] [GtkCallback]
@ -1125,7 +1131,7 @@ namespace Pamac {
set_buttons_sensitive (false); set_buttons_sensitive (false);
refresh_packages_list (); refresh_packages_list ();
} }
transaction.to_load.steal_all (); transaction.to_load.remove_all ();
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
} }
} }

View File

@ -1,56 +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 {
[GtkTemplate (ui = "/org/manjaro/pamac/manager/packages_chooser_dialog.ui")]
public class PackagesChooserDialog : Gtk.FileChooserDialog {
ManagerWindow window;
Transaction transaction;
public PackagesChooserDialog (ManagerWindow window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0);
Gtk.FileFilter package_filter = new Gtk.FileFilter ();
package_filter.set_filter_name (dgettext (null, "Alpm Package"));
package_filter.add_pattern ("*.pkg.tar.xz");
this.add_filter (package_filter);
this.window = window;
this.transaction = transaction;
}
[GtkCallback]
public void on_file_activated () {
SList<string> packages_paths = this.get_filenames ();
if (packages_paths.length () != 0) {
foreach (string path in packages_paths) {
transaction.to_load.insert (path, path);
}
window.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
this.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
transaction.run ();
}
}
}
}

View File

@ -20,18 +20,53 @@
namespace Pamac { namespace Pamac {
[DBus (name = "org.manjaro.pamac")] [DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object { public interface Daemon : Object {
public abstract void start_refresh (int force, bool emit_signal) throws IOError; public abstract void start_refresh (int force) throws IOError;
} }
} }
bool check_pamac_running () {
Application app;
bool run = false;
app = new Application ("org.manjaro.pamac.manager", 0);
try {
app.register ();
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run) {
return run;
}
app = new Application ("org.manjaro.pamac.updater", 0);
try {
app.register ();
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run) {
return run;
}
app = new Application ("org.manjaro.pamac.install", 0);
try {
app.register ();
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
return run;
}
int main (string[] args) { int main (string[] args) {
Pamac.Daemon daemon; Pamac.Daemon daemon;
if (check_pamac_running () == false) {
try { try {
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
"/org/manjaro/pamac"); "/org/manjaro/pamac");
daemon.start_refresh (0, false); daemon.start_refresh (0);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
}
return 0; return 0;
} }

View File

@ -24,10 +24,12 @@ namespace Pamac {
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError; public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError; public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError; public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
public abstract void start_refresh (int force, bool emit_finish_signal) throws IOError; public abstract void start_refresh (int force) throws IOError;
public abstract bool get_checkspace () throws IOError; public abstract bool get_checkspace () throws IOError;
public abstract string get_syncfirst () throws IOError; public abstract string get_syncfirst () throws IOError;
public abstract string get_ignorepkg () throws IOError; public abstract string get_ignorepkg () throws IOError;
public abstract void add_ignorepkg (string pkgname) throws IOError;
public abstract void remove_ignorepkg (string pkgname) throws IOError;
public abstract bool should_hold (string pkgname) throws IOError; public abstract bool should_hold (string pkgname) throws IOError;
public abstract async Pamac.Package[] get_all_pkgs () throws IOError; public abstract async Pamac.Package[] get_all_pkgs () throws IOError;
public abstract async Pamac.Package[] get_installed_pkgs () throws IOError; public abstract async Pamac.Package[] get_installed_pkgs () throws IOError;
@ -88,10 +90,11 @@ namespace Pamac {
public Alpm.TransFlag flags; public Alpm.TransFlag flags;
// those hashtables will be used as set // those hashtables will be used as set
public HashTable<string,string> to_add; public GenericSet<string?> to_add;
public HashTable<string,string> to_remove; public GenericSet<string?> to_remove;
public HashTable<string,string> to_load; public GenericSet<string?> to_load;
public HashTable<string,string> to_build; public GenericSet<string?> to_build;
public GenericSet<string?> special_ignorepkgs;
public Mode mode; public Mode mode;
@ -103,9 +106,6 @@ namespace Pamac {
string previous_filename; string previous_filename;
uint pulse_timeout_id; uint pulse_timeout_id;
bool sysupgrade_after_trans; bool sysupgrade_after_trans;
// it seems that upgrade after build can cause trouble
// so disable it and let's see if it's fine
//bool sysupgrade_after_build;
int build_status; int build_status;
int enable_downgrade; int enable_downgrade;
@ -116,7 +116,6 @@ namespace Pamac {
TransactionSumDialog transaction_sum_dialog; TransactionSumDialog transaction_sum_dialog;
TransactionInfoDialog transaction_info_dialog; TransactionInfoDialog transaction_info_dialog;
ProgressDialog progress_dialog; ProgressDialog progress_dialog;
PreferencesDialog preferences_dialog;
//parent window //parent window
Gtk.ApplicationWindow? window; Gtk.ApplicationWindow? window;
@ -125,17 +124,17 @@ namespace Pamac {
public Transaction (Gtk.ApplicationWindow? window) { public Transaction (Gtk.ApplicationWindow? window) {
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
to_add = new HashTable<string,string> (str_hash, str_equal); to_add = new GenericSet<string?> (str_hash, str_equal);
to_remove = new HashTable<string,string> (str_hash, str_equal); to_remove = new GenericSet<string?> (str_hash, str_equal);
to_load = new HashTable<string,string> (str_hash, str_equal); to_load = new GenericSet<string?> (str_hash, str_equal);
to_build = new HashTable<string,string> (str_hash, str_equal); to_build = new GenericSet<string?> (str_hash, str_equal);
special_ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
connecting_dbus_signals (); connecting_dbus_signals ();
//creating dialogs //creating dialogs
this.window = window; this.window = window;
transaction_sum_dialog = new TransactionSumDialog (window); transaction_sum_dialog = new TransactionSumDialog (window);
transaction_info_dialog = new TransactionInfoDialog (window); transaction_info_dialog = new TransactionInfoDialog (window);
progress_dialog = new ProgressDialog (this, window); progress_dialog = new ProgressDialog (this, window);
preferences_dialog = new PreferencesDialog (window);
//creating terminal //creating terminal
term = new Vte.Terminal (); term = new Vte.Terminal ();
term.scroll_on_output = false; term.scroll_on_output = false;
@ -167,7 +166,6 @@ namespace Pamac {
previous_percent = 0.0; previous_percent = 0.0;
previous_filename = ""; previous_filename = "";
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
//sysupgrade_after_build = false;
build_status = 0; build_status = 0;
} }
@ -216,7 +214,7 @@ namespace Pamac {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
try { try {
daemon.start_refresh (force, true); daemon.start_refresh (force);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
@ -252,6 +250,23 @@ namespace Pamac {
return ignorepkg; return ignorepkg;
} }
public void add_ignorepkg (string pkgname) {
try {
daemon.add_ignorepkg (pkgname);
special_ignorepkgs.add (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
public void remove_ignorepkg (string pkgname) {
try {
daemon.remove_ignorepkg (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
public bool should_hold (string pkgname) { public bool should_hold (string pkgname) {
bool should_hold = false; bool should_hold = false;
try { try {
@ -423,15 +438,23 @@ namespace Pamac {
return updates; return updates;
} }
public void sysupgrade_simple (int enable_downgrade) { public ErrorInfos init () {
progress_dialog.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (true);
var err = ErrorInfos (); var err = ErrorInfos ();
foreach (string pkgname in special_ignorepkgs) {
add_ignorepkg (pkgname);
}
try { try {
err = daemon.trans_init (0); err = daemon.trans_init (0);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
return err;
}
public void sysupgrade_simple (int enable_downgrade) {
progress_dialog.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (true);
var err = init ();
if (err.message != "") { if (err.message != "") {
finished (true); finished (true);
handle_error (err); handle_error (err);
@ -481,18 +504,15 @@ namespace Pamac {
sysupgrade_after_trans = true; sysupgrade_after_trans = true;
} }
foreach (UpdateInfos infos in updates.repos_updates) { foreach (UpdateInfos infos in updates.repos_updates) {
to_add.insert (infos.name, infos.name); to_add.add (infos.name);
} }
// run as a standard transaction // run as a standard transaction
run (); run ();
} else { } else {
if (updates.aur_updates.length != 0) { if (updates.aur_updates.length != 0) {
clear_lists (); clear_lists ();
//if (repos_updates_len != 0) {
//sysupgrade_after_build = true;
//}
foreach (UpdateInfos infos in updates.aur_updates) { foreach (UpdateInfos infos in updates.aur_updates) {
to_build.insert (infos.name, infos.name); to_build.add (infos.name);
} }
} }
if (updates.repos_updates.length != 0) { if (updates.repos_updates.length != 0) {
@ -510,9 +530,9 @@ namespace Pamac {
} }
public void clear_lists () { public void clear_lists () {
to_add.steal_all (); to_add.remove_all ();
to_remove.steal_all (); to_remove.remove_all ();
to_build.steal_all (); to_build.remove_all ();
} }
public void run () { public void run () {
@ -529,10 +549,10 @@ namespace Pamac {
} }
// run // run
var err = ErrorInfos (); var err = ErrorInfos ();
if (to_add.size () == 0 if (to_add.length == 0
&& to_remove.size () == 0 && to_remove.length == 0
&& to_load.size () == 0 && to_load.length == 0
&& to_build.size () != 0) { && to_build.length != 0) {
// there only AUR packages to build so no need to prepare transaction // there only AUR packages to build so no need to prepare transaction
on_trans_prepare_finished (err); on_trans_prepare_finished (err);
} else { } else {
@ -545,7 +565,7 @@ namespace Pamac {
finished (true); finished (true);
handle_error (err); handle_error (err);
} else { } else {
foreach (string name in to_add.get_keys ()) { foreach (string name in to_add) {
try { try {
err = daemon.trans_add_pkg (name); err = daemon.trans_add_pkg (name);
} catch (IOError e) { } catch (IOError e) {
@ -555,7 +575,7 @@ namespace Pamac {
break; break;
} }
} }
foreach (string name in to_remove.get_keys ()) { foreach (string name in to_remove) {
try { try {
err = daemon.trans_remove_pkg (name); err = daemon.trans_remove_pkg (name);
} catch (IOError e) { } catch (IOError e) {
@ -565,7 +585,7 @@ namespace Pamac {
break; break;
} }
} }
foreach (string path in to_load.get_keys ()) { foreach (string path in to_load) {
try { try {
err = daemon.trans_load_pkg (path); err = daemon.trans_load_pkg (path);
} catch (IOError e) { } catch (IOError e) {
@ -595,19 +615,20 @@ namespace Pamac {
var choose_provider_dialog = new ChooseProviderDialog (window); var choose_provider_dialog = new ChooseProviderDialog (window);
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend, len))); choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend, len)));
choose_provider_dialog.comboboxtext.remove_all (); choose_provider_dialog.comboboxtext.remove_all ();
foreach (string provider in providers) foreach (string provider in providers) {
choose_provider_dialog.comboboxtext.append_text (provider); choose_provider_dialog.comboboxtext.append_text (provider);
}
choose_provider_dialog.comboboxtext.active = 0; choose_provider_dialog.comboboxtext.active = 0;
choose_provider_dialog.run (); choose_provider_dialog.run ();
choose_provider_dialog.hide ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
try { try {
daemon.choose_provider (choose_provider_dialog.comboboxtext.active); daemon.choose_provider (choose_provider_dialog.comboboxtext.active);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
choose_provider_dialog.destroy ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
} }
public TransactionType set_transaction_sum () { public TransactionType set_transaction_sum () {
@ -646,7 +667,7 @@ namespace Pamac {
} }
} }
} }
foreach (string name in to_build.get_keys ()) { foreach (string name in to_build) {
_to_build += name; _to_build += name;
} }
int len = prepared_to_remove.length; int len = prepared_to_remove.length;
@ -761,8 +782,9 @@ namespace Pamac {
term.grab_focus (); term.grab_focus ();
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse); pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
string[] cmds = {"yaourt", "-S"}; string[] cmds = {"yaourt", "-S"};
foreach (string name in to_build.get_keys ()) foreach (string name in to_build) {
cmds += name; cmds += name;
}
Pid child_pid; Pid child_pid;
spawn_in_term (cmds, out child_pid); spawn_in_term (cmds, out child_pid);
// watch_child is needed in order to have the child_exited signal emitted // watch_child is needed in order to have the child_exited signal emitted
@ -783,6 +805,9 @@ namespace Pamac {
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
foreach (string pkgname in special_ignorepkgs) {
remove_ignorepkg (pkgname);
}
} }
public void stop_daemon () { public void stop_daemon () {
@ -807,6 +832,7 @@ namespace Pamac {
public async void run_preferences_dialog () { public async void run_preferences_dialog () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf"); var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
var preferences_dialog = new PreferencesDialog (window);
bool enable_aur = pamac_config.enable_aur; bool enable_aur = pamac_config.enable_aur;
bool recurse = pamac_config.recurse; bool recurse = pamac_config.recurse;
int refresh_period = pamac_config.refresh_period; int refresh_period = pamac_config.refresh_period;
@ -841,14 +867,10 @@ namespace Pamac {
} else { } else {
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 1; preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 1;
} }
int response = preferences_dialog.run (); if (preferences_dialog.run () == Gtk.ResponseType.OK) {
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal); 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_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal); var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
if (response == Gtk.ResponseType.OK) {
enable_aur = preferences_dialog.enable_aur_button.get_active (); enable_aur = preferences_dialog.enable_aur_button.get_active ();
recurse = preferences_dialog.remove_unrequired_deps_button.get_active (); recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
refresh_period = preferences_dialog.refresh_period_spin_button.get_value_as_int (); refresh_period = preferences_dialog.refresh_period_spin_button.get_value_as_int ();
@ -890,7 +912,6 @@ namespace Pamac {
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) { && preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) {
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "speed"))); new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "speed")));
} }
}
if (new_pamac_conf.size () != 0) { if (new_pamac_conf.size () != 0) {
start_write_pamac_config (new_pamac_conf); start_write_pamac_config (new_pamac_conf);
SourceFunc callback = run_preferences_dialog.callback; SourceFunc callback = run_preferences_dialog.callback;
@ -918,7 +939,8 @@ namespace Pamac {
yield; yield;
daemon.disconnect (handler_id); daemon.disconnect (handler_id);
} }
preferences_dialog.hide (); }
preferences_dialog.destroy ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
@ -1263,8 +1285,8 @@ namespace Pamac {
sysupgrade (0); sysupgrade (0);
} }
} else { } else {
handle_error (error);
finished (true); finished (true);
handle_error (error);
} }
previous_filename = ""; previous_filename = "";
} }
@ -1275,7 +1297,6 @@ namespace Pamac {
TransactionType type = set_transaction_sum (); TransactionType type = set_transaction_sum ();
if (type == TransactionType.UPDATE && mode == Mode.UPDATER) { if (type == TransactionType.UPDATE && mode == Mode.UPDATER) {
// there only updates // there only updates
//sysupgrade_after_build = false;
start_commit (); start_commit ();
} else if (type != 0) { } else if (type != 0) {
if (transaction_sum_dialog.run () == Gtk.ResponseType.OK) { if (transaction_sum_dialog.run () == Gtk.ResponseType.OK) {
@ -1298,9 +1319,8 @@ namespace Pamac {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
release (); release ();
to_build.steal_all (); to_build.remove_all ();
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
//sysupgrade_after_build = false;
finished (true); finished (true);
} }
} else { } else {
@ -1324,33 +1344,33 @@ namespace Pamac {
public void on_trans_commit_finished (ErrorInfos error) { public void on_trans_commit_finished (ErrorInfos error) {
if (error.message == "") { if (error.message == "") {
if (to_build.size () != 0) { if (to_build.length != 0) {
if (to_add.size () != 0 if (to_add.length != 0
|| to_remove.size () != 0 || to_remove.length != 0
|| to_load.size () != 0) { || to_load.length != 0) {
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"}); spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
} }
build_aur_packages (); build_aur_packages ();
} else { } else {
//progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished")); //progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished"));
//progress_dialog.close_button.set_visible (true);
clear_lists (); clear_lists ();
show_warnings (); show_warnings ();
if (sysupgrade_after_trans) { if (sysupgrade_after_trans) {
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
sysupgrade (0); sysupgrade (0);
//} else if (sysupgrade_after_build) {
//sysupgrade_simple (enable_downgrade);
} else { } else {
if (build_status == 0) { if (build_status == 0) {
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"}); spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
} else {
spawn_in_term ({"echo"});
}
progress_dialog.hide (); progress_dialog.hide ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
} else {
progress_dialog.progressbar.set_fraction (0);
progress_dialog.cancel_button.set_visible (false);
progress_dialog.close_button.set_visible (true);
spawn_in_term ({"echo"});
}
finished (false); finished (false);
} }
} }
@ -1366,7 +1386,7 @@ namespace Pamac {
void on_term_child_exited (int status) { void on_term_child_exited (int status) {
Source.remove (pulse_timeout_id); Source.remove (pulse_timeout_id);
to_build.steal_all (); to_build.remove_all ();
build_status = status; build_status = status;
// let the time to the daemon to update packages // let the time to the daemon to update packages
Timeout.add (1000, () => { Timeout.add (1000, () => {

View File

@ -27,16 +27,17 @@ 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 { public interface Daemon : Object {
public abstract void start_refresh (int force, bool emit_signal) throws IOError; public abstract void start_refresh (int force) throws IOError;
public abstract async Updates get_updates (bool enable_aur) throws IOError; public abstract async Updates get_updates (bool enable_aur) throws IOError;
[DBus (no_reply = true)] public abstract async void quit () throws IOError;
public abstract void quit () throws IOError; public signal void refresh_finished (ErrorInfos error);
} }
public class TrayIcon: Gtk.Application { public class TrayIcon: Gtk.Application {
Notify.Notification notification; Notify.Notification notification;
Daemon daemon; Daemon daemon;
bool locked; bool intern_lock;
bool extern_lock;
uint refresh_timeout_id; uint refresh_timeout_id;
Gtk.StatusIcon status_icon; Gtk.StatusIcon status_icon;
Gtk.Menu menu; Gtk.Menu menu;
@ -54,15 +55,13 @@ namespace Pamac {
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
// Connecting to signal
daemon.refresh_finished.connect (on_refresh_finished);
} }
void stop_daemon () { void stop_daemon () {
if (check_pamac_running () == false && lockfile.query_exists () == false) { if (check_pamac_running () == false && lockfile.query_exists () == false) {
try { daemon.quit.begin ();
daemon.quit ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
} }
} }
@ -97,7 +96,7 @@ namespace Pamac {
try { try {
Process.spawn_command_line_async ("pamac-updater"); Process.spawn_command_line_async ("pamac-updater");
} catch (SpawnError e) { } catch (SpawnError e) {
print(e.message); stderr.printf ("SpawnError: %s\n", e.message);
} }
} }
@ -105,7 +104,7 @@ namespace Pamac {
try { try {
Process.spawn_command_line_async ("pamac-manager"); Process.spawn_command_line_async ("pamac-manager");
} catch (SpawnError e) { } catch (SpawnError e) {
print(e.message); stderr.printf ("SpawnError: %s\n", e.message);
} }
} }
@ -114,11 +113,12 @@ namespace Pamac {
status_icon.set_tooltip_markup (info); status_icon.set_tooltip_markup (info);
} }
bool refresh () { bool start_refresh () {
if (check_pamac_running () == false) { if (check_pamac_running () == false) {
start_daemon (); start_daemon ();
try { try {
daemon.start_refresh (0, false); daemon.start_refresh (0);
intern_lock = true;
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
@ -126,6 +126,11 @@ namespace Pamac {
return true; return true;
} }
void on_refresh_finished () {
intern_lock = false;
check_updates ();
}
void check_updates () { void check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
daemon.get_updates.begin (pamac_config.enable_aur, (obj, res) => { daemon.get_updates.begin (pamac_config.enable_aur, (obj, res) => {
@ -203,9 +208,9 @@ namespace Pamac {
} }
bool check_pacman_running () { bool check_pacman_running () {
if (locked) { if (extern_lock) {
if (lockfile.query_exists () == false) { if (lockfile.query_exists () == false) {
locked = false; extern_lock = false;
// let the time to the daemon to update packages // let the time to the daemon to update packages
Timeout.add (1000, () => { Timeout.add (1000, () => {
check_updates (); check_updates ();
@ -214,7 +219,9 @@ namespace Pamac {
} }
} else { } else {
if (lockfile.query_exists () == true) { if (lockfile.query_exists () == true) {
locked = true; if (intern_lock == false) {
extern_lock = true;
}
} }
} }
return true; return true;
@ -224,7 +231,7 @@ namespace Pamac {
if (refresh_timeout_id != 0) { if (refresh_timeout_id != 0) {
Source.remove (refresh_timeout_id); Source.remove (refresh_timeout_id);
} }
refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, refresh); refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, start_refresh);
} }
public override void startup () { public override void startup () {
@ -234,7 +241,8 @@ namespace Pamac {
base.startup (); base.startup ();
locked = false; intern_lock = false;
extern_lock = false;
refresh_timeout_id = 0; refresh_timeout_id = 0;
status_icon = new Gtk.StatusIcon (); status_icon = new Gtk.StatusIcon ();
@ -249,7 +257,7 @@ namespace Pamac {
var alpm_config = new Alpm.Config ("/etc/pacman.conf"); var alpm_config = new Alpm.Config ("/etc/pacman.conf");
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile); lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
Timeout.add (500, check_pacman_running); Timeout.add (500, check_pacman_running);
refresh (); start_refresh ();
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
launch_refresh_timeout ((uint) pamac_config.refresh_period); launch_refresh_timeout ((uint) pamac_config.refresh_period);

View File

@ -27,6 +27,8 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.TreeView updates_treeview; public Gtk.TreeView updates_treeview;
[GtkChild] [GtkChild]
public Gtk.CellRendererToggle select_update;
[GtkChild]
public Gtk.Label bottom_label; public Gtk.Label bottom_label;
[GtkChild] [GtkChild]
public Gtk.Button apply_button; public Gtk.Button apply_button;
@ -38,7 +40,7 @@ namespace Pamac {
public UpdaterWindow (Gtk.Application application) { public UpdaterWindow (Gtk.Application application) {
Object (application: application); Object (application: application);
updates_list = new Gtk.ListStore (2, typeof (string), typeof (string)); updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
updates_treeview.set_model (updates_list); updates_treeview.set_model (updates_list);
transaction = new Transaction (this as Gtk.ApplicationWindow); transaction = new Transaction (this as Gtk.ApplicationWindow);
@ -51,6 +53,14 @@ namespace Pamac {
on_refresh_button_clicked (); on_refresh_button_clicked ();
} }
[GtkCallback]
public void on_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
updates_list.get_iter (out iter, treepath);
updates_list.set (iter, 0, !select_update.active);
}
[GtkCallback] [GtkCallback]
public void on_preferences_button_clicked () { public void on_preferences_button_clicked () {
transaction.run_preferences_dialog.begin (() => { transaction.run_preferences_dialog.begin (() => {
@ -64,6 +74,23 @@ namespace Pamac {
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
updates_list.foreach ((model, path, iter) => {
GLib.Value val;
updates_list.get_value (iter, 0, out val);
bool selected = val.get_boolean ();
if (selected) {
updates_list.get_value (iter, 1, out val);
// string has the form "pkgname pkgversion"
string pkgname = val.get_string ().split (" ", 2)[0];
transaction.special_ignorepkgs.remove (pkgname);
} else {
updates_list.get_value (iter, 1, out val);
// string has the form "pkgname pkgversion"
string pkgname = val.get_string ().split (" ", 2)[0];
transaction.special_ignorepkgs.add ((owned) pkgname);
}
return false;
});
transaction.sysupgrade (0); transaction.sysupgrade (0);
} }
@ -108,13 +135,17 @@ namespace Pamac {
} }
dsize += infos.download_size; dsize += infos.download_size;
updates_nb++; updates_nb++;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size); if (infos.name in transaction.special_ignorepkgs) {
updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
} else {
updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
}
} }
foreach (UpdateInfos infos in updates.aur_updates) { foreach (UpdateInfos infos in updates.aur_updates) {
name = infos.name + " " + infos.version; name = infos.name + " " + infos.version;
size = ""; size = "";
updates_nb++; updates_nb++;
updates_list.insert_with_values (out iter, -1, 0, name, 1, size); updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
} }
if (updates_nb == 0) { if (updates_nb == 0) {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date"))); top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));