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"
msgstr ""
#: ../src/daemon.vala
#: ../src/daemon.vala ../src/manager_window.vala ../src/preferences_dialog.vala
msgid "Failed to initialize alpm library"
msgstr ""
@ -30,14 +29,6 @@ msgstr ""
msgid "Failed to synchronize any databases"
msgstr ""
#: ../src/daemon.vala
msgid "No"
msgstr ""
#: ../src/daemon.vala
msgid "Yes"
msgstr ""
#: ../src/daemon.vala
msgid "Failed to init transaction"
msgstr ""
@ -90,7 +81,7 @@ msgstr ""
msgid "%s is invalid or corrupted"
msgstr ""
#: ../src/daemon.vala
#: ../src/daemon.vala ../src/transaction.vala
msgid "Authentication failed"
msgstr ""
@ -110,6 +101,11 @@ msgstr ""
msgid "Preparing"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "Choose a provider for %s"
msgstr ""
#: ../src/transaction.vala ../resources/transaction_sum_dialog.ui
msgid "Transaction Summary"
msgstr ""
@ -146,6 +142,14 @@ msgstr ""
msgid "Building packages"
msgstr ""
#: ../src/transaction.vala
msgid "Running pre-transaction hooks"
msgstr ""
#: ../src/transaction.vala
msgid "Running post-transaction hooks"
msgstr ""
#: ../src/transaction.vala
msgid "Checking dependencies"
msgstr ""
@ -257,11 +261,6 @@ msgstr ""
msgid "%s installed as %s.pacsave"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "%s installed as %s.pacorig"
msgstr ""
#: ../src/transaction.vala
#, c-format
msgid "Refreshing %s"
@ -272,6 +271,18 @@ msgstr ""
msgid "Downloading %s"
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
msgid "Warning"
msgstr ""
@ -281,7 +292,7 @@ msgstr ""
msgid "Error"
msgstr ""
#: ../src/transaction.vala ../src/progress_dialog.vala
#: ../src/transaction.vala
msgid "Transaction cancelled"
msgstr ""
@ -324,22 +335,6 @@ msgstr[1] ""
msgid "Show available updates"
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
msgid "Deselect"
msgstr ""
@ -380,6 +375,10 @@ msgstr ""
msgid "Licenses"
msgstr ""
#: ../src/manager_window.vala
msgid "Unknown"
msgstr ""
#: ../src/manager_window.vala
msgid "Depends On"
msgstr ""
@ -416,18 +415,6 @@ msgstr ""
msgid "Groups"
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
msgid "Packager"
msgstr ""
@ -449,11 +436,15 @@ msgid "Installed as a dependency for another package"
msgstr ""
#: ../src/manager_window.vala
msgid "Unknown"
msgid "Install Reason"
msgstr ""
#: ../src/manager_window.vala
msgid "Install Reason"
msgid "Yes"
msgstr ""
#: ../src/manager_window.vala
msgid "No"
msgstr ""
#: ../src/manager_window.vala
@ -461,6 +452,22 @@ msgid "Signatures"
msgstr ""
#: ../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"
msgstr ""
@ -469,12 +476,15 @@ msgid "Out of Date"
msgstr ""
#: ../src/manager_window.vala
msgid "Backup files"
msgstr ""
#: ../src/manager_window.vala
msgid "No package found"
msgstr ""
#, 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
msgid "Uninstalled"
@ -595,7 +605,7 @@ msgstr ""
msgid "State"
msgstr ""
#: ../resources/manager_window.ui
#: ../resources/manager_window.ui ../resources/updater_window.ui
msgid "Repositories"
msgstr ""
@ -611,6 +621,11 @@ msgstr ""
msgid "Size"
msgstr ""
#: ../resources/manager_window.ui ../resources/updater_window.ui
#: ../resources/preferences_dialog.ui
msgid "AUR"
msgstr ""
#: ../resources/manager_window.ui
msgid "Description"
msgstr ""
@ -708,10 +723,6 @@ msgstr ""
msgid "Do not ask for confirmation when building packages"
msgstr ""
#: ../resources/preferences_dialog.ui
msgid "AUR"
msgstr ""
#: ../resources/choose_ignorepkgs_dialog.ui
msgid "Choose Ignored Upgrades"
msgstr ""

View File

@ -207,8 +207,8 @@
<object class="GtkLabel" id="search_aur_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="margin_start">6</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Search in AUR</property>
<property name="xalign">0</property>
</object>
@ -437,117 +437,242 @@
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow6">
<property name="width_request">500</property>
<property name="height_request">200</property>
<object class="GtkNotebook" id="packages_notebook">
<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>
<signal name="switch-page" handler="on_packages_notebook_switch_page" after="yes" swapped="no"/>
<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="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_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>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeViewColumn" id="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_state_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="state_rendererpixbuf"/>
<attributes>
<attribute name="pixbuf">1</attribute>
</attributes>
<object class="GtkTreeView" id="packages_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_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="treeview-selection">
<property name="mode">multiple</property>
<signal name="changed" handler="on_packages_treeview_selection_changed" swapped="no"/>
</object>
</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>
<object class="GtkCellRendererText" id="name_renderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="packages_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_packages_state_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="packages_state_rendererpixbuf"/>
<attributes>
<attribute name="pixbuf">1</attribute>
</attributes>
</child>
</object>
</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>
<object class="GtkCellRendererText" id="version_renderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="packages_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_packages_name_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_name_renderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</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>
<object class="GtkCellRendererText" id="repo_renderertext"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="packages_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_packages_version_column_clicked" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="packages_version_renderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</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>
<object class="GtkCellRendererText" id="size_renderertext"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="packages_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_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>
</object>
</child>
</object>
</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>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
@ -563,11 +688,11 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="viewport1">
<object class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box5">
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
@ -575,8 +700,10 @@
<child>
<object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</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_end">6</property>
<property name="margin_top">6</property>
@ -592,8 +719,10 @@
<child>
<object class="GtkLabel" id="desc_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</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_end">6</property>
<property name="margin_top">6</property>
@ -609,9 +738,10 @@
<child>
<object class="GtkLabel" id="link_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="can_focus">False</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_end">6</property>
<property name="margin_top">6</property>
@ -626,8 +756,10 @@
<child>
<object class="GtkLabel" id="licenses_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</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_end">6</property>
<property name="margin_top">6</property>
@ -647,7 +779,7 @@
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Description</property>
@ -670,7 +802,7 @@
<property name="enable_search">False</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="deps_treeview_selection">
<object class="GtkTreeSelection" id="treeview-selection8">
<property name="mode">none</property>
</object>
</child>
@ -678,7 +810,7 @@
<object class="GtkTreeViewColumn" id="dep_type">
<property name="sizing">autosize</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext12">
<object class="GtkCellRendererText" id="cellrenderertext3">
<property name="yalign">0</property>
<property name="weight">600</property>
</object>
@ -692,7 +824,7 @@
<object class="GtkTreeViewColumn" id="deps">
<property name="sizing">autosize</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext13"/>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
@ -707,7 +839,7 @@
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Dependencies</property>
@ -732,7 +864,7 @@
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection6">
<object class="GtkTreeSelection" id="treeview-selection10">
<property name="mode">none</property>
</object>
</child>
@ -740,7 +872,7 @@
<object class="GtkTreeViewColumn" id="infotype">
<property name="sizing">autosize</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1">
<object class="GtkCellRendererText" id="cellrenderertext6">
<property name="yalign">0</property>
<property name="weight">600</property>
<property name="wrap_mode">word</property>
@ -752,10 +884,10 @@
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="type">
<object class="GtkTreeViewColumn" id="info">
<property name="sizing">autosize</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4">
<object class="GtkCellRendererText" id="cellrenderertext7">
<property name="wrap_mode">word</property>
</object>
<attributes>
@ -772,7 +904,7 @@
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label3">
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Details</property>
@ -824,7 +956,7 @@
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
<property name="shrink">True</property>
</packing>
</child>
</object>

View File

@ -6,7 +6,7 @@
<property name="title" translatable="yes">Progress</property>
<property name="modal">True</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="type_hint">dialog</property>
<property name="deletable">False</property>
@ -29,7 +29,6 @@
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<template class="PamacUpdaterWindow" parent="GtkApplicationWindow">
@ -30,64 +30,142 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width_request">400</property>
<property name="height_request">400</property>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="can_focus">True</property>
<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="can_focus">True</property>
<property name="hexpand">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>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<child>
<object class="GtkCellRendererToggle" id="select_update">
<signal name="toggled" handler="on_select_update_toggled" swapped="no"/>
<object class="GtkTreeView" id="repos_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-selection">
<property name="mode">none</property>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="update_name"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<child>
<object class="GtkCellRendererToggle" id="repos_select_update">
<signal name="toggled" handler="on_repos_select_update_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="download_size"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="expand">True</property>
<child>
<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>
</object>
</child>
</object>
</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>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>

View File

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

View File

@ -1,7 +1,7 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@ -18,112 +18,163 @@
*/
namespace Alpm {
class Repo {
[Compact]
public class Repo {
public string name;
public Signature.Level siglevel;
public Signature.Level siglevel_mask;
public DB.Usage usage;
public string[] urls;
public GLib.List<string> urls;
public Repo (string name) {
this.name = name;
siglevel = Signature.Level.USE_DEFAULT;
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 {
string conf_path;
string rootdir;
string dbpath;
string gpgdir;
string logfile;
string arch;
double deltaratio;
int usesyslog;
public string conf_path;
public string? rootdir;
public string? dbpath;
public string? logfile;
public string? gpgdir;
public string? arch;
public double deltaratio;
public int usesyslog;
public int checkspace;
Alpm.List<string> *cachedirs;
Alpm.List<string> *ignoregroups;
public Alpm.List<string> *ignorepkgs;
Alpm.List<string> *noextracts;
Alpm.List<string> *noupgrades;
public GLib.List<string> holdpkgs;
public GLib.List<string> syncfirsts;
Signature.Level defaultsiglevel;
Signature.Level localfilesiglevel;
Signature.Level remotefilesiglevel;
Repo[] repo_order;
public unowned Handle? handle;
public Alpm.List<string>? cachedirs;
public Alpm.List<string?>? hookdirs;
public Alpm.List<string>? ignoregroups;
public Alpm.List<string>? ignorepkgs;
public Alpm.List<string>? noextracts;
public Alpm.List<string>? noupgrades;
public GLib.List<string>? holdpkgs;
public GLib.List<string>? syncfirsts;
public Signature.Level siglevel;
public Signature.Level localfilesiglevel;
public Signature.Level remotefilesiglevel;
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) {
conf_path = path;
handle = null;
reload ();
}
public void reload () {
// 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> ();
syncfirsts = new GLib.List<string> ();
Alpm.List.free_all (cachedirs);
Alpm.List.free_all (ignoregroups);
Alpm.List.free_all (ignorepkgs);
Alpm.List.free_all (noextracts);
Alpm.List.free_all (noupgrades);
cachedirs = new Alpm.List<string> ();
cachedirs->add_str (default_cachedir);
ignoregroups = new Alpm.List<string> ();
ignorepkgs = new Alpm.List<string> ();
noextracts = new Alpm.List<string> ();
noupgrades = new Alpm.List<string> ();
// free internal data of alpm lists
if (cachedirs != null) {
cachedirs.free_data ();
}
if (hookdirs != null) {
hookdirs.free_data ();
}
if (ignoregroups != null) {
ignoregroups.free_data ();
}
if (ignorepkgs != null) {
ignorepkgs.free_data ();
}
if (noextracts != null) {
noextracts.free_data ();
}
if (noupgrades != null) {
noupgrades.free_data ();
}
usesyslog = 0;
checkspace = 0;
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;
remotefilesiglevel = Signature.Level.USE_DEFAULT;
repo_order = {};
repo_order = new GLib.List<Repo> ();
// parse conf file
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 () {
Alpm.Errno error;
if (handle != null) {
Handle.release (handle);
}
handle = Handle.new (rootdir, dbpath, out error);
if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return;
}
// define options
handle.gpgdir = gpgdir;
handle.logfile = logfile;
handle.gpgdir = gpgdir;
handle.arch = arch;
handle.deltaratio = deltaratio;
handle.usesyslog = usesyslog;
handle.checkspace = checkspace;
handle.defaultsiglevel = defaultsiglevel;
localfilesiglevel = merge_siglevel (defaultsiglevel, localfilesiglevel);
remotefilesiglevel = merge_siglevel (defaultsiglevel, remotefilesiglevel);
handle.defaultsiglevel = siglevel;
localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask);
remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask);
handle.localfilesiglevel = localfilesiglevel;
handle.remotefilesiglevel = remotefilesiglevel;
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.ignorepkgs = ignorepkgs;
handle.noextracts = noextracts;
handle.noupgrades = noupgrades;
// 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);
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));
}
if (repo.usage == 0) {
@ -158,21 +209,37 @@ namespace Alpm {
current_section = line[1:-1];
if (current_section != "options") {
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;
}
splitted = line.split ("=", 2);
string key = splitted[0].strip ();
string? val = null;
if (splitted[1] != null) {
val = splitted[1].strip ();
unowned string key = splitted[0]._strip ();
unowned string? val = null;
if (splitted.length == 2) {
val = splitted[1]._strip ();
}
if (key == "Include") {
parse_file (val, current_section);
}
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;
} else if (key == "LogFile") {
logfile = val;
@ -189,53 +256,46 @@ namespace Alpm {
} else if (key == "CheckSpace") {
checkspace = 1;
} else if (key == "SigLevel") {
defaultsiglevel = define_siglevel (defaultsiglevel, val);
process_siglevel (val, ref siglevel, ref siglevel_mask);
} else if (key == "LocalFileSigLevel") {
localfilesiglevel = define_siglevel (localfilesiglevel, val);
process_siglevel (val, ref localfilesiglevel, ref localfilesiglevel_mask);
} else if (key == "RemoteFileSigLevel") {
remotefilesiglevel = define_siglevel (remotefilesiglevel, val);
process_siglevel (val, ref remotefilesiglevel, ref remotefilesiglevel_mask);
} else if (key == "HoldPkg") {
foreach (string name in val.split (" ")) {
foreach (unowned string name in val.split (" ")) {
holdpkgs.append (name);
}
} else if (key == "SyncFirst") {
foreach (string name in val.split (" ")) {
foreach (unowned string name in val.split (" ")) {
syncfirsts.append (name);
}
} else if (key == "CacheDir") {
foreach (string dir in val.split (" ")) {
cachedirs->add_str (dir);
}
} else if (key == "IgnoreGroup") {
foreach (string name in val.split (" ")) {
ignoregroups->add_str (name);
foreach (unowned string name in val.split (" ")) {
ignoregroups.add (name);
}
} else if (key == "IgnorePkg") {
foreach (string name in val.split (" ")) {
ignorepkgs->add_str (name);
foreach (unowned string name in val.split (" ")) {
ignorepkgs.add (name);
}
} else if (key == "Noextract") {
foreach (string name in val.split (" ")) {
noextracts->add_str (name);
foreach (unowned string name in val.split (" ")) {
noextracts.add (name);
}
} else if (key == "NoUpgrade") {
foreach (string name in val.split (" ")) {
noupgrades->add_str (name);
foreach (unowned string name in val.split (" ")) {
noupgrades.add (name);
}
}
} else {
foreach (var repo in repo_order) {
if (repo.name == current_section) {
if (key == "Server") {
repo.urls += val;
} else if (key == "SigLevel") {
if (repo.siglevel == Signature.Level.USE_DEFAULT) {
repo.siglevel = defaultsiglevel;
}
repo.siglevel = define_siglevel (repo.siglevel, val);
} else if (key == "Usage") {
repo.usage = define_usage (val);
}
unowned GLib.List<Repo>? found = repo_order.search (current_section, (SearchFunc) Repo.search_name);
if (found != null) {
unowned Repo repo = found.data;
if (key == "Server") {
repo.urls.append (val);
} else if (key == "SigLevel") {
process_siglevel (val, ref repo.siglevel, ref repo.siglevel_mask);
} else if (key == "Usage") {
repo.usage = define_usage (val);
}
}
}
@ -295,7 +355,7 @@ namespace Alpm {
file.delete ();
// creating a DataOutputStream to the file
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
dos.put_string (new_line);
}
@ -309,7 +369,7 @@ namespace Alpm {
public DB.Usage define_usage (string conf_string) {
DB.Usage usage = 0;
foreach (string directive in conf_string.split(" ")) {
foreach (unowned string directive in conf_string.split(" ")) {
if (directive == "Sync") {
usage |= DB.Usage.SYNC;
} else if (directive == "Search") {
@ -325,8 +385,8 @@ namespace Alpm {
return usage;
}
public Signature.Level define_siglevel (Signature.Level default_level, string conf_string) {
foreach (string directive in conf_string.split(" ")) {
public void process_siglevel (string conf_string, ref Signature.Level siglevel, ref Signature.Level siglevel_mask) {
foreach (unowned string directive in conf_string.split(" ")) {
bool affect_package = false;
bool affect_database = false;
if ("Package" in directive) {
@ -339,72 +399,62 @@ namespace Alpm {
}
if ("Never" in directive) {
if (affect_package) {
default_level &= ~Signature.Level.PACKAGE;
default_level |= Signature.Level.PACKAGE_SET;
siglevel &= ~Signature.Level.PACKAGE;
siglevel_mask |= Signature.Level.PACKAGE;
}
if (affect_database) {
default_level &= ~Signature.Level.DATABASE;
siglevel &= ~Signature.Level.DATABASE;
siglevel_mask |= Signature.Level.DATABASE;
}
} else if ("Optional" in directive) {
if (affect_package) {
default_level |= Signature.Level.PACKAGE;
default_level |= Signature.Level.PACKAGE_OPTIONAL;
default_level |= Signature.Level.PACKAGE_SET;
siglevel |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
siglevel_mask |= (Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL);
}
if (affect_database) {
default_level |= Signature.Level.DATABASE;
default_level |= Signature.Level.DATABASE_OPTIONAL;
siglevel |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
siglevel_mask |= (Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL);
}
} else if ("Required" in directive) {
if (affect_package) {
default_level |= Signature.Level.PACKAGE;
default_level &= ~Signature.Level.PACKAGE_OPTIONAL;
default_level |= Signature.Level.PACKAGE_SET;
siglevel |= Signature.Level.PACKAGE;
siglevel_mask |= Signature.Level.PACKAGE;
siglevel &= ~Signature.Level.PACKAGE_OPTIONAL;
siglevel_mask |= Signature.Level.PACKAGE_OPTIONAL;
}
if (affect_database) {
default_level |= Signature.Level.DATABASE;
default_level &= ~Signature.Level.DATABASE_OPTIONAL;
siglevel |= Signature.Level.DATABASE;
siglevel_mask |= Signature.Level.DATABASE;
siglevel &= ~Signature.Level.DATABASE_OPTIONAL;
siglevel_mask |= Signature.Level.DATABASE_OPTIONAL;
}
} else if ("TrustedOnly" in directive) {
if (affect_package) {
default_level &= ~Signature.Level.PACKAGE_MARGINAL_OK;
default_level &= ~Signature.Level.PACKAGE_UNKNOWN_OK;
default_level |= Signature.Level.PACKAGE_TRUST_SET;
siglevel &= ~(Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
default_level &= ~Signature.Level.DATABASE_MARGINAL_OK;
default_level &= ~Signature.Level.DATABASE_UNKNOWN_OK;
siglevel &= ~(Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
}
} else if ("TrustAll" in directive) {
if (affect_package) {
default_level |= Signature.Level.PACKAGE_MARGINAL_OK;
default_level |= Signature.Level.PACKAGE_UNKNOWN_OK;
default_level |= Signature.Level.PACKAGE_TRUST_SET;
siglevel |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.PACKAGE_MARGINAL_OK | Signature.Level.PACKAGE_UNKNOWN_OK);
}
if (affect_database) {
default_level |= Signature.Level.DATABASE_MARGINAL_OK;
default_level |= Signature.Level.DATABASE_UNKNOWN_OK;
siglevel |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
siglevel_mask |= (Signature.Level.DATABASE_MARGINAL_OK | Signature.Level.DATABASE_UNKNOWN_OK);
}
} else {
GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
}
}
default_level &= ~Signature.Level.USE_DEFAULT;
return default_level;
siglevel &= ~Signature.Level.USE_DEFAULT;
}
public Signature.Level merge_siglevel (Signature.Level base_level, Signature.Level over_level) {
if ((over_level & Signature.Level.USE_DEFAULT) == 0) {
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;
public Signature.Level merge_siglevel(Signature.Level sigbase, Signature.Level sigover, Signature.Level sigmask) {
return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover;
}
}
}

View File

@ -17,59 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
return strcmp (pkg1.name, pkg2.name);
public int compare_name (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return strcmp (pkg_a.name, pkg_b.name);
}
public Alpm.List<unowned Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
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 int compare_state (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return (int) (pkg_a.origin > pkg_b.origin) - (int) (pkg_a.origin < pkg_b.origin);
}
public Alpm.List<unowned Alpm.Package?> group_pkgs (Alpm.Handle handle, string grp_name) {
var result = new Alpm.List<unowned Alpm.Package?> ();
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 int compare_version (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return Alpm.pkg_vercmp (pkg_a.version, pkg_b.version);
}
public Alpm.List<unowned Alpm.Package?> all_pkgs (Alpm.Handle handle) {
var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
var result = new Alpm.List<unowned Alpm.Package?> ();
result = handle.localdb.pkgcache.copy ();
foreach (var db in handle.syncdbs) {
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;
public int compare_repo (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return strcmp (pkg_a.db.name, pkg_b.db.name);
}
public int compare_size (Alpm.Package pkg_a, Alpm.Package pkg_b) {
return (int) (pkg_a.isize > pkg_b.isize) - (int) (pkg_a.isize < pkg_b.isize);
}

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;
Transaction transaction;
public ChooseDependenciesDialog (Transaction transaction, string pkgname, Gtk.ApplicationWindow? window) {
public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
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));
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]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
GLib.Value val;
bool selected;
GLib.Value selected;
if (deps_list.get_iter_from_string (out iter, path)) {;
deps_list.get_value (iter, 0, out val);
selected = val.get_boolean ();
deps_list.set_value (iter, 0, !selected);
deps_list.get_value (iter, 0, out selected);
deps_list.set_value (iter, 0, !((bool) selected));
}
}
}

View File

@ -31,39 +31,21 @@ namespace Pamac {
public Gtk.ListStore pkgs_list;
Transaction transaction;
public ChooseIgnorepkgsDialog (Gtk.Window window, Transaction transaction) {
public ChooseIgnorepkgsDialog (Gtk.Window window) {
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")));
pkgs_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
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]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
GLib.Value val;
bool selected;
if (pkgs_list.get_iter_from_string (out iter, path)) {;
pkgs_list.get_value (iter, 0, out val);
selected = val.get_boolean ();
pkgs_list.set_value (iter, 0, !selected);
GLib.Value selected;
if (pkgs_list.get_iter_from_string (out iter, path)) {
pkgs_list.get_value (iter, 0, out selected);
pkgs_list.set_value (iter, 0, !((bool) selected));
}
}
}

View File

@ -27,14 +27,8 @@ namespace Pamac {
[GtkChild]
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);
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 {
public struct UpdateInfos {
public struct PackageInfos {
public string name;
public string version;
public string db_name;
@ -27,13 +27,8 @@ namespace Pamac {
public struct Updates {
public bool is_syncfirst;
public UpdateInfos[] repos_updates;
public UpdateInfos[] aur_updates;
public Updates () {
is_syncfirst = false;
repos_updates = {};
aur_updates = {};
}
public PackageInfos[] repos_updates;
public PackageInfos[] aur_updates;
}
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 ();
} else {
transaction = new Pamac.Transaction (null);
transaction.finished.connect (on_emit_trans_finished);
transaction.finished.connect (on_transaction_finished);
this.hold ();
}
}
public override void activate () {
if (pamac_run == false) {
if (!pamac_run) {
print ("\nError: Path(s) of tarball(s) to install is needed\n");
transaction.stop_daemon ();
this.release ();
@ -60,10 +60,9 @@ namespace Pamac {
}
public override void open (File[] files, string hint) {
if (pamac_run == false) {
foreach (File file in files) {
string? path = file.get_path ();
transaction.to_load.add ((owned) path);
if (!pamac_run) {
foreach (unowned File file in files) {
transaction.to_load.add (file.get_path ());
}
transaction.run ();
}
@ -92,7 +91,7 @@ namespace Pamac {
return run;
}
public void on_emit_trans_finished (bool error) {
public void on_transaction_finished () {
transaction.stop_daemon ();
this.release ();
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,10 @@
*/
namespace Alpm {
[Compact]
public class MirrorsConfig: Object {
string conf_path;
string mirrorlists_dir;
public string conf_path;
public string mirrorlists_dir;
public string choosen_generation_method;
public string choosen_country;
public GLib.List<string> countrys;
@ -47,9 +48,7 @@ namespace Alpm {
while ((file_info = enumerator.next_file ()) != null) {
countrys.append(file_info.get_name ());
}
countrys.sort ((a, b) => {
return strcmp (a, b);
});
countrys.sort (strcmp);
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
@ -57,9 +56,7 @@ namespace Alpm {
public void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", path);
} else {
if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
@ -76,11 +73,11 @@ namespace Alpm {
if (line.length == 0) {
continue;
}
splitted = line.split ("=");
string key = splitted[0].strip ();
string? val = null;
if (splitted[1] != null) {
val = splitted[1].strip ();
splitted = line.split ("=", 2);
unowned string key = splitted[0]._strip ();
unowned string? val = null;
if (splitted.length == 2) {
val = splitted[1]._strip ();
}
if (key == "Method") {
choosen_generation_method = val;
@ -93,59 +90,60 @@ namespace Alpm {
} catch (Error e) {
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) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false) {
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
} else {
if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string? line;
string[] data = {};
var data = new GLib.List<string> ();
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
if (line.length == 0) {
data += "\n";
data.append ("\n");
continue;
}
unowned Variant variant;
if (line.contains ("Method")) {
if (new_conf.contains ("Method")) {
string val = new_conf.get ("Method").get_string ();
data += "Method=%s\n".printf (val);
if (new_conf.lookup_extended ("Method", null, out variant)) {
data.append ("Method=%s\n".printf (variant.get_string ()));
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("OnlyCountry")) {
if (new_conf.contains ("OnlyCountry")) {
string val = new_conf.get ("OnlyCountry").get_string ();
if (val == dgettext (null, "Worldwide")) {
data += "#%s\n".printf (line);
if (new_conf.lookup_extended ("OnlyCountry", null, out variant)) {
if (variant.get_string () == dgettext (null, "Worldwide")) {
data.append ("#%s\n".printf (line));
} else {
data += "OnlyCountry=%s\n".printf (val);
data.append ("OnlyCountry=%s\n".printf (variant.get_string ()));
}
} else {
data += line + "\n";
data.append (line + "\n");
}
} else {
data += line + "\n";
data.append (line + "\n");
}
}
// delete the file before rewrite it
file.delete ();
// creating a DataOutputStream to the file
var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
foreach (string new_line in data) {
foreach (unowned string new_line in data) {
// writing a short string to the stream
dos.put_string (new_line);
}
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
} 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) {
if (alpm_pkg != null) {
name = alpm_pkg.name ?? "";
version = alpm_pkg.version ?? "";
desc = alpm_pkg.desc ?? "";
repo = (alpm_pkg.db != null ? (alpm_pkg.db.name ?? "") : "");
name = alpm_pkg.name;
version = alpm_pkg.version;
desc = alpm_pkg.desc;
repo = alpm_pkg.db != null ? alpm_pkg.db.name : "";
size = alpm_pkg.isize;
size_string = format_size (alpm_pkg.isize);
// alpm pkg url can be null
url = alpm_pkg.url ?? "";
StringBuilder licenses_build = new StringBuilder ();
foreach (var license in alpm_pkg.licenses) {
@ -48,9 +49,9 @@ namespace Pamac {
licenses = licenses_build.str;
reason = alpm_pkg.reason;
} else if (aur_json != null ) {
name = aur_json.get_string_member ("Name") ?? "";
version = aur_json.get_string_member ("Version") ?? "";
desc = aur_json.get_string_member ("Description") ?? "";
name = aur_json.get_string_member ("Name");
version = aur_json.get_string_member ("Version");
desc = aur_json.get_string_member ("Description");
repo = "AUR";
size = 0;
size_string = "";
@ -73,15 +74,9 @@ namespace Pamac {
public struct PackageDetails {
string repo;
// for AUR package it is OutOfDate
string has_signature;
// for AUR package it is NumVotes
int reason;
// for AUR package it is Maintainer
string packager;
// for AUR package it is FirstSubmitted
string build_date;
// for AUR package it is LastModified
string install_date;
string[] groups;
string[] backups;

View File

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

View File

@ -17,19 +17,47 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const string VERSION = "3.0.0";
namespace Pamac {
public class Config: Object {
string conf_path;
[Compact]
public class Config {
public string conf_path;
public bool recurse;
public int refresh_period;
public uint64 refresh_period;
public bool no_update_hide_icon;
public bool enable_aur;
public bool search_aur;
public bool check_aur_updates;
public bool no_confirm_build;
public HashTable<string,string> environment_variables;
public Config (string 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
refresh_period = 6;
reload ();
@ -65,16 +93,15 @@ namespace Pamac {
if (line.length == 0) {
continue;
}
splitted = line.split ("=");
string key = splitted[0].strip ();
string? val = null;
if (splitted[1] != null) {
val = splitted[1].strip ();
}
splitted = line.split ("=", 2);
unowned string key = splitted[0]._strip ();
if (key == "RemoveUnrequiredDeps") {
recurse = true;
} 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") {
no_update_hide_icon = true;
} else if (key == "EnableAUR") {
@ -97,7 +124,7 @@ namespace Pamac {
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
string[] data = {};
var data = new GLib.List<string> ();
if (file.query_exists ()) {
try {
// 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
while ((line = dis.read_line ()) != null) {
if (line.length == 0) {
data += "\n";
data.append ("\n");
continue;
}
unowned Variant variant;
if (line.contains ("RemoveUnrequiredDeps")) {
if (new_conf.contains ("RemoveUnrequiredDeps")) {
bool val = new_conf.get ("RemoveUnrequiredDeps").get_boolean ();
if (val == true) {
data += "RemoveUnrequiredDeps\n";
if (new_conf.lookup_extended ("RemoveUnrequiredDeps", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("RemoveUnrequiredDeps\n");
} else {
data += "#RemoveUnrequiredDeps\n";
data.append ("#RemoveUnrequiredDeps\n");
}
new_conf.remove ("RemoveUnrequiredDeps");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("RefreshPeriod")) {
if (new_conf.contains ("RefreshPeriod")) {
int val = new_conf.get ("RefreshPeriod").get_int32 ();
data += "RefreshPeriod = %u\n".printf (val);
if (new_conf.lookup_extended ("RefreshPeriod", null, out variant)) {
data.append ("RefreshPeriod = %llu\n".printf (variant.get_uint64 ()));
new_conf.remove ("RefreshPeriod");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("NoUpdateHideIcon")) {
if (new_conf.contains ("NoUpdateHideIcon")) {
bool val = new_conf.get ("NoUpdateHideIcon").get_boolean ();
if (val == true) {
data += "NoUpdateHideIcon\n";
if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("NoUpdateHideIcon\n");
} else {
data += "#NoUpdateHideIcon\n";
data.append ("#NoUpdateHideIcon\n");
}
new_conf.remove ("NoUpdateHideIcon");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("EnableAUR")) {
if (new_conf.contains ("EnableAUR")) {
bool val = new_conf.get ("EnableAUR").get_boolean ();
if (val == true) {
data += "EnableAUR\n";
if (new_conf.lookup_extended ("EnableAUR", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("EnableAUR\n");
} else {
data += "#EnableAUR\n";
data.append ("#EnableAUR\n");
}
new_conf.remove ("EnableAUR");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("SearchInAURByDefault")) {
if (new_conf.contains ("SearchInAURByDefault")) {
bool val = new_conf.get ("SearchInAURByDefault").get_boolean ();
if (val == true) {
data += "SearchInAURByDefault\n";
if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("SearchInAURByDefault\n");
} else {
data += "#SearchInAURByDefault\n";
data.append ("#SearchInAURByDefault\n");
}
new_conf.remove ("SearchInAURByDefault");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("CheckAURUpdates")) {
if (new_conf.contains ("CheckAURUpdates")) {
bool val = new_conf.get ("CheckAURUpdates").get_boolean ();
if (val == true) {
data += "CheckAURUpdates\n";
if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("CheckAURUpdates\n");
} else {
data += "#CheckAURUpdates\n";
data.append ("#CheckAURUpdates\n");
}
new_conf.remove ("CheckAURUpdates");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else if (line.contains ("NoConfirmBuild")) {
if (new_conf.contains ("NoConfirmBuild")) {
bool val = new_conf.get ("NoConfirmBuild").get_boolean ();
if (val == true) {
data += "NoConfirmBuild\n";
if (new_conf.lookup_extended ("NoConfirmBuild", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("NoConfirmBuild\n");
} else {
data += "#NoConfirmBuild\n";
data.append ("#NoConfirmBuild\n");
}
new_conf.remove ("NoConfirmBuild");
} else {
data += line + "\n";
data.append (line + "\n");
}
} else {
data += line + "\n";
data.append (line + "\n");
}
}
// delete the file before rewrite it
@ -204,54 +225,57 @@ namespace Pamac {
}
// create lines for unexisted options
if (new_conf.size () != 0) {
data += "\n";
new_conf.foreach ((key, val) => {
data.append ("\n");
var iter = HashTableIter<string,Variant> (new_conf);
unowned string key;
unowned Variant val;
while (iter.next (out key, out val)) {
if (key == "RemoveUnrequiredDeps") {
if (val.get_boolean () == true) {
data += "RemoveUnrequiredDeps\n";
if (val.get_boolean ()) {
data.append ("RemoveUnrequiredDeps\n");
} else {
data += "#RemoveUnrequiredDeps\n";
data.append ("#RemoveUnrequiredDeps\n");
}
} 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") {
if (val.get_boolean () == true) {
data += "NoUpdateHideIcon\n";
if (val.get_boolean ()) {
data.append ("NoUpdateHideIcon\n");
} else {
data += "#NoUpdateHideIcon\n";
data.append ("#NoUpdateHideIcon\n");
}
} else if (key == "EnableAUR") {
if (val.get_boolean () == true) {
data += "EnableAUR\n";
if (val.get_boolean ()) {
data.append ("EnableAUR\n");
} else {
data += "#EnableAUR\n";
data.append ("#EnableAUR\n");
}
} else if (key == "SearchInAURByDefault") {
if (val.get_boolean () == true) {
data += "SearchInAURByDefault\n";
if (val.get_boolean ()) {
data.append ("SearchInAURByDefault\n");
} else {
data += "#SearchInAURByDefault\n";
data.append ("#SearchInAURByDefault\n");
}
} else if (key == "CheckAURUpdates") {
if (val.get_boolean () == true) {
data += "CheckAURUpdates\n";
if (val.get_boolean ()) {
data.append ("CheckAURUpdates\n");
} else {
data += "#CheckAURUpdates\n";
data.append ("#CheckAURUpdates\n");
}
} else if (key == "NoConfirmBuild") {
if (val.get_boolean () == true) {
data += "NoConfirmBuild\n";
if (val.get_boolean ()) {
data.append ("NoConfirmBuild\n");
} else {
data += "#NoConfirmBuild\n";
data.append ("#NoConfirmBuild\n");
}
}
});
}
}
// write the file
try {
// creating a DataOutputStream to the file
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
dos.put_string (new_line);
}

View File

@ -60,17 +60,22 @@ namespace Pamac {
public Gtk.CheckButton no_confirm_build_checkbutton;
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);
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") +":");
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
remove_unrequired_deps_button.active = pamac_config.recurse;
check_space_button.active = transaction.get_checkspace ();
if (pamac_config.refresh_period == 0) {
remove_unrequired_deps_button.active = transaction.pamac_config.recurse;
check_space_button.active = (alpm_config.checkspace == 1);
if (transaction.pamac_config.refresh_period == 0) {
check_updates_button.active = false;
refresh_period_label.sensitive = false;
// set default value
@ -81,15 +86,15 @@ namespace Pamac {
ignorepkgs_box.sensitive = false;
} else {
check_updates_button.active = true;
refresh_period_spin_button.value = pamac_config.refresh_period;
previous_refresh_period = pamac_config.refresh_period;
refresh_period_spin_button.value = transaction.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
Gtk.TreeIter iter;
foreach (var name in transaction.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
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);
@ -98,8 +103,8 @@ namespace Pamac {
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);
Pamac.Package pkg = this.transaction.find_local_satisfier ("pacman-mirrorlist");
if (pkg.name == "") {
unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "pacman-mirrorlist");
if (pkg == null) {
mirrors_config_box.visible = false;
} else {
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
@ -107,7 +112,7 @@ namespace Pamac {
mirrors_country_comboboxtext.active = 0;
int index = 1;
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);
if (country == mirrors_config.choosen_country) {
mirrors_country_comboboxtext.active = index;
@ -126,17 +131,17 @@ namespace Pamac {
transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
}
pkg = this.transaction.find_local_satisfier ("yaourt");
if (pkg.name == "") {
pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, "yaourt");
if (pkg == null) {
aur_config_box.visible = false;
} else {
enable_aur_button.active = pamac_config.enable_aur;
search_aur_checkbutton.active = pamac_config.search_aur;
search_aur_checkbutton.sensitive = pamac_config.enable_aur;
check_aur_updates_checkbutton.active = pamac_config.check_aur_updates;
check_aur_updates_checkbutton.sensitive = pamac_config.enable_aur;
no_confirm_build_checkbutton.active = pamac_config.no_confirm_build;
no_confirm_build_checkbutton.sensitive = pamac_config.enable_aur;
enable_aur_button.active = transaction.pamac_config.enable_aur;
search_aur_checkbutton.active = transaction.pamac_config.search_aur;
search_aur_checkbutton.sensitive = transaction.pamac_config.enable_aur;
check_aur_updates_checkbutton.active = transaction.pamac_config.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.pamac_config.enable_aur;
no_confirm_build_checkbutton.active = transaction.pamac_config.no_confirm_build;
no_confirm_build_checkbutton.sensitive = transaction.pamac_config.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
search_aur_checkbutton.toggled.connect (on_search_aur_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;
no_update_hide_icon_checkbutton.sensitive = new_state;
ignorepkgs_box.sensitive = new_state;
if (new_state == true) {
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (previous_refresh_period));
if (new_state) {
new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (previous_refresh_period));
} 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);
return true;
@ -204,7 +209,7 @@ namespace Pamac {
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 no_confirm_build) {
remove_unrequired_deps_button.state = recurse;
@ -248,7 +253,15 @@ namespace Pamac {
[GtkCallback]
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) {
var ignorepkg_string = new StringBuilder ();
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
@ -257,7 +270,7 @@ namespace Pamac {
bool selected = val.get_boolean ();
if (selected) {
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) {
ignorepkg_string.append (" ");
}
@ -287,7 +300,7 @@ namespace Pamac {
ignorepkgs_liststore.foreach ((model, path, iter) => {
GLib.Value 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) {
ignorepkg_string.append (" ");
}
@ -305,8 +318,8 @@ namespace Pamac {
// re-populate ignorepkgs_liststore
Gtk.TreeIter iter;
ignorepkgs_liststore.clear ();
foreach (var name in transaction.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, name);
for (unowned Alpm.List<string> list = alpm_config.ignorepkgs; list != null; list = list.next ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, list.data);
}
}
@ -331,7 +344,7 @@ namespace Pamac {
mirrors_country_comboboxtext.model.foreach ((model, path, iter) => {
GLib.Value val;
model.get_value (iter, 0, out val);
string country = val.get_string ();
unowned string country = val.get_string ();
if (choosen_country == country) {
return true;
}

View File

@ -33,14 +33,12 @@ namespace Pamac {
[GtkChild]
public Gtk.Expander expander;
Transaction transaction;
public Vte.Terminal term;
Vte.Pty pty;
public ProgressDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
public ProgressDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
this.transaction = transaction;
//creating terminal
term = new Vte.Terminal ();
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) {
Pid intern_pid;
try {

View File

@ -1,7 +1,7 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@ -24,10 +24,10 @@ namespace Pamac {
}
[DBus (name = "org.manjaro.pamac")]
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)]
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 (!check_pamac_running ()) {
try {
pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
"/org/manjaro/pamac");
pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
pamac_daemon.refresh_finished.connect (on_refresh_finished);
pamac_daemon.start_refresh (0);
pamac_daemon.start_refresh (false);
loop = new MainLoop ();
loop.run ();
} catch (IOError e) {

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*
* 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
* 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 {
[DBus (name = "org.manjaro.pamac")]
public interface Daemon : Object {
public abstract void start_refresh (int force) throws IOError;
public abstract async Updates get_updates (bool check_aur_updates) throws IOError;
public abstract void start_refresh (bool force) throws IOError;
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
public signal void refresh_finished (ErrorInfos error);
public signal void write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
public signal void get_updates_finished (Updates updates);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build);
public signal void write_alpm_config_finished (bool checkspace);
@ -40,6 +40,7 @@ namespace Pamac {
public class TrayIcon: Gtk.Application {
Notify.Notification notification;
//~ Notification notification;
Daemon daemon;
bool extern_lock;
uint refresh_timeout_id;
@ -54,9 +55,9 @@ namespace Pamac {
void start_daemon () {
try {
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
"/org/manjaro/pamac");
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac", "/org/manjaro/pamac");
// 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_alpm_config_finished.connect (on_write_alpm_config_finished);
} catch (IOError e) {
@ -65,7 +66,7 @@ namespace Pamac {
}
void stop_daemon () {
if (check_pamac_running () == false) {
if (!check_pamac_running ()) {
try {
daemon.quit ();
} catch (IOError e) {
@ -128,7 +129,7 @@ namespace Pamac {
check_updates ();
} else {
try {
daemon.start_refresh (0);
daemon.start_refresh (false);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
@ -136,10 +137,8 @@ namespace Pamac {
return true;
}
void on_write_pamac_config_finished (bool recurse, int refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates,
bool no_confirm_build) {
launch_refresh_timeout ((uint) refresh_period);
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period) {
launch_refresh_timeout (refresh_period);
if (refresh_period == 0) {
status_icon.visible = false;
} else {
@ -151,36 +150,40 @@ namespace Pamac {
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 () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.refresh_period == 0) {
return;
}
daemon.get_updates.begin ((pamac_config.enable_aur && pamac_config.check_aur_updates), (obj, res) => {
var updates = Updates ();
try {
updates = daemon.get_updates.end (res);
} 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 ();
});
try {
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
void show_notification (string info) {
@ -193,16 +196,44 @@ namespace Pamac {
//~ action.activate.connect (execute_updater);
//~ this.add_action (action);
//~ notification.add_button (_("Show available updates"), "app.update");
//~ notification.set_default_action ("app.update");
//~ this.send_notification (_("Update Manager"), notification);
try {
close_notification();
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 ();
} catch (Error e) {
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 () {
Application app;
bool run = false;
@ -238,7 +269,7 @@ namespace Pamac {
bool check_pacman_running () {
if (extern_lock) {
if (lockfile.query_exists () == false) {
if (!lockfile.query_exists ()) {
extern_lock = false;
// let the time to the daemon to update packages
Timeout.add (1000, () => {
@ -247,20 +278,20 @@ namespace Pamac {
});
}
} else {
if (lockfile.query_exists () == true) {
if (lockfile.query_exists ()) {
extern_lock = 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) {
Source.remove (refresh_timeout_id);
refresh_timeout_id = 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 ();
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
start_daemon ();
Timeout.add (500, check_pacman_running);
Timeout.add (200, check_pacman_running);
start_refresh ();
launch_refresh_timeout ((uint) pamac_config.refresh_period);
launch_refresh_timeout (pamac_config.refresh_period);
this.hold ();
}

View File

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

View File

@ -1,7 +1,7 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@ -25,58 +25,114 @@ namespace Pamac {
[GtkChild]
public Gtk.Label top_label;
[GtkChild]
public Gtk.TreeView updates_treeview;
public Gtk.Notebook notebook;
[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]
public Gtk.Label bottom_label;
[GtkChild]
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 UpdaterWindow (Gtk.Application application) {
Object (application: application);
updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
updates_treeview.set_model (updates_list);
repos_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
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.mode = Mode.UPDATER;
transaction.finished.connect (on_transaction_finished);
transaction.daemon.get_updates_finished.connect (on_get_updates_finished);
bottom_label.set_visible (false);
apply_button.set_sensitive (false);
notebook.set_show_tabs (false);
aur_scrolledwindow.set_visible (false);
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]
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.TreeIter iter;
updates_list.get_iter (out iter, treepath);
updates_list.set (iter, 0, !select_update.active);
updates_list.foreach ((model, path, iter) => {
GLib.Value val;
updates_list.get_value (iter, 0, out val);
bool selected = val.get_boolean ();
if (selected) {
apply_button.set_sensitive (true);
return true;
}
apply_button.set_sensitive (false);
return false;
});
GLib.Value name_string;
repos_updates_list.get_iter (out iter, treepath);
repos_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 (repos_select_update.active) {
repos_updates_list.set (iter, 0, false);
transaction.special_ignorepkgs.add (pkgname);
} else {
repos_updates_list.set (iter, 0, true);
transaction.special_ignorepkgs.remove (pkgname);
}
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 () {
SourceFunc callback = run_preferences_dialog.callback;
ulong handler_id = transaction.daemon.get_authorization_finished.connect ((authorized) => {
if (authorized) {
var preferences_dialog = new PreferencesDialog (transaction, this);
var preferences_dialog = new PreferencesDialog (this, transaction);
preferences_dialog.run ();
preferences_dialog.destroy ();
while (Gtk.events_pending ()) {
@ -93,37 +149,20 @@ namespace Pamac {
[GtkCallback]
public void on_preferences_button_clicked () {
run_preferences_dialog.begin (() => {
set_updates_list.begin ();
populate_updates_list ();
});
}
[GtkCallback]
public void on_apply_button_clicked () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
updates_list.foreach ((model, path, iter) => {
GLib.Value val;
updates_list.get_value (iter, 0, out val);
bool selected = val.get_boolean ();
if (selected) {
updates_list.get_value (iter, 1, out val);
// string has the form "pkgname pkgversion"
string pkgname = val.get_string ().split (" ", 2)[0];
transaction.special_ignorepkgs.remove (pkgname);
} else {
updates_list.get_value (iter, 1, out val);
// string has the form "pkgname pkgversion"
string pkgname = val.get_string ().split (" ", 2)[0];
transaction.special_ignorepkgs.add ((owned) pkgname);
}
return false;
});
transaction.sysupgrade (0);
transaction.sysupgrade (false);
}
[GtkCallback]
public void on_refresh_button_clicked () {
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]
@ -131,55 +170,75 @@ namespace Pamac {
this.application.quit ();
}
public void on_transaction_finished (bool error) {
set_updates_list.begin ();
public void on_transaction_finished (bool database_modified) {
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));
transaction.start_get_updates ();
}
public void on_get_updates_finished (Updates updates) {
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);
Gtk.TreeIter iter;
string name;
string size;
uint64 dsize = 0;
uint updates_nb = 0;
Updates updates = yield transaction.get_updates ();
foreach (UpdateInfos infos in updates.repos_updates) {
name = infos.name + " " + infos.version;
if (infos.download_size != 0) {
size = format_size (infos.download_size);
} else {
size = "";
}
uint repos_updates_nb = 0;
uint aur_updates_nb = 0;
foreach (unowned PackageInfos infos in updates.repos_updates) {
string name = infos.name + " " + infos.version;
string size = infos.download_size != 0 ? format_size (infos.download_size) : "";
dsize += infos.download_size;
updates_nb++;
repos_updates_nb++;
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 {
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) {
name = infos.name + " " + infos.version;
size = "";
updates_nb++;
updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
foreach (unowned PackageInfos infos in updates.aur_updates) {
string name = infos.name + " " + infos.version;
aur_updates_nb++;
if (infos.name in transaction.special_ignorepkgs) {
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) {
top_label.set_markup("<b>%s</b>".printf (dgettext (null, "Your system is up-to-date")));
apply_button.set_sensitive (false);
} else {
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) {
bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.set_visible (true);
} else {
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);
}
}

View File

@ -1,70 +1,59 @@
#include <string.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 *p;
int err = alpm_pkg_load(handle, filename, full, level, &p);
if (err == -1) return NULL;
else return p;
alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level) {
alpm_pkg_t* p;
if (alpm_pkg_load(handle, filename, full, level, &p) != -1) {
return p;
} else {
return NULL;
}
}
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg) {
alpm_list_t *list = NULL;
alpm_filelist_t *pkgfiles;
alpm_list_t* list = NULL;
alpm_filelist_t* pkgfiles;
size_t i;
pkgfiles = alpm_pkg_get_files(pkg);
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);
}
return list;
}
void* alpm_list_get_data (alpm_list_t *list) {
return list->data;
void* alpm_list_get_data (alpm_list_t* list) {
if (list) {
return list->data;
} else {
return NULL;
}
}
void* alpm_list_nth_data (alpm_list_t *list, size_t n) {
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) {
alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn) {
list = alpm_list_msort (list, alpm_list_count (list), fn);
return list;
}
alpm_list_t *alpm_list_new () {
alpm_list_t* alpm_list_new () {
return NULL;
}
void alpm_list_free_all (alpm_list_t *list) {
do { alpm_list_free_inner (list, free); alpm_list_free (list); list = NULL; } while (0);
void alpm_list_free_data (alpm_list_t* list) {
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;
}
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) {
void* result = alpm_list_get_data (iter->pos);
void* data = alpm_list_get_data (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_iterator_t;
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_add_str (alpm_list_t *list, const char *str);
alpm_list_t *alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_new ();
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);
void* alpm_list_get_data (alpm_list_t* list);
alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn);
alpm_list_t* alpm_list_new ();
void alpm_list_free_data (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);
#endif //!ALPM_UTIL_H

View File

@ -31,6 +31,14 @@ namespace Alpm {
*/
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? pkg_find(Alpm.List<Package> haystack, string needle);
@ -45,14 +53,11 @@ namespace Alpm {
/**
* Handle
*/
[CCode (cname = "alpm_handle_t")]
[CCode (cname = "alpm_handle_t", free_function = "alpm_release")]
[Compact]
public class Handle {
[CCode (cname = "alpm_initialize")]
public static unowned Handle @new(string root, string dbpath, out Alpm.Errno error);
[CCode (cname = "alpm_release")]
public static int release (Handle handle);
public static Handle? @new(string root, string dbpath, out Alpm.Errno error);
public unowned string root {
[CCode (cname = "alpm_option_get_root")] get;
@ -73,6 +78,15 @@ namespace Alpm {
[CCode (cname = "alpm_option_remove_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 {
[CCode (cname = "alpm_option_get_logfile")] get;
[CCode (cname = "alpm_option_set_logfile")] set;
@ -146,6 +160,11 @@ namespace Alpm {
[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 {
[CCode (cname = "alpm_option_get_default_siglevel")] get;
[CCode (cname = "alpm_option_set_default_siglevel")] set;
@ -195,6 +214,9 @@ namespace Alpm {
[CCode (cname = "alpm_option_set_progresscb")] set;
}
[CCode (cname = "alpm_unlock")]
public int unlock();
[CCode (cname = "alpm_register_syncdb")]
public unowned DB? register_syncdb(string treename, Signature.Level level);
[CCode (cname = "alpm_unregister_all_syncdbs")]
@ -301,7 +323,7 @@ namespace Alpm {
[CCode (cname = "alpm_db_t", cprefix = "alpm_db_")]
[Compact]
public class DB {
public static int unregister(DB db);
public static int unregister(owned DB db);
public unowned string name {
[CCode (cname = "alpm_db_get_name")] get;
@ -354,12 +376,9 @@ namespace Alpm {
/**
* Packages
*/
[CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_")]
[CCode (cname = "alpm_pkg_t", cprefix = "alpm_pkg_", free_function = "alpm_pkg_free")]
[Compact]
public class Package {
public static int free(Package pkg);
/* properties */
public unowned string filename {
[CCode (cname = "alpm_pkg_get_filename")] get;
@ -370,6 +389,9 @@ namespace Alpm {
public unowned string version {
[CCode (cname = "alpm_pkg_get_version")] get;
}
public unowned string pkgbase {
[CCode (cname = "alpm_pkg_get_base")] get;
}
public From origin {
[CCode (cname = "alpm_pkg_get_origin")] get;
}
@ -684,9 +706,6 @@ namespace Alpm {
DATABASE_MARGINAL_OK = (1 << 12),
DATABASE_UNKNOWN_OK = (1 << 13),
PACKAGE_SET = (1 << 27),
PACKAGE_TRUST_SET = (1 << 28),
USE_DEFAULT = (1 << 31)
}
@ -719,6 +738,13 @@ namespace Alpm {
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 */
[CCode (cname = "alpm_loglevel_t", cprefix = "ALPM_LOG_")]
public enum LogLevel {
@ -754,6 +780,10 @@ namespace Alpm {
INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */
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
* PackageOperation for arguments. */
PACKAGE_OPERATION_START,
@ -824,9 +854,14 @@ namespace Alpm {
/** A .pacsave file was created; See PacsaveCreated for
* arguments */
PACSAVE_CREATED,
/** A .pacorig file was created; See PacorigCreated for
* arguments */
PACORIG_CREATED
/** Processing hooks will be started. */
HOOK_START,
/** 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)]
@ -913,14 +948,26 @@ namespace Alpm {
public unowned string file;
}
[CCode (cname = "alpm_event_pacorig_created_t", has_type_id = false)]
public class PacorigCreated {
/** Type of event. */
[CCode (cname = "alpm_event_hook_t", has_type_id = false)]
public class Hook {
/** Type of event.*/
public Type type;
/** New package. */
public unowned Package newpkg;
/** Filename of the file without the .pacorig suffix. */
public unowned string file;
/** Type of hooks. */
public HookWhen when;
}
[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
@ -969,11 +1016,18 @@ namespace Alpm {
public unowned Package pacsave_created_oldpkg;
[CCode (cname = "pacsave_created.file")]
public unowned string pacsave_created_file;
// PacorigCreated pacorig_created;
[CCode (cname = "pacorig_created.newpkg")]
public unowned Package pacorig_created_newpkg;
[CCode (cname = "pacorig_created.file")]
public unowned string pacorig_created_file;
// Hook hook;
[CCode (cname = "hook.when")]
public HookWhen hook_when;
// HookRun hook_run;
[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). */
public int use_index;
/** 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. */
public unowned Depend depend;
}
@ -1130,7 +1184,7 @@ namespace Alpm {
[CCode (cname = "select_provider.use_index")]
public int select_provider_use_index;
[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")]
public unowned Depend select_provider_depend;
// ImportKey import_key;
@ -1261,6 +1315,7 @@ namespace Alpm {
TRANS_ABORT,
TRANS_TYPE,
TRANS_NOT_LOCKED,
TRANS_HOOK_FAILED,
/* Packages */
PKG_NOT_FOUND,
PKG_IGNORED,
@ -1293,17 +1348,14 @@ namespace Alpm {
GPGME
}
[CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h",
free_function = "alpm_list_free")]
[CCode (cname = "alpm_list_t", cprefix = "alpm_list_", cheader_filename = "alpm_list.h,alpm-util.h",
dup_function = "alpm_list_copy", free_function = "alpm_list_free")]
[Compact]
public class List<G> {
[CCode (cname = "alpm_list_new")]
public List ();
public static void free_all(List list);
/* Comparator*/
/* comparator */
[CCode (cname = "alpm_list_fn_cmp", has_target = false)]
public delegate int CompareFunc<G>(G a, G b);
@ -1317,25 +1369,25 @@ namespace Alpm {
/* item mutators */
[ReturnsModifiedPointer ()]
public unowned void add(G data);
public void add(owned G data);
[ReturnsModifiedPointer ()]
public unowned void add_str(string str);
public void join(owned List<G> list);
[ReturnsModifiedPointer ()]
public unowned void join(List<G> list);
public void sort(CompareFunc fn);
[CCode (cname = "alpm_list_sort_data"), ReturnsModifiedPointer ()]
public unowned void sort(CompareFunc fn);
[ReturnsModifiedPointer ()]
public void remove(G data, CompareFunc fn, out G removed_data );
[CCode (cname = "alpm_list_remove_data"), ReturnsModifiedPointer ()]
public unowned void? remove(G data, CompareFunc fn);
/* free the internal data of this */
public void free_data();
public List<G> copy();
public List<unowned G> copy();
public List<G> copy_data();
[ReturnsModifiedPointer ()]
public unowned void reverse ();
public void reverse ();
/* item accessors */
public unowned List<G>? first();
@ -1344,13 +1396,12 @@ namespace Alpm {
public unowned List<G>? next();
public unowned List<G>? previous();
public unowned G? nth_data(size_t index);
/* misc */
public unowned G? find(G needle, CompareFunc fn);
public unowned string? find_str(string needle);
/** @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 */
public Iterator<G> iterator();
@ -1359,6 +1410,7 @@ namespace Alpm {
public struct Iterator<G> {
public unowned G? next_value();
}
}
}