This commit is contained in:
guinux 2016-02-02 09:28:07 +01:00
parent d7d393ed4e
commit 00553e5e58
30 changed files with 3058 additions and 2398 deletions

View File

@ -21,8 +21,7 @@ msgstr ""
msgid "Authentication is required" msgid "Authentication is required"
msgstr "" msgstr ""
#: ../src/daemon.vala ../src/manager_window.vala ../src/preferences_dialog.vala
#: ../src/daemon.vala
msgid "Failed to initialize alpm library" msgid "Failed to initialize alpm library"
msgstr "" msgstr ""
@ -30,14 +29,6 @@ msgstr ""
msgid "Failed to synchronize any databases" msgid "Failed to synchronize any databases"
msgstr "" msgstr ""
#: ../src/daemon.vala
msgid "No"
msgstr ""
#: ../src/daemon.vala
msgid "Yes"
msgstr ""
#: ../src/daemon.vala #: ../src/daemon.vala
msgid "Failed to init transaction" msgid "Failed to init transaction"
msgstr "" msgstr ""
@ -90,7 +81,7 @@ msgstr ""
msgid "%s is invalid or corrupted" msgid "%s is invalid or corrupted"
msgstr "" msgstr ""
#: ../src/daemon.vala #: ../src/daemon.vala ../src/transaction.vala
msgid "Authentication failed" msgid "Authentication failed"
msgstr "" msgstr ""
@ -110,6 +101,11 @@ msgstr ""
msgid "Preparing" msgid "Preparing"
msgstr "" msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "Choose a provider for %s"
msgstr ""
#: ../src/transaction.vala ../resources/transaction_sum_dialog.ui #: ../src/transaction.vala ../resources/transaction_sum_dialog.ui
msgid "Transaction Summary" msgid "Transaction Summary"
msgstr "" msgstr ""
@ -146,6 +142,14 @@ msgstr ""
msgid "Building packages" msgid "Building packages"
msgstr "" msgstr ""
#: ../src/transaction.vala
msgid "Running pre-transaction hooks"
msgstr ""
#: ../src/transaction.vala
msgid "Running post-transaction hooks"
msgstr ""
#: ../src/transaction.vala #: ../src/transaction.vala
msgid "Checking dependencies" msgid "Checking dependencies"
msgstr "" msgstr ""
@ -257,11 +261,6 @@ msgstr ""
msgid "%s installed as %s.pacsave" msgid "%s installed as %s.pacsave"
msgstr "" msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "%s installed as %s.pacorig"
msgstr ""
#: ../src/transaction.vala #: ../src/transaction.vala
#, c-format #, c-format
msgid "Refreshing %s" msgid "Refreshing %s"
@ -272,6 +271,18 @@ msgstr ""
msgid "Downloading %s" msgid "Downloading %s"
msgstr "" msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "About %u seconds remaining"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "About %lu minute remaining"
msgid_plural "About %lu minutes remaining"
msgstr[0] ""
msgstr[1] ""
#: ../src/transaction.vala #: ../src/transaction.vala
msgid "Warning" msgid "Warning"
msgstr "" msgstr ""
@ -281,7 +292,7 @@ msgstr ""
msgid "Error" msgid "Error"
msgstr "" msgstr ""
#: ../src/transaction.vala ../src/progress_dialog.vala #: ../src/transaction.vala
msgid "Transaction cancelled" msgid "Transaction cancelled"
msgstr "" msgstr ""
@ -324,22 +335,6 @@ msgstr[1] ""
msgid "Show available updates" msgid "Show available updates"
msgstr "" msgstr ""
#: ../src/choose_provider_dialog.vala
#, c-format
msgid "Choose a provider for %s"
msgstr ""
#: ../src/choose_dep_dialog.vala
#, c-format
msgid ""
"%s has %u uninstalled optional dependency.\n"
"Choose if you would like to install it"
msgid_plural ""
"%s has %u uninstalled optional dependencies.\n"
"Choose those you would like to install"
msgstr[0] ""
msgstr[1] ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Deselect" msgid "Deselect"
msgstr "" msgstr ""
@ -380,6 +375,10 @@ msgstr ""
msgid "Licenses" msgid "Licenses"
msgstr "" msgstr ""
#: ../src/manager_window.vala
msgid "Unknown"
msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Depends On" msgid "Depends On"
msgstr "" msgstr ""
@ -416,18 +415,6 @@ msgstr ""
msgid "Groups" msgid "Groups"
msgstr "" msgstr ""
#: ../src/manager_window.vala
msgid "Maintainer"
msgstr ""
#: ../src/manager_window.vala
msgid "First Submitted"
msgstr ""
#: ../src/manager_window.vala
msgid "Last Modified"
msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Packager" msgid "Packager"
msgstr "" msgstr ""
@ -449,11 +436,15 @@ msgid "Installed as a dependency for another package"
msgstr "" msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Unknown" msgid "Install Reason"
msgstr "" msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Install Reason" msgid "Yes"
msgstr ""
#: ../src/manager_window.vala
msgid "No"
msgstr "" msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
@ -461,6 +452,22 @@ msgid "Signatures"
msgstr "" msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Backup files"
msgstr ""
#: ../src/manager_window.vala
msgid "Maintainer"
msgstr ""
#: ../src/manager_window.vala
msgid "First Submitted"
msgstr ""
#: ../src/manager_window.vala
msgid "Last Modified"
msgstr ""
#: ../src/manager_window.vala ../resources/manager_window.ui
msgid "Votes" msgid "Votes"
msgstr "" msgstr ""
@ -469,12 +476,15 @@ msgid "Out of Date"
msgstr "" msgstr ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Backup files" #, c-format
msgstr "" msgid ""
"%s has %u uninstalled optional dependency.\n"
#: ../src/manager_window.vala "Choose if you would like to install it"
msgid "No package found" msgid_plural ""
msgstr "" "%s has %u uninstalled optional dependencies.\n"
"Choose those you would like to install"
msgstr[0] ""
msgstr[1] ""
#: ../src/manager_window.vala #: ../src/manager_window.vala
msgid "Uninstalled" msgid "Uninstalled"
@ -595,7 +605,7 @@ msgstr ""
msgid "State" msgid "State"
msgstr "" msgstr ""
#: ../resources/manager_window.ui #: ../resources/manager_window.ui ../resources/updater_window.ui
msgid "Repositories" msgid "Repositories"
msgstr "" msgstr ""
@ -611,6 +621,11 @@ msgstr ""
msgid "Size" msgid "Size"
msgstr "" msgstr ""
#: ../resources/manager_window.ui ../resources/updater_window.ui
#: ../resources/preferences_dialog.ui
msgid "AUR"
msgstr ""
#: ../resources/manager_window.ui #: ../resources/manager_window.ui
msgid "Description" msgid "Description"
msgstr "" msgstr ""
@ -708,10 +723,6 @@ msgstr ""
msgid "Do not ask for confirmation when building packages" msgid "Do not ask for confirmation when building packages"
msgstr "" msgstr ""
#: ../resources/preferences_dialog.ui
msgid "AUR"
msgstr ""
#: ../resources/choose_ignorepkgs_dialog.ui #: ../resources/choose_ignorepkgs_dialog.ui
msgid "Choose Ignored Upgrades" msgid "Choose Ignored Upgrades"
msgstr "" msgstr ""

View File

@ -207,8 +207,8 @@
<object class="GtkLabel" id="search_aur_label"> <object class="GtkLabel" id="search_aur_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Search in AUR</property> <property name="label" translatable="yes">Search in AUR</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
@ -437,117 +437,242 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow6"> <object class="GtkNotebook" id="packages_notebook">
<property name="width_request">500</property>
<property name="height_request">200</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="hexpand">True</property> <signal name="switch-page" handler="on_packages_notebook_switch_page" after="yes" swapped="no"/>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="packages_treeview"> <object class="GtkScrolledWindow" id="packages_scrolledwindow">
<property name="width_request">500</property>
<property name="height_request">200</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="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="search_column">0</property> <property name="shadow_type">in</property>
<property name="show_expanders">False</property>
<signal name="button-press-event" handler="on_packages_treeview_button_press_event" swapped="no"/>
<signal name="row-activated" handler="on_packages_treeview_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="packages_treeview_selection">
<property name="mode">multiple</property>
<signal name="changed" handler="on_packages_treeview_selection_changed" swapped="no"/>
</object>
</child>
<child> <child>
<object class="GtkTreeViewColumn" id="state_column"> <object class="GtkTreeView" id="packages_treeview">
<property name="resizable">True</property> <property name="visible">True</property>
<property name="fixed_width">40</property> <property name="can_focus">True</property>
<property name="min_width">20</property> <property name="hexpand">True</property>
<property name="title" translatable="yes">State</property> <property name="vexpand">True</property>
<property name="clickable">True</property> <property name="search_column">0</property>
<signal name="clicked" handler="on_state_column_clicked" swapped="no"/> <property name="show_expanders">False</property>
<child> <signal name="button-press-event" handler="on_packages_treeview_button_press_event" swapped="no"/>
<object class="GtkCellRendererPixbuf" id="state_rendererpixbuf"/> <signal name="row-activated" handler="on_packages_treeview_row_activated" swapped="no"/>
<attributes> <child internal-child="selection">
<attribute name="pixbuf">1</attribute> <object class="GtkTreeSelection" id="treeview-selection">
</attributes> <property name="mode">multiple</property>
<signal name="changed" handler="on_packages_treeview_selection_changed" swapped="no"/>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="name_column">
<property name="resizable">True</property>
<property name="fixed_width">150</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_name_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererText" id="name_renderertext"/> <object class="GtkTreeViewColumn" id="packages_state_column">
<attributes> <property name="resizable">True</property>
<attribute name="text">0</attribute> <property name="fixed_width">40</property>
</attributes> <property name="min_width">20</property>
<property name="title" translatable="yes">State</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_packages_state_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="packages_state_rendererpixbuf"/>
<attributes>
<attribute name="pixbuf">1</attribute>
</attributes>
</child>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="version_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Version</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_version_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererText" id="version_renderertext"/> <object class="GtkTreeViewColumn" id="packages_name_column">
<attributes> <property name="resizable">True</property>
<attribute name="text">2</attribute> <property name="fixed_width">150</property>
</attributes> <property name="min_width">20</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_packages_name_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_name_renderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="repo_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Repository</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_repo_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererText" id="repo_renderertext"/> <object class="GtkTreeViewColumn" id="packages_version_column">
<attributes> <property name="resizable">True</property>
<attribute name="text">3</attribute> <property name="fixed_width">90</property>
</attributes> <property name="min_width">20</property>
<property name="title" translatable="yes">Version</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_packages_version_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_version_renderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="size_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Size</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_size_column_clicked" swapped="no"/>
<child> <child>
<object class="GtkCellRendererText" id="size_renderertext"/> <object class="GtkTreeViewColumn" id="packages_repo_column">
<attributes> <property name="resizable">True</property>
<attribute name="text">4</attribute> <property name="fixed_width">90</property>
</attributes> <property name="min_width">20</property>
<property name="title" translatable="yes">Repository</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_packages_repo_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_repo_renderertext"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="packages_size_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Size</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_packages_size_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_size_renderertext"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Repositories</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="aur_scrolledwindow">
<property name="width_request">500</property>
<property name="height_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="aur_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<signal name="button-press-event" handler="on_aur_treeview_button_press_event" swapped="no"/>
<signal name="row-activated" handler="on_aur_treeview_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection12">
<property name="mode">multiple</property>
<signal name="changed" handler="on_aur_treeview_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="aur_state_column">
<property name="resizable">True</property>
<property name="fixed_width">40</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">State</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_aur_state_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="aur_state_rendererpixbuf"/>
<attributes>
<attribute name="pixbuf">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="aur_name_column">
<property name="resizable">True</property>
<property name="fixed_width">150</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_aur_name_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="aur_name_renderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="aur_version_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Version</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_aur_version_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="aur_version_renderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="aur_votes_column">
<property name="resizable">True</property>
<property name="fixed_width">90</property>
<property name="min_width">20</property>
<property name="title" translatable="yes">Votes</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_aur_votes_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="aur_votes_renderertext"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">AUR</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="resize">True</property> <property name="resize">True</property>
<property name="shrink">False</property> <property name="shrink">True</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -563,11 +688,11 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkViewport" id="viewport2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkBox" id="box5"> <object class="GtkBox" id="box4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
@ -575,8 +700,10 @@
<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">True</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
@ -592,8 +719,10 @@
<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">True</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
@ -609,9 +738,10 @@
<child> <child>
<object class="GtkLabel" id="link_label"> <object class="GtkLabel" id="link_label">
<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="halign">start</property> <property name="halign">start</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
@ -626,8 +756,10 @@
<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">True</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_start">6</property> <property name="margin_start">6</property>
<property name="margin_end">6</property> <property name="margin_end">6</property>
<property name="margin_top">6</property> <property name="margin_top">6</property>
@ -647,7 +779,7 @@
</object> </object>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel" id="label1"> <object class="GtkLabel" id="label7">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Description</property> <property name="label" translatable="yes">Description</property>
@ -670,7 +802,7 @@
<property name="enable_search">False</property> <property name="enable_search">False</property>
<property name="show_expanders">False</property> <property name="show_expanders">False</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="deps_treeview_selection"> <object class="GtkTreeSelection" id="treeview-selection8">
<property name="mode">none</property> <property name="mode">none</property>
</object> </object>
</child> </child>
@ -678,7 +810,7 @@
<object class="GtkTreeViewColumn" id="dep_type"> <object class="GtkTreeViewColumn" id="dep_type">
<property name="sizing">autosize</property> <property name="sizing">autosize</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext12"> <object class="GtkCellRendererText" id="cellrenderertext3">
<property name="yalign">0</property> <property name="yalign">0</property>
<property name="weight">600</property> <property name="weight">600</property>
</object> </object>
@ -692,7 +824,7 @@
<object class="GtkTreeViewColumn" id="deps"> <object class="GtkTreeViewColumn" id="deps">
<property name="sizing">autosize</property> <property name="sizing">autosize</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext13"/> <object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes> <attributes>
<attribute name="text">1</attribute> <attribute name="text">1</attribute>
</attributes> </attributes>
@ -707,7 +839,7 @@
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel" id="label2"> <object class="GtkLabel" id="label8">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Dependencies</property> <property name="label" translatable="yes">Dependencies</property>
@ -732,7 +864,7 @@
<property name="search_column">0</property> <property name="search_column">0</property>
<property name="show_expanders">False</property> <property name="show_expanders">False</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection6"> <object class="GtkTreeSelection" id="treeview-selection10">
<property name="mode">none</property> <property name="mode">none</property>
</object> </object>
</child> </child>
@ -740,7 +872,7 @@
<object class="GtkTreeViewColumn" id="infotype"> <object class="GtkTreeViewColumn" id="infotype">
<property name="sizing">autosize</property> <property name="sizing">autosize</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext1"> <object class="GtkCellRendererText" id="cellrenderertext6">
<property name="yalign">0</property> <property name="yalign">0</property>
<property name="weight">600</property> <property name="weight">600</property>
<property name="wrap_mode">word</property> <property name="wrap_mode">word</property>
@ -752,10 +884,10 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn" id="type"> <object class="GtkTreeViewColumn" id="info">
<property name="sizing">autosize</property> <property name="sizing">autosize</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext4"> <object class="GtkCellRendererText" id="cellrenderertext7">
<property name="wrap_mode">word</property> <property name="wrap_mode">word</property>
</object> </object>
<attributes> <attributes>
@ -772,7 +904,7 @@
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel" id="label3"> <object class="GtkLabel" id="label9">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Details</property> <property name="label" translatable="yes">Details</property>
@ -824,7 +956,7 @@
</object> </object>
<packing> <packing>
<property name="resize">True</property> <property name="resize">True</property>
<property name="shrink">False</property> <property name="shrink">True</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -6,7 +6,7 @@
<property name="title" translatable="yes">Progress</property> <property name="title" translatable="yes">Progress</property>
<property name="modal">True</property> <property name="modal">True</property>
<property name="window_position">center-on-parent</property> <property name="window_position">center-on-parent</property>
<property name="default_width">500</property> <property name="width_request">500</property>
<property name="icon_name">system-software-install</property> <property name="icon_name">system-software-install</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="deletable">False</property> <property name="deletable">False</property>
@ -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>
<signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.19.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.12"/>
<template class="PamacUpdaterWindow" parent="GtkApplicationWindow"> <template class="PamacUpdaterWindow" parent="GtkApplicationWindow">
@ -30,64 +30,142 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkNotebook" id="notebook">
<property name="width_request">400</property>
<property name="height_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child> <child>
<object class="GtkTreeView" id="updates_treeview"> <object class="GtkScrolledWindow" id="repos_scrolledwindow">
<property name="width_request">400</property>
<property name="height_request">400</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="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">none</property>
</object>
</child>
<child> <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3"> <object class="GtkTreeView" id="repos_updates_treeview">
<child> <property name="visible">True</property>
<object class="GtkCellRendererToggle" id="select_update"> <property name="can_focus">True</property>
<signal name="toggled" handler="on_select_update_toggled" swapped="no"/> <property name="vexpand">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection">
<property name="mode">none</property>
</object> </object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="expand">True</property>
<child> <child>
<object class="GtkCellRendererText" id="update_name"/> <object class="GtkTreeViewColumn" id="treeviewcolumn3">
<attributes> <child>
<attribute name="text">1</attribute> <object class="GtkCellRendererToggle" id="repos_select_update">
</attributes> <signal name="toggled" handler="on_repos_select_update_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child> <child>
<object class="GtkCellRendererText" id="download_size"/> <object class="GtkTreeViewColumn" id="treeviewcolumn1">
<attributes> <property name="expand">True</property>
<attribute name="text">2</attribute> <child>
</attributes> <object class="GtkCellRendererText" id="repos_update_name"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="repos_update_download_size"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child type="tab">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Repositories</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="aur_scrolledwindow">
<property name="width_request">400</property>
<property name="height_request">400</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkTreeView" id="aur_updates_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<property name="mode">none</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<child>
<object class="GtkCellRendererToggle" id="aur_select_update">
<signal name="toggled" handler="on_aur_select_update_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="aur_update_name"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">AUR</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>

View File

@ -1,23 +1,28 @@
COMMON_VALA_FLAGS = -X -w \ COMMON_VALA_FLAGS = -g --save-temps -X -w \
--pkg=libalpm \ --pkg=libalpm \
--pkg=gio-2.0 \ --pkg=gio-2.0 \
--pkg=posix \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--vapidir=../vapi \ --vapidir=../vapi \
--Xcc=-I../util \ --Xcc=-I../util \
-X -D_FILE_OFFSET_BITS=64 \ -X -D_FILE_OFFSET_BITS=64 \
-X -DGETTEXT_PACKAGE="pamac" \ -X -DGETTEXT_PACKAGE="pamac" \
--target-glib=2.38 --target-glib=2.38
TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \ TRANSACTION_VALA_FLAGS = --pkg=gtk+-3.0 \
--pkg=gtk+-3.0 \
--pkg=gmodule-2.0 \ --pkg=gmodule-2.0 \
--pkg=gdk-3.0 \ --pkg=gdk-3.0 \
--pkg=vte-2.91 --pkg=vte-2.91 \
-X -lm
COMMON_SOURCES = ../util/alpm-util.c \ COMMON_SOURCES = ../util/alpm-util.c \
common.vala \ common.vala \
pamac_config.vala \ pamac_config.vala \
package.vala \ alpm_config.vala \
alpm_utils.vala \
aur.vala \
TRANSACTION_SOURCES = transaction.vala \ TRANSACTION_SOURCES = transaction.vala \
choose_provider_dialog.vala \ choose_provider_dialog.vala \
@ -44,37 +49,28 @@ pamac-refresh: pamac_config.vala refresh.vala
valac -o pamac-refresh \ valac -o pamac-refresh \
-X -w \ -X -w \
--pkg=gio-2.0 \ --pkg=gio-2.0 \
--pkg=posix \
pamac_config.vala \ pamac_config.vala \
refresh.vala refresh.vala
pamac-tray: ../vapi/libalpm.vapi ../util/alpm-util.c common.vala alpm_config.vala pamac_config.vala tray.vala pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
valac -o pamac-tray \ valac -o pamac-tray \
$(COMMON_VALA_FLAGS) \ $(COMMON_VALA_FLAGS) \
../util/alpm-util.c \
--pkg=posix \
--pkg=gtk+-3.0 \ --pkg=gtk+-3.0 \
--pkg=libnotify \ --pkg=libnotify \
common.vala \ $(COMMON_SOURCES) \
alpm_config.vala \
pamac_config.vala \
tray.vala tray.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala alpm_config.vala alpm_utils.vala aur.vala daemon.vala pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) mirrors_config.vala daemon.vala
valac -o pamac-daemon \ valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \ $(COMMON_VALA_FLAGS) \
--pkg=posix \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=polkit-gobject-1 \ --pkg=polkit-gobject-1 \
--thread \ --thread \
$(COMMON_SOURCES) \ $(COMMON_SOURCES) \
mirrors_config.vala \ mirrors_config.vala \
alpm_config.vala \
aur.vala \
alpm_utils.vala \
daemon.vala daemon.vala
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala manager_window.vala manager.vala pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) choose_dep_dialog.vala history_dialog.vala ../resources/manager_resources.c packages_model.vala aur_model.vala manager_window.vala manager.vala
valac -o pamac-manager \ valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \ $(COMMON_VALA_FLAGS) \
$(TRANSACTION_VALA_FLAGS) \ $(TRANSACTION_VALA_FLAGS) \
@ -86,6 +82,7 @@ pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(P
choose_dep_dialog.vala \ choose_dep_dialog.vala \
history_dialog.vala \ history_dialog.vala \
packages_model.vala \ packages_model.vala \
aur_model.vala \
manager_window.vala \ manager_window.vala \
manager.vala manager.vala

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * pamac-vala
* *
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org> * Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,112 +18,163 @@
*/ */
namespace Alpm { namespace Alpm {
class Repo { [Compact]
public class Repo {
public string name; public string name;
public Signature.Level siglevel; public Signature.Level siglevel;
public Signature.Level siglevel_mask;
public DB.Usage usage; public DB.Usage usage;
public string[] urls; public GLib.List<string> urls;
public Repo (string name) { public Repo (string name) {
this.name = name; this.name = name;
siglevel = Signature.Level.USE_DEFAULT; siglevel = Signature.Level.USE_DEFAULT;
usage = 0; usage = 0;
urls = {}; urls = new GLib.List<string> ();
} }
public static int compare_name (Repo a, Repo b) {
return strcmp (a.name, b.name);
}
public static int search_name (Repo a, string name) {
return strcmp (a.name, name);
}
} }
[Compact]
public class Config { public class Config {
string conf_path; public string conf_path;
string rootdir; public string? rootdir;
string dbpath; public string? dbpath;
string gpgdir; public string? logfile;
string logfile; public string? gpgdir;
string arch; public string? arch;
double deltaratio; public double deltaratio;
int usesyslog; public int usesyslog;
public int checkspace; public int checkspace;
Alpm.List<string> *cachedirs; public Alpm.List<string>? cachedirs;
Alpm.List<string> *ignoregroups; public Alpm.List<string?>? hookdirs;
public Alpm.List<string> *ignorepkgs; public Alpm.List<string>? ignoregroups;
Alpm.List<string> *noextracts; public Alpm.List<string>? ignorepkgs;
Alpm.List<string> *noupgrades; public Alpm.List<string>? noextracts;
public GLib.List<string> holdpkgs; public Alpm.List<string>? noupgrades;
public GLib.List<string> syncfirsts; public GLib.List<string>? holdpkgs;
Signature.Level defaultsiglevel; public GLib.List<string>? syncfirsts;
Signature.Level localfilesiglevel; public Signature.Level siglevel;
Signature.Level remotefilesiglevel; public Signature.Level localfilesiglevel;
Repo[] repo_order; public Signature.Level remotefilesiglevel;
public unowned Handle? handle; public Signature.Level siglevel_mask;
public Signature.Level localfilesiglevel_mask;
public Signature.Level remotefilesiglevel_mask;
public GLib.List<Repo> repo_order;
public Handle? handle;
public Config (string path) { public Config (string path) {
conf_path = path; conf_path = path;
handle = null;
reload (); reload ();
} }
public void reload () { public void reload () {
// set default options // set default options
rootdir = "/";
dbpath = "/var/lib/pacman";
gpgdir = "/etc/pacman.d/gnupg/";
logfile = "/var/log/pacman.log";
string default_cachedir = "/var/cache/pacman/pkg/";
arch = Posix.utsname().machine;
holdpkgs = new GLib.List<string> (); holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> (); syncfirsts = new GLib.List<string> ();
Alpm.List.free_all (cachedirs); // free internal data of alpm lists
Alpm.List.free_all (ignoregroups); if (cachedirs != null) {
Alpm.List.free_all (ignorepkgs); cachedirs.free_data ();
Alpm.List.free_all (noextracts); }
Alpm.List.free_all (noupgrades); if (hookdirs != null) {
cachedirs = new Alpm.List<string> (); hookdirs.free_data ();
cachedirs->add_str (default_cachedir); }
ignoregroups = new Alpm.List<string> (); if (ignoregroups != null) {
ignorepkgs = new Alpm.List<string> (); ignoregroups.free_data ();
noextracts = new Alpm.List<string> (); }
noupgrades = new Alpm.List<string> (); if (ignorepkgs != null) {
ignorepkgs.free_data ();
}
if (noextracts != null) {
noextracts.free_data ();
}
if (noupgrades != null) {
noupgrades.free_data ();
}
usesyslog = 0; usesyslog = 0;
checkspace = 0; checkspace = 0;
deltaratio = 0.7; deltaratio = 0.7;
defaultsiglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL; siglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = Signature.Level.USE_DEFAULT; localfilesiglevel = Signature.Level.USE_DEFAULT;
remotefilesiglevel = Signature.Level.USE_DEFAULT; remotefilesiglevel = Signature.Level.USE_DEFAULT;
repo_order = {}; repo_order = new GLib.List<Repo> ();
// parse conf file // parse conf file
parse_file (conf_path); parse_file (conf_path);
// if rootdir is set and dbpath/logfile are not
// set, then set those as well to reside under the root.
if (rootdir != null) {
if (dbpath == null) {
dbpath = Path.build_path ("/", rootdir, "var/lib/pacman/");
}
if (logfile == null) {
logfile = Path.build_path ("/", rootdir, "var/log/pacman.log");
}
} else {
rootdir = "/";
if (dbpath == null) {
dbpath = "/var/lib/pacman/";
}
if (logfile == null) {
logfile = "/var/log/pacman.log";
}
}
if (cachedirs.length == 0) {
cachedirs.add ("/var/cache/pacman/pkg/");
}
if (hookdirs.length == 0) {
hookdirs.add ("/etc/pacman.d/hooks/");
}
if (gpgdir == null) {
// gpgdir it is not relative to rootdir, even if
// rootdir is defined because it contains configuration data.
gpgdir = "/etc/pacman.d/gnupg/";
}
if (arch == null) {
arch = Posix.utsname().machine;
}
} }
public void get_handle () { public void get_handle () {
Alpm.Errno error; Alpm.Errno error;
if (handle != null) {
Handle.release (handle);
}
handle = Handle.new (rootdir, dbpath, out error); handle = Handle.new (rootdir, dbpath, out error);
if (handle == null) { if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error))); stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return; return;
} }
// define options // define options
handle.gpgdir = gpgdir;
handle.logfile = logfile; handle.logfile = logfile;
handle.gpgdir = gpgdir;
handle.arch = arch; handle.arch = arch;
handle.deltaratio = deltaratio; handle.deltaratio = deltaratio;
handle.usesyslog = usesyslog; handle.usesyslog = usesyslog;
handle.checkspace = checkspace; handle.checkspace = checkspace;
handle.defaultsiglevel = defaultsiglevel; handle.defaultsiglevel = siglevel;
localfilesiglevel = merge_siglevel (defaultsiglevel, localfilesiglevel); localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask);
remotefilesiglevel = merge_siglevel (defaultsiglevel, remotefilesiglevel); remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask);
handle.localfilesiglevel = localfilesiglevel; handle.localfilesiglevel = localfilesiglevel;
handle.remotefilesiglevel = remotefilesiglevel; handle.remotefilesiglevel = remotefilesiglevel;
handle.cachedirs = cachedirs; handle.cachedirs = cachedirs;
// add hook directories 1-by-1 to avoid overwriting the system directory
foreach (unowned string hookdir in hookdirs) {
handle.add_hookdir (hookdir);
}
handle.ignoregroups = ignoregroups; handle.ignoregroups = ignoregroups;
handle.ignorepkgs = ignorepkgs; handle.ignorepkgs = ignorepkgs;
handle.noextracts = noextracts; handle.noextracts = noextracts;
handle.noupgrades = noupgrades; handle.noupgrades = noupgrades;
// register dbs // register dbs
foreach (var repo in repo_order) { foreach (unowned Repo repo in repo_order) {
repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel); unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (var url in repo.urls) { foreach (unowned string url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch)); db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
} }
if (repo.usage == 0) { if (repo.usage == 0) {
@ -158,21 +209,37 @@ namespace Alpm {
current_section = line[1:-1]; current_section = line[1:-1];
if (current_section != "options") { if (current_section != "options") {
var repo = new Repo (current_section); var repo = new Repo (current_section);
repo_order += repo; if (repo_order.find_custom (repo, Repo.compare_name) == null) {
repo_order.append ((owned) repo);
}
} }
continue; continue;
} }
splitted = line.split ("=", 2); splitted = line.split ("=", 2);
string key = splitted[0].strip (); unowned string key = splitted[0]._strip ();
string? val = null; unowned string? val = null;
if (splitted[1] != null) { if (splitted.length == 2) {
val = splitted[1].strip (); val = splitted[1]._strip ();
} }
if (key == "Include") { if (key == "Include") {
parse_file (val, current_section); parse_file (val, current_section);
} }
if (current_section == "options") { if (current_section == "options") {
if (key == "GPGDir") { if (key == "RootDir") {
rootdir = val;
} else if (key == "DBPath") {
dbpath = val;
} else if (key == "CacheDir") {
foreach (unowned string dir in val.split (" ")) {
cachedirs.add (dir);
}
} else if (key == "HookDir") {
foreach (unowned string dir in val.split (" ")) {
hookdirs.add (dir);
}
} else if (key == "LogFile") {
logfile = val;
} else if (key == "GPGDir") {
gpgdir = val; gpgdir = val;
} else if (key == "LogFile") { } else if (key == "LogFile") {
logfile = val; logfile = val;
@ -189,53 +256,46 @@ namespace Alpm {
} else if (key == "CheckSpace") { } else if (key == "CheckSpace") {
checkspace = 1; checkspace = 1;
} else if (key == "SigLevel") { } else if (key == "SigLevel") {
defaultsiglevel = define_siglevel (defaultsiglevel, val); process_siglevel (val, ref siglevel, ref siglevel_mask);
} else if (key == "LocalFileSigLevel") { } else if (key == "LocalFileSigLevel") {
localfilesiglevel = define_siglevel (localfilesiglevel, val); process_siglevel (val, ref localfilesiglevel, ref localfilesiglevel_mask);
} else if (key == "RemoteFileSigLevel") { } else if (key == "RemoteFileSigLevel") {
remotefilesiglevel = define_siglevel (remotefilesiglevel, val); process_siglevel (val, ref remotefilesiglevel, ref remotefilesiglevel_mask);
} else if (key == "HoldPkg") { } else if (key == "HoldPkg") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
holdpkgs.append (name); holdpkgs.append (name);
} }
} else if (key == "SyncFirst") { } else if (key == "SyncFirst") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
syncfirsts.append (name); syncfirsts.append (name);
} }
} else if (key == "CacheDir") {
foreach (string dir in val.split (" ")) {
cachedirs->add_str (dir);
}
} else if (key == "IgnoreGroup") { } else if (key == "IgnoreGroup") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
ignoregroups->add_str (name); ignoregroups.add (name);
} }
} else if (key == "IgnorePkg") { } else if (key == "IgnorePkg") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
ignorepkgs->add_str (name); ignorepkgs.add (name);
} }
} else if (key == "Noextract") { } else if (key == "Noextract") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
noextracts->add_str (name); noextracts.add (name);
} }
} else if (key == "NoUpgrade") { } else if (key == "NoUpgrade") {
foreach (string name in val.split (" ")) { foreach (unowned string name in val.split (" ")) {
noupgrades->add_str (name); noupgrades.add (name);
} }
} }
} else { } else {
foreach (var repo in repo_order) { unowned GLib.List<Repo>? found = repo_order.search (current_section, (SearchFunc) Repo.search_name);
if (repo.name == current_section) { if (found != null) {
if (key == "Server") { unowned Repo repo = found.data;
repo.urls += val; if (key == "Server") {
} else if (key == "SigLevel") { repo.urls.append (val);
if (repo.siglevel == Signature.Level.USE_DEFAULT) { } else if (key == "SigLevel") {
repo.siglevel = defaultsiglevel; process_siglevel (val, ref repo.siglevel, ref repo.siglevel_mask);
} } else if (key == "Usage") {
repo.siglevel = define_siglevel (repo.siglevel, val); repo.usage = define_usage (val);
} else if (key == "Usage") {
repo.usage = define_usage (val);
}
} }
} }
} }
@ -295,7 +355,7 @@ namespace Alpm {
file.delete (); file.delete ();
// creating a DataOutputStream to the file // creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) { foreach (unowned string new_line in data) {
// writing a short string to the stream // writing a short string to the stream
dos.put_string (new_line); dos.put_string (new_line);
} }
@ -309,7 +369,7 @@ namespace Alpm {
public DB.Usage define_usage (string conf_string) { public DB.Usage define_usage (string conf_string) {
DB.Usage usage = 0; DB.Usage usage = 0;
foreach (string directive in conf_string.split(" ")) { foreach (unowned string directive in conf_string.split(" ")) {
if (directive == "Sync") { if (directive == "Sync") {
usage |= DB.Usage.SYNC; usage |= DB.Usage.SYNC;
} else if (directive == "Search") { } else if (directive == "Search") {
@ -325,8 +385,8 @@ namespace Alpm {
return usage; return usage;
} }
public Signature.Level define_siglevel (Signature.Level default_level, string conf_string) { public void process_siglevel (string conf_string, ref Signature.Level siglevel, ref Signature.Level siglevel_mask) {
foreach (string directive in conf_string.split(" ")) { foreach (unowned string directive in conf_string.split(" ")) {
bool affect_package = false; bool affect_package = false;
bool affect_database = false; bool affect_database = false;
if ("Package" in directive) { if ("Package" in directive) {
@ -339,72 +399,62 @@ namespace Alpm {
} }
if ("Never" in directive) { if ("Never" in directive) {
if (affect_package) { if (affect_package) {
default_level &= ~Signature.Level.PACKAGE; siglevel &= ~Signature.Level.PACKAGE;
default_level |= Signature.Level.PACKAGE_SET; siglevel_mask |= Signature.Level.PACKAGE;
} }
if (affect_database) { if (affect_database) {
default_level &= ~Signature.Level.DATABASE; siglevel &= ~Signature.Level.DATABASE;
siglevel_mask |= Signature.Level.DATABASE;
} }
} else if ("Optional" in directive) { } else if ("Optional" in directive) {
if (affect_package) { if (affect_package) {
default_level |= Signature.Level.PACKAGE; siglevel |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
default_level |= Signature.Level.PACKAGE_OPTIONAL; siglevel_mask |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
default_level |= Signature.Level.PACKAGE_SET;
} }
if (affect_database) { if (affect_database) {
default_level |= Signature.Level.DATABASE; siglevel |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
default_level |= Signature.Level.DATABASE_OPTIONAL; siglevel_mask |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
} }
} else if ("Required" in directive) { } else if ("Required" in directive) {
if (affect_package) { if (affect_package) {
default_level |= Signature.Level.PACKAGE; siglevel |= Signature.Level.PACKAGE;
default_level &= ~Signature.Level.PACKAGE_OPTIONAL; siglevel_mask |= Signature.Level.PACKAGE;
default_level |= Signature.Level.PACKAGE_SET; siglevel &= ~Signature.Level.PACKAGE_OPTIONAL;
siglevel_mask |= Signature.Level.PACKAGE_OPTIONAL;
} }
if (affect_database) { if (affect_database) {
default_level |= Signature.Level.DATABASE; siglevel |= Signature.Level.DATABASE;
default_level &= ~Signature.Level.DATABASE_OPTIONAL; siglevel_mask |= Signature.Level.DATABASE;
siglevel &= ~Signature.Level.DATABASE_OPTIONAL;
siglevel_mask |= Signature.Level.DATABASE_OPTIONAL;
} }
} else if ("TrustedOnly" in directive) { } else if ("TrustedOnly" in directive) {
if (affect_package) { if (affect_package) {
default_level &= ~Signature.Level.PACKAGE_MARGINAL_OK; siglevel &= ~(Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
default_level &= ~Signature.Level.PACKAGE_UNKNOWN_OK; siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
default_level |= Signature.Level.PACKAGE_TRUST_SET;
} }
if (affect_database) { if (affect_database) {
default_level &= ~Signature.Level.DATABASE_MARGINAL_OK; siglevel &= ~(Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
default_level &= ~Signature.Level.DATABASE_UNKNOWN_OK; siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
} }
} else if ("TrustAll" in directive) { } else if ("TrustAll" in directive) {
if (affect_package) { if (affect_package) {
default_level |= Signature.Level.PACKAGE_MARGINAL_OK; siglevel |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
default_level |= Signature.Level.PACKAGE_UNKNOWN_OK; siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
default_level |= Signature.Level.PACKAGE_TRUST_SET;
} }
if (affect_database) { if (affect_database) {
default_level |= Signature.Level.DATABASE_MARGINAL_OK; siglevel |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
default_level |= Signature.Level.DATABASE_UNKNOWN_OK; siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
} }
} else { } else {
GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string); GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
} }
} }
default_level &= ~Signature.Level.USE_DEFAULT; siglevel &= ~Signature.Level.USE_DEFAULT;
return default_level;
} }
public Signature.Level merge_siglevel (Signature.Level base_level, Signature.Level over_level) { public Signature.Level merge_siglevel(Signature.Level sigbase, Signature.Level sigover, Signature.Level sigmask) {
if ((over_level & Signature.Level.USE_DEFAULT) == 0) { return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover;
if ((over_level & Signature.Level.PACKAGE_SET) == 0) {
over_level |= base_level & Signature.Level.PACKAGE;
over_level |= base_level & Signature.Level.PACKAGE_OPTIONAL;
}
if ((over_level & Signature.Level.PACKAGE_TRUST_SET) == 0) {
over_level |= base_level & Signature.Level.PACKAGE_MARGINAL_OK;
over_level |= base_level & Signature.Level.PACKAGE_UNKNOWN_OK;
}
}
return over_level;
} }
} }
} }

View File

@ -17,59 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) { public int compare_name (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return strcmp (pkg1.name, pkg2.name); return strcmp (pkg_a.name, pkg_b.name);
} }
public Alpm.List<unowned Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) { public int compare_state (Alpm.Package pkg_a, Alpm.Package pkg_b) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> (); return (int) (pkg_a.origin > pkg_b.origin) - (int) (pkg_a.origin < pkg_b.origin);
var result = handle.localdb.search (needles);
foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0)
syncpkgs = db.search (needles);
else {
syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
} }
public Alpm.List<unowned Alpm.Package?> group_pkgs (Alpm.Handle handle, string grp_name) { public int compare_version (Alpm.Package pkg_a, Alpm.Package pkg_b) {
var result = new Alpm.List<unowned Alpm.Package?> (); return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
unowned Alpm.Group? grp = handle.localdb.get_group (grp_name);
if (grp != null) {
foreach (var pkg in grp.packages)
result.add (pkg);
}
result.join (Alpm.find_group_pkgs (handle.syncdbs, grp_name).diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
} }
public Alpm.List<unowned Alpm.Package?> all_pkgs (Alpm.Handle handle) { public int compare_repo (Alpm.Package pkg_a, Alpm.Package pkg_b) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> (); return strcmp (pkg_a.db.name, pkg_b.db.name);
var result = new Alpm.List<unowned Alpm.Package?> (); }
result = handle.localdb.pkgcache.copy ();
public int compare_size (Alpm.Package pkg_a, Alpm.Package pkg_b) {
foreach (var db in handle.syncdbs) { return (int) (pkg_a.isize > pkg_b.isize) - (int) (pkg_a.isize < pkg_b.isize);
if (syncpkgs.length == 0)
syncpkgs = db.pkgcache.copy ();
else {
syncpkgs.join (db.pkgcache.diff (syncpkgs, (Alpm.List.CompareFunc) pkgcmp));
}
}
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) pkgcmp));
//result.sort ((Alpm.List.CompareFunc) pkgcmp);
return result;
} }

271
src/aur_model.vala Normal file
View File

@ -0,0 +1,271 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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/>.
*/
Pamac.ManagerWindow manager_window;
// custom sort functions
public int aur_compare_name (Json.Object pkg_a, Json.Object pkg_b) {
return strcmp (pkg_a.get_string_member ("Name"), pkg_b.get_string_member ("Name"));
}
public int aur_compare_state (Json.Object pkg_a, Json.Object pkg_b) {
unowned Alpm.Package? alpm_pkg_a = manager_window.alpm_config.handle.localdb.get_pkg (pkg_a.get_string_member ("Name"));
unowned Alpm.Package? alpm_pkg_b = manager_window.alpm_config.handle.localdb.get_pkg (pkg_b.get_string_member ("Name"));
if (pkg_a != null) {
if (pkg_b != null) {
return (int) (alpm_pkg_a.origin > alpm_pkg_b.origin) - (int) (alpm_pkg_a.origin < alpm_pkg_b.origin);
} else {
return 1;
}
} else {
if (pkg_b != null) {
return -1;
} else {
return 0;
}
}
}
public int aur_compare_version (Json.Object pkg_a, Json.Object pkg_b) {
return Alpm.pkg_vercmp (pkg_a.get_string_member ("Version"), pkg_b.get_string_member ("Version"));
}
public int aur_compare_votes (Json.Object pkg_a, Json.Object pkg_b) {
return (int) (pkg_a.get_int_member ("NumVotes") > pkg_b.get_int_member ("NumVotes")) - (int) (pkg_a.get_int_member ("NumVotes") < pkg_b.get_int_member ("NumVotes"));
}
namespace Pamac {
public class AURModel : Object, Gtk.TreeModel {
private Json.Array pkgs_infos;
private GLib.List<Json.Object?> pkgs;
public AURModel (Json.Array? pkgs_infos, ManagerWindow _manager_window) {
manager_window = _manager_window;
this.pkgs_infos = pkgs_infos;
pkgs = new GLib.List<Json.Object?> ();
if (pkgs_infos != null) {
pkgs_infos.foreach_element ((array, index, node) => {
pkgs.append (node.get_object ());
});
}
}
// TreeModel interface
public Type get_column_type (int index) {
switch (index) {
case 0: // name
case 2: // version
return typeof (string);
case 3: // votes
return typeof (int64);
case 1: // icon
return typeof (Gdk.Pixbuf);
default:
return Type.INVALID;
}
}
public Gtk.TreeModelFlags get_flags () {
return Gtk.TreeModelFlags.LIST_ONLY | Gtk.TreeModelFlags.ITERS_PERSIST;
}
public void get_value (Gtk.TreeIter iter, int column, out Value val) {
unowned Json.Object? pkg_info = pkgs.nth_data (iter.stamp);
switch (column) {
case 0:
val = Value (typeof (string));
if (pkg_info == null) {
val.set_string (dgettext (null, "No package found"));
} else {
val.set_string (pkg_info.get_string_member ("Name"));
}
break;
case 1:
val = Value (typeof (Object));
if (pkg_info != null) {
unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) {
if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon);
} else if (manager_window.transaction.to_remove.contains (pkg.name)) {
val.set_object (manager_window.to_remove_icon);
} else {
val.set_object (manager_window.installed_icon);
}
} else if (manager_window.transaction.to_build.contains (pkg_info.get_string_member ("Name"))) {
val.set_object (manager_window.to_install_icon);
} else {
val.set_object (manager_window.uninstalled_icon);
}
}
break;
case 2:
val = Value (typeof (string));
if (pkg_info != null) {
unowned Alpm.Package? pkg = manager_window.alpm_config.handle.localdb.get_pkg (pkg_info.get_string_member ("Name"));
if (pkg != null) {
val.set_string (pkg.version);
} else {
val.set_string (pkg_info.get_string_member ("Version"));
}
}
break;
case 3:
if (pkg_info != null) {
val = Value (typeof (int64));
val.set_int64 (pkg_info.get_int_member ("NumVotes"));
} else {
// if pkg_info is null, set val to an empty string to not display "0"
val = Value (typeof (string));
}
break;
default:
val = Value (Type.INVALID);
break;
}
}
public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
if (path.get_depth () != 1) {
return invalid_iter (out iter);
}
iter = Gtk.TreeIter ();
int pos = path.get_indices ()[0];
iter.stamp = pos;
return true;
}
public int get_n_columns () {
// name, icon, version, votes
return 4;
}
public Gtk.TreePath? get_path (Gtk.TreeIter iter) {
return new Gtk.TreePath.from_indices (iter.stamp);
}
public int iter_n_children (Gtk.TreeIter? iter) {
return 0;
}
public bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1;
if (pos >= pkgs.length ()) {
return false;
}
iter.stamp = pos;
return true;
}
public bool iter_previous (ref Gtk.TreeIter iter) {
int pos = iter.stamp;
if (pos >= 0) {
return false;
}
iter.stamp = (--pos);
return true;
}
public bool iter_nth_child (out Gtk.TreeIter iter, Gtk.TreeIter? parent, int n) {
return invalid_iter (out iter);
}
public bool iter_children (out Gtk.TreeIter iter, Gtk.TreeIter? parent) {
return invalid_iter (out iter);
}
public bool iter_has_child (Gtk.TreeIter iter) {
return false;
}
public bool iter_parent (out Gtk.TreeIter iter, Gtk.TreeIter child) {
return invalid_iter (out iter);
}
private bool invalid_iter (out Gtk.TreeIter iter) {
iter = Gtk.TreeIter ();
iter.stamp = -1;
return false;
}
// custom get pkg function
public unowned Json.Object? get_pkg_at_path (Gtk.TreePath path) {
return pkgs.nth_data (path.get_indices ()[0]);
}
public void sort_by_name (Gtk.SortType order) {
pkgs.sort ((GLib.CompareFunc) aur_compare_name);
if (order == Gtk.SortType.DESCENDING) {
pkgs.reverse ();
}
manager_window.aur_name_column.sort_order = order;
manager_window.aur_state_column.sort_indicator = false;
manager_window.aur_name_column.sort_indicator = true;
manager_window.aur_version_column.sort_indicator = false;
manager_window.aur_votes_column.sort_indicator = false;
manager_window.sortinfo.column_number = 0;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_state (Gtk.SortType order) {
pkgs.sort ((GLib.CompareFunc) aur_compare_state);
if (order == Gtk.SortType.DESCENDING) {
pkgs.reverse ();
}
manager_window.aur_state_column.sort_order = order;
manager_window.aur_state_column.sort_indicator = true;
manager_window.aur_name_column.sort_indicator = false;
manager_window.aur_version_column.sort_indicator = false;
manager_window.aur_votes_column.sort_indicator = false;
manager_window.sortinfo.column_number = 1;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_version (Gtk.SortType order) {
pkgs.sort ((GLib.CompareFunc) aur_compare_version);
if (order == Gtk.SortType.DESCENDING) {
pkgs.reverse ();
}
manager_window.aur_version_column.sort_order = order;
manager_window.aur_state_column.sort_indicator = false;
manager_window.aur_name_column.sort_indicator = false;
manager_window.aur_version_column.sort_indicator = true;
manager_window.aur_votes_column.sort_indicator = false;
manager_window.sortinfo.column_number = 2;
manager_window.sortinfo.sort_type = order;
}
public void sort_by_votes (Gtk.SortType order) {
pkgs.sort ((GLib.CompareFunc) aur_compare_votes);
if (order == Gtk.SortType.DESCENDING) {
pkgs.reverse ();
}
manager_window.aur_votes_column.sort_order = order;
manager_window.aur_state_column.sort_indicator = false;
manager_window.aur_name_column.sort_indicator = false;
manager_window.aur_version_column.sort_indicator = false;
manager_window.aur_votes_column.sort_indicator = true;
manager_window.sortinfo.column_number = 3;
manager_window.sortinfo.sort_type = order;
}
}
}

View File

@ -31,38 +31,20 @@ namespace Pamac {
public Gtk.ListStore deps_list; public Gtk.ListStore deps_list;
Transaction transaction; public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
public ChooseDependenciesDialog (Transaction transaction, string pkgname, Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction;
string[] optdeps = transaction.get_pkg_uninstalled_optdeps (pkgname);
label.set_markup ("<b>%s</b>".printf (
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 (pkgname, optdeps.length)));
deps_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string)); deps_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
treeview.set_model (deps_list); treeview.set_model (deps_list);
Gtk.TreeIter iter;
foreach (var optdep in optdeps) {
string[] split = optdep.split (":", 2);
deps_list.insert_with_values (out iter, -1,
0, false,
1, split[0],
2, split[1]);
}
} }
[GtkCallback] [GtkCallback]
void on_renderertoggle_toggled (string path) { void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter; Gtk.TreeIter iter;
GLib.Value val; GLib.Value selected;
bool selected;
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 selected);
selected = val.get_boolean (); deps_list.set_value (iter, 0, !((bool) selected));
deps_list.set_value (iter, 0, !selected);
} }
} }
} }

View File

@ -31,39 +31,21 @@ namespace Pamac {
public Gtk.ListStore pkgs_list; public Gtk.ListStore pkgs_list;
Transaction transaction; public ChooseIgnorepkgsDialog (Gtk.Window window) {
public ChooseIgnorepkgsDialog (Gtk.Window window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction;
label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose the packages you do not want to upgrade"))); label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose the packages you do not want to upgrade")));
pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string)); pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
treeview.set_model (pkgs_list); treeview.set_model (pkgs_list);
transaction.get_installed_pkgs.begin ((obj, res) => {
Pamac.Package[] pkgs = transaction.get_installed_pkgs.end (res);
Gtk.TreeIter iter;
string[] already_ignorepkgs = transaction.get_ignorepkgs ();
foreach (var pkg in pkgs) {
if (pkg.name in already_ignorepkgs) {
pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
} else {
pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
}
}
});
} }
[GtkCallback] [GtkCallback]
void on_renderertoggle_toggled (string path) { void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter; Gtk.TreeIter iter;
GLib.Value val; GLib.Value selected;
bool selected; if (pkgs_list.get_iter_from_string (out iter, path)) {
if (pkgs_list.get_iter_from_string (out iter, path)) {; pkgs_list.get_value (iter, 0, out selected);
pkgs_list.get_value (iter, 0, out val); pkgs_list.set_value (iter, 0, !((bool) selected));
selected = val.get_boolean ();
pkgs_list.set_value (iter, 0, !selected);
} }
} }
} }

View File

@ -27,14 +27,8 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.ComboBoxText comboboxtext; public Gtk.ComboBoxText comboboxtext;
public ChooseProviderDialog (string depend, string[] providers, Gtk.ApplicationWindow? window) { public ChooseProviderDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend)));
foreach (string provider in providers) {
comboboxtext.append_text (provider);
}
comboboxtext.active = 0;
} }
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
namespace Pamac { namespace Pamac {
public struct UpdateInfos { public struct PackageInfos {
public string name; public string name;
public string version; public string version;
public string db_name; public string db_name;
@ -27,13 +27,8 @@ namespace Pamac {
public struct Updates { public struct Updates {
public bool is_syncfirst; public bool is_syncfirst;
public UpdateInfos[] repos_updates; public PackageInfos[] repos_updates;
public UpdateInfos[] aur_updates; public PackageInfos[] aur_updates;
public Updates () {
is_syncfirst = false;
repos_updates = {};
aur_updates = {};
}
} }
public struct ErrorInfos { public struct ErrorInfos {

File diff suppressed because it is too large Load Diff

View File

@ -46,13 +46,13 @@ namespace Pamac {
transaction_info_dialog.hide (); transaction_info_dialog.hide ();
} else { } else {
transaction = new Pamac.Transaction (null); transaction = new Pamac.Transaction (null);
transaction.finished.connect (on_emit_trans_finished); transaction.finished.connect (on_transaction_finished);
this.hold (); this.hold ();
} }
} }
public override void activate () { public override void activate () {
if (pamac_run == false) { if (!pamac_run) {
print ("\nError: Path(s) of tarball(s) to install is needed\n"); print ("\nError: Path(s) of tarball(s) to install is needed\n");
transaction.stop_daemon (); transaction.stop_daemon ();
this.release (); this.release ();
@ -60,10 +60,9 @@ namespace Pamac {
} }
public override void open (File[] files, string hint) { public override void open (File[] files, string hint) {
if (pamac_run == false) { if (!pamac_run) {
foreach (File file in files) { foreach (unowned File file in files) {
string? path = file.get_path (); transaction.to_load.add (file.get_path ());
transaction.to_load.add ((owned) path);
} }
transaction.run (); transaction.run ();
} }
@ -92,7 +91,7 @@ namespace Pamac {
return run; return run;
} }
public void on_emit_trans_finished (bool error) { public void on_transaction_finished () {
transaction.stop_daemon (); transaction.stop_daemon ();
this.release (); this.release ();
} }

View File

@ -50,18 +50,17 @@ namespace Pamac {
} }
public override void activate () { public override void activate () {
if (pamac_run == false) { if (!pamac_run) {
manager_window.present (); manager_window.present ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
Gtk.main_iteration (); Gtk.main_iteration ();
} }
manager_window.show_all_pkgs ();
} }
} }
public override void shutdown () { public override void shutdown () {
base.shutdown (); base.shutdown ();
if (pamac_run == false) { if (!pamac_run) {
manager_window.transaction.stop_daemon (); manager_window.transaction.stop_daemon ();
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,10 @@
*/ */
namespace Alpm { namespace Alpm {
[Compact]
public class MirrorsConfig: Object { public class MirrorsConfig: Object {
string conf_path; public string conf_path;
string mirrorlists_dir; public string mirrorlists_dir;
public string choosen_generation_method; public string choosen_generation_method;
public string choosen_country; public string choosen_country;
public GLib.List<string> countrys; public GLib.List<string> countrys;
@ -47,9 +48,7 @@ namespace Alpm {
while ((file_info = enumerator.next_file ()) != null) { while ((file_info = enumerator.next_file ()) != null) {
countrys.append(file_info.get_name ()); countrys.append(file_info.get_name ());
} }
countrys.sort ((a, b) => { countrys.sort (strcmp);
return strcmp (a, b);
});
} catch (Error e) { } catch (Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
} }
@ -57,9 +56,7 @@ namespace Alpm {
public void parse_file (string path) { public void parse_file (string path) {
var file = GLib.File.new_for_path (path); var file = GLib.File.new_for_path (path);
if (file.query_exists () == false) { if (file.query_exists ()) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
} else {
try { try {
// Open file for reading and wrap returned FileInputStream into a // Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line // DataInputStream, so we can read line by line
@ -76,11 +73,11 @@ namespace Alpm {
if (line.length == 0) { if (line.length == 0) {
continue; continue;
} }
splitted = line.split ("="); splitted = line.split ("=", 2);
string key = splitted[0].strip (); unowned string key = splitted[0]._strip ();
string? val = null; unowned string? val = null;
if (splitted[1] != null) { if (splitted.length == 2) {
val = splitted[1].strip (); val = splitted[1]._strip ();
} }
if (key == "Method") { if (key == "Method") {
choosen_generation_method = val; choosen_generation_method = val;
@ -93,59 +90,60 @@ namespace Alpm {
} catch (Error e) { } catch (Error e) {
GLib.stderr.printf("%s\n", e.message); GLib.stderr.printf("%s\n", e.message);
} }
} else {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
} }
} }
public void write (HashTable<string,Variant> new_conf) { public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path); var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false) { if (file.query_exists ()) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
} else {
try { try {
// Open file for reading and wrap returned FileInputStream into a // Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line // DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ()); var dis = new DataInputStream (file.read ());
string? line; string? line;
string[] data = {}; var data = new GLib.List<string> ();
// Read lines until end of file (null) is reached // Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) { while ((line = dis.read_line ()) != null) {
if (line.length == 0) { if (line.length == 0) {
data += "\n"; data.append ("\n");
continue; continue;
} }
unowned Variant variant;
if (line.contains ("Method")) { if (line.contains ("Method")) {
if (new_conf.contains ("Method")) { if (new_conf.lookup_extended ("Method", null, out variant)) {
string val = new_conf.get ("Method").get_string (); data.append ("Method=%s\n".printf (variant.get_string ()));
data += "Method=%s\n".printf (val);
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("OnlyCountry")) { } else if (line.contains ("OnlyCountry")) {
if (new_conf.contains ("OnlyCountry")) { if (new_conf.lookup_extended ("OnlyCountry", null, out variant)) {
string val = new_conf.get ("OnlyCountry").get_string (); if (variant.get_string () == dgettext (null, "Worldwide")) {
if (val == dgettext (null, "Worldwide")) { data.append ("#%s\n".printf (line));
data += "#%s\n".printf (line);
} else { } else {
data += "OnlyCountry=%s\n".printf (val); data.append ("OnlyCountry=%s\n".printf (variant.get_string ()));
} }
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} }
// delete the file before rewrite it // delete the file before rewrite it
file.delete (); file.delete ();
// creating a DataOutputStream to the file // creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) { foreach (unowned string new_line in data) {
// writing a short string to the stream // writing a short string to the stream
dos.put_string (new_line); dos.put_string (new_line);
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message); GLib.stderr.printf("%s\n", e.message);
} }
} else {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
} }
} }
} }

View File

@ -31,12 +31,13 @@ namespace Pamac {
public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) { public Package (Alpm.Package? alpm_pkg, Json.Object? aur_json) {
if (alpm_pkg != null) { if (alpm_pkg != null) {
name = alpm_pkg.name ?? ""; name = alpm_pkg.name;
version = alpm_pkg.version ?? ""; version = alpm_pkg.version;
desc = alpm_pkg.desc ?? ""; desc = alpm_pkg.desc;
repo = (alpm_pkg.db != null ? (alpm_pkg.db.name ?? "") : ""); repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
size = alpm_pkg.isize; size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize); size_string = format_size (alpm_pkg.isize);
// alpm pkg url can be null
url = alpm_pkg.url ?? ""; url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder (); StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) { foreach (var license in alpm_pkg.licenses) {
@ -48,9 +49,9 @@ namespace Pamac {
licenses = licenses_build.str; licenses = licenses_build.str;
reason = alpm_pkg.reason; reason = alpm_pkg.reason;
} else if (aur_json != null ) { } else if (aur_json != null ) {
name = aur_json.get_string_member ("Name") ?? ""; name = aur_json.get_string_member ("Name");
version = aur_json.get_string_member ("Version") ?? ""; version = aur_json.get_string_member ("Version");
desc = aur_json.get_string_member ("Description") ?? ""; desc = aur_json.get_string_member ("Description");
repo = "AUR"; repo = "AUR";
size = 0; size = 0;
size_string = ""; size_string = "";
@ -73,15 +74,9 @@ namespace Pamac {
public struct PackageDetails { public struct PackageDetails {
string repo; string repo;
// for AUR package it is OutOfDate
string has_signature; string has_signature;
// for AUR package it is NumVotes
int reason; int reason;
// for AUR package it is Maintainer
string packager; string packager;
// for AUR package it is FirstSubmitted
string build_date;
// for AUR package it is LastModified
string install_date; string install_date;
string[] groups; string[] groups;
string[] backups; string[] backups;

View File

@ -20,21 +20,12 @@
namespace Pamac { namespace Pamac {
public class PackagesModel : Object, Gtk.TreeModel { public class PackagesModel : Object, Gtk.TreeModel {
private GLib.List<Pamac.Package?> all_pkgs; private Alpm.List<unowned Alpm.Package?>? pkgs;
public ManagerWindow manager_window; private ManagerWindow manager_window;
public PackagesModel (Pamac.Package[] pkgs, ManagerWindow manager_window) { public PackagesModel (owned Alpm.List<unowned Alpm.Package?>? pkgs, ManagerWindow manager_window) {
this.manager_window = manager_window; this.manager_window = manager_window;
all_pkgs = new GLib.List<Pamac.Package?> (); this.pkgs = (owned) pkgs;
foreach (var pkg in pkgs) {
all_pkgs.append (pkg);
}
if (all_pkgs.length () == 0) {
// create a fake "No package found" package
var fake_pkg = Pamac.Package (null, null);
fake_pkg.name = dgettext (null, "No package found");
all_pkgs.append (fake_pkg);
}
} }
// TreeModel interface // TreeModel interface
@ -57,16 +48,21 @@ namespace Pamac {
} }
public void get_value (Gtk.TreeIter iter, int column, out Value val) { public void get_value (Gtk.TreeIter iter, int column, out Value val) {
Pamac.Package pkg = all_pkgs.nth_data (iter.stamp); unowned Alpm.Package? pkg = pkgs.nth (iter.stamp).data;
switch (column) { switch (column) {
case 0: case 0:
val = Value (typeof (string)); val = Value (typeof (string));
val.set_string (pkg.name); if (pkg == null) {
val.set_string (dgettext (null, "No package found"));
} else {
val.set_string (pkg.name);
}
break; break;
case 1: case 1:
val = Value (typeof (Object)); val = Value (typeof (Object));
if (pkg.repo == "local") { if (pkg != null) {
if (manager_window.transaction.should_hold (pkg.name)) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
if (manager_window.alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
val.set_object (manager_window.locked_icon); val.set_object (manager_window.locked_icon);
} else if (manager_window.transaction.to_add.contains (pkg.name)) { } else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_reinstall_icon); val.set_object (manager_window.to_reinstall_icon);
@ -75,32 +71,30 @@ namespace Pamac {
} else { } else {
val.set_object (manager_window.installed_icon); val.set_object (manager_window.installed_icon);
} }
} else if (pkg.repo == "AUR") {
if (manager_window.transaction.to_build.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon);
} else {
val.set_object (manager_window.uninstalled_icon);
}
} else if (pkg.name == dgettext (null, "No package found")) {
// nothing to do
break;
} else if (manager_window.transaction.to_add.contains (pkg.name)) { } else if (manager_window.transaction.to_add.contains (pkg.name)) {
val.set_object (manager_window.to_install_icon); val.set_object (manager_window.to_install_icon);
} else { } else {
val.set_object (manager_window.uninstalled_icon); val.set_object (manager_window.uninstalled_icon);
} }
}
break; break;
case 2: case 2:
val = Value (typeof (string)); val = Value (typeof (string));
val.set_string (pkg.version); if (pkg != null) {
val.set_string (pkg.version);
}
break; break;
case 3: case 3:
val = Value (typeof (string)); val = Value (typeof (string));
val.set_string (pkg.repo); if (pkg != null) {
val.set_string (pkg.db.name);
}
break; break;
case 4: case 4:
val = Value (typeof (string)); val = Value (typeof (string));
val.set_string (pkg.size_string); if (pkg != null) {
val.set_string (format_size (pkg.isize));
}
break; break;
default: default:
val = Value (Type.INVALID); val = Value (Type.INVALID);
@ -109,7 +103,7 @@ namespace Pamac {
} }
public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {; public bool get_iter (out Gtk.TreeIter iter, Gtk.TreePath path) {;
if (path.get_depth () != 1 || all_pkgs.length () == 0) { if (path.get_depth () != 1) {
return invalid_iter (out iter); return invalid_iter (out iter);
} }
iter = Gtk.TreeIter (); iter = Gtk.TreeIter ();
@ -133,7 +127,7 @@ namespace Pamac {
public bool iter_next (ref Gtk.TreeIter iter) { public bool iter_next (ref Gtk.TreeIter iter) {
int pos = (iter.stamp) + 1; int pos = (iter.stamp) + 1;
if (pos >= all_pkgs.length ()) { if (pos >= pkgs.length) {
return false; return false;
} }
iter.stamp = pos; iter.stamp = pos;
@ -172,109 +166,82 @@ namespace Pamac {
} }
// custom get pkg function // custom get pkg function
public Pamac.Package get_pkg_at_path (Gtk.TreePath path) { public unowned Alpm.Package? get_pkg_at_path (Gtk.TreePath path) {
return all_pkgs.nth_data (path.get_indices ()[0]); return pkgs.nth (path.get_indices ()[0]).data;
} }
// custom sort functions // custom sort functions
public void sort_by_name (Gtk.SortType order) { public void sort_by_name (Gtk.SortType order) {
CompareFunc<Pamac.Package?> namecmp = (pkg_a, pkg_b) => { pkgs.sort ((Alpm.List.CompareFunc) compare_name);
return strcmp (pkg_a.name, pkg_b.name);
};
all_pkgs.sort (namecmp);
if (order == Gtk.SortType.DESCENDING) { if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse (); pkgs.reverse ();
} }
manager_window.name_column.sort_order = order; manager_window.packages_name_column.sort_order = order;
manager_window.state_column.sort_indicator = false; manager_window.packages_state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = true; manager_window.packages_name_column.sort_indicator = true;
manager_window.version_column.sort_indicator = false; manager_window.packages_version_column.sort_indicator = false;
manager_window.repo_column.sort_indicator = false; manager_window.packages_repo_column.sort_indicator = false;
manager_window.size_column.sort_indicator = false; manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 0; manager_window.sortinfo.column_number = 0;
manager_window.sortinfo.sort_type = order; manager_window.sortinfo.sort_type = order;
} }
public void sort_by_state (Gtk.SortType order) { public void sort_by_state (Gtk.SortType order) {
CompareFunc<Pamac.Package?> statecmp = (pkg_a, pkg_b) => { pkgs.sort ((Alpm.List.CompareFunc) compare_state);
int state_a;
int state_b;
if (pkg_a.repo == "local") {
state_a = 0;
} else {
state_a = 1;
}
if (pkg_b.repo == "local") {
state_b = 0;
} else {
state_b = 1;
}
return (int) (state_a > state_b) - (int) (state_a < state_b);
};
all_pkgs.sort (statecmp);
if (order == Gtk.SortType.DESCENDING) { if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse (); pkgs.reverse ();
} }
manager_window.state_column.sort_order = order; manager_window.packages_state_column.sort_order = order;
manager_window.state_column.sort_indicator = true; manager_window.packages_state_column.sort_indicator = true;
manager_window.name_column.sort_indicator = false; manager_window.packages_name_column.sort_indicator = false;
manager_window.version_column.sort_indicator = false; manager_window.packages_version_column.sort_indicator = false;
manager_window.repo_column.sort_indicator = false; manager_window.packages_repo_column.sort_indicator = false;
manager_window.size_column.sort_indicator = false; manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 1; manager_window.sortinfo.column_number = 1;
manager_window.sortinfo.sort_type = order; manager_window.sortinfo.sort_type = order;
} }
public void sort_by_version (Gtk.SortType order) { public void sort_by_version (Gtk.SortType order) {
CompareFunc<Pamac.Package?> versioncmp = (pkg_a, pkg_b) => { pkgs.sort ((Alpm.List.CompareFunc) compare_version);
return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
};
all_pkgs.sort (versioncmp);
if (order == Gtk.SortType.DESCENDING) { if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse (); pkgs.reverse ();
} }
manager_window.version_column.sort_order = order; manager_window.packages_version_column.sort_order = order;
manager_window.state_column.sort_indicator = false; manager_window.packages_state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false; manager_window.packages_name_column.sort_indicator = false;
manager_window.version_column.sort_indicator = true; manager_window.packages_version_column.sort_indicator = true;
manager_window.repo_column.sort_indicator = false; manager_window.packages_repo_column.sort_indicator = false;
manager_window.size_column.sort_indicator = false; manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 2; manager_window.sortinfo.column_number = 2;
manager_window.sortinfo.sort_type = order; manager_window.sortinfo.sort_type = order;
} }
public void sort_by_repo (Gtk.SortType order) { public void sort_by_repo (Gtk.SortType order) {
CompareFunc<Pamac.Package?> repocmp = (pkg_a, pkg_b) => { pkgs.sort ((Alpm.List.CompareFunc) compare_repo);
return strcmp (pkg_a.repo, pkg_b.repo);
};
all_pkgs.sort (repocmp);
if (order == Gtk.SortType.DESCENDING) { if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse (); pkgs.reverse ();
} }
manager_window.repo_column.sort_order = order; manager_window.packages_repo_column.sort_order = order;
manager_window.state_column.sort_indicator = false; manager_window.packages_state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false; manager_window.packages_name_column.sort_indicator = false;
manager_window.version_column.sort_indicator = false; manager_window.packages_version_column.sort_indicator = false;
manager_window.repo_column.sort_indicator = true; manager_window.packages_repo_column.sort_indicator = true;
manager_window.size_column.sort_indicator = false; manager_window.packages_size_column.sort_indicator = false;
manager_window.sortinfo.column_number = 3; manager_window.sortinfo.column_number = 3;
manager_window.sortinfo.sort_type = order; manager_window.sortinfo.sort_type = order;
} }
public void sort_by_size (Gtk.SortType order) { public void sort_by_size (Gtk.SortType order) {
CompareFunc<Pamac.Package?> sizecmp = (pkg_a, pkg_b) => { pkgs.sort ((Alpm.List.CompareFunc) compare_size);
return (int) (pkg_a.size > pkg_b.size) - (int) (pkg_a.size < pkg_b.size);
};
all_pkgs.sort (sizecmp);
if (order == Gtk.SortType.DESCENDING) { if (order == Gtk.SortType.DESCENDING) {
all_pkgs.reverse (); pkgs.reverse ();
} }
manager_window.size_column.sort_order = order; manager_window.packages_size_column.sort_order = order;
manager_window.state_column.sort_indicator = false; manager_window.packages_state_column.sort_indicator = false;
manager_window.name_column.sort_indicator = false; manager_window.packages_name_column.sort_indicator = false;
manager_window.version_column.sort_indicator = false; manager_window.packages_version_column.sort_indicator = false;
manager_window.repo_column.sort_indicator = false; manager_window.packages_repo_column.sort_indicator = false;
manager_window.size_column.sort_indicator = true; manager_window.packages_size_column.sort_indicator = true;
manager_window.sortinfo.column_number = 4; manager_window.sortinfo.column_number = 4;
manager_window.sortinfo.sort_type = order; manager_window.sortinfo.sort_type = order;
} }

View File

@ -17,19 +17,47 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
const string VERSION = "3.0.0";
namespace Pamac { namespace Pamac {
public class Config: Object { [Compact]
string conf_path; public class Config {
public string conf_path;
public bool recurse; public bool recurse;
public int refresh_period; public uint64 refresh_period;
public bool no_update_hide_icon; public bool no_update_hide_icon;
public bool enable_aur; public bool enable_aur;
public bool search_aur; public bool search_aur;
public bool check_aur_updates; public bool check_aur_updates;
public bool no_confirm_build; public bool no_confirm_build;
public HashTable<string,string> environment_variables;
public Config (string path) { public Config (string path) {
conf_path = path; conf_path = path;
//get environment variables
environment_variables = new HashTable<string,string> (str_hash, str_equal);
var utsname = Posix.utsname();
environment_variables.insert ("HTTP_USER_AGENT", "pamac/%s (%s %s)".printf (VERSION, utsname.sysname, utsname.machine));
unowned string? variable = Environment.get_variable ("http_proxy");
if (variable != null) {
environment_variables.insert ("http_proxy", variable);
}
variable = Environment.get_variable ("https_proxy");
if (variable != null) {
environment_variables.insert ("https_proxy", variable);
}
variable = Environment.get_variable ("ftp_proxy");
if (variable != null) {
environment_variables.insert ("ftp_proxy", variable);
}
variable = Environment.get_variable ("socks_proxy");
if (variable != null) {
environment_variables.insert ("socks_proxy", variable);
}
variable = Environment.get_variable ("no_proxy");
if (variable != null) {
environment_variables.insert ("no_proxy", variable);
}
// set default option // set default option
refresh_period = 6; refresh_period = 6;
reload (); reload ();
@ -65,16 +93,15 @@ namespace Pamac {
if (line.length == 0) { if (line.length == 0) {
continue; continue;
} }
splitted = line.split ("="); splitted = line.split ("=", 2);
string key = splitted[0].strip (); unowned string key = splitted[0]._strip ();
string? val = null;
if (splitted[1] != null) {
val = splitted[1].strip ();
}
if (key == "RemoveUnrequiredDeps") { if (key == "RemoveUnrequiredDeps") {
recurse = true; recurse = true;
} else if (key == "RefreshPeriod") { } else if (key == "RefreshPeriod") {
refresh_period = int.parse (val); if (splitted.length == 2) {
unowned string val = splitted[1]._strip ();
refresh_period = uint64.parse (val);
}
} else if (key == "NoUpdateHideIcon") { } else if (key == "NoUpdateHideIcon") {
no_update_hide_icon = true; no_update_hide_icon = true;
} else if (key == "EnableAUR") { } else if (key == "EnableAUR") {
@ -97,7 +124,7 @@ namespace Pamac {
public void write (HashTable<string,Variant> new_conf) { public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path); var file = GLib.File.new_for_path (conf_path);
string[] data = {}; var data = new GLib.List<string> ();
if (file.query_exists ()) { if (file.query_exists ()) {
try { try {
// Open file for reading and wrap returned FileInputStream into a // Open file for reading and wrap returned FileInputStream into a
@ -107,91 +134,85 @@ namespace Pamac {
// Read lines until end of file (null) is reached // Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) { while ((line = dis.read_line ()) != null) {
if (line.length == 0) { if (line.length == 0) {
data += "\n"; data.append ("\n");
continue; continue;
} }
unowned Variant variant;
if (line.contains ("RemoveUnrequiredDeps")) { if (line.contains ("RemoveUnrequiredDeps")) {
if (new_conf.contains ("RemoveUnrequiredDeps")) { if (new_conf.lookup_extended ("RemoveUnrequiredDeps", null, out variant)) {
bool val = new_conf.get ("RemoveUnrequiredDeps").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("RemoveUnrequiredDeps\n");
data += "RemoveUnrequiredDeps\n";
} else { } else {
data += "#RemoveUnrequiredDeps\n"; data.append ("#RemoveUnrequiredDeps\n");
} }
new_conf.remove ("RemoveUnrequiredDeps"); new_conf.remove ("RemoveUnrequiredDeps");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("RefreshPeriod")) { } else if (line.contains ("RefreshPeriod")) {
if (new_conf.contains ("RefreshPeriod")) { if (new_conf.lookup_extended ("RefreshPeriod", null, out variant)) {
int val = new_conf.get ("RefreshPeriod").get_int32 (); data.append ("RefreshPeriod = %llu\n".printf (variant.get_uint64 ()));
data += "RefreshPeriod = %u\n".printf (val);
new_conf.remove ("RefreshPeriod"); new_conf.remove ("RefreshPeriod");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("NoUpdateHideIcon")) { } else if (line.contains ("NoUpdateHideIcon")) {
if (new_conf.contains ("NoUpdateHideIcon")) { if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
bool val = new_conf.get ("NoUpdateHideIcon").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("NoUpdateHideIcon\n");
data += "NoUpdateHideIcon\n";
} else { } else {
data += "#NoUpdateHideIcon\n"; data.append ("#NoUpdateHideIcon\n");
} }
new_conf.remove ("NoUpdateHideIcon"); new_conf.remove ("NoUpdateHideIcon");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("EnableAUR")) { } else if (line.contains ("EnableAUR")) {
if (new_conf.contains ("EnableAUR")) { if (new_conf.lookup_extended ("EnableAUR", null, out variant)) {
bool val = new_conf.get ("EnableAUR").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("EnableAUR\n");
data += "EnableAUR\n";
} else { } else {
data += "#EnableAUR\n"; data.append ("#EnableAUR\n");
} }
new_conf.remove ("EnableAUR"); new_conf.remove ("EnableAUR");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("SearchInAURByDefault")) { } else if (line.contains ("SearchInAURByDefault")) {
if (new_conf.contains ("SearchInAURByDefault")) { if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) {
bool val = new_conf.get ("SearchInAURByDefault").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("SearchInAURByDefault\n");
data += "SearchInAURByDefault\n";
} else { } else {
data += "#SearchInAURByDefault\n"; data.append ("#SearchInAURByDefault\n");
} }
new_conf.remove ("SearchInAURByDefault"); new_conf.remove ("SearchInAURByDefault");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("CheckAURUpdates")) { } else if (line.contains ("CheckAURUpdates")) {
if (new_conf.contains ("CheckAURUpdates")) { if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) {
bool val = new_conf.get ("CheckAURUpdates").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("CheckAURUpdates\n");
data += "CheckAURUpdates\n";
} else { } else {
data += "#CheckAURUpdates\n"; data.append ("#CheckAURUpdates\n");
} }
new_conf.remove ("CheckAURUpdates"); new_conf.remove ("CheckAURUpdates");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else if (line.contains ("NoConfirmBuild")) { } else if (line.contains ("NoConfirmBuild")) {
if (new_conf.contains ("NoConfirmBuild")) { if (new_conf.lookup_extended ("NoConfirmBuild", null, out variant)) {
bool val = new_conf.get ("NoConfirmBuild").get_boolean (); if (variant.get_boolean ()) {
if (val == true) { data.append ("NoConfirmBuild\n");
data += "NoConfirmBuild\n";
} else { } else {
data += "#NoConfirmBuild\n"; data.append ("#NoConfirmBuild\n");
} }
new_conf.remove ("NoConfirmBuild"); new_conf.remove ("NoConfirmBuild");
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} else { } else {
data += line + "\n"; data.append (line + "\n");
} }
} }
// delete the file before rewrite it // delete the file before rewrite it
@ -204,54 +225,57 @@ namespace Pamac {
} }
// create lines for unexisted options // create lines for unexisted options
if (new_conf.size () != 0) { if (new_conf.size () != 0) {
data += "\n"; data.append ("\n");
new_conf.foreach ((key, val) => { var iter = HashTableIter<string,Variant> (new_conf);
unowned string key;
unowned Variant val;
while (iter.next (out key, out val)) {
if (key == "RemoveUnrequiredDeps") { if (key == "RemoveUnrequiredDeps") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "RemoveUnrequiredDeps\n"; data.append ("RemoveUnrequiredDeps\n");
} else { } else {
data += "#RemoveUnrequiredDeps\n"; data.append ("#RemoveUnrequiredDeps\n");
} }
} else if (key == "RefreshPeriod") { } else if (key == "RefreshPeriod") {
data += "RefreshPeriod = %u\n".printf (val.get_int32 ()); data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ()));
} else if (key =="NoUpdateHideIcon") { } else if (key =="NoUpdateHideIcon") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "NoUpdateHideIcon\n"; data.append ("NoUpdateHideIcon\n");
} else { } else {
data += "#NoUpdateHideIcon\n"; data.append ("#NoUpdateHideIcon\n");
} }
} else if (key == "EnableAUR") { } else if (key == "EnableAUR") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "EnableAUR\n"; data.append ("EnableAUR\n");
} else { } else {
data += "#EnableAUR\n"; data.append ("#EnableAUR\n");
} }
} else if (key == "SearchInAURByDefault") { } else if (key == "SearchInAURByDefault") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "SearchInAURByDefault\n"; data.append ("SearchInAURByDefault\n");
} else { } else {
data += "#SearchInAURByDefault\n"; data.append ("#SearchInAURByDefault\n");
} }
} else if (key == "CheckAURUpdates") { } else if (key == "CheckAURUpdates") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "CheckAURUpdates\n"; data.append ("CheckAURUpdates\n");
} else { } else {
data += "#CheckAURUpdates\n"; data.append ("#CheckAURUpdates\n");
} }
} else if (key == "NoConfirmBuild") { } else if (key == "NoConfirmBuild") {
if (val.get_boolean () == true) { if (val.get_boolean ()) {
data += "NoConfirmBuild\n"; data.append ("NoConfirmBuild\n");
} else { } else {
data += "#NoConfirmBuild\n"; data.append ("#NoConfirmBuild\n");
} }
} }
}); }
} }
// write the file // write the file
try { try {
// creating a DataOutputStream to the file // creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) { foreach (unowned string new_line in data) {
// writing a short string to the stream // writing a short string to the stream
dos.put_string (new_line); dos.put_string (new_line);
} }

View File

@ -60,17 +60,22 @@ namespace Pamac {
public Gtk.CheckButton no_confirm_build_checkbutton; public Gtk.CheckButton no_confirm_build_checkbutton;
Transaction transaction; Transaction transaction;
int previous_refresh_period; Alpm.Config alpm_config;
uint64 previous_refresh_period;
public PreferencesDialog (Transaction transaction, Gtk.ApplicationWindow? window) { public PreferencesDialog (Gtk.ApplicationWindow? window, Transaction transaction) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction; this.transaction = transaction;
alpm_config = new Alpm.Config ("/etc/pacman.conf");
alpm_config.get_handle ();
if (alpm_config.handle == null) {
stderr.printf (dgettext (null, "Failed to initialize alpm library"));
}
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":"); refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); remove_unrequired_deps_button.active = transaction.pamac_config.recurse;
remove_unrequired_deps_button.active = pamac_config.recurse; check_space_button.active = (alpm_config.checkspace == 1);
check_space_button.active = transaction.get_checkspace (); if (transaction.pamac_config.refresh_period == 0) {
if (pamac_config.refresh_period == 0) {
check_updates_button.active = false; check_updates_button.active = false;
refresh_period_label.sensitive = false; refresh_period_label.sensitive = false;
// set default value // set default value
@ -81,15 +86,15 @@ namespace Pamac {
ignorepkgs_box.sensitive = false; ignorepkgs_box.sensitive = false;
} else { } else {
check_updates_button.active = true; check_updates_button.active = true;
refresh_period_spin_button.value = pamac_config.refresh_period; refresh_period_spin_button.value = transaction.pamac_config.refresh_period;
previous_refresh_period = pamac_config.refresh_period; previous_refresh_period = transaction.pamac_config.refresh_period;
} }
no_update_hide_icon_checkbutton.active = pamac_config.no_update_hide_icon; no_update_hide_icon_checkbutton.active = transaction.pamac_config.no_update_hide_icon;
// populate ignorepkgs_liststore // populate ignorepkgs_liststore
Gtk.TreeIter iter; Gtk.TreeIter iter;
foreach (var name in transaction.get_ignorepkgs ()) { for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name); ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
} }
remove_unrequired_deps_button.state_set.connect (on_remove_unrequired_deps_button_state_set); remove_unrequired_deps_button.state_set.connect (on_remove_unrequired_deps_button_state_set);
check_space_button.state_set.connect (on_check_space_button_state_set); check_space_button.state_set.connect (on_check_space_button_state_set);
@ -98,8 +103,8 @@ namespace Pamac {
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled); no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
Pamac.Package pkg = this.transaction.find_local_satisfier ("pacman-mirrorlist"); unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "pacman-mirrorlist");
if (pkg.name == "") { if (pkg == null) {
mirrors_config_box.visible = false; mirrors_config_box.visible = false;
} else { } else {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf"); var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
@ -107,7 +112,7 @@ namespace Pamac {
mirrors_country_comboboxtext.active = 0; mirrors_country_comboboxtext.active = 0;
int index = 1; int index = 1;
mirrors_config.get_countrys (); mirrors_config.get_countrys ();
foreach (string country in mirrors_config.countrys) { foreach (unowned string country in mirrors_config.countrys) {
mirrors_country_comboboxtext.append_text (country); mirrors_country_comboboxtext.append_text (country);
if (country == mirrors_config.choosen_country) { if (country == mirrors_config.choosen_country) {
mirrors_country_comboboxtext.active = index; mirrors_country_comboboxtext.active = index;
@ -126,17 +131,17 @@ namespace Pamac {
transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished); transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
} }
pkg = this.transaction.find_local_satisfier ("yaourt"); pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
if (pkg.name == "") { if (pkg == null) {
aur_config_box.visible = false; aur_config_box.visible = false;
} else { } else {
enable_aur_button.active = pamac_config.enable_aur; enable_aur_button.active = transaction.pamac_config.enable_aur;
search_aur_checkbutton.active = pamac_config.search_aur; search_aur_checkbutton.active = transaction.pamac_config.search_aur;
search_aur_checkbutton.sensitive = pamac_config.enable_aur; search_aur_checkbutton.sensitive = transaction.pamac_config.enable_aur;
check_aur_updates_checkbutton.active = pamac_config.check_aur_updates; check_aur_updates_checkbutton.active = transaction.pamac_config.check_aur_updates;
check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur; check_aur_updates_checkbutton.sensitive = transaction.pamac_config.enable_aur;
no_confirm_build_checkbutton.active = pamac_config.no_confirm_build; no_confirm_build_checkbutton.active = transaction.pamac_config.no_confirm_build;
no_confirm_build_checkbutton.sensitive = pamac_config.enable_aur; no_confirm_build_checkbutton.sensitive = transaction.pamac_config.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set); enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled); search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled);
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled); check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
@ -158,10 +163,10 @@ namespace Pamac {
refresh_period_spin_button.sensitive = new_state; refresh_period_spin_button.sensitive = new_state;
no_update_hide_icon_checkbutton.sensitive = new_state; no_update_hide_icon_checkbutton.sensitive = new_state;
ignorepkgs_box.sensitive = new_state; ignorepkgs_box.sensitive = new_state;
if (new_state == true) { if (new_state) {
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (previous_refresh_period)); new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (previous_refresh_period));
} else { } else {
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (0)); new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (0));
} }
transaction.start_write_pamac_config (new_pamac_conf); transaction.start_write_pamac_config (new_pamac_conf);
return true; return true;
@ -204,7 +209,7 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf); transaction.start_write_pamac_config (new_pamac_conf);
} }
void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon, void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) { bool no_confirm_build) {
remove_unrequired_deps_button.state = recurse; remove_unrequired_deps_button.state = recurse;
@ -248,7 +253,15 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
void on_add_ignorepkgs_button_clicked () { void on_add_ignorepkgs_button_clicked () {
var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this, transaction); var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this);
foreach (var pkg in alpm_config.handle.localdb.pkgcache) {
Gtk.TreeIter iter;
if (alpm_config.ignorepkgs.find_str (pkg.name) == null) {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
} else {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
}
}
if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) { if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) {
var ignorepkg_string = new StringBuilder (); var ignorepkg_string = new StringBuilder ();
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => { choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
@ -257,7 +270,7 @@ namespace Pamac {
bool selected = val.get_boolean (); bool selected = val.get_boolean ();
if (selected) { if (selected) {
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 1, out val); choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 1, out val);
string name = val.get_string (); unowned string name = val.get_string ();
if (ignorepkg_string.len != 0) { if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" "); ignorepkg_string.append (" ");
} }
@ -287,7 +300,7 @@ namespace Pamac {
ignorepkgs_liststore.foreach ((model, path, iter) => { ignorepkgs_liststore.foreach ((model, path, iter) => {
GLib.Value val; GLib.Value val;
ignorepkgs_liststore.get_value (iter, 0, out val); ignorepkgs_liststore.get_value (iter, 0, out val);
string name = val.get_string (); unowned string name = val.get_string ();
if (ignorepkg_string.len != 0) { if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" "); ignorepkg_string.append (" ");
} }
@ -305,8 +318,8 @@ namespace Pamac {
// re-populate ignorepkgs_liststore // re-populate ignorepkgs_liststore
Gtk.TreeIter iter; Gtk.TreeIter iter;
ignorepkgs_liststore.clear (); ignorepkgs_liststore.clear ();
foreach (var name in transaction.get_ignorepkgs ()) { for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name); ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
} }
} }
@ -331,7 +344,7 @@ namespace Pamac {
mirrors_country_comboboxtext.model.foreach ((model, path, iter) => { mirrors_country_comboboxtext.model.foreach ((model, path, iter) => {
GLib.Value val; GLib.Value val;
model.get_value (iter, 0, out val); model.get_value (iter, 0, out val);
string country = val.get_string (); unowned string country = val.get_string ();
if (choosen_country == country) { if (choosen_country == country) {
return true; return true;
} }

View File

@ -33,14 +33,12 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.Expander expander; public Gtk.Expander expander;
Transaction transaction;
public Vte.Terminal term; public Vte.Terminal term;
Vte.Pty pty; Vte.Pty pty;
public ProgressDialog (Transaction transaction, Gtk.ApplicationWindow? window) { public ProgressDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0); Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction;
//creating terminal //creating terminal
term = new Vte.Terminal (); term = new Vte.Terminal ();
term.scroll_on_output = false; term.scroll_on_output = false;
@ -72,18 +70,6 @@ namespace Pamac {
} }
} }
[GtkCallback]
public void on_cancel_button_clicked () {
transaction.cancel ();
transaction.clear_lists ();
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
this.hide ();
transaction.finished (false);
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
}
public void spawn_in_term (string[] args, out Pid child_pid = null) { public void spawn_in_term (string[] args, out Pid child_pid = null) {
Pid intern_pid; Pid intern_pid;
try { try {

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * pamac-vala
* *
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org> * Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -24,10 +24,10 @@ 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) throws IOError; public abstract void start_refresh (bool force) throws IOError;
[DBus (no_reply = true)] [DBus (no_reply = true)]
public abstract void quit () throws IOError; public abstract void quit () throws IOError;
public signal void refresh_finished (ErrorInfos error); public signal void refresh_finished (bool success);
} }
} }
@ -84,10 +84,9 @@ int main () {
if (pamac_config.refresh_period != 0) { if (pamac_config.refresh_period != 0) {
if (!check_pamac_running ()) { if (!check_pamac_running ()) {
try { try {
pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
"/org/manjaro/pamac");
pamac_daemon.refresh_finished.connect (on_refresh_finished); pamac_daemon.refresh_finished.connect (on_refresh_finished);
pamac_daemon.start_refresh (0); pamac_daemon.start_refresh (false);
loop = new MainLoop (); loop = new MainLoop ();
loop.run (); loop.run ();
} catch (IOError e) { } catch (IOError e) {

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * pamac-vala
* *
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org> * Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,12 +27,12 @@ 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) throws IOError; public abstract void start_refresh (bool force) throws IOError;
public abstract async Updates get_updates (bool check_aur_updates) throws IOError; public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)] [DBus (no_reply = true)]
public abstract void quit () throws IOError; public abstract void quit () throws IOError;
public signal void refresh_finished (ErrorInfos error); public signal void get_updates_finished (Updates updates);
public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon, public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates, bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build); bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace); public signal void write_alpm_config_finished (bool checkspace);
@ -40,6 +40,7 @@ namespace Pamac {
public class TrayIcon: Gtk.Application { public class TrayIcon: Gtk.Application {
Notify.Notification notification; Notify.Notification notification;
//~ Notification notification;
Daemon daemon; Daemon daemon;
bool extern_lock; bool extern_lock;
uint refresh_timeout_id; uint refresh_timeout_id;
@ -54,9 +55,9 @@ namespace Pamac {
void start_daemon () { void start_daemon () {
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");
// Connecting to signals // Connecting to signals
daemon.get_updates_finished.connect (on_get_updates_finished);
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished); daemon.write_alpm_config_finished.connect (on_write_alpm_config_finished);
} catch (IOError e) { } catch (IOError e) {
@ -65,7 +66,7 @@ namespace Pamac {
} }
void stop_daemon () { void stop_daemon () {
if (check_pamac_running () == false) { if (!check_pamac_running ()) {
try { try {
daemon.quit (); daemon.quit ();
} catch (IOError e) { } catch (IOError e) {
@ -128,7 +129,7 @@ namespace Pamac {
check_updates (); check_updates ();
} else { } else {
try { try {
daemon.start_refresh (0); daemon.start_refresh (false);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
@ -136,10 +137,8 @@ namespace Pamac {
return true; return true;
} }
void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon, void on_write_pamac_config_finished (bool recurse, uint64 refresh_period) {
bool enable_aur, bool search_aur, bool check_aur_updates, launch_refresh_timeout (refresh_period);
bool no_confirm_build) {
launch_refresh_timeout ((uint) refresh_period);
if (refresh_period == 0) { if (refresh_period == 0) {
status_icon.visible = false; status_icon.visible = false;
} else { } else {
@ -151,36 +150,40 @@ namespace Pamac {
check_updates (); check_updates ();
} }
void on_get_updates_finished (Updates updates) {
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
if (updates_nb == 0) {
this.update_icon (noupdate_icon_name, noupdate_info);
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.no_update_hide_icon) {
status_icon.visible = false;
} else {
status_icon.visible = true;
}
close_notification();
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
this.update_icon (update_icon_name, info);
status_icon.visible = true;
if (check_pamac_running ()) {
update_notification (info);
} else {
show_notification (info);
}
}
stop_daemon ();
}
void check_updates () { void check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.refresh_period == 0) { if (pamac_config.refresh_period == 0) {
return; return;
} }
daemon.get_updates.begin ((pamac_config.enable_aur && pamac_config.check_aur_updates), (obj, res) => { try {
var updates = Updates (); daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
try { } catch (IOError e) {
updates = daemon.get_updates.end (res); stderr.printf ("IOError: %s\n", e.message);
} catch (IOError e) { }
stderr.printf ("IOError: %s\n", e.message);
}
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
if (updates_nb == 0) {
this.update_icon (noupdate_icon_name, noupdate_info);
if (pamac_config.no_update_hide_icon) {
status_icon.visible = false;
} else {
status_icon.visible = true;
}
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
this.update_icon (update_icon_name, info);
status_icon.visible = true;
if (check_pamac_running () == false) {
show_notification (info);
}
}
stop_daemon ();
});
} }
void show_notification (string info) { void show_notification (string info) {
@ -193,16 +196,44 @@ namespace Pamac {
//~ action.activate.connect (execute_updater); //~ action.activate.connect (execute_updater);
//~ this.add_action (action); //~ this.add_action (action);
//~ notification.add_button (_("Show available updates"), "app.update"); //~ notification.add_button (_("Show available updates"), "app.update");
//~ notification.set_default_action ("app.update");
//~ this.send_notification (_("Update Manager"), notification); //~ this.send_notification (_("Update Manager"), notification);
try { try {
close_notification();
notification = new Notify.Notification (_("Update Manager"), info, "system-software-update"); notification = new Notify.Notification (_("Update Manager"), info, "system-software-update");
notification.add_action ("update", _("Show available updates"), execute_updater); notification.add_action ("default", _("Show available updates"), execute_updater);
notification.show (); notification.show ();
} catch (Error e) { } catch (Error e) {
stderr.printf ("Notify Error: %s", e.message); stderr.printf ("Notify Error: %s", e.message);
} }
} }
void update_notification (string info) {
try {
if (notification != null) {
if (notification.get_closed_reason() == -1 && notification.body != info) {
notification.update (_("Update Manager"), info, "system-software-update");
notification.show ();
}
} else {
show_notification (info);
}
} catch (Error e) {
stderr.printf ("Notify Error: %s", e.message);
}
}
void close_notification () {
try {
if (notification != null) {
notification.close();
notification = null;
}
} catch (Error e) {
stderr.printf ("Notify Error: %s", e.message);
}
}
bool check_pamac_running () { bool check_pamac_running () {
Application app; Application app;
bool run = false; bool run = false;
@ -238,7 +269,7 @@ namespace Pamac {
bool check_pacman_running () { bool check_pacman_running () {
if (extern_lock) { if (extern_lock) {
if (lockfile.query_exists () == false) { if (!lockfile.query_exists ()) {
extern_lock = 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, () => {
@ -247,20 +278,20 @@ namespace Pamac {
}); });
} }
} else { } else {
if (lockfile.query_exists () == true) { if (lockfile.query_exists ()) {
extern_lock = true; extern_lock = true;
} }
} }
return true; return true;
} }
void launch_refresh_timeout (uint refresh_period_in_hours) { void launch_refresh_timeout (uint64 refresh_period_in_hours) {
if (refresh_timeout_id != 0) { if (refresh_timeout_id != 0) {
Source.remove (refresh_timeout_id); Source.remove (refresh_timeout_id);
refresh_timeout_id = 0; refresh_timeout_id = 0;
} }
if (refresh_period_in_hours != 0) { if (refresh_period_in_hours != 0) {
refresh_timeout_id = Timeout.add_seconds (refresh_period_in_hours*3600, start_refresh); refresh_timeout_id = Timeout.add_seconds ((uint) refresh_period_in_hours*3600, start_refresh);
} }
} }
@ -293,9 +324,9 @@ namespace Pamac {
alpm_config.get_handle (); alpm_config.get_handle ();
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile); lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
start_daemon (); start_daemon ();
Timeout.add (500, check_pacman_running); Timeout.add (200, check_pacman_running);
start_refresh (); start_refresh ();
launch_refresh_timeout ((uint) pamac_config.refresh_period); launch_refresh_timeout (pamac_config.refresh_period);
this.hold (); this.hold ();
} }

View File

@ -50,14 +50,14 @@ namespace Pamac {
} }
public override void activate () { public override void activate () {
if (pamac_run == false) { if (!pamac_run) {
updater_window.present (); updater_window.present ();
} }
} }
public override void shutdown () { public override void shutdown () {
base.shutdown (); base.shutdown ();
if (pamac_run == false) { if (!pamac_run) {
updater_window.transaction.stop_daemon (); updater_window.transaction.stop_daemon ();
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* pamac-vala * pamac-vala
* *
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org> * Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,58 +25,114 @@ namespace Pamac {
[GtkChild] [GtkChild]
public Gtk.Label top_label; public Gtk.Label top_label;
[GtkChild] [GtkChild]
public Gtk.TreeView updates_treeview; public Gtk.Notebook notebook;
[GtkChild] [GtkChild]
public Gtk.CellRendererToggle select_update; public Gtk.ScrolledWindow repos_scrolledwindow;
[GtkChild]
public Gtk.ScrolledWindow aur_scrolledwindow;
[GtkChild]
public Gtk.TreeView repos_updates_treeview;
[GtkChild]
public Gtk.CellRendererToggle repos_select_update;
[GtkChild]
public Gtk.TreeView aur_updates_treeview;
[GtkChild]
public Gtk.CellRendererToggle aur_select_update;
[GtkChild] [GtkChild]
public Gtk.Label bottom_label; public Gtk.Label bottom_label;
[GtkChild] [GtkChild]
public Gtk.Button apply_button; public Gtk.Button apply_button;
public Gtk.ListStore updates_list; public Gtk.ListStore repos_updates_list;
public Gtk.ListStore aur_updates_list;
public Pamac.Transaction transaction; public Pamac.Transaction transaction;
public UpdaterWindow (Gtk.Application application) { public UpdaterWindow (Gtk.Application application) {
Object (application: application); Object (application: application);
updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string)); repos_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
updates_treeview.set_model (updates_list); repos_updates_treeview.set_model (repos_updates_list);
aur_updates_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
aur_updates_treeview.set_model (aur_updates_list);
transaction = new Transaction (this as Gtk.ApplicationWindow); transaction = new Transaction (this as Gtk.ApplicationWindow);
transaction.mode = Mode.UPDATER; transaction.mode = Mode.UPDATER;
transaction.finished.connect (on_transaction_finished); transaction.finished.connect (on_transaction_finished);
transaction.daemon.get_updates_finished.connect (on_get_updates_finished);
bottom_label.set_visible (false); bottom_label.set_visible (false);
apply_button.set_sensitive (false); apply_button.set_sensitive (false);
notebook.set_show_tabs (false);
aur_scrolledwindow.set_visible (false);
on_refresh_button_clicked (); on_refresh_button_clicked ();
} }
public void set_apply_button_sensitive () {
bool sensitive = false;
repos_updates_list.foreach ((model, path, iter) => {
GLib.Value selected;
repos_updates_list.get_value (iter, 0, out selected);
sensitive = (bool) selected;
return sensitive;
});
if (!sensitive) {
aur_updates_list.foreach ((model, path, iter) => {
GLib.Value selected;
aur_updates_list.get_value (iter, 0, out selected);
sensitive = (bool) selected;
return sensitive;
});
}
apply_button.set_sensitive (sensitive);
}
[GtkCallback] [GtkCallback]
public void on_select_update_toggled (string path) { public void on_repos_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path); Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter; Gtk.TreeIter iter;
updates_list.get_iter (out iter, treepath); GLib.Value name_string;
updates_list.set (iter, 0, !select_update.active); repos_updates_list.get_iter (out iter, treepath);
updates_list.foreach ((model, path, iter) => { repos_updates_list.get_value (iter, 1, out name_string);
GLib.Value val; // string has the form "pkgname pkgversion"
updates_list.get_value (iter, 0, out val); string pkgname = name_string.get_string ().split (" ", 2)[0];
bool selected = val.get_boolean (); if (repos_select_update.active) {
if (selected) { repos_updates_list.set (iter, 0, false);
apply_button.set_sensitive (true); transaction.special_ignorepkgs.add (pkgname);
return true; } else {
} repos_updates_list.set (iter, 0, true);
apply_button.set_sensitive (false); transaction.special_ignorepkgs.remove (pkgname);
return false; }
}); set_apply_button_sensitive ();
}
[GtkCallback]
public void on_aur_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
GLib.Value name_string;
aur_updates_list.get_iter (out iter, treepath);
aur_updates_list.get_value (iter, 1, out name_string);
// string has the form "pkgname pkgversion"
string pkgname = name_string.get_string ().split (" ", 2)[0];
if (aur_select_update.active) {
aur_updates_list.set (iter, 0, false);
transaction.special_ignorepkgs.add (pkgname);
} else {
aur_updates_list.set (iter, 0, true);
transaction.special_ignorepkgs.remove (pkgname);
}
set_apply_button_sensitive ();
} }
public async void run_preferences_dialog () { public async void run_preferences_dialog () {
SourceFunc callback = run_preferences_dialog.callback; SourceFunc callback = run_preferences_dialog.callback;
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => { ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
if (authorized) { if (authorized) {
var preferences_dialog = new PreferencesDialog (transaction, this); var preferences_dialog = new PreferencesDialog (this, transaction);
preferences_dialog.run (); preferences_dialog.run ();
preferences_dialog.destroy (); preferences_dialog.destroy ();
while (Gtk.events_pending ()) { while (Gtk.events_pending ()) {
@ -93,37 +149,20 @@ namespace Pamac {
[GtkCallback] [GtkCallback]
public void on_preferences_button_clicked () { public void on_preferences_button_clicked () {
run_preferences_dialog.begin (() => { run_preferences_dialog.begin (() => {
set_updates_list.begin (); populate_updates_list ();
}); });
} }
[GtkCallback] [GtkCallback]
public void on_apply_button_clicked () { public void on_apply_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
updates_list.foreach ((model, path, iter) => { transaction.sysupgrade (false);
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);
} }
[GtkCallback] [GtkCallback]
public void on_refresh_button_clicked () { public void on_refresh_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.start_refresh (0); transaction.start_refresh (false);
} }
[GtkCallback] [GtkCallback]
@ -131,55 +170,75 @@ namespace Pamac {
this.application.quit (); this.application.quit ();
} }
public void on_transaction_finished (bool error) { public void on_transaction_finished (bool database_modified) {
set_updates_list.begin (); if (database_modified) {
populate_updates_list ();
} else {
this.get_window ().set_cursor (null);
}
} }
public async void set_updates_list () { public void populate_updates_list () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
transaction.start_get_updates ();
}
public void on_get_updates_finished (Updates updates) {
top_label.set_markup (""); top_label.set_markup ("");
updates_list.clear (); repos_updates_list.clear ();
notebook.set_show_tabs (false);
repos_scrolledwindow.set_visible (true);
aur_updates_list.clear ();
bottom_label.set_visible (false); bottom_label.set_visible (false);
Gtk.TreeIter iter; Gtk.TreeIter iter;
string name;
string size;
uint64 dsize = 0; uint64 dsize = 0;
uint updates_nb = 0; uint repos_updates_nb = 0;
Updates updates = yield transaction.get_updates (); uint aur_updates_nb = 0;
foreach (UpdateInfos infos in updates.repos_updates) { foreach (unowned PackageInfos infos in updates.repos_updates) {
name = infos.name + " " + infos.version; string name = infos.name + " " + infos.version;
if (infos.download_size != 0) { string size = infos.download_size != 0 ? format_size (infos.download_size) : "";
size = format_size (infos.download_size);
} else {
size = "";
}
dsize += infos.download_size; dsize += infos.download_size;
updates_nb++; repos_updates_nb++;
if (infos.name in transaction.special_ignorepkgs) { if (infos.name in transaction.special_ignorepkgs) {
updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size); repos_updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
} else { } else {
updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size); repos_updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
} }
} }
foreach (UpdateInfos infos in updates.aur_updates) { foreach (unowned PackageInfos infos in updates.aur_updates) {
name = infos.name + " " + infos.version; string name = infos.name + " " + infos.version;
size = ""; aur_updates_nb++;
updates_nb++; if (infos.name in transaction.special_ignorepkgs) {
updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size); aur_updates_list.insert_with_values (out iter, -1, 0, false, 1, name);
} else {
aur_updates_list.insert_with_values (out iter, -1, 0, true, 1, name);
}
} }
uint updates_nb = repos_updates_nb + aur_updates_nb;
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")));
apply_button.set_sensitive (false);
} else { } else {
top_label.set_markup("<b>%s</b>".printf (dngettext (null, "%u available update", "%u available updates", updates_nb).printf (updates_nb))); top_label.set_markup("<b>%s</b>".printf (dngettext (null, "%u available update", "%u available updates", updates_nb).printf (updates_nb)));
apply_button.set_sensitive (true);
} }
set_apply_button_sensitive ();
if (dsize != 0) { if (dsize != 0) {
bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize))); bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.set_visible (true); bottom_label.set_visible (true);
} else { } else {
bottom_label.set_visible (false); bottom_label.set_visible (false);
} }
if (repos_updates_nb != 0) {
notebook.set_show_tabs (true);
}
if (aur_updates_nb == 0) {
aur_scrolledwindow.set_visible (false);
} else {
aur_scrolledwindow.set_visible (true);
if (repos_updates_nb == 0) {
repos_scrolledwindow.set_visible (false);
}
notebook.set_show_tabs (true);
}
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
} }
} }

View File

@ -1,70 +1,59 @@
#include <string.h>
#include "alpm-util.h" #include "alpm-util.h"
alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level) { alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level) {
alpm_pkg_t *p; alpm_pkg_t* p;
int err = alpm_pkg_load(handle, filename, full, level, &p); if (alpm_pkg_load(handle, filename, full, level, &p) != -1) {
if (err == -1) return NULL; return p;
else return p; } else {
return NULL;
}
} }
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg) { alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg) {
alpm_list_t *list = NULL; alpm_list_t* list = NULL;
alpm_filelist_t *pkgfiles; alpm_filelist_t* pkgfiles;
size_t i; size_t i;
pkgfiles = alpm_pkg_get_files(pkg); pkgfiles = alpm_pkg_get_files(pkg);
for(i = 0; i < pkgfiles->count; i++) { for(i = 0; i < pkgfiles->count; i++) {
const alpm_file_t *file = pkgfiles->files + i; const alpm_file_t* file = pkgfiles->files + i;
list = alpm_list_add(list, file); list = alpm_list_add(list, file);
} }
return list; return list;
} }
void* alpm_list_get_data (alpm_list_t *list) { void* alpm_list_get_data (alpm_list_t* list) {
return list->data; if (list) {
return list->data;
} else {
return NULL;
}
} }
void* alpm_list_nth_data (alpm_list_t *list, size_t n) { alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn) {
return alpm_list_nth (list, n)->data;
}
alpm_list_t* alpm_list_add_str (alpm_list_t *list, const char *str) {
char *dup = strdup (str);
list = alpm_list_add (list, dup);
return list;
}
alpm_list_t* alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn) {
void *data = NULL;
list = alpm_list_remove (list, needle, fn, data);
free(data);
return list;
}
alpm_list_t* alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn) {
list = alpm_list_msort (list, alpm_list_count (list), fn); list = alpm_list_msort (list, alpm_list_count (list), fn);
return list; return list;
} }
alpm_list_t *alpm_list_new () { alpm_list_t* alpm_list_new () {
return NULL; return NULL;
} }
void alpm_list_free_all (alpm_list_t *list) { void alpm_list_free_data (alpm_list_t* list) {
do { alpm_list_free_inner (list, free); alpm_list_free (list); list = NULL; } while (0); alpm_list_free_inner (list, free);
} }
void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* iter) { void alpm_list_iterator (alpm_list_t* list, alpm_list_iterator_t* iter) {
iter->pos = list; iter->pos = list;
} }
void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter) { void* alpm_list_iterator_next_value (alpm_list_iterator_t* iter) {
if (iter->pos) { if (iter->pos) {
void* result = alpm_list_get_data (iter->pos); void* data = alpm_list_get_data (iter->pos);
iter->pos = alpm_list_next (iter->pos); iter->pos = alpm_list_next (iter->pos);
return result; return data;
} else {
return NULL;
} }
else return NULL;
} }

View File

@ -7,17 +7,14 @@ typedef struct __alpm_list_iterator_t {
alpm_list_t* pos; alpm_list_t* pos;
} alpm_list_iterator_t; } alpm_list_iterator_t;
void* alpm_list_get_data (alpm_list_t *list); void* alpm_list_get_data (alpm_list_t* list);
void* alpm_list_nth_data (alpm_list_t *list, size_t n); alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn);
alpm_list_t* alpm_list_add_str (alpm_list_t *list, const char *str); alpm_list_t* alpm_list_new ();
alpm_list_t *alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn); void alpm_list_free_data (alpm_list_t* list);
alpm_list_t *alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn); void alpm_list_iterator (alpm_list_t* list, alpm_list_iterator_t* i);
alpm_list_t *alpm_list_new (); void* alpm_list_iterator_next_value (alpm_list_iterator_t* iter);
void alpm_list_free_all (alpm_list_t *list);
void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* i);
void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter);
alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level); alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level);
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg); alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg);
#endif //!ALPM_UTIL_H #endif //!ALPM_UTIL_H

View File

@ -31,6 +31,14 @@ namespace Alpm {
*/ */
public unowned string version(); public unowned string version();
[CCode (cname = "alpm_caps", cprefix = "ALPM_CAPABILITY_")]
public enum Capabilities {
NLS = (1 << 0),
DOWNLOADER = (1 << 1),
SIGNATURES = (1 << 2)
}
public Capabilities capabilities();
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);
@ -45,14 +53,11 @@ namespace Alpm {
/** /**
* Handle * Handle
*/ */
[CCode (cname = "alpm_handle_t")] [CCode (cname = "alpm_handle_t", free_function = "alpm_release")]
[Compact] [Compact]
public class Handle { public class Handle {
[CCode (cname = "alpm_initialize")] [CCode (cname = "alpm_initialize")]
public static unowned Handle @new(string root, string dbpath, out Alpm.Errno error); public static Handle? @new(string root, string dbpath, out Alpm.Errno error);
[CCode (cname = "alpm_release")]
public static int release (Handle handle);
public unowned string root { public unowned string root {
[CCode (cname = "alpm_option_get_root")] get; [CCode (cname = "alpm_option_get_root")] get;
@ -73,6 +78,15 @@ namespace Alpm {
[CCode (cname = "alpm_option_remove_cachedir")] [CCode (cname = "alpm_option_remove_cachedir")]
public int remove_cachedir(string cachedir); public int remove_cachedir(string cachedir);
public unowned Alpm.List<unowned string?> hookdirs {
[CCode (cname = "alpm_option_get_hookdirs")] get;
[CCode (cname = "alpm_option_set_hookdirs")] set;
}
[CCode (cname = "alpm_option_add_hookdir")]
public int add_hookdir(string hookdir);
[CCode (cname = "alpm_option_remove_hookdir")]
public int remove_hookdir(string hookdir);
public unowned string logfile { public unowned string logfile {
[CCode (cname = "alpm_option_get_logfile")] get; [CCode (cname = "alpm_option_get_logfile")] get;
[CCode (cname = "alpm_option_set_logfile")] set; [CCode (cname = "alpm_option_set_logfile")] set;
@ -146,6 +160,11 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_checkspace")] set; [CCode (cname = "alpm_option_set_checkspace")] set;
} }
public unowned string dbext {
[CCode (cname = "alpm_option_get_dbext")] get;
[CCode (cname = "alpm_option_set_dbext")] set;
}
public Signature.Level defaultsiglevel { public Signature.Level defaultsiglevel {
[CCode (cname = "alpm_option_get_default_siglevel")] get; [CCode (cname = "alpm_option_get_default_siglevel")] get;
[CCode (cname = "alpm_option_set_default_siglevel")] set; [CCode (cname = "alpm_option_set_default_siglevel")] set;
@ -195,6 +214,9 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_progresscb")] set; [CCode (cname = "alpm_option_set_progresscb")] set;
} }
[CCode (cname = "alpm_unlock")]
public int unlock();
[CCode (cname = "alpm_register_syncdb")] [CCode (cname = "alpm_register_syncdb")]
public unowned DB? register_syncdb(string treename, Signature.Level level); public unowned DB? register_syncdb(string treename, Signature.Level level);
[CCode (cname = "alpm_unregister_all_syncdbs")] [CCode (cname = "alpm_unregister_all_syncdbs")]
@ -301,7 +323,7 @@ namespace Alpm {
[CCode (cname = "alpm_db_t", cprefix = "alpm_db_")] [CCode (cname = "alpm_db_t", cprefix = "alpm_db_")]
[Compact] [Compact]
public class DB { public class DB {
public static int unregister(DB db); public static int unregister(owned DB db);
public unowned string name { public unowned string name {
[CCode (cname = "alpm_db_get_name")] get; [CCode (cname = "alpm_db_get_name")] get;
@ -354,12 +376,9 @@ namespace Alpm {
/** /**
* Packages * Packages
*/ */
[CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_")] [CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_", free_function = "alpm_pkg_free")]
[Compact] [Compact]
public class Package { public class Package {
public static int free(Package pkg);
/* properties */ /* properties */
public unowned string filename { public unowned string filename {
[CCode (cname = "alpm_pkg_get_filename")] get; [CCode (cname = "alpm_pkg_get_filename")] get;
@ -370,6 +389,9 @@ namespace Alpm {
public unowned string version { public unowned string version {
[CCode (cname = "alpm_pkg_get_version")] get; [CCode (cname = "alpm_pkg_get_version")] get;
} }
public unowned string pkgbase {
[CCode (cname = "alpm_pkg_get_base")] get;
}
public From origin { public From origin {
[CCode (cname = "alpm_pkg_get_origin")] get; [CCode (cname = "alpm_pkg_get_origin")] get;
} }
@ -684,9 +706,6 @@ namespace Alpm {
DATABASE_MARGINAL_OK = (1 << 12), DATABASE_MARGINAL_OK = (1 << 12),
DATABASE_UNKNOWN_OK = (1 << 13), DATABASE_UNKNOWN_OK = (1 << 13),
PACKAGE_SET = (1 << 27),
PACKAGE_TRUST_SET = (1 << 28),
USE_DEFAULT = (1 << 31) USE_DEFAULT = (1 << 31)
} }
@ -719,6 +738,13 @@ namespace Alpm {
public unowned Signature.Result[] results; public unowned Signature.Result[] results;
} }
/** Hooks */
[CCode (cname = "alpm_hook_when_t", cprefix = "ALPM_HOOK_")]
public enum HookWhen {
PRE_TRANSACTION = 1,
POST_TRANSACTION
}
/** Logging Levels */ /** Logging Levels */
[CCode (cname = "alpm_loglevel_t", cprefix = "ALPM_LOG_")] [CCode (cname = "alpm_loglevel_t", cprefix = "ALPM_LOG_")]
public enum LogLevel { public enum LogLevel {
@ -754,6 +780,10 @@ namespace Alpm {
INTERCONFLICTS_START, INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */ /** Inter-conflicts were checked for target package. */
INTERCONFLICTS_DONE, INTERCONFLICTS_DONE,
/** Processing the package transaction is starting. */
TRANSACTION_START,
/** Processing the package transaction is finished. */
TRANSACTION_DONE,
/** Package will be installed/upgraded/downgraded/re-installed/removed; See /** Package will be installed/upgraded/downgraded/re-installed/removed; See
* PackageOperation for arguments. */ * PackageOperation for arguments. */
PACKAGE_OPERATION_START, PACKAGE_OPERATION_START,
@ -824,9 +854,14 @@ namespace Alpm {
/** A .pacsave file was created; See PacsaveCreated for /** A .pacsave file was created; See PacsaveCreated for
* arguments */ * arguments */
PACSAVE_CREATED, PACSAVE_CREATED,
/** A .pacorig file was created; See PacorigCreated for /** Processing hooks will be started. */
* arguments */ HOOK_START,
PACORIG_CREATED /** Processing hooks is finished. */
HOOK_DONE,
/** A hook is starting */
HOOK_RUN_START,
/** A hook has finnished runnning */
HOOK_RUN_DONE
} }
[CCode (cname = "alpm_event_any_t", has_type_id = false)] [CCode (cname = "alpm_event_any_t", has_type_id = false)]
@ -913,14 +948,26 @@ namespace Alpm {
public unowned string file; public unowned string file;
} }
[CCode (cname = "alpm_event_pacorig_created_t", has_type_id = false)] [CCode (cname = "alpm_event_hook_t", has_type_id = false)]
public class PacorigCreated { public class Hook {
/** Type of event. */ /** Type of event.*/
public Type type; public Type type;
/** New package. */ /** Type of hooks. */
public unowned Package newpkg; public HookWhen when;
/** Filename of the file without the .pacorig suffix. */ }
public unowned string file;
[CCode (cname = "alpm_event_hook_run_t", has_type_id = false)]
public class HookRun {
/** Type of event.*/
public Type type;
/** Name of hook */
public unowned string name;
/** Description of hook to be outputted */
public unowned string desc;
/** position of hook being run */
public size_t position;
/** total hooks being run */
public size_t total;
} }
/** This is an union passed to the callback, that allows the frontend to know /** This is an union passed to the callback, that allows the frontend to know
@ -969,11 +1016,18 @@ namespace Alpm {
public unowned Package pacsave_created_oldpkg; public unowned Package pacsave_created_oldpkg;
[CCode (cname = "pacsave_created.file")] [CCode (cname = "pacsave_created.file")]
public unowned string pacsave_created_file; public unowned string pacsave_created_file;
// PacorigCreated pacorig_created; // Hook hook;
[CCode (cname = "pacorig_created.newpkg")] [CCode (cname = "hook.when")]
public unowned Package pacorig_created_newpkg; public HookWhen hook_when;
[CCode (cname = "pacorig_created.file")] // HookRun hook_run;
public unowned string pacorig_created_file; [CCode (cname = "hook_run.name")]
public unowned string hook_run_name;
[CCode (cname = "hook_run.desc")]
public unowned string hook_run_desc;
[CCode (cname = "hook_run.position")]
public size_t hook_run_position;
[CCode (cname = "hook_run.total")]
public size_t hook_run_total;
} }
} }
@ -1070,7 +1124,7 @@ namespace Alpm {
/** Answer: which provider to use (index from providers). */ /** Answer: which provider to use (index from providers). */
public int use_index; public int use_index;
/** List of alpm_pkg_t* as possible providers. */ /** List of alpm_pkg_t* as possible providers. */
public unowned Alpm.List<Package?> providers; public unowned Alpm.List<unowned Package?> providers;
/** What providers provide for. */ /** What providers provide for. */
public unowned Depend depend; public unowned Depend depend;
} }
@ -1130,7 +1184,7 @@ namespace Alpm {
[CCode (cname = "select_provider.use_index")] [CCode (cname = "select_provider.use_index")]
public int select_provider_use_index; public int select_provider_use_index;
[CCode (cname = "select_provider.providers")] [CCode (cname = "select_provider.providers")]
public unowned Alpm.List<Package?> select_provider_providers; public unowned Alpm.List<unowned Package?> select_provider_providers;
[CCode (cname = "select_provider.depend")] [CCode (cname = "select_provider.depend")]
public unowned Depend select_provider_depend; public unowned Depend select_provider_depend;
// ImportKey import_key; // ImportKey import_key;
@ -1261,6 +1315,7 @@ namespace Alpm {
TRANS_ABORT, TRANS_ABORT,
TRANS_TYPE, TRANS_TYPE,
TRANS_NOT_LOCKED, TRANS_NOT_LOCKED,
TRANS_HOOK_FAILED,
/* Packages */ /* Packages */
PKG_NOT_FOUND, PKG_NOT_FOUND,
PKG_IGNORED, PKG_IGNORED,
@ -1293,17 +1348,14 @@ namespace Alpm {
GPGME GPGME
} }
[CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h", [CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h",
free_function = "alpm_list_free")] dup_function = "alpm_list_copy", free_function = "alpm_list_free")]
[Compact] [Compact]
public class List<G> { public class List<G> {
[CCode (cname = "alpm_list_new")]
public List (); public List ();
public static void free_all(List list); /* comparator */
/* Comparator*/
[CCode (cname = "alpm_list_fn_cmp", has_target = false)] [CCode (cname = "alpm_list_fn_cmp", has_target = false)]
public delegate int CompareFunc<G>(G a, G b); public delegate int CompareFunc<G>(G a, G b);
@ -1317,25 +1369,25 @@ namespace Alpm {
/* item mutators */ /* item mutators */
[ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void add(G data); public void add(owned G data);
[ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void add_str(string str); public void join(owned List<G> list);
[ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void join(List<G> list); public void sort(CompareFunc fn);
[CCode (cname = "alpm_list_sort_data"), ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void sort(CompareFunc fn); public void remove(G data, CompareFunc fn, out G removed_data );
[CCode (cname = "alpm_list_remove_data"), ReturnsModifiedPointer ()] /* free the internal data of this */
public unowned void? remove(G data, CompareFunc fn); public void free_data();
public List<G> copy(); public List<unowned G> copy();
public List<G> copy_data(); public List<G> copy_data();
[ReturnsModifiedPointer ()] [ReturnsModifiedPointer ()]
public unowned void reverse (); public void reverse ();
/* item accessors */ /* item accessors */
public unowned List<G>? first(); public unowned List<G>? first();
@ -1344,13 +1396,12 @@ namespace Alpm {
public unowned List<G>? next(); public unowned List<G>? next();
public unowned List<G>? previous(); public unowned List<G>? previous();
public unowned G? nth_data(size_t index);
/* misc */ /* misc */
public unowned G? find(G needle, CompareFunc fn);
public unowned string? find_str(string needle); public unowned string? find_str(string needle);
/** @return a list containing all items in `this` not present in `list` */ /** @return a list containing all items in `this` not present in `list` */
public unowned List<G>? diff(List<G>? list, CompareFunc fn); public List<unowned G>? diff(List<G>? list, CompareFunc fn);
/* iterator */ /* iterator */
public Iterator<G> iterator(); public Iterator<G> iterator();
@ -1359,6 +1410,7 @@ namespace Alpm {
public struct Iterator<G> { public struct Iterator<G> {
public unowned G? next_value(); public unowned G? next_value();
} }
} }
} }