add appstream support and redesign ui

This commit is contained in:
guinux 2017-09-09 10:23:59 +02:00
parent 282aedada1
commit 80ea4ea70f
23 changed files with 3924 additions and 953 deletions

View File

@ -134,6 +134,5 @@ Icon=system-software-install
Exec=pamac-manager
Terminal=false
Type=Application
Categories=GNOME;GTK;System;
#NotShowIn=KDE;
Categories=GNOME;GTK;System;Settings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
StartupNotify=true

View File

@ -130,6 +130,5 @@ Icon=system-software-update
Exec=pamac-updater
Terminal=false
Type=Application
Categories=GNOME;GTK;System;
#NotShowIn=KDE
Categories=GNOME;GTK;System;Settings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
StartupNotify=true

View File

@ -1,13 +1,13 @@
# Translation of Pamac.
# Copyright (C) 2013-2016 Manjaro Developers <manjaro-dev@manjaro.org>
# Copyright (C) 2013-2017 Manjaro Developers <manjaro-dev@manjaro.org>
# This file is distributed under the same license as the Pamac package.
# Guillaume Benoit <guillaume@manjaro.org>, 2013-2016.
# Guillaume Benoit <guillaume@manjaro.org>, 2013-2017.
#
msgid ""
msgstr ""
"Project-Id-Version: Pamac\n"
"Report-Msgid-Bugs-To: guillaume@manjaro.org\n"
"POT-Creation-Date: 2016-04-24 08:44+0200\n"
"POT-Creation-Date: 2017-09-09 09:46+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -170,6 +170,10 @@ msgstr ""
msgid "To reinstall"
msgstr ""
#: ../src/transaction.vala
msgid "To upgrade"
msgstr ""
#: ../src/transaction.vala ../src/manager_window.vala
msgid "Total download size"
msgstr ""
@ -333,7 +337,7 @@ msgid "Warning"
msgstr ""
#: ../src/transaction.vala ../resources/progress_dialog.ui
#: ../resources/history_dialog.ui
#: ../resources/history_dialog.ui ../resources/preferences_dialog.ui
msgid "_Close"
msgstr ""
@ -349,6 +353,10 @@ msgstr ""
msgid "Pamac is already running"
msgstr ""
#: ../src/installer.vala ../src/manager_window.vala
msgid "Waiting for another package manager to quit"
msgstr ""
#: ../src/tray.vala ../src/manager_window.vala
msgid "Your system is up-to-date"
msgstr ""
@ -373,6 +381,10 @@ msgstr[1] ""
msgid "Details"
msgstr ""
#: ../src/manager_window.vala
msgid "No package found"
msgstr ""
#: ../src/manager_window.vala
msgid "Deselect"
msgstr ""
@ -389,10 +401,6 @@ msgstr ""
msgid "Remove"
msgstr ""
#: ../src/manager_window.vala
msgid "Waiting for another package manager to quit"
msgstr ""
#: ../src/manager_window.vala
#, c-format
msgid "%u pending operation"
@ -400,7 +408,7 @@ msgid_plural "%u pending operations"
msgstr[0] ""
msgstr[1] ""
#: ../src/manager_window.vala
#: ../src/manager_window.vala ../resources/manager_window.ui
msgid "Installed"
msgstr ""
@ -413,7 +421,47 @@ msgid "Foreign"
msgstr ""
#: ../src/manager_window.vala
msgid "Pending"
msgid "Accessories"
msgstr ""
#: ../src/manager_window.vala
msgid "Audio & Video"
msgstr ""
#: ../src/manager_window.vala
msgid "Development"
msgstr ""
#: ../src/manager_window.vala
msgid "Education"
msgstr ""
#: ../src/manager_window.vala
msgid "Games"
msgstr ""
#: ../src/manager_window.vala
msgid "Graphics"
msgstr ""
#: ../src/manager_window.vala
msgid "Internet"
msgstr ""
#: ../src/manager_window.vala
msgid "Office"
msgstr ""
#: ../src/manager_window.vala
msgid "Science"
msgstr ""
#: ../src/manager_window.vala
msgid "Settings"
msgstr ""
#: ../src/manager_window.vala
msgid "System Tools"
msgstr ""
#: ../src/manager_window.vala
@ -594,7 +642,7 @@ msgstr ""
msgid "View History"
msgstr ""
#: ../resources/manager_window.ui
#: ../resources/manager_window.ui ../resources/preferences_dialog.ui
msgid "Preferences"
msgstr ""
@ -603,11 +651,7 @@ msgid "About"
msgstr ""
#: ../resources/manager_window.ui
msgid "Search"
msgstr ""
#: ../resources/manager_window.ui
msgid "State"
msgid "Categories"
msgstr ""
#: ../resources/manager_window.ui
@ -618,6 +662,18 @@ msgstr ""
msgid "Updates"
msgstr ""
#: ../resources/manager_window.ui
msgid "Pending"
msgstr ""
#: ../resources/manager_window.ui
msgid "Search"
msgstr ""
#: ../resources/manager_window.ui
msgid "State"
msgstr ""
#: ../resources/manager_window.ui
msgid "Version"
msgstr ""

View File

@ -1,13 +1,13 @@
# Translation of Pamac.
# Copyright (C) 2013-2016 Manjaro Developers <manjaro-dev@manjaro.org>
# Copyright (C) 2013-2017 Manjaro Developers <manjaro-dev@manjaro.org>
# This file is distributed under the same license as the Pamac package.
# Guillaume Benoit <guillaume@manjaro.org>, 2013-2016.
# Guillaume Benoit <guillaume@manjaro.org>, 2013-2017.
#
msgid ""
msgstr ""
"Project-Id-Version: Pamac\n"
"Report-Msgid-Bugs-To: guillaume@manjaro.org\n"
"POT-Creation-Date: 2016-04-24 08:44+0200\n"
"POT-Creation-Date: 2017-09-09 09:46+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacChooseIgnorepkgsDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">3</property>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacChooseProviderDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">3</property>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacHistoryDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">3</property>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -11,5 +11,6 @@
<file preprocess="to-pixdata">package-reinstall.png</file>
<file preprocess="to-pixdata">package-remove.png</file>
<file preprocess="to-pixdata">package-upgrade.png</file>
<file preprocess="to-pixdata">package-generic.png</file>
</gresource>
</gresources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="cache_keep_nb_adjustment">
<property name="upper">10</property>
<property name="value">3</property>
@ -18,6 +18,7 @@
<template class="PamacPreferencesDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="title" translatable="yes">Preferences</property>
<property name="window_position">center-on-parent</property>
<property name="icon_name">system-software-install</property>
<property name="type_hint">dialog</property>
@ -31,20 +32,31 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
<object class="GtkButton" id="close_button">
<property name="label" translatable="yes">_Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="stack">
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox" id="general_config_box">
<property name="visible">True</property>
@ -370,9 +382,15 @@
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="general_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">General</property>
</object>
<packing>
<property name="name">general</property>
<property name="title" translatable="yes">General</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
@ -485,11 +503,20 @@
</child>
</object>
<packing>
<property name="name">official_repositories</property>
<property name="title" translatable="yes">Official Repositories</property>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="mirrors_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Official Repositories</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="aur_config_box">
<property name="visible">True</property>
@ -640,11 +667,20 @@ All AUR users should be familiar with the build process.</property>
</child>
</object>
<packing>
<property name="name">aur</property>
<property name="title" translatable="yes">AUR</property>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="aur_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">AUR</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="cache_config_box">
<property name="visible">True</property>
@ -736,37 +772,34 @@ All AUR users should be familiar with the build process.</property>
</child>
</object>
<packing>
<property name="name">cache</property>
<property name="title" translatable="yes">Cache</property>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="cache_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Cache</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<placeholder/>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="stackswitcher">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="stack">stack</property>
</object>
</child>
</object>
<action-widgets>
<action-widget response="-7">close_button</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</template>
</interface>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacProgressBox" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacProgressDialog" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="border_width">6</property>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<template class="PamacTransactionSumDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">3</property>

View File

@ -69,6 +69,7 @@ pamac-user-daemon: ../vapi/libalpm.vapi alpm_config.vala common.vala package.val
$(ALPM_VALA_FLAGS) \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=appstream-glib \
--thread \
alpm_config.vala \
common.vala \
@ -112,6 +113,7 @@ pamac-manager: libpamac.so ../resources/manager_resources.c history_dialog.vala
$(PAMAC_LIB_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--pkg=libsoup-2.4 \
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
history_dialog.vala \

View File

@ -61,7 +61,7 @@ namespace Pamac {
this.set_accels_for_action ("app.back", accels);
// search accel
action = new SimpleAction ("search", null);
action.activate.connect (() => {manager_window.filters_stack.visible_child_name = "search";});
action.activate.connect (() => {manager_window.search_button.activate ();});
this.add_action (action);
accels = {"<Ctrl>F"};
this.set_accels_for_action ("app.search", accels);
@ -70,11 +70,16 @@ namespace Pamac {
public override int command_line (ApplicationCommandLine cmd) {
if (cmd.get_arguments ()[0] == "pamac-updater") {
if (!started) {
manager_window.update_lists ();
started = true;
}
manager_window.display_package_queue.clear ();
manager_window.main_stack.visible_child_name = "browse";
manager_window.filters_stack.visible_child_name = "updates";
} else if (!started) {
manager_window.show_default_pkgs ();
manager_window.update_lists ();
manager_window.refresh_packages_list ();
started = true;
}
if (!pamac_run) {

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
namespace Pamac {
public struct AlpmPackage {
public string name;
public string app_name;
public string version;
public string installed_version;
public string desc;
@ -27,15 +28,20 @@ namespace Pamac {
public uint64 size;
public uint64 download_size;
public uint origin;
public string icon;
}
public struct AlpmPackageDetails {
public string name;
public string app_name;
public string version;
public string desc;
public string long_desc;
public string repo;
public uint origin;
public string url;
public string icon;
public string screenshot;
public string packager;
public string builddate;
public string installdate;
@ -69,9 +75,9 @@ namespace Pamac {
public string packagebase;
public string url;
public string maintainer;
public int64 firstsubmitted;
public int64 lastmodified;
public int64 outofdate;
public string firstsubmitted;
public string lastmodified;
public string outofdate;
public int64 numvotes;
public string[] licenses;
public string[] depends;

View File

@ -62,10 +62,11 @@ namespace Pamac {
Gtk.ListStore ignorepkgs_liststore;
Transaction transaction;
uint64 previous_refresh_period;
string[] countries;
public PreferencesDialog (Transaction transaction) {
Object (transient_for: transaction.application_window, use_header_bar: 1);
int use_header_bar;
Gtk.Settings.get_default ().get ("gtk-dialogs-use-header", out use_header_bar);
Object (transient_for: transaction.application_window, use_header_bar: use_header_bar);
this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
@ -109,9 +110,11 @@ namespace Pamac {
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
mirrors_country_comboboxtext.active = 0;
countries = transaction.get_mirrors_countries ();
if (transaction.preferences_available_countries.length == 0) {
transaction.preferences_available_countries = transaction.get_mirrors_countries ();
}
int index = 1;
foreach (unowned string country in countries) {
foreach (unowned string country in transaction.preferences_available_countries) {
mirrors_country_comboboxtext.append_text (country);
if (country == mirrors_config.choosen_country) {
mirrors_country_comboboxtext.active = index;

View File

@ -551,19 +551,23 @@ namespace Pamac {
}
return AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
// desc can be null
desc = alpm_pkg.desc ?? "",
repo = (owned) repo_name,
size = alpm_pkg.isize,
origin = (uint) alpm_pkg.origin
origin = (uint) alpm_pkg.origin,
icon = ""
};
} else {
return AlpmPackage () {
name = "",
app_name = "",
version = "",
desc = "",
repo = ""
repo = "",
icon = ""
};
}
}

View File

@ -36,11 +36,12 @@ namespace Pamac {
public abstract AlpmPackage find_sync_satisfier (string depstring) throws IOError;
public abstract async AlpmPackage[] search_pkgs (string search_string) throws IOError;
public abstract async AURPackage[] search_in_aur (string search_string) throws IOError;
public abstract async AlpmPackage[] get_category_pkgs (string category) throws IOError;
public abstract string[] get_repos_names () throws IOError;
public abstract async AlpmPackage[] get_repo_pkgs (string repo) throws IOError;
public abstract string[] get_groups_names () throws IOError;
public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws IOError;
public abstract AlpmPackageDetails get_pkg_details (string pkgname) throws IOError;
public abstract AlpmPackageDetails get_pkg_details (string pkgname, string app_name) throws IOError;
public abstract string[] get_pkg_files (string pkgname) throws IOError;
public abstract async AURPackageDetails get_aur_details (string pkgname) throws IOError;
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
@ -154,6 +155,7 @@ namespace Pamac {
StringBuilder warning_textbuffer;
//dialogs
public string[] preferences_available_countries;
TransactionSumDialog transaction_sum_dialog;
public ProgressBox progress_box;
Vte.Terminal term;
@ -198,6 +200,7 @@ namespace Pamac {
connecting_user_daemon ();
//creating dialogs
this.application_window = application_window;
preferences_available_countries = {};
transaction_sum_dialog = new TransactionSumDialog (application_window);
progress_box = new ProgressBox ();
progress_box.progressbar.text = "";
@ -658,6 +661,16 @@ namespace Pamac {
return pkgs;
}
public async AlpmPackage[] get_category_pkgs (string category) {
AlpmPackage[] pkgs = {};
try {
pkgs = yield user_daemon.get_category_pkgs (category);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
return pkgs;
}
public string[] get_repos_names () {
string[] repos_names = {};
try {
@ -708,9 +721,9 @@ namespace Pamac {
return optdeps;
}
public AlpmPackageDetails get_pkg_details (string pkgname) {
public AlpmPackageDetails get_pkg_details (string pkgname, string app_name) {
try {
return user_daemon.get_pkg_details (pkgname);
return user_daemon.get_pkg_details (pkgname, app_name);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
return AlpmPackageDetails () {

View File

@ -89,6 +89,8 @@ namespace Pamac {
private Json.Array aur_updates_results;
private HashTable<string, Json.Array> aur_search_results;
private HashTable<string, Json.Object> aur_infos;
private As.Store app_store;
private string locale;
public signal void get_updates_finished (Updates updates);
@ -98,6 +100,20 @@ namespace Pamac {
aur_search_results = new HashTable<string, Json.Array> (str_hash, str_equal);
aur_infos = new HashTable<string, Json.Object> (str_hash, str_equal);
refresh_handle ();
// init appstream
app_store = new As.Store ();
locale = Environ.get_variable (Environ.get (), "LANG");
if (locale != null) {
// remove .UTF-8 from locale
locale = locale.split (".")[0];
} else {
locale = "C";
}
try {
app_store.load (As.StoreLoadFlags.APP_INFO_SYSTEM);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
}
public void refresh_handle () {
@ -156,7 +172,124 @@ namespace Pamac {
return 0;
}
private string get_localized_string (HashTable<string,string> hashtable) {
unowned string val;
if (!hashtable.lookup_extended (locale, null, out val)) {
// try with just the language
if (!hashtable.lookup_extended (locale.split ("_")[0], null, out val)) {
// try C locale
if (!hashtable.lookup_extended ("C", null, out val)) {
return "";
}
}
}
return val;
}
private string get_app_name (As.App app) {
return get_localized_string (app.get_names ());
}
private string get_app_summary (As.App app) {
return get_localized_string (app.get_comments ());
}
private string get_app_description (As.App app) {
return get_localized_string (app.get_descriptions ());
}
private string get_app_icon (As.App app, string dbname) {
string icon = "";
app.get_icons ().foreach ((as_icon) => {
if (as_icon.get_kind () == As.IconKind.CACHED) {
if (as_icon.get_height () == 64) {
icon = "/usr/share/app-info/icons/archlinux-arch-%s/64x64/%s".printf (dbname, as_icon.get_name ());
}
}
});
return icon;
}
private string get_app_screenshot (As.App app) {
string screenshot = "";
app.get_screenshots ().foreach ((as_screenshot) => {
if (as_screenshot.get_kind () == As.ScreenshotKind.DEFAULT) {
As.Image? as_image = as_screenshot.get_source ();
if (as_image != null) {
screenshot = as_image.get_url ();
}
}
});
return screenshot;
}
private As.App[] get_pkgname_matching_apps (string pkgname) {
As.App[] matching_apps = {};
app_store.get_apps ().foreach ((app) => {
if (app.get_pkgname_default () == pkgname) {
matching_apps += app;
}
});
return matching_apps;
}
private AlpmPackage initialise_pkg_struct (Alpm.Package? alpm_pkg) {
if (alpm_pkg != null) {
string installed_version = "";
string repo_name = "";
string desc = alpm_pkg.desc ?? "";
string icon = "";
string app_name = "";
if (alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
installed_version = alpm_pkg.version;
unowned Alpm.Package? sync_pkg = get_syncpkg (alpm_pkg.name);
if (sync_pkg != null) {
repo_name = sync_pkg.db.name;
}
} else if (alpm_pkg.origin == Alpm.Package.From.SYNCDB) {
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (alpm_pkg.name);
if (local_pkg != null) {
installed_version = local_pkg.version;
}
repo_name = alpm_pkg.db.name;
}
if (repo_name != "") {
// find if pkgname provides only one app
As.App[] matching_apps = get_pkgname_matching_apps (alpm_pkg.name);
if (matching_apps.length == 1) {
As.App app = matching_apps[0];
app_name = get_app_name (app);
desc = get_app_summary (app);
icon = get_app_icon (app, repo_name);
}
}
return AlpmPackage () {
name = alpm_pkg.name,
app_name = (owned) app_name,
version = alpm_pkg.version,
installed_version = (owned) installed_version,
desc = (owned) desc,
repo = (owned) repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = (owned) icon
};
} else {
return AlpmPackage () {
name = "",
app_name = "",
version = "",
installed_version = "",
desc = "",
repo = "",
icon = ""
};
}
}
private AlpmPackage[] initialise_pkg_structs (Alpm.Package? alpm_pkg) {
AlpmPackage[] pkgs = {};
if (alpm_pkg != null) {
string installed_version = "";
string repo_name = "";
@ -173,26 +306,54 @@ namespace Pamac {
}
repo_name = alpm_pkg.db.name;
}
return AlpmPackage () {
name = alpm_pkg.name,
version = alpm_pkg.version,
installed_version = (owned) installed_version,
// desc can be null
desc = alpm_pkg.desc ?? "",
repo = (owned) repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin
};
} else {
return AlpmPackage () {
name = "",
version = "",
installed_version = "",
desc = "",
repo = ""
};
if (repo_name != "") {
As.App[] apps = get_pkgname_matching_apps (alpm_pkg.name);
if (apps.length > 0) {
// alpm_pkg provide some apps
foreach (unowned As.App app in apps) {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = get_app_name (app),
version = alpm_pkg.version,
installed_version = installed_version,
desc = get_app_summary (app),
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = get_app_icon (app, repo_name)
};
}
} else {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
installed_version = installed_version,
desc = alpm_pkg.desc ?? "",
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = ""
};
}
} else {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
installed_version = installed_version,
desc = alpm_pkg.desc ?? "",
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = ""
};
}
}
return pkgs;
}
public async AlpmPackage[] get_installed_pkgs () {
@ -200,7 +361,9 @@ namespace Pamac {
unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache;
while (pkgcache != null) {
unowned Alpm.Package alpm_pkg = pkgcache.data;
pkgs += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgcache.next ();
}
return pkgs;
@ -212,7 +375,9 @@ namespace Pamac {
while (pkgcache != null) {
unowned Alpm.Package alpm_pkg = pkgcache.data;
if (alpm_pkg.reason == Alpm.Package.Reason.EXPLICIT) {
pkgs += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
}
pkgcache.next ();
}
@ -236,7 +401,9 @@ namespace Pamac {
syncdbs.next ();
}
if (sync_found == false) {
pkgs += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
}
pkgcache.next ();
}
@ -253,7 +420,9 @@ namespace Pamac {
if (requiredby.length == 0) {
Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor ();
if (optionalfor.length == 0) {
pkgs += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
} else {
optionalfor.free_inner (GLib.free);
}
@ -336,15 +505,17 @@ namespace Pamac {
}
public async AlpmPackage[] search_pkgs (string search_string) {
AlpmPackage[] result = {};
AlpmPackage[] pkgs = {};
Alpm.List<unowned Alpm.Package> alpm_pkgs = search_all_dbs (search_string);
unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs;
while (list != null) {
unowned Alpm.Package alpm_pkg = list.data;
result += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
list.next ();
}
return result;
return pkgs;
}
private AURPackage initialise_aur_struct (Json.Object json_object) {
@ -388,9 +559,9 @@ namespace Pamac {
string packagebase = "";
string url = "";
string maintainer = "";
int64 firstsubmitted = 0;
int64 lastmodified = 0;
int64 outofdate = 0;
string firstsubmitted = "";
string lastmodified = "";
string outofdate = "";
int64 numvotes = 0;
string[] licenses = {};
string[] depends = {};
@ -431,13 +602,16 @@ namespace Pamac {
maintainer = node.get_string ();
}
// firstsubmitted
firstsubmitted = json_object.get_int_member ("FirstSubmitted");
GLib.Time time = GLib.Time.local ((time_t) json_object.get_int_member ("FirstSubmitted"));
firstsubmitted = time.format ("%x");
// lastmodified
lastmodified = json_object.get_int_member ("LastModified");
time = GLib.Time.local ((time_t) json_object.get_int_member ("LastModified"));
lastmodified = time.format ("%x");
// outofdate can be null
node = json_object.get_member ("OutOfDate");
if (!node.is_null ()) {
outofdate = node.get_int ();
time = GLib.Time.local ((time_t) node.get_int ());
outofdate = time.format ("%x");
}
//numvotes
numvotes = json_object.get_int_member ("NumVotes");
@ -544,9 +718,13 @@ namespace Pamac {
unowned Alpm.Package sync_pkg = pkgcache.data;
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (sync_pkg.name);
if (local_pkg != null) {
pkgs += initialise_pkg_struct (local_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (local_pkg)) {
pkgs += pkg;
}
} else {
pkgs += initialise_pkg_struct (sync_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (sync_pkg)) {
pkgs += pkg;
}
}
pkgcache.next ();
}
@ -619,12 +797,52 @@ namespace Pamac {
unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs;
while (list != null) {
unowned Alpm.Package alpm_pkg = list.data;
pkgs += initialise_pkg_struct (alpm_pkg);
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
list.next ();
}
return pkgs;
}
public async AlpmPackage[] get_category_pkgs (string category) {
AlpmPackage[] pkgs = {};
app_store.get_apps ().foreach ((app) => {
app.get_categories ().foreach ((cat_name) => {
if (cat_name == category) {
string pkgname = app.get_pkgname_default ();
string installed_version = "";
string repo_name = "";
uint origin;
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (pkgname);
unowned Alpm.Package? sync_pkg = get_syncpkg (pkgname);
if (sync_pkg != null) {
if (local_pkg == null) {
repo_name = sync_pkg.db.name;
origin = (uint) sync_pkg.origin;
} else {
installed_version = local_pkg.version;
origin = (uint) local_pkg.origin;
}
pkgs += AlpmPackage () {
name = sync_pkg.name,
app_name = get_app_name (app),
version = sync_pkg.version,
installed_version = (owned) installed_version,
desc = get_app_summary (app),
repo = (owned) repo_name,
size = sync_pkg.isize,
download_size = sync_pkg.download_size,
origin = origin,
icon = get_app_icon (app, sync_pkg.db.name)
};
}
}
});
});
return pkgs;
}
public string[] get_pkg_uninstalled_optdeps (string pkgname) {
string[] optdeps = {};
unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname);
@ -644,11 +862,15 @@ namespace Pamac {
return optdeps;
}
public AlpmPackageDetails get_pkg_details (string pkgname) {
public AlpmPackageDetails get_pkg_details (string pkgname, string appname) {
string name = "";
string app_name = "";
string version = "";
string desc = "";
string long_desc = "";
string url = "";
string icon = "";
string screenshot = "";
string repo = "";
string has_signature = "";
string reason = "";
@ -667,8 +889,9 @@ namespace Pamac {
string[] conflicts = {};
var details = AlpmPackageDetails ();
unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname);
unowned Alpm.Package? sync_pkg = get_syncpkg (pkgname);
if (alpm_pkg == null) {
alpm_pkg = get_syncpkg (pkgname);
alpm_pkg = sync_pkg;
}
if (alpm_pkg != null) {
// name
@ -679,6 +902,36 @@ namespace Pamac {
if (alpm_pkg.desc != null) {
desc = alpm_pkg.desc;
}
if (sync_pkg != null) {
if (appname != "") {
app_store.get_apps ().foreach ((app) => {
if (get_app_name (app) == appname) {
app_name = appname;
try {
long_desc = As.markup_convert_simple (get_app_description (app));
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
icon = get_app_icon (app, sync_pkg.db.name);
screenshot = get_app_screenshot (app);
}
});
} else {
// find if pkgname provides only one app
As.App[] matching_apps = get_pkgname_matching_apps (pkgname);
if (matching_apps.length == 1) {
As.App app = matching_apps[0];
app_name = get_app_name (app);
try {
desc = As.markup_convert_simple (get_app_description (app));
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
icon = get_app_icon (app, sync_pkg.db.name);
screenshot = get_app_screenshot (app);
}
}
}
details.origin = (uint) alpm_pkg.origin;
// url can be null
if (alpm_pkg.url != null) {
@ -700,11 +953,10 @@ namespace Pamac {
}
// build_date
GLib.Time time = GLib.Time.local ((time_t) alpm_pkg.builddate);
builddate = time.format ("%a %d %b %Y %X %Z");
builddate = time.format ("%x");
// local pkg
if (alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
// repo
unowned Alpm.Package? sync_pkg = get_syncpkg (alpm_pkg.name);
if (sync_pkg != null) {
repo = sync_pkg.db.name;
}
@ -718,7 +970,7 @@ namespace Pamac {
}
// install_date
time = GLib.Time.local ((time_t) alpm_pkg.installdate);
installdate = time.format ("%a %d %b %Y %X %Z");
installdate = time.format ("%x");
// backups
list = alpm_pkg.backups;
while (list != null) {
@ -780,10 +1032,14 @@ namespace Pamac {
}
}
details.name = (owned) name;
details.app_name = (owned) app_name;
details.version = (owned) version;
details.desc = (owned) desc;
details.long_desc = (owned) long_desc;
details.repo = (owned) repo;
details.url = (owned) url;
details.icon = (owned) icon;
details.screenshot = (owned) screenshot;
details.packager = (owned) packager;
details.builddate = (owned) builddate;
details.installdate = (owned) installdate;

2077
vapi/appstream-glib.vapi Normal file

File diff suppressed because it is too large Load Diff