diff options
| -rw-r--r-- | .build.yml | 219 | ||||
| -rw-r--r-- | .github/dependabot.yml | 8 | ||||
| -rwxr-xr-x | .github/workflows/archlinux.sh | 52 | ||||
| -rwxr-xr-x | .github/workflows/builds.sh | 38 | ||||
| -rw-r--r-- | .github/workflows/builds.yml | 92 | ||||
| -rwxr-xr-x | .github/workflows/debian.sh | 60 | ||||
| -rwxr-xr-x | .github/workflows/fedora.sh | 58 | ||||
| -rwxr-xr-x | .github/workflows/mate-desktop.sh | 148 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 31 | ||||
| -rwxr-xr-x | .github/workflows/ubuntu.sh | 60 | ||||
| -rw-r--r-- | .travis.yml | 89 | ||||
| -rw-r--r-- | command/README | 59 | ||||
| -rw-r--r-- | command/src/command.c | 6 | ||||
| -rw-r--r-- | configure.ac | 4 | ||||
| -rw-r--r-- | invest-applet/data/Makefile.am | 2 | ||||
| -rw-r--r-- | invest-applet/invest/Makefile.am | 2 | ||||
| -rw-r--r-- | invest-applet/invest/invest-applet-chart.c | 36 | ||||
| -rw-r--r-- | invest-applet/invest/invest-applet.c | 38 |
18 files changed, 673 insertions, 329 deletions
diff --git a/.build.yml b/.build.yml deleted file mode 100644 index f2abb29b..00000000 --- a/.build.yml +++ /dev/null @@ -1,219 +0,0 @@ -########################################################## -# THE FOLLOWING LINES IS USED BY docker-build -########################################################## -requires: - archlinux: - # Useful URL: https://git.archlinux.org/svntogit/community.git/tree/mate-applets - - autoconf-archive - - clang - - cpupower - - gcc - - git - - gucharmap - - gtksourceview4 - - itstool - - libgtop - - libnotify - - make - - mate-common - - mate-desktop - - mate-menus - - mate-panel - - polkit - - upower - - which - - wireless_tools - - yelp-tools - # mate-desktop dependencies - - iso-codes - - gobject-introspection - - debian: - # Useful URL: https://github.com/mate-desktop/debian-packages - # Useful URL: https://salsa.debian.org/debian-mate-team/mate-applets - - autopoint - - clang - - clang-tools - - cppcheck - - gcc - - git - - libcpupower-dev - - libdbus-1-dev - - libdbus-glib-1-dev - - libglib2.0-dev - - libgtk-3-dev - - libgtksourceview-4-dev - - libgtop2-dev - - libgucharmap-2-90-dev - - libiw-dev - - libmate-desktop-dev - - libmate-menu-dev - - libmate-panel-applet-dev - - libmateweather-dev - - libnl-genl-3-dev - - libnotify-dev - - libpolkit-gobject-1-dev - - libupower-glib-dev - - libwnck-3-dev - - libx11-dev - - libxml2-dev - - make - - mate-common - - x11proto-kb-dev - - yelp-tools - # mate-desktop dependencies - - iso-codes - - gobject-introspection - - libgirepository1.0-dev - - fedora: - # Useful URL: https://src.fedoraproject.org/cgit/rpms/mate-applets.git - - autoconf-archive - - clang - - clang-analyzer - - cppcheck-htmlreport - - gcc - - git - - gtksourceview4-devel - - gucharmap-devel - - kernel-tools-libs-devel - - libgtop2-devel - - libnl3-devel - - libnotify-devel - - libmateweather-devel - - libwnck3-devel - - libxml2-devel - - libICE-devel - - libSM-devel - - make - - mate-common - - mate-desktop-devel - - mate-menus-devel - - mate-settings-daemon-devel - - mate-notification-daemon - - mate-panel-devel - - polkit-devel - - redhat-rpm-config - - startup-notification-devel - - upower-devel - # mate-desktop dependencies - - iso-codes-devel - - gobject-introspection-devel - - ubuntu: - - autopoint - - clang - - clang-tools - - gcc - - git - - libcpufreq-dev - - libdbus-1-dev - - libdbus-glib-1-dev - - libglib2.0-dev - - libgtk-3-dev - - libgtksourceview-4-dev - - libgtop2-dev - - libgucharmap-2-90-dev - - libiw-dev - - libmate-desktop-dev - - libmate-menu-dev - - libmate-panel-applet-dev - - libmateweather-dev - - libnl-genl-3-dev - - libnotify-dev - - libpolkit-gobject-1-dev - - libupower-glib-dev - - libwnck-3-dev - - libx11-dev - - libxml2-dev - - make - - mate-common - - x11proto-kb-dev - - yelp-tools - # mate-desktop dependencies - - iso-codes - - gobject-introspection - - libgirepository1.0-dev - -variables: - - 'CHECKERS=" - -enable-checker deadcode.DeadStores - -enable-checker alpha.deadcode.UnreachableCode - -enable-checker alpha.core.CastSize - -enable-checker alpha.core.CastToStruct - -enable-checker alpha.core.IdenticalExpr - -enable-checker alpha.core.SizeofPtr - -enable-checker alpha.security.ArrayBoundV2 - -enable-checker alpha.security.MallocOverflow - -enable-checker alpha.security.ReturnPtrRange - -enable-checker alpha.unix.SimpleStream - -enable-checker alpha.unix.cstring.BufferOverlap - -enable-checker alpha.unix.cstring.NotNullTerminated - -enable-checker alpha.unix.cstring.OutOfBounds - -enable-checker alpha.core.FixedAddr - -enable-checker security.insecureAPI.strcpy"' - - MATE_DESKTOP_VERSION=1.27.1 - -before_scripts: - -build_scripts: - - cd ${START_DIR} - - if [ ! -f mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz ];then - - curl -Ls -o mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz https://github.com/mate-desktop/mate-desktop/releases/download/v${MATE_DESKTOP_VERSION}/mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz - - fi - - tar xf mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz - - cd mate-desktop-${MATE_DESKTOP_VERSION} - - if [ ${DISTRO_NAME} == "debian" -o ${DISTRO_NAME} == "ubuntu" ];then - - ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu - - else - - ./autogen.sh --prefix=/usr - - fi - - if [ ${TRAVIS} == "false" ]; then - - make clean - - fi - - make - - make install - - - cd ${START_DIR} - - if [ ${DISTRO_NAME} == "debian" ];then - - export CFLAGS+=" -Wsign-compare" - - cppcheck --enable=warning,style,performance,portability,information,missingInclude . - - fi - - - NOCONFIGURE=1 ./autogen.sh - - scan-build $CHECKERS ./configure --enable-compile-warnings=maximum - - if [ $CPU_COUNT -gt 1 ]; then - - if [ ${DISTRO_NAME} == "debian" ];then - - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT - - make clean - - fi - - scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT - - else - - if [ ${DISTRO_NAME} == "debian" ];then - - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make - - make clean - - fi - - scan-build $CHECKERS --keep-cc -o html-report make - - fi - -after_scripts: - - if [ ${DISTRO_NAME} == "fedora" ];then - - cppcheck --xml --output-file=cppcheck.xml --enable=warning,style,performance,portability,information,missingInclude . - - cppcheck-htmlreport --title=${REPO_NAME} --file=cppcheck.xml --report-dir=cppcheck-htmlreport - - ./gen-index -l 20 -i https://github.com/${OWNER_NAME}/mate-applets/raw/master/cpufreq/pixmaps/cpufreq-100.png - - fi - - make distcheck - -releases: - draft: false - prerelease: false - checksum: true - file_glob: true - files: mate-applets-*.tar.xz - github_release: - tags: true - overwrite: true - base_version: 1.20.0 - notify_servers: - - https://release.mate-desktop.org/release - diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..80851cd3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +# Enable dependabot to keep our GHA pins automatically +# updated, so we don't fall too far behind in the future +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly diff --git a/.github/workflows/archlinux.sh b/.github/workflows/archlinux.sh new file mode 100755 index 00000000..f9e3cfab --- /dev/null +++ b/.github/workflows/archlinux.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Archlinux +requires=( + ccache # Use ccache to speed up build + clang # Build with clang on Archlinux +) + +# https://gitlab.archlinux.org/archlinux/packaging/packages/mate-applets +requires+=( + autoconf-archive + cpupower + dbus-glib + gcc + git + glib2-devel + gtksourceview4 + gucharmap + intltool + itstool + json-glib + libgtop + libnl + libnotify + libsoup3 + make + mate-common + mate-panel + polkit + upower + which + wireless_tools + yelp-tools +) + +infobegin "Update system" +pacman --noconfirm -Syu +infoend + +infobegin "Install dependency packages" +pacman --noconfirm -S ${requires[@]} +infoend diff --git a/.github/workflows/builds.sh b/.github/workflows/builds.sh new file mode 100755 index 00000000..b192d971 --- /dev/null +++ b/.github/workflows/builds.sh @@ -0,0 +1,38 @@ +#!/usr/bin/bash + +set -e +set -o pipefail + +CPUS=$(grep processor /proc/cpuinfo | wc -l) + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +if [ -f autogen.sh ]; then + infobegin "Configure (autotools)" + NOCONFIGURE=1 ./autogen.sh + ./configure --prefix=/usr --enable-compile-warnings=maximum || { + cat config.log + exit 1 + } + infoend + + infobegin "Build (autotools)" + make -j ${CPUS} + infoend + + infobegin "Check (autotools)" + make -j ${CPUS} check || { + true + } + infoend + + infobegin "Distcheck (autotools)" + make -j ${CPUS} distcheck + infoend +fi diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 00000000..01b3ba8e --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,92 @@ +name: CI Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +# cancel already running builds of the same branch or pull request +concurrency: + group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref || github.sha }} + cancel-in-progress: true + +env: + MATE_DESKTOP_VERSION: 1.28.2 + CACHE_PATH: /tmp/.cache + +jobs: + build: + name: Build on ${{matrix.container}} (using ${{matrix.cc}}) + runs-on: ubuntu-latest + container: + image: ${{matrix.container}} + volumes: + - /tmp/.cache + - /var/cache/apt + + strategy: + fail-fast: false # don't cancel other jobs in the matrix if one fails + matrix: + container: + [ + "debian:testing", + "fedora:latest", + "ubuntu:rolling", + "archlinux:latest", + ] + cc: ["gcc"] + cxx: ["g++"] + include: + - container: "archlinux:latest" + cc: "clang" + cxx: "clang++" + + env: + # Speed up build with ccache + CC: ccache ${{ matrix.cc }} + CXX: ccache ${{ matrix.cxx }} + CONTAINER: ${{ matrix.container }} + + steps: + - name: Setup environment variables + id: distro-name + shell: bash + run: | + split=(${CONTAINER//:/ }) + distro=${split[0]} + short_sha=${SHA:0:8} + echo "DISTRO=$distro" | tee -a $GITHUB_ENV + - name: Install git command + shell: bash + run: | + echo "::group::Install git ..." + apt-get update -qq && apt-get install --assume-yes git || true + dnf update -y && dnf install -y git || true + pacman --noconfirm -Sy git || true + echo "::endgroup::" + - name: Repository checkout + uses: actions/checkout@v6 + - name: Install dependency packages + run: .github/workflows/${{ env.DISTRO }}.sh + - name: Enable ccache to speed up builds + uses: hendrikmuhs/[email protected] + with: + key: ${{ env.DISTRO }}-${{ matrix.cc }} + + # INFO: Depends on mate-desktop 1.27.1+, so we should install it from source. + - name: Cache mate-desktop binary packages + uses: actions/cache@v5 + id: cache-mate-desktop + with: + path: ${{ env.CACHE_PATH }} + key: ${{ env.DISTRO }}-build-mate-desktop-${{env.MATE_DESKTOP_VERSION}} + - name: Built and install mate-desktop from source + run: .github/workflows/mate-desktop.sh ${{env.MATE_DESKTOP_VERSION}} ${{ env.CACHE_PATH }} + # INFO: mate-desktop dependency install finished. + + - name: Build the source code + run: .github/workflows/builds.sh diff --git a/.github/workflows/debian.sh b/.github/workflows/debian.sh new file mode 100755 index 00000000..fe0f711e --- /dev/null +++ b/.github/workflows/debian.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Debian +requires=( + ccache # Use ccache to speed up build +) + +# https://salsa.debian.org/debian-mate-team/mate-applets +requires+=( + autopoint + gcc + git + libcpupower-dev + libdbus-1-dev + libdbus-glib-1-dev + libglib2.0-dev + libgtk-3-dev + libgtksourceview-4-dev + libgtop2-dev + libgucharmap-2-90-dev + libiw-dev + libmate-desktop-dev + libmate-menu-dev + libmate-panel-applet-dev + libmateweather-dev + libnl-genl-3-dev + libnotify-dev + libpolkit-gobject-1-dev + libupower-glib-dev + libwnck-3-dev + libx11-dev + libxml2-dev + make + mate-common + x11proto-kb-dev + yelp-tools + iso-codes + gobject-introspection + libgirepository1.0-dev +) + +infobegin "Update system" +apt-get update -qq +infoend + +infobegin "Install dependency packages" +env DEBIAN_FRONTEND=noninteractive \ + apt-get install --assume-yes \ + ${requires[@]} +infoend diff --git a/.github/workflows/fedora.sh b/.github/workflows/fedora.sh new file mode 100755 index 00000000..bc77b083 --- /dev/null +++ b/.github/workflows/fedora.sh @@ -0,0 +1,58 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Fedora +requires=( + ccache # Use ccache to speed up build +) + +# https://src.fedoraproject.org/cgit/rpms/mate-applets.git +requires+=( + autoconf-archive + dbus-glib-devel + gcc + git + gtksourceview4-devel + gucharmap-devel + json-glib-devel + kernel-tools-libs-devel + libgtop2-devel + libnl3-devel + libnotify-devel + libmateweather-devel + libsoup3-devel + libwnck3-devel + libxml2-devel + libICE-devel + libSM-devel + make + mate-common + mate-desktop-devel + mate-menus-devel + mate-settings-daemon-devel + mate-notification-daemon + mate-panel-devel + polkit-devel + redhat-rpm-config + startup-notification-devel + upower-devel + iso-codes-devel + gobject-introspection-devel +) + +infobegin "Update system" +dnf update -y +infoend + +infobegin "Install dependency packages" +dnf install -y ${requires[@]} +infoend diff --git a/.github/workflows/mate-desktop.sh b/.github/workflows/mate-desktop.sh new file mode 100755 index 00000000..b55046d5 --- /dev/null +++ b/.github/workflows/mate-desktop.sh @@ -0,0 +1,148 @@ +#!/usr/bin/bash + +set -e +set -o pipefail + +NAME="mate-desktop" +TEMP_DIR=$(mktemp -d) +OS=$(cat /etc/os-release | grep ^ID | head -n 1 | awk -F= '{ print $2}') +TAG=$1 +CACHE_DIR=$2 + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages to build mate-desktop +# https://gitlab.archlinux.org/archlinux/packaging/packages/mate-desktop +arch_requires=( + autoconf-archive + gobject-introspection + mate-common + intltool +) + +# https://salsa.debian.org/debian-mate-team/mate-desktop/-/blob/master/debian/control +debian_requires=( + autoconf-archive + autopoint + gobject-introspection + gtk-doc-tools + intltool + iso-codes + libdconf-dev + libgdk-pixbuf-2.0-dev + libgirepository1.0-dev + libglib2.0-dev + libglib2.0-doc + libgtk-3-dev + libgtk-3-doc + librsvg2-bin + libstartup-notification0-dev + libx11-dev + libxml2-dev + libxrandr-dev + mate-common +) + +# https://src.fedoraproject.org/rpms/mate-desktop/blob/rawhide/f/mate-desktop.spec +fedora_requires=( + dconf-devel + desktop-file-utils + gobject-introspection-devel + make + mate-common + startup-notification-devel + gtk3-devel + iso-codes-devel + gobject-introspection-devel + cairo-gobject-devel +) + +# https://git.launchpad.net/ubuntu/+source/mate-desktop/tree/debian/control +ubuntu_requires=( + autoconf-archive + autopoint + gobject-introspection + gtk-doc-tools + intltool + iso-codes + libdconf-dev + libgdk-pixbuf-2.0-dev + libgirepository1.0-dev + libglib2.0-dev + libglib2.0-doc + libgtk-3-dev + libgtk-3-doc + librsvg2-bin + libstartup-notification0-dev + libx11-dev + libxml2-dev + libxrandr-dev + mate-common +) + +requires=$(eval echo '${'"${OS}_requires[@]}") + +infobegin "Install Depends for mate-desktop" +case ${OS} in +arch) + pacman --noconfirm -Syu + pacman --noconfirm -S ${requires[@]} + ;; +debian | ubuntu) + apt-get update -qq + env DEBIAN_FRONTEND=noninteractive \ + apt-get install --assume-yes --no-install-recommends ${requires[@]} + ;; +fedora) + dnf update -y + dnf install -y ${requires[@]} + ;; +esac +infoend + +# Use cached packages first +if [ -f $CACHE_DIR/${NAME}-${TAG}.tar.xz ]; then + echo "Found cache package, reuse it" + tar -C / -Jxf $CACHE_DIR/${NAME}-${TAG}.tar.xz +else + git clone --recurse-submodules https://github.com/mate-desktop/${NAME} + + # Foldable output information + infobegin "Configure" + cd ${NAME} + git checkout v${TAG} + if [[ ${OS} == "debian" || ${OS} == "ubuntu" ]]; then + ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu || { + cat config.log + exit 1 + } + else + ./autogen.sh --prefix=/usr || { + cat config.log + exit 1 + } + fi + infoend + + infobegin "Build" + make -j ${JOBS} + infoend + + infobegin "Install" + make install + infoend + + # Cache this package version + infobegin "Cache" + [ -d ${CACHE_DIR} ] || mkdir -p ${CACHE_DIR} + make install DESTDIR=${TEMP_DIR} + cd $TEMP_DIR + tar -J -cf $CACHE_DIR/${NAME}-${TAG}.tar.xz * + infoend +fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..00327658 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release Version +on: + push: + tags: + - "v*.*.*" + +env: + MATE_DESKTOP_VERSION: 1.28.2 + CACHE_PATH: /tmp/.cache + +jobs: + release: + name: Release New Version + runs-on: ubuntu-latest + steps: + - name: Repository checkout + uses: actions/checkout@v6 + + - name: Install dependency packages + run: sudo .github/workflows/ubuntu.sh + + - name: Install higher version Mate component packages + run: sudo .github/workflows/mate-desktop.sh ${{env.MATE_DESKTOP_VERSION}} ${{ env.CACHE_PATH }} + + - name: Build the source code + run: .github/workflows/builds.sh autotools + - name: Create github release + run: | + gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --generate-notes mate-applets-*.tar.xz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ubuntu.sh b/.github/workflows/ubuntu.sh new file mode 100755 index 00000000..291ab39b --- /dev/null +++ b/.github/workflows/ubuntu.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Ubuntu +requires=( + ccache # Use ccache to speed up build +) + +# https://git.launchpad.net/ubuntu/+source/mate-applets/tree/debian/control +requires+=( + autopoint + gcc + git + libcpufreq-dev + libdbus-1-dev + libdbus-glib-1-dev + libglib2.0-dev + libgtk-3-dev + libgtksourceview-4-dev + libgtop2-dev + libgucharmap-2-90-dev + libiw-dev + libmate-desktop-dev + libmate-menu-dev + libmate-panel-applet-dev + libmateweather-dev + libnl-genl-3-dev + libnotify-dev + libpolkit-gobject-1-dev + libupower-glib-dev + libwnck-3-dev + libx11-dev + libxml2-dev + make + mate-common + x11proto-kb-dev + yelp-tools + iso-codes + gobject-introspection + libgirepository1.0-dev +) + +infobegin "Update system" +apt-get update -y +infoend + +infobegin "Install dependency packages" +env DEBIAN_FRONTEND=noninteractive \ + apt-get install --assume-yes \ + ${requires[@]} +infoend diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 607574b4..00000000 --- a/.travis.yml +++ /dev/null @@ -1,89 +0,0 @@ -# vim: set ts=2 sts=2 sw=2 expandtab : -dist: jammy -language: shell -os: linux -services: - - docker -addons: - apt: - packages: - - python3-pip - - python3-setuptools - -branches: - except: - - gh-pages - -before_install: - - curl -Ls -o docker-build https://github.com/mate-desktop/mate-dev-scripts/raw/master/travis/docker-build - - curl -Ls -o gen-index https://github.com/mate-desktop/mate-dev-scripts/raw/master/travis/gen-index.sh - - chmod +x docker-build gen-index - -install: - - sudo apt-get install -y python3-pip python3-setuptools - - sudo pip3 install --upgrade pip - - sudo pip3 install PyGithub - - ./docker-build --name ${DISTRO} --config .build.yml --install - -script: - - ./docker-build --name ${DISTRO} --verbose --config .build.yml --build scripts - -script: - - ./docker-build --name ${DISTRO} --verbose --config .build.yml --build scripts - -notifications: - irc: - if: (tag OR branch = master) AND - repo = "mate-desktop/mate-applets" - channels: - - "irc.libera.chat#mate-dev" - template: - - "[%{repository_name}] %{author}: %{commit_subject}" - - "[%{branch}] %{commit} %{message} %{build_url}" - on_success: never - on_failure: always - -before_deploy: - - yes | gem update --system --force - - gem install bundler - - gem install faraday-net_http -v '3.3.0' # Avoid faraday version problem - - gem install uri - - gem install logger - -deploy: - - provider: pages - edge: - branch: v2.0.5 - token: $GITHUB_TOKEN - keep_history: false - committer_from_gh: true - target_branch: gh-pages - local_dir: html-report - strategy: git - on: - all_branches: true - condition: ${DISTRO} =~ ^fedora.*$ - - provider: script - edge: - branch: v2.0.5 - script: ./docker-build --verbose --config .build.yml --release github - on: - tags: true - condition: "${TRAVIS_TAG} =~ ^v.*$ && ${DISTRO} =~ ^fedora.*$" - -after_success: - - 'if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" && "$TRAVIS_PULL_REQUEST" != "false" && ${DISTRO} =~ ^fedora.*$ ]]; then - REPO_SLUG_ARRAY=(${TRAVIS_REPO_SLUG//\// }); - REPO_NAME=${REPO_SLUG_ARRAY[1]}; - URL="https://${REPO_NAME}.mate-desktop.dev"; - COMMENT="Code analysis completed"; - curl -H "Authorization: token $GITHUB_TOKEN" -X POST - -d "{\"state\": \"success\", \"description\": \"$COMMENT\", \"context\":\"scan-build\", \"target_url\": \"$URL\"}" - https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA}; - fi' - -env: -# - DISTRO="archlinux:latest" - - DISTRO="debian:testing" - - DISTRO="fedora:latest" -# - DISTRO="ubuntu:rolling" diff --git a/command/README b/command/README new file mode 100644 index 00000000..854c8197 --- /dev/null +++ b/command/README @@ -0,0 +1,59 @@ +SUMMARY +------- + +MATE Command Applet diplays the output of a commnd on the MATE Panel. + + +PREFERENCES +----------- + +- Command: command to execute. The command is executed without a + shell. If you need shell functionality (pipes, ENV vars, + etc) use /bin/sh -c 'some shell command' + +- Interval: interval in seconds after which the command will be + executed again + +- Maximum width: command output will be truncated to this number of + characters (see COMMAND OUTPUT) + +- Show icon: enable display of an icon near the command output + +COMMAND OUTPUT +-------------- + +Simple: + +The command outputs a single line of text. The text is truncated to +"Maximum width" characters and displayed on the panel. + +GKeyFile: + +If the output starts with "[Command]", the output is interpreted as +GKeyFile. Valid keys are: + +- Output + Required. Value will be parsed as pango markup and displayed on the + panel. Truncation to "Maximum Width" is not applied. + +- Tooltip + Optional: When set, the value will be used as tooltip instead of + the default (the command) and will be displayed, when cursor is + moved over the applet. + +- Icon + Optional: Filename of an icon to show, when "Show icon" is enabled. + +EXAMPLES +-------- + +- Commands with simple output: + date +%T + /bin/sh -c 'vmstat -s | grep free.memory' + +- GKeyFile command output: + + [Command] + Output=<span foreground="red">3</span> Warnings + Tooltip=7 checks ok\n3 checks failed + Icon=dialog-error diff --git a/command/src/command.c b/command/src/command.c index c4ff027a..8df97630 100644 --- a/command/src/command.c +++ b/command/src/command.c @@ -49,6 +49,7 @@ #define GK_COMMAND_GROUP "Command" #define GK_COMMAND_OUTPUT "Output" #define GK_COMMAND_ICON "Icon" +#define GK_COMMAND_TOOLTIP "Tooltip" #define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x)))) #define GET_DIALOG(x) (GTK_DIALOG (gtk_builder_get_object (builder, (x)))) @@ -301,6 +302,7 @@ process_command_output (CommandApplet *command_applet, gchar *output) { gchar *goutput = g_key_file_get_string (file, GK_COMMAND_GROUP, GK_COMMAND_OUTPUT, NULL); gchar *icon = g_key_file_get_string (file, GK_COMMAND_GROUP, GK_COMMAND_ICON, NULL); + gchar *tooltip = g_key_file_get_string (file, GK_COMMAND_GROUP, GK_COMMAND_TOOLTIP, NULL); if (goutput) { @@ -311,8 +313,12 @@ process_command_output (CommandApplet *command_applet, gchar *output) if (icon) gtk_image_set_from_icon_name (command_applet->image, icon, GTK_ICON_SIZE_LARGE_TOOLBAR); + if (tooltip) + gtk_widget_set_tooltip_text (GTK_WIDGET (command_applet->label), tooltip); + g_free (goutput); g_free (icon); + g_free (tooltip); } else gtk_label_set_text (command_applet->label, ERROR_OUTPUT); diff --git a/configure.ac b/configure.ac index 42da335b..df1f9eed 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ GTK_REQUIRED=3.22.0 LIBPANEL4_REQUIRED=1.25.2 LIBGTOP_REQUIRED=2.12.0 LIBNOTIFY_REQUIRED=0.7.0 -LIBSOUP_REQUIRED=2.42.0 +LIBSOUP_REQUIRED=3.0.0 JSON_GLIB_REQUIRED=1.0.0 UPOWER_REQUIRED=0.99.8 DBUS_GLIB_REQUIRED=0.74 @@ -102,7 +102,7 @@ AC_SUBST(LIBNOTIFY_CFLAGS) AC_SUBST(LIBNOTIFY_LIBS) dnl -- check for libsoup (optional) ----------------------------------------- -PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4 >= $LIBSOUP_REQUIRED, +PKG_CHECK_MODULES(LIBSOUP, libsoup-3.0 >= $LIBSOUP_REQUIRED, HAVE_LIBSOUP="yes", HAVE_LIBSOUP="no") PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= $JSON_GLIB_REQUIRED, diff --git a/invest-applet/data/Makefile.am b/invest-applet/data/Makefile.am index 615f23e5..856cef2c 100644 --- a/invest-applet/data/Makefile.am +++ b/invest-applet/data/Makefile.am @@ -18,6 +18,8 @@ gsettings_SCHEMAS = $(gschema_in_files:.xml.in=.xml) investbindir = $(libdir)/invest-applet +service_in_files = org.mate.panel.applet.InvestAppletFactory.service.in + # ****************************************************************************** # Build rules # ****************************************************************************** diff --git a/invest-applet/invest/Makefile.am b/invest-applet/invest/Makefile.am index 2ee22ab1..9fdf5087 100644 --- a/invest-applet/invest/Makefile.am +++ b/invest-applet/invest/Makefile.am @@ -11,7 +11,9 @@ AM_CPPFLAGS = \ APPLET_SOURCES = \ invest-applet.c \ + invest-applet.h \ invest-applet-chart.c \ + invest-applet-chart.h \ $(NULL) APPLET_LIBS = \ diff --git a/invest-applet/invest/invest-applet-chart.c b/invest-applet/invest/invest-applet-chart.c index 1114b900..c6699088 100644 --- a/invest-applet/invest/invest-applet-chart.c +++ b/invest-applet/invest/invest-applet-chart.c @@ -49,7 +49,7 @@ struct _InvestChart { }; static void fetch_chart_data (InvestChart *chart); -static void on_chart_data_received (SoupSession *session, SoupMessage *msg, gpointer user_data); +static void on_chart_data_received (GObject *source_object, GAsyncResult *result, gpointer user_data); static gboolean chart_draw_cb (GtkWidget *widget, cairo_t *cr, InvestChart *chart); static gboolean chart_window_key_press (GtkWidget *widget, GdkEventKey *event, InvestChart *chart); static void chart_range_button_clicked (GtkWidget *widget, InvestChart *chart); @@ -221,15 +221,17 @@ fetch_chart_data (InvestChart *chart) SoupMessage *msg = soup_message_new ("GET", url); /* HACK: avoid rate limiting */ - soup_message_headers_replace (msg->request_headers, "User-Agent", + SoupMessageHeaders *headers = soup_message_get_request_headers (msg); + soup_message_headers_replace (headers, "User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"); - gpointer *user_data_with_index = g_malloc (2 * sizeof (gpointer)); + gpointer *user_data_with_index = g_malloc (3 * sizeof (gpointer)); user_data_with_index[0] = chart; user_data_with_index[1] = GINT_TO_POINTER (i); + user_data_with_index[2] = msg; /* Queue the actual request to the Yahoo Finance API */ - soup_session_queue_message (chart->applet->soup_session, msg, on_chart_data_received, user_data_with_index); + soup_session_send_and_read_async (chart->applet->soup_session, msg, G_PRIORITY_DEFAULT, NULL, on_chart_data_received, user_data_with_index); g_free (url); } @@ -237,29 +239,42 @@ fetch_chart_data (InvestChart *chart) } static void -on_chart_data_received (SoupSession *session, SoupMessage *msg, gpointer user_data) +on_chart_data_received (GObject *source_object, GAsyncResult *result, gpointer user_data) { gpointer *user_data_with_index = (gpointer *)user_data; InvestChart *chart = (InvestChart *)user_data_with_index[0]; gint symbol_index = GPOINTER_TO_INT (user_data_with_index[1]); + SoupMessage *msg = SOUP_MESSAGE (user_data_with_index[2]); JsonParser *parser = NULL; JsonNode *root; JsonObject *root_obj; GError *error = NULL; + GBytes *response_body; - if (msg->status_code != SOUP_STATUS_OK) { - g_warning ("Failed to fetch chart data for symbol %d: %s", symbol_index, msg->reason_phrase); + response_body = soup_session_send_and_read_finish (SOUP_SESSION (source_object), result, &error); + if (error) { + g_warning ("Failed to fetch chart data for symbol %d: %s", symbol_index, error->message); + g_error_free (error); + goto cleanup; + } + + if (soup_message_get_status (msg) != SOUP_STATUS_OK) { + g_warning ("Failed to fetch chart data for symbol %d: %s", symbol_index, soup_message_get_reason_phrase (msg)); + g_bytes_unref (response_body); goto cleanup; } parser = json_parser_new (); - if (!json_parser_load_from_data (parser, msg->response_body->data, - msg->response_body->length, &error)) { + gsize data_length; + const gchar *data = g_bytes_get_data (response_body, &data_length); + if (!json_parser_load_from_data (parser, data, data_length, &error)) { g_warning ("Failed to parse chart JSON for symbol %d: %s", symbol_index, error->message); g_error_free (error); + g_bytes_unref (response_body); goto cleanup; } + g_bytes_unref (response_body); root = json_parser_get_root (parser); root_obj = json_node_get_object (root); @@ -349,6 +364,9 @@ cleanup: if (parser) { g_object_unref (parser); } + if (msg) { + g_object_unref (msg); + } /* Redraw chart if window is still visible */ if (chart->window && gtk_widget_get_visible (chart->window)) { diff --git a/invest-applet/invest/invest-applet.c b/invest-applet/invest/invest-applet.c index 979d90fb..d35c053c 100644 --- a/invest-applet/invest/invest-applet.c +++ b/invest-applet/invest/invest-applet.c @@ -66,31 +66,44 @@ invest_applet_update_display (InvestApplet *applet) } static void -on_stock_data_received (SoupSession *session, - SoupMessage *msg, - gpointer user_data) +on_stock_data_received (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { gpointer *user_data_with_index = (gpointer *)user_data; InvestApplet *applet = INVEST_APPLET (user_data_with_index[0]); gint symbol_index = GPOINTER_TO_INT (user_data_with_index[1]); + SoupMessage *msg = SOUP_MESSAGE (user_data_with_index[2]); JsonParser *parser = NULL; JsonNode *root; JsonObject *root_obj; GError *error = NULL; + GBytes *response_body; - if (msg->status_code != SOUP_STATUS_OK) { - g_warning ("Failed to fetch stock data for symbol %d: %s", symbol_index, msg->reason_phrase); + response_body = soup_session_send_and_read_finish (SOUP_SESSION (source_object), result, &error); + if (error) { + g_warning ("Failed to fetch stock data for symbol %d: %s", symbol_index, error->message); + g_error_free (error); + goto cleanup; + } + + if (soup_message_get_status (msg) != SOUP_STATUS_OK) { + g_warning ("Failed to fetch stock data for symbol %d: %s", symbol_index, soup_message_get_reason_phrase (msg)); + g_bytes_unref (response_body); goto cleanup; } parser = json_parser_new (); - if (!json_parser_load_from_data (parser, msg->response_body->data, - msg->response_body->length, &error)) { + gsize data_length; + const gchar *data = g_bytes_get_data (response_body, &data_length); + if (!json_parser_load_from_data (parser, data, data_length, &error)) { g_warning ("Failed to parse JSON for symbol %d: %s", symbol_index, error->message); g_error_free (error); + g_bytes_unref (response_body); goto cleanup; } + g_bytes_unref (response_body); root = json_parser_get_root (parser); root_obj = json_node_get_object (root); @@ -148,6 +161,9 @@ cleanup: if (parser) { g_object_unref (parser); } + if (msg) { + g_object_unref (msg); + } applet->pending_requests--; if (applet->pending_requests == 0) { @@ -227,14 +243,16 @@ invest_applet_update_stocks (gpointer user_data) SoupMessage *msg = soup_message_new ("GET", url); /* HACK: avoid rate limiting */ - soup_message_headers_replace (msg->request_headers, "User-Agent", + SoupMessageHeaders *headers = soup_message_get_request_headers (msg); + soup_message_headers_replace (headers, "User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"); - gpointer *user_data_with_index = g_malloc (2 * sizeof (gpointer)); + gpointer *user_data_with_index = g_malloc (3 * sizeof (gpointer)); user_data_with_index[0] = applet; user_data_with_index[1] = GINT_TO_POINTER (i); + user_data_with_index[2] = msg; - soup_session_queue_message (applet->soup_session, msg, on_stock_data_received, user_data_with_index); + soup_session_send_and_read_async (applet->soup_session, msg, G_PRIORITY_DEFAULT, NULL, on_stock_data_received, user_data_with_index); g_free (url); } |
