some fixes and improvements

This commit is contained in:
guinux 2014-11-16 11:31:44 +01:00
parent 0d3b34d7c4
commit ed0bacc1d3
18 changed files with 168 additions and 158 deletions

View File

@ -408,12 +408,12 @@ msgstr "Vérification de l'espace disque disponible"
#: src/transaction.vala:685 #: src/transaction.vala:685
#, c-format #, c-format
msgid "%s optionally requires %s" msgid "%s optionally requires %s"
msgstr "" msgstr "%s peut nécessiter %s"
#: src/transaction.vala:688 #: src/transaction.vala:688
#, c-format #, c-format
msgid "Database file for %s does not exist" msgid "Database file for %s does not exist"
msgstr "" msgstr "Le dépôt %s n'existe pas"
#: src/transaction.vala:740 #: src/transaction.vala:740
#, c-format #, c-format

View File

@ -2,7 +2,6 @@
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.12"/>
<template class="PamacChooseDependenciesDialog" parent="GtkDialog"> <template class="PamacChooseDependenciesDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes">Choose Optional Dependencies</property> <property name="title" translatable="yes">Choose Optional Dependencies</property>
<property name="modal">True</property> <property name="modal">True</property>
@ -25,7 +24,6 @@
<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">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -2,7 +2,6 @@
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.12"/>
<template class="PamacChooseProviderDialog" parent="GtkDialog"> <template class="PamacChooseProviderDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes">Choose a Provider</property> <property name="title" translatable="yes">Choose a Provider</property>
<property name="modal">True</property> <property name="modal">True</property>
@ -25,7 +24,6 @@
<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">True</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>

View File

@ -2,7 +2,6 @@
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.12"/>
<template class="PamacHistoryDialog" parent="GtkDialog"> <template class="PamacHistoryDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes">Pamac History</property> <property name="title" translatable="yes">Pamac History</property>
<property name="default_width">600</property> <property name="default_width">600</property>
@ -25,7 +24,6 @@
<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">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -23,7 +23,7 @@
<object class="GtkButton" id="refresh_button"> <object class="GtkButton" id="refresh_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Refresh databases</property> <property name="tooltip_text" translatable="yes">Refresh databases</property>
<property name="focus_on_click">False</property> <property name="can_focus">True</property>
<signal name="clicked" handler="on_refresh_button_clicked" swapped="no"/> <signal name="clicked" handler="on_refresh_button_clicked" swapped="no"/>
<style> <style>
<class name="image-button"/> <class name="image-button"/>
@ -46,7 +46,7 @@
<object class="GtkButton" id="valid_button"> <object class="GtkButton" id="valid_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Apply changes</property> <property name="tooltip_text" translatable="yes">Apply changes</property>
<property name="focus_on_click">False</property> <property name="can_focus">True</property>
<signal name="clicked" handler="on_valid_button_clicked" swapped="no"/> <signal name="clicked" handler="on_valid_button_clicked" swapped="no"/>
<style> <style>
<class name="image-button"/> <class name="image-button"/>
@ -69,7 +69,7 @@
<object class="GtkButton" id="cancel_button"> <object class="GtkButton" id="cancel_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Cancel all planned changes</property> <property name="tooltip_text" translatable="yes">Cancel all planned changes</property>
<property name="focus_on_click">False</property> <property name="can_focus">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/> <signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
<style> <style>
<class name="image-button"/> <class name="image-button"/>
@ -91,6 +91,7 @@
<child> <child>
<object class="GtkMenuButton" id="menu_button"> <object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="popup">main_menu</property> <property name="popup">main_menu</property>
<property name="use_popover">True</property> <property name="use_popover">True</property>
<style> <style>
@ -164,6 +165,7 @@
<child> <child>
<object class="GtkSwitch" id="search_aur_button"> <object class="GtkSwitch" id="search_aur_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Search in AUR</property>
<property name="halign">end</property> <property name="halign">end</property>
</object> </object>
<packing> <packing>
@ -492,7 +494,7 @@
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkViewport" id="viewport1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<child> <child>
<object class="GtkBox" id="box5"> <object class="GtkBox" id="box5">
<property name="visible">True</property> <property name="visible">True</property>
@ -502,7 +504,7 @@
<child> <child>
<object class="GtkLabel" id="name_label"> <object class="GtkLabel" id="name_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin">6</property> <property name="margin">6</property>
<property name="selectable">True</property> <property name="selectable">True</property>
@ -516,7 +518,7 @@
<child> <child>
<object class="GtkLabel" id="desc_label"> <object class="GtkLabel" id="desc_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin">6</property> <property name="margin">6</property>
<property name="selectable">True</property> <property name="selectable">True</property>
@ -544,7 +546,7 @@
<child> <child>
<object class="GtkLabel" id="licenses_label"> <object class="GtkLabel" id="licenses_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin">6</property> <property name="margin">6</property>
<property name="selectable">True</property> <property name="selectable">True</property>
@ -579,7 +581,7 @@
<child> <child>
<object class="GtkTreeView" id="deps_treeview"> <object class="GtkTreeView" id="deps_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="headers_visible">False</property> <property name="headers_visible">False</property>
<property name="headers_clickable">False</property> <property name="headers_clickable">False</property>
<property name="enable_search">False</property> <property name="enable_search">False</property>
@ -640,7 +642,7 @@
<child> <child>
<object class="GtkTreeView" id="details_treeview"> <object class="GtkTreeView" id="details_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="headers_visible">False</property> <property name="headers_visible">False</property>
<property name="headers_clickable">False</property> <property name="headers_clickable">False</property>
<property name="enable_search">False</property> <property name="enable_search">False</property>

View File

@ -29,7 +29,6 @@
<property name="use_underline">True</property> <property name="use_underline">True</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>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -43,8 +42,6 @@
<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="can_default">True</property>
<property name="receives_default">False</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -28,6 +28,7 @@
<property name="label" translatable="yes">_Cancel</property> <property name="label" translatable="yes">_Cancel</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/> <signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
@ -40,6 +41,7 @@
<property name="label" translatable="yes">_Close</property> <property name="label" translatable="yes">_Close</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">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>
@ -78,7 +80,7 @@
<child> <child>
<object class="GtkExpander" id="expander"> <object class="GtkExpander" id="expander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="resize_toplevel">True</property> <property name="resize_toplevel">True</property>
<child> <child>
<placeholder/> <placeholder/>

View File

@ -21,7 +21,6 @@
<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">True</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</object> </object>
<packing> <packing>

View File

@ -34,7 +34,6 @@
<property name="label" translatable="yes">_OK</property> <property name="label" translatable="yes">_OK</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>
</object> </object>
<packing> <packing>

View File

@ -38,7 +38,7 @@
<child> <child>
<object class="GtkTreeView" id="updates_treeview"> <object class="GtkTreeView" id="updates_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="headers_visible">False</property> <property name="headers_visible">False</property>
<property name="headers_clickable">False</property> <property name="headers_clickable">False</property>
@ -101,7 +101,6 @@
<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">True</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>
@ -119,8 +118,7 @@
<child> <child>
<object class="GtkButtonBox" id="buttonbox1"> <object class="GtkButtonBox" id="buttonbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="has_focus">True</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<property name="layout_style">end</property> <property name="layout_style">end</property>
<child> <child>
@ -128,7 +126,6 @@
<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">True</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>
@ -142,7 +139,7 @@
<property name="label" translatable="yes">_Apply</property> <property name="label" translatable="yes">_Apply</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">True</property> <property name="has_focus">True</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>
@ -156,7 +153,6 @@
<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">True</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>

View File

@ -59,8 +59,6 @@ public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
public unowned Alpm.List<Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) { public unowned Alpm.List<Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) {
unowned Alpm.List<Alpm.Package?> syncpkgs = null; unowned Alpm.List<Alpm.Package?> syncpkgs = null;
unowned Alpm.List<Alpm.Package?> tmp = null;
unowned Alpm.List<Alpm.Package?> diff = null;
unowned Alpm.List<Alpm.Package?> result = null; unowned Alpm.List<Alpm.Package?> result = null;
result = handle.localdb.search (needles); result = handle.localdb.search (needles);
@ -69,15 +67,11 @@ public unowned Alpm.List<Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm
if (syncpkgs.length == 0) if (syncpkgs.length == 0)
syncpkgs = db.search (needles); syncpkgs = db.search (needles);
else { else {
tmp = db.search (needles); syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
diff = tmp.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp);
syncpkgs.join (diff);
} }
} }
diff = syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp); result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
result.join (diff);
//result.sort ((Alpm.List.CompareFunc) pkgcmp); //result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result; return result;
@ -92,17 +86,7 @@ public unowned Alpm.List<Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle,
result.add (pkg); result.add (pkg);
} }
// FIX IT: provided methods don't work for syncdbs so it's done manually result.join (Alpm.find_group_pkgs (handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) pkgcmp));
foreach (unowned Alpm.DB db in handle.syncdbs) {
foreach (unowned Alpm.Package pkg in db.pkgcache) {
foreach (string name in pkg.groups) {
if (name == grp_name) {
if (Alpm.pkg_find (result, pkg.name) == null)
result.add (pkg);
}
}
}
}
//result.sort ((Alpm.List.CompareFunc) pkgcmp); //result.sort ((Alpm.List.CompareFunc) pkgcmp);
@ -111,25 +95,19 @@ public unowned Alpm.List<Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle,
public unowned Alpm.List<Alpm.Package?> get_all_pkgs (Alpm.Handle handle) { public unowned Alpm.List<Alpm.Package?> get_all_pkgs (Alpm.Handle handle) {
unowned Alpm.List<Alpm.Package?> syncpkgs = null; unowned Alpm.List<Alpm.Package?> syncpkgs = null;
unowned Alpm.List<Alpm.Package?> tmp = null;
unowned Alpm.List<Alpm.Package?> diff = null;
unowned Alpm.List<Alpm.Package?> result = null; unowned Alpm.List<Alpm.Package?> result = null;
result = handle.localdb.pkgcache; result = handle.localdb.pkgcache.copy ();
foreach (unowned Alpm.DB db in handle.syncdbs) { foreach (unowned Alpm.DB db in handle.syncdbs) {
if (syncpkgs.length == 0) if (syncpkgs.length == 0)
syncpkgs = db.pkgcache; syncpkgs = db.pkgcache.copy ();
else { else {
tmp = db.pkgcache; syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
diff = tmp.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp);
syncpkgs.join (diff);
} }
} }
diff = syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp); result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
result.join (diff);
//result.sort ((Alpm.List.CompareFunc) pkgcmp); //result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result; return result;

View File

@ -74,12 +74,12 @@ namespace Pamac {
previous_percent = 0; previous_percent = 0;
} }
public async void write_config (HashTable<string,string> new_conf, GLib.BusName sender) { public void write_config (HashTable<string,string> new_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 (null);
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
Polkit.AuthorizationResult result = yield authority.check_authorization ( Polkit.AuthorizationResult result = authority.check_authorization_sync (
subject, subject,
"org.manjaro.pamac.commit", "org.manjaro.pamac.commit",
null, null,
@ -94,11 +94,11 @@ namespace Pamac {
} }
} }
public async void set_pkgreason (string pkgname, uint reason, GLib.BusName sender) { public void 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 (null);
Polkit.Subject subject = Polkit.SystemBusName.new (sender); Polkit.Subject subject = Polkit.SystemBusName.new (sender);
Polkit.AuthorizationResult result = yield authority.check_authorization ( Polkit.AuthorizationResult result = authority.check_authorization_sync (
subject, subject,
"org.manjaro.pamac.commit", "org.manjaro.pamac.commit",
null, null,
@ -483,6 +483,7 @@ namespace Pamac {
public void trans_cancel () { public void trans_cancel () {
handle.trans_interrupt (); handle.trans_interrupt ();
handle.trans_release (); handle.trans_release ();
init_alpm_config ();
} }
public void quit () { public void quit () {

View File

@ -21,7 +21,6 @@ namespace Pamac {
public class Installer: Gtk.Application { public class Installer: Gtk.Application {
Transaction transaction; Transaction transaction;
Pamac.Config pamac_config;
bool pamac_run; bool pamac_run;
public Installer () { public Installer () {
@ -46,8 +45,7 @@ namespace Pamac {
transaction_info_dialog.run (); transaction_info_dialog.run ();
transaction_info_dialog.hide (); transaction_info_dialog.hide ();
} else { } else {
pamac_config = new Pamac.Config ("/etc/pamac.conf"); transaction = new Pamac.Transaction (null);
transaction = new Pamac.Transaction (null, pamac_config);
transaction.finished.connect (on_emit_trans_finished); transaction.finished.connect (on_emit_trans_finished);
this.hold (); this.hold ();
} }

View File

@ -49,8 +49,12 @@ namespace Pamac {
} }
public override void activate () { public override void activate () {
if (pamac_run == false) if (pamac_run == false) {
manager_window.present (); manager_window.present ();
while (Gtk.events_pending ())
Gtk.main_iteration ();
manager_window.show_all_pkgs ();
}
} }
public override void shutdown () { public override void shutdown () {

View File

@ -59,8 +59,6 @@ namespace Pamac {
[GtkChild] [GtkChild]
public TreeView search_treeview; public TreeView search_treeview;
[GtkChild] [GtkChild]
public TreeSelection search_treeview_selection;
[GtkChild]
public TreeView groups_treeview; public TreeView groups_treeview;
[GtkChild] [GtkChild]
public TreeView states_treeview; public TreeView states_treeview;
@ -93,27 +91,29 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Button cancel_button; public Button cancel_button;
public Gtk.Menu right_click_menu; // menu
public Gtk.MenuItem deselect_item; Gtk.Menu right_click_menu;
public Gtk.MenuItem install_item; Gtk.MenuItem deselect_item;
public Gtk.MenuItem remove_item; Gtk.MenuItem install_item;
public Gtk.SeparatorMenuItem separator_item; Gtk.MenuItem remove_item;
public Gtk.MenuItem reinstall_item; Gtk.SeparatorMenuItem separator_item;
public Gtk.MenuItem install_optional_deps_item; Gtk.MenuItem reinstall_item;
public Gtk.MenuItem explicitly_installed_item; Gtk.MenuItem install_optional_deps_item;
public GLib.List<Pamac.Package> selected_pkgs; Gtk.MenuItem explicitly_installed_item;
GLib.List<Pamac.Package> selected_pkgs;
public ListStore search_list; // liststore
public ListStore groups_list; ListStore search_list;
public ListStore states_list; ListStore groups_list;
public ListStore repos_list; ListStore states_list;
public ListStore deps_list; ListStore repos_list;
public ListStore details_list; ListStore deps_list;
ListStore details_list;
PackagesModel packages_list; PackagesModel packages_list;
HashTable<string, Json.Array> aur_results; HashTable<string, Json.Array> aur_results;
public Pamac.Config pamac_config; Pamac.Config pamac_config;
public Transaction transaction; public Transaction transaction;
public SortInfo sortinfo; public SortInfo sortinfo;
@ -177,7 +177,8 @@ namespace Pamac {
pamac_config = new Pamac.Config ("/etc/pamac.conf"); pamac_config = new Pamac.Config ("/etc/pamac.conf");
transaction = new Pamac.Transaction (this as ApplicationWindow, pamac_config); transaction = new Pamac.Transaction (this as ApplicationWindow);
transaction.check_aur = pamac_config.enable_aur;
transaction.finished.connect (on_emit_trans_finished); transaction.finished.connect (on_emit_trans_finished);
history_dialog = new HistoryDialog (this); history_dialog = new HistoryDialog (this);
@ -201,9 +202,18 @@ namespace Pamac {
cancel_button.set_sensitive (sensitive); cancel_button.set_sensitive (sensitive);
} }
public void show_all_pkgs () {
this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
populate_packages_list (get_all_pkgs (transaction.handle));
this.get_window ().set_cursor (null);
}
public void update_lists () { public void update_lists () {
string[] grps = {}; string[] grps = {};
TreeIter iter; TreeIter iter;
TreeSelection selection;
selection = repos_treeview.get_selection ();
selection.changed.disconnect (on_repos_treeview_selection_changed);
foreach (unowned DB db in transaction.handle.syncdbs) { foreach (unowned DB db in transaction.handle.syncdbs) {
repos_list.insert_with_values (out iter, -1, 0, db.name); repos_list.insert_with_values (out iter, -1, 0, db.name);
foreach (unowned Group grp in db.groupcache) { foreach (unowned Group grp in db.groupcache) {
@ -213,14 +223,29 @@ namespace Pamac {
} }
} }
repos_list.insert_with_values (out iter, -1, 0, dgettext (null, "local")); repos_list.insert_with_values (out iter, -1, 0, dgettext (null, "local"));
repos_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_repos_treeview_selection_changed);
selection = groups_treeview.get_selection ();
selection.changed.disconnect (on_groups_treeview_selection_changed);
foreach (string name in grps) foreach (string name in grps)
groups_list.insert_with_values (out iter, -1, 0, name); groups_list.insert_with_values (out iter, -1, 0, name);
groups_list.set_sort_column_id (0, SortType.ASCENDING); groups_list.set_sort_column_id (0, SortType.ASCENDING);
groups_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_groups_treeview_selection_changed);
selection = states_treeview.get_selection ();
selection.changed.disconnect (on_states_treeview_selection_changed);
states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Installed")); states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Installed"));
//states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Uninstalled")); //states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Uninstalled"));
states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Orphans")); states_list.insert_with_values (out iter, -1, 0, dgettext (null, "Orphans"));
states_list.insert_with_values (out iter, -1, 0, dgettext (null, "To install")); states_list.insert_with_values (out iter, -1, 0, dgettext (null, "To install"));
states_list.insert_with_values (out iter, -1, 0, dgettext (null, "To remove")); states_list.insert_with_values (out iter, -1, 0, dgettext (null, "To remove"));
states_list.get_iter_first (out iter);
selection.select_iter (iter);
selection.changed.connect_after (on_states_treeview_selection_changed);
} }
public void set_infos_list (Pamac.Package pkg) { public void set_infos_list (Pamac.Package pkg) {
@ -654,11 +679,10 @@ namespace Pamac {
void on_explicitly_installed_item_activate () { void on_explicitly_installed_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
transaction.set_pkgreason.begin (pkg.name, PkgReason.EXPLICIT, (obj, res) => { transaction.set_pkgreason (pkg.name, PkgReason.EXPLICIT);
transaction.set_pkgreason.end (res);
refresh_packages_list ();
});
} }
transaction.refresh_alpm_config ();
refresh_packages_list ();
} }
[GtkCallback] [GtkCallback]
@ -833,7 +857,7 @@ namespace Pamac {
search_pkgs.begin (search_string, (obj, res) => { search_pkgs.begin (search_string, (obj, res) => {
Json.Array aur_pkgs; Json.Array aur_pkgs;
unowned Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs); unowned Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs);
if (pkgs.length != 0) { if (pkgs.length != 0 || aur_pkgs.get_length () != 0) {
// add search string in search_list if needed // add search string in search_list if needed
bool found = false; bool found = false;
TreeIter? iter; TreeIter? iter;
@ -855,27 +879,28 @@ namespace Pamac {
if ((string) line == search_string) { if ((string) line == search_string) {
found = true; found = true;
// block the signal to not populate when we select the iter in search_list // block the signal to not populate when we select the iter in search_list
search_treeview_selection.changed.disconnect (on_search_treeview_selection_changed); selection.changed.disconnect (on_search_treeview_selection_changed);
selection.select_iter (_iter); selection.select_iter (_iter);
search_treeview_selection.changed.connect_after (on_search_treeview_selection_changed); selection.changed.connect_after (on_search_treeview_selection_changed);
populate_packages_list (pkgs, aur_pkgs); populate_packages_list (pkgs, aur_pkgs);
} }
return found; return found;
}); });
} }
} }
if (!found) { if (found == false) {
search_list.insert_with_values (out iter, -1, 0, search_string); search_list.insert_with_values (out iter, -1, 0, search_string);
// block the signal to not populate when we select the iter in search_list // block the signal to not populate when we select the iter in search_list
search_treeview_selection.changed.disconnect (on_search_treeview_selection_changed); selection.changed.disconnect (on_search_treeview_selection_changed);
selection.select_iter (iter); selection.select_iter (iter);
search_treeview_selection.changed.connect_after (on_search_treeview_selection_changed); selection.changed.connect_after (on_search_treeview_selection_changed);
populate_packages_list (pkgs, aur_pkgs); populate_packages_list (pkgs, aur_pkgs);
} }
} else } else {
// populate with empty lists // populate with empty lists
populate_packages_list (pkgs, aur_pkgs); populate_packages_list (pkgs, aur_pkgs);
}); }
});
} }
} }
@ -955,15 +980,11 @@ namespace Pamac {
} else if (state == dgettext (null, "Installed")) { } else if (state == dgettext (null, "Installed")) {
pkgs = transaction.handle.localdb.pkgcache; pkgs = transaction.handle.localdb.pkgcache;
} else if (state == dgettext (null, "Uninstalled")) { } else if (state == dgettext (null, "Uninstalled")) {
unowned Alpm.List<Alpm.Package?> tmp = null;
unowned Alpm.List<Alpm.Package?> diff = null;
foreach (unowned DB db in transaction.handle.syncdbs) { foreach (unowned DB db in transaction.handle.syncdbs) {
if (pkgs.length == 0) if (pkgs.length == 0)
pkgs = db.pkgcache; pkgs = db.pkgcache.copy ();
else { else {
tmp = db.pkgcache; pkgs.join (db.pkgcache.diff (pkgs, (Alpm.List.CompareFunc) pkgcmp));
diff = tmp.diff (pkgs, (Alpm.List.CompareFunc) pkgcmp);
pkgs.join (diff);
} }
} }
} else if (state == dgettext (null, "Orphans")) { } else if (state == dgettext (null, "Orphans")) {
@ -1094,11 +1115,9 @@ namespace Pamac {
if (refresh_period != pamac_config.refresh_period) if (refresh_period != pamac_config.refresh_period)
new_conf.insert ("RefreshPeriod", refresh_period.to_string ()); new_conf.insert ("RefreshPeriod", refresh_period.to_string ());
if (new_conf.size () != 0) { if (new_conf.size () != 0) {
transaction.write_config.begin (new_conf, (obj, res) => { transaction.write_config (new_conf);
transaction.write_config.end (res); pamac_config.reload ();
pamac_config.reload (); search_aur_button.set_active (pamac_config.enable_aur);
search_aur_button.set_active (pamac_config.enable_aur);
});
} }
} }
preferences_dialog.hide (); preferences_dialog.hide ();

View File

@ -24,8 +24,8 @@ using Alpm;
namespace Pamac { namespace Pamac {
[DBus (name = "org.manjaro.pamac")] [DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object { public interface Daemon : Object {
public abstract async void write_config (HashTable<string,string> new_conf) throws IOError; public abstract void write_config (HashTable<string,string> new_conf) throws IOError;
public abstract async void set_pkgreason (string pkgname, uint reason) 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 void refresh (int force, bool emit_signal) throws IOError;
public abstract ErrorInfos trans_init (TransFlag transflags) throws IOError; public abstract ErrorInfos trans_init (TransFlag transflags) throws IOError;
public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError; public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
@ -59,7 +59,6 @@ namespace Pamac {
public string[] holdpkg; public string[] holdpkg;
public string[] ignorepkg; public string[] ignorepkg;
public Handle handle; public Handle handle;
public Pamac.Config pamac_config;
public Alpm.TransFlag flags; public Alpm.TransFlag flags;
// those hashtables will be used as set // those hashtables will be used as set
@ -81,6 +80,9 @@ namespace Pamac {
bool sysupgrade_after_build; bool sysupgrade_after_build;
int build_status; int build_status;
int enable_downgrade; int enable_downgrade;
public bool check_aur;
UpdatesInfos[] aur_updates;
bool aur_checked;
Terminal term; Terminal term;
Pty pty; Pty pty;
@ -94,9 +96,8 @@ namespace Pamac {
public signal void finished (bool error); public signal void finished (bool error);
public Transaction (ApplicationWindow? window, Pamac.Config pamac_config) { public Transaction (ApplicationWindow? window) {
refresh_alpm_config (); refresh_alpm_config ();
this.pamac_config = pamac_config;
mode = Mode.MANAGER; mode = Mode.MANAGER;
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
to_add = new HashTable<string, string> (str_hash, str_equal); to_add = new HashTable<string, string> (str_hash, str_equal);
@ -142,19 +143,22 @@ namespace Pamac {
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
sysupgrade_after_build = false; sysupgrade_after_build = false;
build_status = 0; build_status = 0;
check_aur = false;
aur_updates = {};
aur_checked = false;
} }
public async void write_config (HashTable<string,string> new_conf) { public void write_config (HashTable<string,string> new_conf) {
try { try {
yield daemon.write_config (new_conf); daemon.write_config (new_conf);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
} }
public async void set_pkgreason (string pkgname, PkgReason reason) { public void set_pkgreason (string pkgname, PkgReason reason) {
try { try {
yield daemon.set_pkgreason (pkgname, (uint) reason); daemon.set_pkgreason (pkgname, (uint) reason);
refresh_alpm_config (); refresh_alpm_config ();
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
@ -247,8 +251,11 @@ namespace Pamac {
} else { } else {
UpdatesInfos[] updates = get_repos_updates (handle, ignorepkg); UpdatesInfos[] updates = get_repos_updates (handle, ignorepkg);
uint repos_updates_len = updates.length; uint repos_updates_len = updates.length;
if (pamac_config.enable_aur) { if (check_aur) {
UpdatesInfos[] aur_updates = get_aur_updates (handle, ignorepkg); if (aur_checked == false) {
aur_updates = get_aur_updates (handle, ignorepkg);
aur_checked = true;
}
if (aur_updates.length != 0) { if (aur_updates.length != 0) {
clear_lists (); clear_lists ();
if (repos_updates_len != 0) if (repos_updates_len != 0)
@ -749,22 +756,32 @@ namespace Pamac {
} }
if (total_download > 0) { if (total_download > 0) {
fraction = (float) (xfered + already_downloaded) / total_download; fraction = (float) (xfered + already_downloaded) / total_download;
textbar = "%s/%s".printf (format_size (xfered + already_downloaded), format_size (total_download)); if (fraction > 0)
textbar = "%s/%s".printf (format_size (xfered + already_downloaded), format_size (total_download));
else
textbar = "%s".printf (format_size (xfered + already_downloaded));
} else { } else {
fraction = (float) xfered / total; fraction = (float) xfered / total;
textbar = "%s/%s".printf (format_size (xfered), format_size (total)); if (fraction > 0)
textbar = "%s/%s".printf (format_size (xfered), format_size (total));
else
textbar = "%s".printf (format_size (xfered));
} }
if (fraction != previous_percent) { if (fraction > 0) {
previous_percent = fraction; if (fraction != previous_percent) {
progress_dialog.progressbar.set_fraction (fraction); previous_percent = fraction;
} progress_dialog.progressbar.set_fraction (fraction);
}
} else
progress_dialog.progressbar.set_fraction (0);
if (textbar != previous_textbar) { if (textbar != previous_textbar) {
previous_textbar = textbar; previous_textbar = textbar;
progress_dialog.progressbar.set_text (textbar); progress_dialog.progressbar.set_text (textbar);
} }
if (xfered == total) if (xfered == total) {
already_downloaded += total; already_downloaded += total;
previous_filename = "";
}
} }
void on_emit_totaldownload (uint64 total) { void on_emit_totaldownload (uint64 total) {

View File

@ -47,17 +47,17 @@ namespace Pamac {
updates_list = new Gtk.ListStore (2, typeof (string), typeof (string)); updates_list = new Gtk.ListStore (2, typeof (string), typeof (string));
updates_treeview.set_model (updates_list); updates_treeview.set_model (updates_list);
transaction = new Transaction (this as ApplicationWindow, pamac_config); transaction = new Transaction (this as ApplicationWindow);
transaction.mode = Mode.UPDATER; transaction.mode = Mode.UPDATER;
transaction.check_aur = pamac_config.enable_aur;
transaction.finished.connect (on_emit_trans_finished); transaction.finished.connect (on_emit_trans_finished);
preferences_dialog = new PreferencesDialog (this as ApplicationWindow); preferences_dialog = new PreferencesDialog (this as ApplicationWindow);
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));
bottom_label.set_visible (false); bottom_label.set_visible (false);
apply_button.set_sensitive (false); apply_button.set_sensitive (false);
transaction.refresh (0); on_refresh_button_clicked ();
} }
[GtkCallback] [GtkCallback]
@ -84,11 +84,9 @@ namespace Pamac {
if (refresh_period != pamac_config.refresh_period) if (refresh_period != pamac_config.refresh_period)
new_conf.insert ("RefreshPeriod", refresh_period.to_string ()); new_conf.insert ("RefreshPeriod", refresh_period.to_string ());
if (new_conf.size () != 0) { if (new_conf.size () != 0) {
transaction.write_config.begin (new_conf, (obj, res) => { transaction.write_config (new_conf);
transaction.write_config.end (res); pamac_config.reload ();
pamac_config.reload (); set_updates_list.begin ();
set_updates_list.begin ();
});
} }
} }
preferences_dialog.hide (); preferences_dialog.hide ();
@ -118,12 +116,7 @@ namespace Pamac {
} }
public void on_emit_trans_finished (bool error) { public void on_emit_trans_finished (bool error) {
while (Gtk.events_pending ()) set_updates_list.begin ();
Gtk.main_iteration ();
set_updates_list.begin ((obj, res) => {
set_updates_list.end (res);
this.get_window ().set_cursor (null);
});
} }
public async void set_updates_list () { public async void set_updates_list () {
@ -132,6 +125,10 @@ namespace Pamac {
string size; string size;
uint64 dsize = 0; uint64 dsize = 0;
uint updates_nb = 0; uint updates_nb = 0;
this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
while (Gtk.events_pending ())
Gtk.main_iteration ();
top_label.set_markup ("");
updates_list.clear (); updates_list.clear ();
// get syncfirst updates // get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.handle, transaction.syncfirst); UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.handle, transaction.syncfirst);
@ -147,6 +144,8 @@ namespace Pamac {
updates_list.insert_with_values (out iter, -1, 0, name, 1, size); updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
} }
} else { } else {
while (Gtk.events_pending ())
Gtk.main_iteration ();
UpdatesInfos[] updates = get_repos_updates (transaction.handle, transaction.ignorepkg); UpdatesInfos[] updates = get_repos_updates (transaction.handle, transaction.ignorepkg);
foreach (UpdatesInfos infos in updates) { foreach (UpdatesInfos infos in updates) {
name = infos.name + " " + infos.version; name = infos.name + " " + infos.version;
@ -187,6 +186,10 @@ namespace Pamac {
bottom_label.set_visible (true); bottom_label.set_visible (true);
} else } else
bottom_label.set_visible (false); bottom_label.set_visible (false);
this.get_window ().set_cursor (null);
while (Gtk.events_pending ())
Gtk.main_iteration ();
} }
} }
} }

View File

@ -34,7 +34,7 @@ namespace Alpm {
public unowned Package? find_satisfier(Alpm.List<Package> pkgs, string depstring); public unowned Package? find_satisfier(Alpm.List<Package> pkgs, string depstring);
public unowned Package? pkg_find(Alpm.List<Package> haystack, string needle); public unowned Package? pkg_find(Alpm.List<Package> haystack, string needle);
public int pkg_vercmp(string a, string b); public int pkg_vercmp(string a, string b);
public unowned Alpm.List<Package?> find_group_pkgs(Alpm.List<DB> dbs, string name); public unowned Alpm.List<unowned Package?> find_group_pkgs(Alpm.List<DB> dbs, string name);
public unowned Package? sync_newversion(Package pkg, Alpm.List<DB> dbs); public unowned Package? sync_newversion(Package pkg, Alpm.List<DB> dbs);
/** Returns the string corresponding to an error number. */ /** Returns the string corresponding to an error number. */
public unowned string strerror(Errno err); public unowned string strerror(Errno err);
@ -247,7 +247,7 @@ namespace Alpm {
[CCode (cname = "alpm_get_localdb")] get; [CCode (cname = "alpm_get_localdb")] get;
} }
public unowned Alpm.List<DB?> syncdbs { public unowned Alpm.List<unowned DB?> syncdbs {
[CCode (cname = "alpm_get_syncdbs")] get; [CCode (cname = "alpm_get_syncdbs")] get;
} }
@ -281,11 +281,11 @@ namespace Alpm {
/** Returns a list of packages added by the transaction.*/ /** Returns a list of packages added by the transaction.*/
[CCode (cname = "alpm_trans_get_add")] [CCode (cname = "alpm_trans_get_add")]
public unowned Alpm.List<Package?> trans_to_add(); public unowned Alpm.List<unowned Package?> trans_to_add();
/** Returns the list of packages removed by the transaction.*/ /** Returns the list of packages removed by the transaction.*/
[CCode (cname = "alpm_trans_get_remove")] [CCode (cname = "alpm_trans_get_remove")]
public unowned Alpm.List<Package?> trans_to_remove(); public unowned Alpm.List<unowned Package?> trans_to_remove();
public LogCallBack logcb { public LogCallBack logcb {
[CCode (cname = "alpm_option_get_logcb")] get; [CCode (cname = "alpm_option_get_logcb")] get;
@ -406,11 +406,11 @@ namespace Alpm {
[CCode (cname = "alpm_db_set_servers")] set; [CCode (cname = "alpm_db_set_servers")] set;
} }
public unowned Alpm.List<Package?> pkgcache { public unowned Alpm.List<unowned Package?> pkgcache {
[CCode (cname = "alpm_db_get_pkgcache")] get; [CCode (cname = "alpm_db_get_pkgcache")] get;
} }
public unowned Alpm.List<Group?> groupcache { public unowned Alpm.List<unowned Group?> groupcache {
[CCode (cname = "alpm_db_get_groupcache")] get; [CCode (cname = "alpm_db_get_groupcache")] get;
} }
@ -422,7 +422,7 @@ namespace Alpm {
public unowned Package? get_pkg(string name); public unowned Package? get_pkg(string name);
public unowned Group? get_group(string name); public unowned Group? get_group(string name);
public unowned Alpm.List<Package?> search(Alpm.List<string> needles); public unowned Alpm.List<unowned Package?> search(Alpm.List<string> needles);
} }
/** /**
@ -505,25 +505,25 @@ namespace Alpm {
public unowned Alpm.List<unowned string?> groups { public unowned Alpm.List<unowned string?> groups {
[CCode (cname = "alpm_pkg_get_groups")] get; [CCode (cname = "alpm_pkg_get_groups")] get;
} }
public unowned Alpm.List<Depend?> depends { public unowned Alpm.List<unowned Depend?> depends {
[CCode (cname = "alpm_pkg_get_depends")] get; [CCode (cname = "alpm_pkg_get_depends")] get;
} }
public unowned Alpm.List<Depend?> optdepends { public unowned Alpm.List<unowned Depend?> optdepends {
[CCode (cname = "alpm_pkg_get_optdepends")] get; [CCode (cname = "alpm_pkg_get_optdepends")] get;
} }
public unowned Alpm.List<Depend?> conflicts { public unowned Alpm.List<unowned Depend?> conflicts {
[CCode (cname = "alpm_pkg_get_conflicts")] get; [CCode (cname = "alpm_pkg_get_conflicts")] get;
} }
public unowned Alpm.List<Depend?> provides { public unowned Alpm.List<unowned Depend?> provides {
[CCode (cname = "alpm_pkg_get_provides")] get; [CCode (cname = "alpm_pkg_get_provides")] get;
} }
public unowned Alpm.List<Depend?> replaces { public unowned Alpm.List<unowned Depend?> replaces {
[CCode (cname = "alpm_pkg_get_replaces")] get; [CCode (cname = "alpm_pkg_get_replaces")] get;
} }
public unowned Alpm.List<File?> files { public unowned Alpm.List<unowned File?> files {
[CCode (cname = "alpm_pkg_get_files_list")] get; [CCode (cname = "alpm_pkg_get_files_list")] get;
} }
public unowned Alpm.List<Backup?> backup { public unowned Alpm.List<unowned Backup?> backup {
[CCode (cname = "alpm_pkg_get_backup")] get; [CCode (cname = "alpm_pkg_get_backup")] get;
} }
public unowned DB? db { public unowned DB? db {
@ -579,7 +579,7 @@ namespace Alpm {
[CCode (cname = "alpm_group_t", has_type_id = false)] [CCode (cname = "alpm_group_t", has_type_id = false)]
public class Group { public class Group {
public string name; public string name;
public unowned Alpm.List<Package?> packages; public unowned Alpm.List<unowned Package?> packages;
} }
/** Package upgrade delta */ /** Package upgrade delta */
@ -988,7 +988,8 @@ namespace Alpm {
[CCode (cname = "alpm_list_remove_data"), ReturnsModifiedPointer ()] [CCode (cname = "alpm_list_remove_data"), ReturnsModifiedPointer ()]
public unowned void? remove(G data, CompareFunc fn); public unowned void? remove(G data, CompareFunc fn);
public List<G> copy(); public unowned List<G> copy();
public List<G> copy_data();
[ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void reverse (); public unowned void reverse ();