From 00f4092ee43f62b64a507f9f83730064073015b0 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Fri, 10 Nov 2017 22:36:50 -0300 Subject: [PATCH] change config to gsettings --- CMakeLists.txt | 3 +- data/config/CMakeLists.txt | 19 -- data/config/noaur/CMakeLists.txt | 19 -- data/config/noaur/pamac.conf | 26 -- data/config/pamac.conf | 41 --- data/schemas/CMakeLists.txt | 33 +++ data/schemas/org.pamac.aur.gschema.xml | 37 +++ data/schemas/org.pamac.main.gschema.xml | 69 +++++ meson.build | 7 +- pamac.avprj | 24 +- po/pamac.pot | 2 +- src/CMakeLists.txt | 6 +- src/meson.build | 6 +- src/pamac-clean-cache/CMakeLists.txt | 5 +- src/pamac-clean-cache/clean_cache.vala | 2 +- src/pamac-clean-cache/meson.build | 3 +- src/pamac-install/CMakeLists.txt | 4 +- src/pamac-install/meson.build | 2 +- src/pamac-manager/CMakeLists.txt | 4 +- src/pamac-manager/manager_window.vala | 8 +- src/pamac-manager/meson.build | 2 +- src/pamac-system-daemon/CMakeLists.txt | 4 +- src/pamac-system-daemon/meson.build | 2 +- src/pamac-system-daemon/system_daemon.vala | 20 +- src/pamac-tray/CMakeLists.txt | 4 +- src/pamac-tray/meson.build | 2 +- src/pamac-tray/tray-appindicator.vala | 8 + src/pamac-tray/tray-gtk.vala | 4 + src/pamac-tray/tray.vala | 31 ++- src/pamac-user-daemon/CMakeLists.txt | 4 +- src/pamac-user-daemon/meson.build | 2 +- src/pamac_config.vala | 302 ++------------------- src/pamacclassic.pc | 2 +- src/preferences_dialog.vala | 130 ++++----- src/transaction.vala | 55 ++-- 35 files changed, 347 insertions(+), 545 deletions(-) delete mode 100644 data/config/CMakeLists.txt delete mode 100644 data/config/noaur/CMakeLists.txt delete mode 100644 data/config/noaur/pamac.conf delete mode 100644 data/config/pamac.conf create mode 100644 data/schemas/CMakeLists.txt create mode 100644 data/schemas/org.pamac.aur.gschema.xml create mode 100644 data/schemas/org.pamac.main.gschema.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index ff8991a..0252e40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,17 +61,16 @@ if ( NOT WHERE_GRESOURCE ) endif() add_subdirectory(src/vapis) +add_subdirectory(data/schemas) add_subdirectory(po) add_subdirectory(data/pixmaps) add_subdirectory(data/mime) add_subdirectory(data/polkit) add_subdirectory(data/systemd) -add_subdirectory(data/config) add_subdirectory(data) add_subdirectory(data/dbus) add_subdirectory(data/icons/24x24/status) add_subdirectory(data/icons/16x16/apps) -add_subdirectory(data/config/noaur) add_subdirectory(data/icons/32x32/apps) add_subdirectory(data/interface) add_subdirectory(src) diff --git a/data/config/CMakeLists.txt b/data/config/CMakeLists.txt deleted file mode 100644 index 23cf845..0000000 --- a/data/config/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -### CMakeLists automatically created with AutoVala -### Do not edit - -if (NOT(DISABLE_AUR)) - IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf) - install(DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf - DESTINATION - /etc - ) -ELSE() - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf - DESTINATION - /etc - ) -ENDIF() - -endif () diff --git a/data/config/noaur/CMakeLists.txt b/data/config/noaur/CMakeLists.txt deleted file mode 100644 index 43039ab..0000000 --- a/data/config/noaur/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -### CMakeLists automatically created with AutoVala -### Do not edit - -if (DISABLE_AUR) - IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf) - install(DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf - DESTINATION - /etc - ) -ELSE() - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/pamac.conf - DESTINATION - /etc - ) -ENDIF() - -endif () diff --git a/data/config/noaur/pamac.conf b/data/config/noaur/pamac.conf deleted file mode 100644 index 7ae75ca..0000000 --- a/data/config/noaur/pamac.conf +++ /dev/null @@ -1,26 +0,0 @@ -### Pamac configuration file - -## When removing a package, also remove those dependencies -## that are not required by other packages (recurse option): -#RemoveUnrequiredDeps - -## How often to check for updates, value in hours (0 to disable): -RefreshPeriod = 6 - -## When there are no updates available, hide the tray icon: -#NoUpdateHideIcon - -## Number of versions of each package to keep in the cache: -KeepNumPackages = 3 - -## Remove only the versions of uninstalled packages when clean cache: -#OnlyRmUninstalled - -## Terminal background color -BackgroundColor = rgb(0,0,0) - -## Terminal foreground color -ForegroundColor = rgb(255,255,255) - -## The font used in the terminal -TerminalFont = Monospace Regular 12 diff --git a/data/config/pamac.conf b/data/config/pamac.conf deleted file mode 100644 index 7e58b6b..0000000 --- a/data/config/pamac.conf +++ /dev/null @@ -1,41 +0,0 @@ -### Pamac configuration file - -## When removing a package, also remove those dependencies -## that are not required by other packages (recurse option): -#RemoveUnrequiredDeps - -## How often to check for updates, value in hours (0 to disable): -RefreshPeriod = 6 - -## When there are no updates available, hide the tray icon: -#NoUpdateHideIcon - -## Allow Pamac to search and install packages from AUR: -#EnableAUR - -## When AUR support is enabled search in AUR by default: -#SearchInAURByDefault - -## When AUR support is enabled check for updates from AUR: -#CheckAURUpdates - -## AUR build directory: -BuildDirectory = /tmp - -## Do not ask for confirmation when building packages: -#NoConfirmBuild - -## Number of versions of each package to keep in the cache: -KeepNumPackages = 3 - -## Remove only the versions of uninstalled packages when clean cache: -#OnlyRmUninstalled - -## Terminal background color -BackgroundColor = rgb(0,0,0) - -## Terminal foreground color -ForegroundColor = rgb(255,255,255) - -## The font used in the terminal -TerminalFont = Monospace Regular 12 diff --git a/data/schemas/CMakeLists.txt b/data/schemas/CMakeLists.txt new file mode 100644 index 0000000..3590f79 --- /dev/null +++ b/data/schemas/CMakeLists.txt @@ -0,0 +1,33 @@ +### CMakeLists automatically created with AutoVala +### Do not edit + +IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.main.gschema.xml) + install(DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.main.gschema.xml + DESTINATION + /usr/share/glib-2.0/schemas + ) +ELSE() + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.main.gschema.xml + DESTINATION + /usr/share/glib-2.0/schemas + ) +ENDIF() + +if (NOT DISABLE_AUR) + IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.aur.gschema.xml) + install(DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.aur.gschema.xml + DESTINATION + /usr/share/glib-2.0/schemas + ) +ELSE() + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/org.pamac.aur.gschema.xml + DESTINATION + /usr/share/glib-2.0/schemas + ) +ENDIF() + +endif () diff --git a/data/schemas/org.pamac.aur.gschema.xml b/data/schemas/org.pamac.aur.gschema.xml new file mode 100644 index 0000000..8956daf --- /dev/null +++ b/data/schemas/org.pamac.aur.gschema.xml @@ -0,0 +1,37 @@ + + + + + false + Enable AUR + + Allow Pamac to search and install packages from AUR + + + + + true + Search in AUR by default + + When AUR support is enabled search in AUR by default + + + + + false + Check AUR for updates + + When AUR support is enabled check for updates from AUR + + + + + "/tmp" + AUR build directory + + Directory where to build packages that come from the AUR + + + + + diff --git a/data/schemas/org.pamac.main.gschema.xml b/data/schemas/org.pamac.main.gschema.xml new file mode 100644 index 0000000..b82f8c0 --- /dev/null +++ b/data/schemas/org.pamac.main.gschema.xml @@ -0,0 +1,69 @@ + + + + + false + Remove unrequired dependencies + + When removing a package, also remove those dependencies that are not required by other packages (recurse option) + + + + + 6 + Refresh period + + How often to check for updates, value in hours (0 to disable) + + + + + true + Hide icon if there are no updates + + When there are no updates available, hide the tray icon + + + + + 3 + Numer of packages to keep + + Number of versions of each package to keep in the cache + + + + + false + Remove only uninstalled packages when cleaning cache + + Remove only the versions of uninstalled packages when clean cache + + + + + "rgb(0,0,0)" + Terminal background color + + Terminal background color + + + + + "rgb(255,255,255)" + Terminal foreground color + + Terminal foreground color + + + + + "Monospace Regular 12" + Terminal font + + The font used in the terminal + + + + + diff --git a/meson.build b/meson.build index f63acb7..b40833d 100644 --- a/meson.build +++ b/meson.build @@ -36,11 +36,10 @@ meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts',' meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts','install_data.sh'),'/usr/lib/systemd/system',join_paths(meson.current_source_dir(),'data/systemd','pamac-mirrorlist.timer')) -if DISABLE_AUR - meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts','install_data.sh'),'/etc',join_paths(meson.current_source_dir(),'data/config/noaur','pamac.conf')) +meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts','install_data.sh'),'/usr/share/glib-2.0/schemas',join_paths(meson.current_source_dir(),'data/schemas','org.pamac.main.gschema.xml')) -else - meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts','install_data.sh'),'/etc',join_paths(meson.current_source_dir(),'data/config','pamac.conf')) +if not DISABLE_AUR + meson.add_install_script(join_paths(meson.current_source_dir(),'meson_scripts','install_data.sh'),'/usr/share/glib-2.0/schemas',join_paths(meson.current_source_dir(),'data/schemas','org.pamac.aur.gschema.xml')) endif pamac_installer_gresource_xml_generator = generator(find_program('glib-compile-resources'), arguments: [ '--sourcedir=@SOURCE_DIR@/data' , '--generate-source', '--target=@BUILD_DIR@/pamac.installer.gresource.xml.c', '@INPUT@'], output: '@PLAINNAME@.c') diff --git a/pamac.avprj b/pamac.avprj index 2a7dd05..34ac185 100644 --- a/pamac.avprj +++ b/pamac.avprj @@ -1,7 +1,7 @@ ### AutoVala Project ### autovala_version: 27 project_name: pamac-classic -project_version: 6.5.2 +project_version: 6.6.0 vala_version: 0.38 custom: data/systemd/pamac-system.service /usr/lib/systemd/system @@ -9,10 +9,9 @@ custom: data/systemd/pamac-cleancache.service /usr/lib/systemd/system custom: data/systemd/pamac-cleancache.timer /usr/lib/systemd/system custom: data/systemd/pamac-mirrorlist.service /usr/lib/systemd/system custom: data/systemd/pamac-mirrorlist.timer /usr/lib/systemd/system -if DISABLE_AUR -custom: data/config/noaur/pamac.conf /etc -else -custom: data/config/pamac.conf /etc +custom: data/schemas/org.pamac.main.gschema.xml /usr/share/glib-2.0/schemas +if NOT DISABLE_AUR +custom: data/schemas/org.pamac.aur.gschema.xml /usr/share/glib-2.0/schemas end define: ENABLE_UPDATE_ICON @@ -27,19 +26,18 @@ define: KDE_TRAY vapidir: src/vapis vala_binary: src/pamac-clean-cache/pamac-clean-cache -*version: 6.5.2 +*version: 6.6.0 vala_local_package: pamacclassic vala_package: posix vala_check_package: gtk+-3.0 vala_check_package: json-glib-1.0 -*vala_check_package: gio-2.0 *vala_check_package: glib-2.0 *vala_check_package: gobject-2.0 *vala_source: clean_cache.vala *vala_source: pamac_config.vala vala_binary: src/pamac-install/pamac-install -*version: 6.5.2 +*version: 6.6.0 use_gresource: pamac_installer_gresource_xml vala_local_package: pamacclassic vala_check_package: gtk+-3.0 @@ -51,7 +49,7 @@ vala_check_package: json-glib-1.0 *vala_source: progress_dialog.vala vala_binary: src/pamac-manager/pamac-manager -*version: 6.5.2 +*version: 6.6.0 alias: pamac-updater use_gresource: pamac_manager_gresource_xml vala_local_package: pamacclassic @@ -65,7 +63,7 @@ vala_check_package: json-glib-1.0 *vala_source: manager_window.vala vala_binary: src/pamac-system-daemon/pamac-system-daemon -*version: 6.5.2 +*version: 6.6.0 vala_local_package: pamacclassic vala_package: posix vala_check_package: gtk+-3.0 @@ -83,7 +81,7 @@ vala_check_package: polkit-gobject-1 *vala_source: system_daemon.vala vala_binary: src/pamac-tray/pamac-tray -*version: 6.5.2 +*version: 6.6.0 vala_local_package: pamacclassic vala_package: posix vala_check_package: json-glib-1.0 @@ -107,7 +105,7 @@ end *vala_source: tray.vala vala_binary: src/pamac-user-daemon/pamac-user-daemon -*version: 6.5.2 +*version: 6.6.0 vala_local_package: pamacclassic vala_package: posix vala_check_package: gtk+-3.0 @@ -122,7 +120,7 @@ vala_check_package: libsoup-2.4 vala_library: src/pamac-classic -*version: 6.5.2 +*version: 6.6.0 namespace: pamacclassic use_gresource: pamac_transaction_gresource_xml vala_package: posix diff --git a/po/pamac.pot b/po/pamac.pot index a8aa893..768fcf6 100644 --- a/po/pamac.pot +++ b/po/pamac.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Pamac\n" "Report-Msgid-Bugs-To: cromer@cromnix.org\n" -"POT-Creation-Date: 2017-11-08 16:24-0300\n" +"POT-Creation-Date: 2017-11-10 22:35-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77150a0..c94afb9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") @@ -15,7 +15,7 @@ configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.base ${CMAKE_BINARY_DIR}/src add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") configure_file (${CMAKE_CURRENT_SOURCE_DIR}/pamacclassic.pc ${CMAKE_CURRENT_BINARY_DIR}/pamacclassic.pc) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/pamacclassic.deps ${CMAKE_CURRENT_BINARY_DIR}/pamacclassic.deps) -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) link_libraries ( ${DEPS_LIBRARIES} ) link_directories ( ${DEPS_LIBRARY_DIRS} ) @@ -101,7 +101,7 @@ add_dependencies( pamacclassic ${pamacclassic_DEPENDENCIES} ) target_link_libraries( pamacclassic m ) set_target_properties( pamacclassic PROPERTIES VERSION - 6.5.2 + 6.6.0 SOVERSION 6 ) diff --git a/src/meson.build b/src/meson.build index ecfee03..49775b4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,7 +4,7 @@ cfg_pamac_classic.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_classic.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_classic.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_classic.set('PREFIX', get_option('prefix')) -cfg_pamac_classic.set('VERSION', '6.5.2') +cfg_pamac_classic.set('VERSION', '6.6.0') cfg_pamac_classic.set('TESTSRCDIR', meson.source_root()) cfgfile_1 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_classic) @@ -59,7 +59,7 @@ pamac_classic_deps += [meson.get_compiler('c').find_library('m', required : fals pamac_classic_vala_args += ['--gir=pamacclassic-6.0.gir'] -pamacclassic_library = shared_library('pamacclassic',pamac_classic_sources,dependencies: pamac_classic_deps,vala_args: pamac_classic_vala_args,c_args: pamac_classic_c_args,version: '6.5.2',soversion: '6',install: true) +pamacclassic_library = shared_library('pamacclassic',pamac_classic_sources,dependencies: pamac_classic_deps,vala_args: pamac_classic_vala_args,c_args: pamac_classic_c_args,version: '6.6.0',soversion: '6',install: true) pamac_classic_requires = [] pamac_classic_requires += ['gdk-3.0'] @@ -74,7 +74,7 @@ pamac_classic_requires += ['glib-2.0'] pamac_classic_requires += ['gobject-2.0'] pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : pamacclassic_library, - version : '6.5.2', + version : '6.6.0', name : 'pamacclassic', filebase : 'pamacclassic', description : 'pamacclassic', diff --git a/src/pamac-clean-cache/CMakeLists.txt b/src/pamac-clean-cache/CMakeLists.txt index 4f88fa6..34944c4 100644 --- a/src/pamac-clean-cache/CMakeLists.txt +++ b/src/pamac-clean-cache/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-clean-cache/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-clean-cache/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) @@ -26,7 +26,6 @@ include (ValaPrecompile) set (VALA_PACKAGES ${VALA_PACKAGES} posix) set (VALA_PACKAGES ${VALA_PACKAGES} gtk+-3.0) set (VALA_PACKAGES ${VALA_PACKAGES} json-glib-1.0) -set (VALA_PACKAGES ${VALA_PACKAGES} gio-2.0) set (VALA_PACKAGES ${VALA_PACKAGES} glib-2.0) set (VALA_PACKAGES ${VALA_PACKAGES} gobject-2.0) diff --git a/src/pamac-clean-cache/clean_cache.vala b/src/pamac-clean-cache/clean_cache.vala index 8574cbb..2110b32 100644 --- a/src/pamac-clean-cache/clean_cache.vala +++ b/src/pamac-clean-cache/clean_cache.vala @@ -19,7 +19,7 @@ */ int main () { - var pamac_config = new Pamac.Config ("/etc/pamac.conf"); + var pamac_config = new Pamac.Config (); string rm_only_uninstalled_str = ""; if (pamac_config.rm_only_uninstalled) { rm_only_uninstalled_str = "-u"; diff --git a/src/pamac-clean-cache/meson.build b/src/pamac-clean-cache/meson.build index a80b4aa..a4d0b14 100644 --- a/src/pamac-clean-cache/meson.build +++ b/src/pamac-clean-cache/meson.build @@ -4,14 +4,13 @@ cfg_pamac_clean_cache.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_clean_cache.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_clean_cache.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_clean_cache.set('PREFIX', get_option('prefix')) -cfg_pamac_clean_cache.set('VERSION', '6.5.2') +cfg_pamac_clean_cache.set('VERSION', '6.6.0') cfg_pamac_clean_cache.set('TESTSRCDIR', meson.source_root()) cfgfile_4 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_clean_cache) pamac_clean_cache_deps = [gtk_3_0_dep] pamac_clean_cache_deps += [json_glib_1_0_dep] -pamac_clean_cache_deps += [gio_2_0_dep] pamac_clean_cache_deps += [glib_2_0_dep] pamac_clean_cache_deps += [gobject_2_0_dep] pamac_clean_cache_sources = [cfgfile_4] diff --git a/src/pamac-install/CMakeLists.txt b/src/pamac-install/CMakeLists.txt index 05b3157..896417a 100644 --- a/src/pamac-install/CMakeLists.txt +++ b/src/pamac-install/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-install/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-install/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) diff --git a/src/pamac-install/meson.build b/src/pamac-install/meson.build index 0c9f281..0e5528b 100644 --- a/src/pamac-install/meson.build +++ b/src/pamac-install/meson.build @@ -4,7 +4,7 @@ cfg_pamac_install.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_install.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_install.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_install.set('PREFIX', get_option('prefix')) -cfg_pamac_install.set('VERSION', '6.5.2') +cfg_pamac_install.set('VERSION', '6.6.0') cfg_pamac_install.set('TESTSRCDIR', meson.source_root()) cfgfile_5 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_install) diff --git a/src/pamac-manager/CMakeLists.txt b/src/pamac-manager/CMakeLists.txt index 88928b1..9e822ac 100644 --- a/src/pamac-manager/CMakeLists.txt +++ b/src/pamac-manager/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-manager/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-manager/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) diff --git a/src/pamac-manager/manager_window.vala b/src/pamac-manager/manager_window.vala index 5a99caa..d1a8865 100644 --- a/src/pamac-manager/manager_window.vala +++ b/src/pamac-manager/manager_window.vala @@ -367,7 +367,7 @@ namespace Pamac { #endif transaction.important_details_outpout.connect (on_important_details_outpout); transaction.finished.connect (on_transaction_finished); - transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished); + transaction.save_pamac_config_finished.connect (on_save_pamac_config_finished); transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished); transaction.generate_mirrors_list.connect (on_generate_mirrors_list); transaction.run_preferences_dialog_finished.connect (on_run_preferences_dialog_finished); @@ -398,14 +398,14 @@ namespace Pamac { } #if DISABLE_AUR - void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { + void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { } #else - void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, + void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, bool enable_aur, bool search_aur) { support_aur (enable_aur); - } #endif + } void on_set_pkgreason_finished () { transaction.unlock (); diff --git a/src/pamac-manager/meson.build b/src/pamac-manager/meson.build index c73ccff..2b1a60a 100644 --- a/src/pamac-manager/meson.build +++ b/src/pamac-manager/meson.build @@ -4,7 +4,7 @@ cfg_pamac_manager.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_manager.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_manager.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_manager.set('PREFIX', get_option('prefix')) -cfg_pamac_manager.set('VERSION', '6.5.2') +cfg_pamac_manager.set('VERSION', '6.6.0') cfg_pamac_manager.set('TESTSRCDIR', meson.source_root()) cfgfile_6 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_manager) diff --git a/src/pamac-system-daemon/CMakeLists.txt b/src/pamac-system-daemon/CMakeLists.txt index 7748058..51780df 100644 --- a/src/pamac-system-daemon/CMakeLists.txt +++ b/src/pamac-system-daemon/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-system-daemon/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-system-daemon/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) diff --git a/src/pamac-system-daemon/meson.build b/src/pamac-system-daemon/meson.build index 0629101..2dc78be 100644 --- a/src/pamac-system-daemon/meson.build +++ b/src/pamac-system-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_system_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_op cfg_pamac_system_daemon.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_system_daemon.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_system_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_system_daemon.set('VERSION', '6.5.2') +cfg_pamac_system_daemon.set('VERSION', '6.6.0') cfg_pamac_system_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_7 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_system_daemon) diff --git a/src/pamac-system-daemon/system_daemon.vala b/src/pamac-system-daemon/system_daemon.vala index 0205bc0..716a4d2 100644 --- a/src/pamac-system-daemon/system_daemon.vala +++ b/src/pamac-system-daemon/system_daemon.vala @@ -103,9 +103,9 @@ namespace Pamac { 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); + public signal void save_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, + public signal void save_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); @@ -356,21 +356,15 @@ namespace Pamac { }); } - public void start_write_pamac_config (HashTable new_pamac_conf, GLib.BusName sender) { - check_authorization.begin (sender, (obj, res) => { - var pamac_config = new Pamac.Config ("/etc/pamac.conf"); - bool authorized = check_authorization.end (res); - if (authorized ) { - pamac_config.write (new_pamac_conf); - pamac_config.reload (); - } + public void start_save_pamac_config () { + var pamac_config = new Pamac.Config (); + pamac_config.reload (); #if DISABLE_AUR - write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon); + save_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon); #else - write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon, + save_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon, pamac_config.enable_aur, pamac_config.search_aur, pamac_config.aur_build_dir, pamac_config.check_aur_updates); #endif - }); } private void write_alpm_config () { diff --git a/src/pamac-tray/CMakeLists.txt b/src/pamac-tray/CMakeLists.txt index eb5875a..f2e4890 100644 --- a/src/pamac-tray/CMakeLists.txt +++ b/src/pamac-tray/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.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.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) diff --git a/src/pamac-tray/meson.build b/src/pamac-tray/meson.build index ecafe0b..7af7d19 100644 --- a/src/pamac-tray/meson.build +++ b/src/pamac-tray/meson.build @@ -4,7 +4,7 @@ cfg_pamac_tray.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('dat cfg_pamac_tray.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_tray.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_tray.set('PREFIX', get_option('prefix')) -cfg_pamac_tray.set('VERSION', '6.5.2') +cfg_pamac_tray.set('VERSION', '6.6.0') cfg_pamac_tray.set('TESTSRCDIR', meson.source_root()) cfgfile_3 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_tray) diff --git a/src/pamac-tray/tray-appindicator.vala b/src/pamac-tray/tray-appindicator.vala index ab80c18..14c73c2 100644 --- a/src/pamac-tray/tray-appindicator.vala +++ b/src/pamac-tray/tray-appindicator.vala @@ -48,6 +48,14 @@ namespace Pamac { return indicator_status_icon.get_icon (); } + public override bool get_icon_visible () { + if (indicator_status_icon.get_status () == AppIndicator.IndicatorStatus.ACTIVE) { + return true; + } else { + return false; + } + } + public override void set_icon_visible (bool visible) { if (visible) { indicator_status_icon.set_status (AppIndicator.IndicatorStatus.ACTIVE); diff --git a/src/pamac-tray/tray-gtk.vala b/src/pamac-tray/tray-gtk.vala index 0d22b99..49f208f 100644 --- a/src/pamac-tray/tray-gtk.vala +++ b/src/pamac-tray/tray-gtk.vala @@ -47,6 +47,10 @@ namespace Pamac { return status_icon.get_icon_name (); } + public override bool get_icon_visible () { + return status_icon.visible; + } + public override void set_icon_visible (bool visible) { if (visible) { status_icon.visible = true; diff --git a/src/pamac-tray/tray.vala b/src/pamac-tray/tray.vala index 27a88c9..053d72e 100644 --- a/src/pamac-tray/tray.vala +++ b/src/pamac-tray/tray.vala @@ -45,8 +45,10 @@ namespace Pamac { UserDaemon daemon; bool extern_lock; uint refresh_timeout_id; + uint icon_timeout_id; public Gtk.Menu menu; GLib.File lockfile; + bool updates_available; public TrayIcon () { application_id = "org.pamac.tray"; @@ -116,10 +118,12 @@ namespace Pamac { public abstract string get_icon (); + public abstract bool get_icon_visible (); + public abstract void set_icon_visible (bool visible); bool check_updates () { - var pamac_config = new Pamac.Config ("/etc/pamac.conf"); + var pamac_config = new Pamac.Config (); if (pamac_config.refresh_period != 0) { try { #if DISABLE_AUR @@ -141,12 +145,14 @@ namespace Pamac { uint updates_nb = updates.repos_updates.length + updates.aur_updates.length; #endif if (updates_nb == 0) { + updates_available = false; set_icon (noupdate_icon_name); set_tooltip (noupdate_info); - var pamac_config = new Pamac.Config ("/etc/pamac.conf"); + var pamac_config = new Pamac.Config (); set_icon_visible (!pamac_config.no_update_hide_icon); close_notification (); } else { + updates_available = true; string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb); set_icon (update_icon_name); set_tooltip (info); @@ -241,6 +247,22 @@ namespace Pamac { return true; } + bool check_icon_hide_setting () { + var pamac_config = new Pamac.Config (); + if (!updates_available) { + set_icon_visible (!pamac_config.no_update_hide_icon); + } + return true; + } + + void launch_icon_check_timeout () { + if (icon_timeout_id != 0) { + Source.remove (icon_timeout_id); + icon_timeout_id = 0; + } + icon_timeout_id = Timeout.add_seconds ((uint) 1, check_icon_hide_setting); + } + void launch_refresh_timeout (uint64 refresh_period_in_hours) { if (refresh_timeout_id != 0) { Source.remove (refresh_timeout_id); @@ -256,7 +278,7 @@ namespace Pamac { Intl.textdomain ("pamac"); Intl.setlocale (LocaleCategory.ALL, ""); - var pamac_config = new Pamac.Config ("/etc/pamac.conf"); + var pamac_config = new Pamac.Config (); // if refresh period is 0, just return so tray will exit if (pamac_config.refresh_period == 0) { return; @@ -266,6 +288,7 @@ namespace Pamac { extern_lock = false; refresh_timeout_id = 0; + icon_timeout_id = 0; create_menu (); init_status_icon (); @@ -286,9 +309,11 @@ namespace Pamac { Timeout.add (200, check_extern_lock); // wait 30 seconds before check updates Timeout.add_seconds (30, () => { + check_icon_hide_setting (); check_updates (); return false; }); + launch_icon_check_timeout (); launch_refresh_timeout (pamac_config.refresh_period); this.hold (); diff --git a/src/pamac-user-daemon/CMakeLists.txt b/src/pamac-user-daemon/CMakeLists.txt index 43e3d0c..c876f6d 100644 --- a/src/pamac-user-daemon/CMakeLists.txt +++ b/src/pamac-user-daemon/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac-classic") set (RELEASE_NAME "pamac-classic") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.5.2") +set (VERSION "6.6.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-user-daemon/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-user-daemon/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.5.2") +set (VERSION "6.6.0") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lpamacclassic ) diff --git a/src/pamac-user-daemon/meson.build b/src/pamac-user-daemon/meson.build index 4637bb6..2476c76 100644 --- a/src/pamac-user-daemon/meson.build +++ b/src/pamac-user-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_user_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_user_daemon.set('GETTEXT_PACKAGE', 'pamac-classic') cfg_pamac_user_daemon.set('RELEASE_NAME', 'pamac-classic') cfg_pamac_user_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_user_daemon.set('VERSION', '6.5.2') +cfg_pamac_user_daemon.set('VERSION', '6.6.0') cfg_pamac_user_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_2 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_user_daemon) diff --git a/src/pamac_config.vala b/src/pamac_config.vala index ff83f65..46def80 100644 --- a/src/pamac_config.vala +++ b/src/pamac_config.vala @@ -20,7 +20,6 @@ namespace Pamac { class Config { - string conf_path; HashTable _environment_variables; public bool recurse { get; private set; } @@ -44,8 +43,7 @@ namespace Pamac { } } - public Config (string path) { - conf_path = path; + public Config () { //get environment variables _environment_variables = new HashTable (str_hash, str_equal); var utsname = Posix.utsname(); @@ -91,291 +89,29 @@ namespace Pamac { terminal_background = "rgb(0,0,0)"; terminal_foreground = "rgb(255,255,255)"; terminal_font = "Sans Regular 12"; - parse_file (conf_path); + //parse_file (conf_path); + load_settings (); } - void parse_file (string path) { - var file = GLib.File.new_for_path (path); - 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; - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - continue; - } - // ignore whole line and end of line comments - string[] splitted = line.split ("#", 2); - line = splitted[0].strip (); - if (line.length == 0) { - continue; - } - splitted = line.split ("=", 2); - unowned string key = splitted[0]._strip (); - if (key == "RemoveUnrequiredDeps") { - recurse = true; - } else if (key == "RefreshPeriod") { - if (splitted.length == 2) { - unowned string val = splitted[1]._strip (); - refresh_period = uint64.parse (val); - } - } else if (key == "NoUpdateHideIcon") { - no_update_hide_icon = true; + void load_settings () { + var settings = new Settings ("org.pamac.main"); + recurse = settings.get_boolean ("remove-unrequired-deps"); + refresh_period = settings.get_uint64 ("refresh-period"); + no_update_hide_icon = settings.get_boolean ("no-update-hide-icon"); + keep_num_pkgs = settings.get_uint64 ("keep-num-packages"); + rm_only_uninstalled = settings.get_boolean ("only-rm-uninstalled"); + terminal_background = settings.get_string ("background-color"); + terminal_foreground = settings.get_string ("foreground-color"); + terminal_font = settings.get_string ("terminal-font"); + #if DISABLE_AUR #else - } else if (key == "EnableAUR") { - enable_aur = true; - } else if (key == "SearchInAURByDefault") { - search_aur = true; - } else if (key == "BuildDirectory") { - if (splitted.length == 2) { - aur_build_dir = splitted[1]._strip (); - } - } else if (key == "CheckAURUpdates") { - check_aur_updates = true; + settings = new Settings ("org.pamac.aur"); + enable_aur = settings.get_boolean ("enable-aur"); + search_aur = settings.get_boolean ("search-in-aur"); + check_aur_updates = settings.get_boolean ("check-aur-updates"); + aur_build_dir = settings.get_string ("build-directory"); #endif - } else if (key == "KeepNumPackages") { - if (splitted.length == 2) { - unowned string val = splitted[1]._strip (); - keep_num_pkgs = uint64.parse (val); - } - } else if (key == "OnlyRmUninstalled") { - rm_only_uninstalled = true; - } else if (key == "BackgroundColor") { - if (splitted.length == 2) { - terminal_background = splitted[1]._strip (); - } - } else if (key == "ForegroundColor") { - if (splitted.length == 2) { - terminal_foreground = splitted[1]._strip (); - } - } else if (key == "TerminalFont") { - if (splitted.length == 2) { - terminal_font = splitted[1]._strip (); - } - } - } - } catch (GLib.Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", path); - } - } - public void write (HashTable new_conf) { - var file = GLib.File.new_for_path (conf_path); - var data = new GLib.List (); - 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; - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - data.append ("\n"); - continue; - } - unowned Variant variant; - if (line.contains ("RemoveUnrequiredDeps")) { - if (new_conf.lookup_extended ("RemoveUnrequiredDeps", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("RemoveUnrequiredDeps\n"); - } else { - data.append ("#RemoveUnrequiredDeps\n"); - } - new_conf.remove ("RemoveUnrequiredDeps"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("RefreshPeriod")) { - if (new_conf.lookup_extended ("RefreshPeriod", null, out variant)) { - data.append ("RefreshPeriod = %llu\n".printf (variant.get_uint64 ())); - new_conf.remove ("RefreshPeriod"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("NoUpdateHideIcon")) { - if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("NoUpdateHideIcon\n"); - } else { - data.append ("#NoUpdateHideIcon\n"); - } - new_conf.remove ("NoUpdateHideIcon"); - } else { - data.append (line + "\n"); - } -#if DISABLE_AUR -#else - } else if (line.contains ("EnableAUR")) { - if (new_conf.lookup_extended ("EnableAUR", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("EnableAUR\n"); - } else { - data.append ("#EnableAUR\n"); - } - new_conf.remove ("EnableAUR"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("SearchInAURByDefault")) { - if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("SearchInAURByDefault\n"); - } else { - data.append ("#SearchInAURByDefault\n"); - } - new_conf.remove ("SearchInAURByDefault"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("BuildDirectory")) { - if (new_conf.lookup_extended ("BuildDirectory", null, out variant)) { - data.append ("BuildDirectory = %s\n".printf (variant.get_string ())); - new_conf.remove ("BuildDirectory"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("CheckAURUpdates")) { - if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("CheckAURUpdates\n"); - } else { - data.append ("#CheckAURUpdates\n"); - } - new_conf.remove ("CheckAURUpdates"); - } else { - data.append (line + "\n"); - } -#endif - } else if (line.contains ("KeepNumPackages")) { - if (new_conf.lookup_extended ("KeepNumPackages", null, out variant)) { - data.append ("KeepNumPackages = %llu\n".printf (variant.get_uint64 ())); - new_conf.remove ("KeepNumPackages"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("OnlyRmUninstalled")) { - if (new_conf.lookup_extended ("OnlyRmUninstalled", null, out variant)) { - if (variant.get_boolean ()) { - data.append ("OnlyRmUninstalled\n"); - } else { - data.append ("#OnlyRmUninstalled\n"); - } - new_conf.remove ("OnlyRmUninstalled"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("BackgroundColor")) { - if (new_conf.lookup_extended ("BackgroundColor", null, out variant)) { - data.append ("BackgroundColor = %s\n".printf (variant.get_string ())); - new_conf.remove ("BackgroundColor"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("ForegroundColor")) { - if (new_conf.lookup_extended ("ForegroundColor", null, out variant)) { - data.append ("ForegroundColor = %s\n".printf (variant.get_string ())); - new_conf.remove ("ForegroundColor"); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("TerminalFont")) { - if (new_conf.lookup_extended ("TerminalFont", null, out variant)) { - data.append ("TerminalFont = %s\n".printf (variant.get_string ())); - new_conf.remove ("TerminalFont"); - } else { - data.append (line + "\n"); - } - } else { - data.append (line + "\n"); - } - } - // delete the file before rewrite it - file.delete (); - } catch (GLib.Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path); - } - // create lines for unexisted options - if (new_conf.size () != 0) { - data.append ("\n"); - var iter = HashTableIter (new_conf); - unowned string key; - unowned Variant val; - while (iter.next (out key, out val)) { - if (key == "RemoveUnrequiredDeps") { - if (val.get_boolean ()) { - data.append ("RemoveUnrequiredDeps\n"); - } else { - data.append ("#RemoveUnrequiredDeps\n"); - } - } else if (key == "RefreshPeriod") { - data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ())); - } else if (key =="NoUpdateHideIcon") { - if (val.get_boolean ()) { - data.append ("NoUpdateHideIcon\n"); - } else { - data.append ("#NoUpdateHideIcon\n"); - } -#if DISABLE_AUR -#else - } else if (key == "EnableAUR") { - if (val.get_boolean ()) { - data.append ("EnableAUR\n"); - } else { - data.append ("#EnableAUR\n"); - } - } else if (key == "SearchInAURByDefault") { - if (val.get_boolean ()) { - data.append ("SearchInAURByDefault\n"); - } else { - data.append ("#SearchInAURByDefault\n"); - } - } else if (key == "BuildDirectory") { - data.append ("BuildDirectory = %s\n".printf (val.get_string ())); - } else if (key == "CheckAURUpdates") { - if (val.get_boolean ()) { - data.append ("CheckAURUpdates\n"); - } else { - data.append ("#CheckAURUpdates\n"); - } -#endif - } else if (key == "KeepNumPackages") { - data.append ("KeepNumPackages = %llu\n".printf (val.get_uint64 ())); - } else if (key == "OnlyRmUninstalled") { - if (val.get_boolean ()) { - data.append ("OnlyRmUninstalled\n"); - } else { - data.append ("#OnlyRmUninstalled\n"); - } - } else if (key == "BackgroundColor") { - data.append ("BackgroundColor = %s\n".printf (val.get_string ())); - } else if (key == "ForegroundColor") { - data.append ("ForegroundCOlor = %s\n".printf (val.get_string ())); - } else if (key == "TerminalFont") { - data.append ("TerminalFont = %s\n".printf (val.get_string ())); - } - } - } - // write the file - try { - // creating a DataOutputStream to the file - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - 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); - } } } } diff --git a/src/pamacclassic.pc b/src/pamacclassic.pc index eeec2de..491c7a5 100644 --- a/src/pamacclassic.pc +++ b/src/pamacclassic.pc @@ -4,7 +4,7 @@ includedir=@DOLLAR@{prefix}/${CMAKE_INSTALL_INCLUDEDIR} Name: pamacclassic Description: pamacclassic -Version: 6.5.2 +Version: 6.6.0 Libs: -L@DOLLAR@{libdir} -lpamacclassic Cflags: -I@DOLLAR@{includedir} Requires: gdk-3.0 gtk+-3.0 json-glib-1.0 libalpm libnotify libsoup-2.4 vte-2.91 gio-2.0 glib-2.0 gobject-2.0 diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala index c51fd3a..3de247f 100644 --- a/src/preferences_dialog.vala +++ b/src/preferences_dialog.vala @@ -137,7 +137,6 @@ namespace Pamac { no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled); cache_keep_nb_spin_button.value_changed.connect (on_cache_keep_nb_spin_button_value_changed); cache_only_uninstalled_checkbutton.toggled.connect (on_cache_only_uninstalled_checkbutton_toggled); - transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished); terminal_background.color_set.connect (on_select_background); terminal_foreground.color_set.connect (on_select_foreground); terminal_font.font_set.connect (on_select_font); @@ -194,109 +193,117 @@ namespace Pamac { } bool on_remove_unrequired_deps_button_state_set (bool new_state) { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("RemoveUnrequiredDeps", new Variant.boolean (new_state)); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_boolean ("remove-unrequired-deps", new_state); + config_changed(); + transaction.start_save_pamac_config (); return true; } bool on_check_updates_button_state_set (bool new_state) { - var new_pamac_conf = new HashTable (str_hash, str_equal); + var settings = new Settings ("org.pamac.main"); refresh_period_label.sensitive = new_state; refresh_period_spin_button.sensitive = new_state; no_update_hide_icon_checkbutton.sensitive = new_state; ignorepkgs_box.sensitive = new_state; if (new_state) { - new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (previous_refresh_period)); + settings.set_uint64 ("refresh-period", previous_refresh_period); } else { - new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (0)); + settings.set_uint64 ("refresh-period", 0); } - transaction.start_write_pamac_config (new_pamac_conf); + config_changed(); + transaction.start_save_pamac_config (); return true; } void on_refresh_period_spin_button_value_changed () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("RefreshPeriod", new Variant.uint64 (refresh_period_spin_button.get_value_as_int ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_uint64 ("refresh-period", refresh_period_spin_button.get_value_as_int ()); + config_changed(); + transaction.start_save_pamac_config (); } - void on_cache_keep_nb_spin_button_value_changed () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("KeepNumPackages", new Variant.uint64 (cache_keep_nb_spin_button.get_value_as_int ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_uint64 ("keep-num-packages", cache_keep_nb_spin_button.get_value_as_int ()); + config_changed(); + transaction.start_save_pamac_config (); } void on_cache_only_uninstalled_checkbutton_toggled () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("OnlyRmUninstalled", new Variant.boolean (cache_only_uninstalled_checkbutton.active)); - transaction.start_write_pamac_config (new_pamac_conf); -} + var settings = new Settings ("org.pamac.main"); + settings.set_boolean ("only-rm-uninstalled", cache_only_uninstalled_checkbutton.active); + config_changed(); + transaction.start_save_pamac_config (); + } void on_no_update_hide_icon_checkbutton_toggled () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active)); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_boolean ("no-update-hide-icon", no_update_hide_icon_checkbutton.active); + config_changed(); + transaction.start_save_pamac_config (); } void on_select_background () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("BackgroundColor", new Variant.string (terminal_background.rgba.to_string ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_string ("background-color", terminal_background.rgba.to_string ()); + config_changed(); + transaction.start_save_pamac_config (); transaction.update_terminal_background (terminal_background.rgba.to_string ()); } void on_select_foreground () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("ForegroundColor", new Variant.string (terminal_foreground.rgba.to_string ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_string ("foreground-color", terminal_foreground.rgba.to_string ()); + config_changed(); + transaction.start_save_pamac_config (); transaction.update_terminal_foreground (terminal_foreground.rgba.to_string ()); } void on_select_font () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("TerminalFont", new Variant.string (terminal_font.get_font_name ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.main"); + settings.set_string ("terminal-font", terminal_font.get_font_name ()); + config_changed(); + transaction.start_save_pamac_config (); transaction.update_terminal_font (terminal_font.get_font_name ()); } #if DISABLE_AUR #else bool on_enable_aur_button_state_set (bool new_state) { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("EnableAUR", new Variant.boolean (new_state)); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.aur"); + settings.set_boolean ("enable-aur", new_state); + config_changed(); + transaction.start_save_pamac_config (); return true; } void on_search_aur_checkbutton_toggled () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("SearchInAURByDefault", new Variant.boolean (search_aur_checkbutton.active)); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.aur"); + settings.set_boolean ("search-in-aur", search_aur_checkbutton.active); + config_changed(); + transaction.start_save_pamac_config (); } void on_aur_build_dir_set () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("BuildDirectory", new Variant.string (aur_build_dir_file_chooser.get_filename ())); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.aur"); + settings.set_string ("build-directory", aur_build_dir_file_chooser.get_filename ()); + config_changed(); + transaction.start_save_pamac_config (); } void on_check_aur_updates_checkbutton_toggled () { - var new_pamac_conf = new HashTable (str_hash, str_equal); - new_pamac_conf.insert ("CheckAURUpdates", new Variant.boolean (check_aur_updates_checkbutton.active)); - transaction.start_write_pamac_config (new_pamac_conf); + var settings = new Settings ("org.pamac.aur"); + settings.set_boolean ("check-aur-updates", check_aur_updates_checkbutton.active); + config_changed(); + transaction.start_save_pamac_config (); } #endif -#if DISABLE_AUR - void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { -#else - void on_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 - remove_unrequired_deps_button.state = recurse; - if (refresh_period == 0) { + void config_changed() { + transaction.config_changed(); + remove_unrequired_deps_button.state = transaction.recurse; + if (transaction.refresh_period == 0) { check_updates_button.state = false; refresh_period_label.sensitive = false; refresh_period_spin_button.sensitive = false; @@ -305,28 +312,29 @@ namespace Pamac { } else { check_updates_button.state = true; refresh_period_label.sensitive = true; - refresh_period_spin_button.value = refresh_period; - previous_refresh_period = refresh_period; + refresh_period_spin_button.value = transaction.refresh_period; + previous_refresh_period = transaction.refresh_period; refresh_period_spin_button.sensitive = true; no_update_hide_icon_checkbutton.sensitive = true; ignorepkgs_box.sensitive = true; } - no_update_hide_icon_checkbutton.active = no_update_hide_icon; + no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon; #if DISABLE_AUR #else - enable_aur_button.state = enable_aur; - search_aur_checkbutton.active = search_aur; - search_aur_checkbutton.sensitive = enable_aur; - aur_build_dir_label.sensitive = enable_aur; - aur_build_dir_file_chooser.sensitive = enable_aur; - check_aur_updates_checkbutton.active = check_aur_updates; - check_aur_updates_checkbutton.sensitive = enable_aur; + enable_aur_button.state = transaction.enable_aur; + search_aur_checkbutton.active = transaction.search_aur; + search_aur_checkbutton.sensitive = transaction.enable_aur; + aur_build_dir_label.sensitive = transaction.enable_aur; + aur_build_dir_file_chooser.sensitive = transaction.enable_aur; + check_aur_updates_checkbutton.active = transaction.check_aur_updates; + check_aur_updates_checkbutton.sensitive = transaction.enable_aur; #endif } bool on_check_space_button_state_set (bool new_state) { var new_alpm_conf = new HashTable (str_hash, str_equal); new_alpm_conf.insert ("CheckSpace", new Variant.boolean (new_state)); + check_space_button.state = new_state; transaction.start_write_alpm_config (new_alpm_conf); return true; } diff --git a/src/transaction.vala b/src/transaction.vala index 9f5e702..b0af570 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -70,7 +70,7 @@ namespace Pamac { public abstract bool get_lock () throws IOError; public abstract bool unlock () throws IOError; public abstract void start_get_authorization () throws IOError; - public abstract void start_write_pamac_config (HashTable new_pamac_conf) throws IOError; + public abstract void start_save_pamac_config () throws IOError; public abstract void start_write_alpm_config (HashTable new_alpm_conf) throws IOError; public abstract void start_write_mirrors_config (HashTable new_mirrors_conf) throws IOError; public abstract void start_generate_mirrors_list () throws IOError; @@ -108,9 +108,9 @@ namespace Pamac { 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); + public signal void save_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, + public signal void save_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); @@ -149,7 +149,7 @@ namespace Pamac { public string terminal_background { get { return pamac_config.terminal_background; } } public string terminal_foreground { get { return pamac_config.terminal_foreground; } } public string terminal_font { get { return pamac_config.terminal_font; } } - public unowned GLib.HashTable environment_variables { get {return pamac_config.environment_variables; } } + public unowned GLib.HashTable environment_variables { get { return pamac_config.environment_variables; } } public bool no_update_hide_icon { get { return pamac_config.no_update_hide_icon; } } public bool recurse { get { return pamac_config.recurse; } } public uint64 refresh_period { get { return pamac_config.refresh_period; } } @@ -221,9 +221,9 @@ namespace Pamac { public signal void finished (bool success); public signal void set_pkgreason_finished (); #if DISABLE_AUR - public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon); + public signal void save_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, + public signal void save_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); @@ -234,7 +234,7 @@ namespace Pamac { public Transaction (Gtk.ApplicationWindow? application_window) { mode = Mode.MANAGER; - pamac_config = new Pamac.Config ("/etc/pamac.conf"); + pamac_config = new Pamac.Config (); flags = (1 << 4); //Alpm.TransFlag.CASCADE if (pamac_config.recurse) { flags |= (1 << 5); //Alpm.TransFlag.RECURSE @@ -306,6 +306,10 @@ namespace Pamac { warning_textbuffer = new StringBuilder (); } + public void config_changed() { + pamac_config.reload(); + } + public void update_terminal_background (string background) { var tmp = Gdk.RGBA (); tmp.parse (background); @@ -324,18 +328,13 @@ namespace Pamac { } public void run_preferences_dialog () { - check_authorization.begin ((obj, res) => { - bool authorized = check_authorization.end (res); - if (authorized) { - var preferences_dialog = new PreferencesDialog (this); - preferences_dialog.run (); - preferences_dialog.destroy (); - while (Gtk.events_pending ()) { - Gtk.main_iteration (); - } - } - run_preferences_dialog_finished (); - }); + var preferences_dialog = new PreferencesDialog (this); + preferences_dialog.run (); + preferences_dialog.destroy (); + while (Gtk.events_pending ()) { + Gtk.main_iteration (); + } + run_preferences_dialog_finished (); } public ErrorInfos get_current_error () { @@ -396,13 +395,13 @@ namespace Pamac { return authorized; } - public void start_write_pamac_config (HashTable new_pamac_conf) { + public void start_save_pamac_config () { try { - system_daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); - system_daemon.start_write_pamac_config (new_pamac_conf); + system_daemon.save_pamac_config_finished.connect (on_save_pamac_config_finished); + system_daemon.start_save_pamac_config (); } catch (IOError e) { stderr.printf ("IOError: %s\n", e.message); - system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished); + system_daemon.save_pamac_config_finished.disconnect (on_save_pamac_config_finished); } } @@ -1924,21 +1923,21 @@ namespace Pamac { } #if DISABLE_AUR - void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { + void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { #else - void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, + void on_save_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 - system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished); + system_daemon.save_pamac_config_finished.disconnect (on_save_pamac_config_finished); pamac_config.reload (); flags = (1 << 4); //Alpm.TransFlag.CASCADE if (pamac_config.recurse) { flags |= (1 << 5); //Alpm.TransFlag.RECURSE } #if DISABLE_AUR - write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon); + save_pamac_config_finished (recurse, refresh_period, no_update_hide_icon); #else - write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, + save_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, enable_aur, search_aur, aur_build_dir, check_aur_updates); #endif }