customized builds

This commit is contained in:
2017-10-10 16:29:22 -03:00
parent 3d5d662152
commit 235c95aa2b
246 changed files with 8857 additions and 1535 deletions

View File

@@ -0,0 +1 @@
add_dependencies(pamac-tray Pamac AUR)

View File

@@ -0,0 +1,106 @@
### CMakeLists automatically created with AutoVala
### Do not edit
set (DATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
set (PKGDATADIR "${DATADIR}/pamac")
set (GETTEXT_PACKAGE "pamac")
set (RELEASE_NAME "pamac")
set (CMAKE_C_FLAGS "")
set (PREFIX ${CMAKE_INSTALL_PREFIX})
set (VERSION "6.0.0")
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
set (DOLLAR "$")
configure_file (${CMAKE_SOURCE_DIR}/src/pamac-tray/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-tray/Config.vala)
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
set (VERSION "6.0.0")
add_definitions (${DEPS_CFLAGS})
include_directories ( ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/aur )
link_libraries ( ${DEPS_LIBRARIES} -lPamac -lAUR )
link_directories ( ${DEPS_LIBRARY_DIRS} ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/aur )
find_package (Vala REQUIRED)
include (ValaVersion)
ensure_vala_version ("0.38" MINIMUM)
include (ValaPrecompile)
set (VALA_PACKAGES ${VALA_PACKAGES} posix)
set (VALA_PACKAGES ${VALA_PACKAGES} json-glib-1.0)
set (VALA_PACKAGES ${VALA_PACKAGES} libnotify)
if (KDE_TRAY)
set (VALA_PACKAGES ${VALA_PACKAGES} appindicator3-0.1)
else ()
set (VALA_PACKAGES ${VALA_PACKAGES} gtk+-3.0)
endif ()
set (VALA_PACKAGES ${VALA_PACKAGES} gio-2.0)
set (VALA_PACKAGES ${VALA_PACKAGES} glib-2.0)
set (VALA_PACKAGES ${VALA_PACKAGES} gobject-2.0)
set (APP_SOURCES ${APP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Config.vala)
if (KDE_TRAY)
set (APP_SOURCES ${APP_SOURCES} tray-appindicator.vala)
else ()
set (APP_SOURCES ${APP_SOURCES} tray-gtk.vala)
endif ()
set (APP_SOURCES ${APP_SOURCES} pamac_config.vala)
set (APP_SOURCES ${APP_SOURCES} tray.vala)
set (APP_SOURCES ${APP_SOURCES} user_daemon.vala)
set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_BINARY_DIR}/src/Pamac.vapi)
if (NOT DISABLE_AUR)
set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_BINARY_DIR}/src/aur/AUR.vapi)
endif ()
if (DISABLE_AUR)
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} -D DISABLE_AUR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_AUR " )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_AUR " )
endif ()
if (KDE_TRAY)
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} -D KDE_TRAY)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKDE_TRAY " )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKDE_TRAY " )
endif ()
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --vapidir=${CMAKE_SOURCE_DIR}/src/vapis )
if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(COMPILE_OPTIONS ${COMPILE_OPTIONS} "-g")
endif()
vala_precompile(VALA_C pamac-tray
${APP_SOURCES}
PACKAGES
${VALA_PACKAGES}
CUSTOM_VAPIS
${CUSTOM_VAPIS_LIST}
OPTIONS
${COMPILE_OPTIONS}
)
add_executable(pamac-tray ${VALA_C})
install(TARGETS
pamac-tray
RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR}
)
if(HAVE_VALADOC)
valadoc(pamac-tray
${CMAKE_BINARY_DIR}/valadoc/pamac-tray
${APP_SOURCES}
PACKAGES
${VALA_PACKAGES}
CUSTOM_VAPIS
${CUSTOM_VAPIS_LIST}
)
install(DIRECTORY
${CMAKE_BINARY_DIR}/valadoc
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/doc/pamac
)
endif()
if (KDE_TRAY)
else ()
endif ()
include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeDepends.txt)

View File

@@ -0,0 +1,10 @@
namespace Constants {
public const string DATADIR = "@DATADIR@";
public const string PKGDATADIR = "@PKGDATADIR@";
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string RELEASE_NAME = "@RELEASE_NAME@";
public const string VERSION = "@VERSION@";
#if UNITEST
public const string TESTSRCDIR = "@TESTSRCDIR@";
#endif
}

View File

@@ -0,0 +1 @@
../pamac_config.vala

View File

@@ -0,0 +1,64 @@
/*
* pamac-vala
*
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
class IndicatorTrayIcon: TrayIcon {
AppIndicator.Indicator indicator_status_icon;
public override void init_status_icon () {
indicator_status_icon = new AppIndicator.Indicator ("Update Manager", noupdate_icon_name, AppIndicator.IndicatorCategory.APPLICATION_STATUS);
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.PASSIVE);
// add a item without label to not show it in menu
// this allow left click action
var item = new Gtk.MenuItem ();
item.visible = true;
item.activate.connect (left_clicked);
menu.append (item);
indicator_status_icon.set_menu (menu);
indicator_status_icon.set_secondary_activate_target (item);
}
public override void set_tooltip (string info) {
indicator_status_icon.set_title (info);
}
public override void set_icon (string icon) {
indicator_status_icon.set_icon_full (icon, icon);
}
public override string get_icon () {
return indicator_status_icon.get_icon ();
}
public override void set_icon_visible (bool visible) {
if (visible) {
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.ACTIVE);
} else {
indicator_status_icon.set_status (AppIndicator.IndicatorStatus.PASSIVE);
}
}
}
}
int main (string[] args) {
var tray_icon = new Pamac.IndicatorTrayIcon();
return tray_icon.run (args);
}

View File

@@ -0,0 +1,63 @@
/*
* pamac-vala
*
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
class GtkTrayIcon: TrayIcon {
Gtk.StatusIcon status_icon;
public override void init_status_icon () {
status_icon = new Gtk.StatusIcon ();
status_icon.visible = false;
status_icon.activate.connect (left_clicked);
status_icon.popup_menu.connect (menu_popup);
}
// Show popup menu on right button
void menu_popup (uint button, uint time) {
menu.popup (null, null, null, button, time);
}
public override void set_tooltip (string info) {
status_icon.set_tooltip_markup (info);
}
public override void set_icon (string icon) {
status_icon.set_from_icon_name (icon);
}
public override string get_icon () {
return status_icon.get_icon_name ();
}
public override void set_icon_visible (bool visible) {
if (visible) {
status_icon.visible = true;
} else {
status_icon.visible = false;
}
}
}
}
int main (string[] args) {
var tray_icon = new Pamac.GtkTrayIcon();
return tray_icon.run (args);
}

290
src/pamac-tray/tray.vala Normal file
View File

@@ -0,0 +1,290 @@
/*
* pamac-vala
*
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
* Copyright (C) 2014-2017 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/>.
*/
// i18n
const string GETTEXT_PACKAGE = "pamac";
const string update_icon_name = "pamac-tray-update";
const string noupdate_icon_name = "pamac-tray-no-update";
const string noupdate_info = _("Your system is up-to-date");
namespace Pamac {
[DBus (name = "org.pamac.user")]
public abstract class TrayIcon: Gtk.Application {
Notify.Notification notification;
UserDaemon daemon;
bool extern_lock;
uint refresh_timeout_id;
public Gtk.Menu menu;
GLib.File lockfile;
public TrayIcon () {
application_id = "org.pamac.tray";
flags = ApplicationFlags.FLAGS_NONE;
}
public abstract void init_status_icon ();
void start_daemon () {
try {
daemon = Bus.get_proxy_sync (BusType.SESSION, "org.pamac.user", "/org/pamac/user");
daemon.get_updates_finished.connect (on_get_updates_finished);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
void stop_daemon () {
if (!check_pamac_running ()) {
try {
daemon.quit ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
}
// Create menu for right button
void create_menu () {
menu = new Gtk.Menu ();
var item = new Gtk.MenuItem.with_label (_("Package Manager"));
item.activate.connect (execute_manager);
menu.append (item);
item = new Gtk.MenuItem.with_mnemonic (_("_Quit"));
item.activate.connect (this.release);
menu.append (item);
menu.show_all ();
}
public void left_clicked () {
if (get_icon () == "pamac-tray-update") {
execute_updater ();
} else {
execute_manager ();
}
}
void execute_updater () {
try {
Process.spawn_command_line_async ("pamac-updater");
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
}
void execute_manager () {
try {
Process.spawn_command_line_async ("pamac-manager");
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
}
public abstract void set_tooltip (string info);
public abstract void set_icon (string icon);
public abstract string get_icon ();
public abstract void set_icon_visible (bool visible);
bool check_updates () {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.refresh_period != 0) {
try {
#if DISABLE_AUR
daemon.start_get_updates ();
#else
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
#endif
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
return true;
}
void on_get_updates_finished (Updates updates) {
#if DISABLE_AUR
uint updates_nb = updates.repos_updates.length;
#else
uint updates_nb = updates.repos_updates.length + updates.aur_updates.length;
#endif
if (updates_nb == 0) {
set_icon (noupdate_icon_name);
set_tooltip (noupdate_info);
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
set_icon_visible (!pamac_config.no_update_hide_icon);
close_notification ();
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
set_icon (update_icon_name);
set_tooltip (info);
set_icon_visible (true);
if (check_pamac_running ()) {
update_notification (info);
} else {
show_notification (info);
}
}
stop_daemon ();
}
void show_notification (string info) {
try {
close_notification ();
notification = new Notify.Notification (_("Package Manager"), info, "system-software-update");
notification.add_action ("default", _("Details"), 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 (_("Package 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.get_closed_reason () == -1) {
notification.close ();
notification = null;
}
} catch (Error e) {
stderr.printf ("Notify Error: %s", e.message);
}
}
bool check_pamac_running () {
Application app;
bool run = false;
app = new Application ("org.pamac.manager", 0);
try {
app.register ();
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
if (run) {
return run;
}
app = new Application ("org.pamac.installer", 0);
try {
app.register ();
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
run = app.get_is_remote ();
return run;
}
bool check_extern_lock () {
if (extern_lock) {
if (!lockfile.query_exists ()) {
extern_lock = false;
try {
daemon.refresh_handle ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
check_updates ();
}
} else {
if (lockfile.query_exists ()) {
if (!check_pamac_running ()) {
extern_lock = true;
}
}
}
return true;
}
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 ((uint) refresh_period_in_hours*3600, check_updates);
}
}
public override void startup () {
// i18n
Intl.textdomain ("pamac");
Intl.setlocale (LocaleCategory.ALL, "");
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
// if refresh period is 0, just return so tray will exit
if (pamac_config.refresh_period == 0) {
return;
}
base.startup ();
extern_lock = false;
refresh_timeout_id = 0;
create_menu ();
init_status_icon ();
set_icon (noupdate_icon_name);
set_tooltip (noupdate_info);
set_icon_visible (!pamac_config.no_update_hide_icon);
Notify.init (_("Package Manager"));
start_daemon ();
try {
lockfile = GLib.File.new_for_path (daemon.get_lockfile ());
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
//try standard lock file
lockfile = GLib.File.new_for_path ("var/lib/pacman/db.lck");
}
Timeout.add (200, check_extern_lock);
// wait 30 seconds before check updates
Timeout.add_seconds (30, () => {
check_updates ();
return false;
});
launch_refresh_timeout (pamac_config.refresh_period);
this.hold ();
}
public override void activate () {
// nothing to do
}
}
}

View File

@@ -0,0 +1,61 @@
/*
* pamac-vala
*
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
[DBus (name = "org.pamac.user")]
interface UserDaemon : Object {
public abstract void refresh_handle () throws IOError;
#if DISABLE_AUR
public abstract void start_get_updates () throws IOError;
#else
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
#endif
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
public signal void get_updates_finished (Updates updates);
public abstract string get_lockfile () throws IOError;
}
[DBus (name = "org.pamac.system")]
interface SystemDaemon : Object {
[DBus (no_reply = true)]
public signal void get_updates_finished (Updates updates);
public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers);
public signal void emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
public signal void emit_log (uint level, string msg);
public signal void set_pkgreason_finished ();
public signal void refresh_finished (bool success);
public signal void trans_prepare_finished (bool success);
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
#if DISABLE_AUR
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon);
#else
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates);
#endif
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line);
public signal void generate_mirrors_list_finished ();
}
}