Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

48 refactor with clang tidy or sonarlint #50

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
BasedOnStyle: Google
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Left
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: 'true'
ColumnLimit: '120'
CompactNamespaces: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '3'
ContinuationIndentWidth: '3'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'true'
IndentPPDirectives: None
IndentWidth: '3'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: None
PointerAlignment: Left
SortIncludes: 'false'
SortUsingDeclarations: 'false'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '3'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'true'
Standard: Cpp11
TabWidth: '3'
UseTab: Never

...
16 changes: 16 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# vim: set ft=yaml
CompileFlags:
CompilationDatabase: ./build
Diagnostics:
UnusedIncludes: Strict
ClangTidy:
Add:
- linuxkernel-*
- llvmlibc-*
- modernize-*
- portability-*
- readability-*
Remove:
- modernize-macro-to-enum
- readability-identifier-length
- readability-redundant-function-ptr-dereference
7 changes: 0 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/debian/.devcontainer/base.Dockerfile

# [Choice] Debian version: buster, stretch
FROM "xfce/xfce-build"

# ** [Optional] Uncomment this section to install additional packages. **
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN useradd -m vscode
25 changes: 8 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/debian
{
"name": "xfce-build",
"build": {

"dockerfile": "Dockerfile"
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
"customizations": {
"vscode": {
"terminal.integrated.shell.linux": "/bin/bash",
"extensions": [
"llvm-vs-code-extensions.vscode-clangd"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
"remoteUser": "vscode"
}
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Makefile]
indent_style = tab
indent_size = 4

[*.{c,h}]
indent_style = space
indent_size = 3

2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Runs a set of commands using the runners shell
- name: Build and Install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ po/Makefile.in
po/POTFILES
po/stamp-it
po/xfce4-hamster-plugin.pot
compile_commands.json
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(xfce4-hamster-plugin
DESCRIPTION "A recreation of the gnome hamster shell extension for the xfce4 panel"
LANGUAGES C
)
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/projecthamster/xfce4-hamster-plugin")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(PkgConfig REQUIRED)
find_package(Gettext REQUIRED)
Expand Down Expand Up @@ -74,3 +76,18 @@ install(TARGETS hamster LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/xfce4/panel
install(FILES ${PROJECT_BINARY_DIR}/hamster.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xfce4/panel/plugins/)
install(PROGRAMS ${PROJECT_BINARY_DIR}/xfce4-popup-hamstermenu DESTINATION ${CMAKE_INSTALL_BINDIR})

# CPACK
set(CPACK_ADD_VERSION 2)
set(CPACK_PACKAGE_CONTACT "Hakan Erduman <[email protected]>")

# deb specific
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_ADD_VERSION})
set(CPACK_DEBIAN_PACKAGE_SECTION "Xfce")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

# rpm specific
set(CPACK_RPM_FILE_NAME, "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_RELEASE ${CPACK_ADD_VERSION})

include(CPack)
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# minimal makefile to ease cmake usage

CMAKE_BUILD_TYPE ?= RelWithDebInfo # sane, strip later on
CMAKE_INSTALL_PREFIX ?= /usr # panel plugins only work here
CMAKE_GENERATOR ?= $(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || echo "Unix Makefiles")

.PHONY: default info cmake install deb rpm

default: cmake

info:
@echo '*** you can override these ***'
@echo "CMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)"
@echo "CMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)"
@echo "CMAKE_GENERATOR=$(CMAKE_GENERATOR)"
@echo '*** this one depends on CMAKE_GENERATOR ***'

./build:
cmake -B build -G $(CMAKE_GENERATOR) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)

cmake: ./build
cmake --build build

install: cmake
cmake --install build

clean:
rm -rf build

deb: cmake
cd build && cpack -G DEB

rpm: cmake
cd build && cpack -G RPM
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ libxfconf-0-dev libxfce4util-dev`

Common: `build-essential cmake intltool`

Tested on Arch with xfce 4.16, Ubuntu 20.04 with xfce 4.14 and
Debian Buster with xfce 4.12. Uses GTK+3 only, requires APIs that are
not available before xfce 4.10. Support for older versions are in
Tested on Arch with xfce 4.18, Ubuntu 22.04 with xfce 4.16 and
Debian Bookworm with xfce 4.18. Uses GTK+3 only, requires APIs that are
not available before xfce 4.10. Support for older versions are
available in the git history. Also seen running on Alpine and void (musl).

## Translators
Expand All @@ -26,9 +26,12 @@ the following bias:
## Compilation
Checkout as outlined under Contribution below, cd to the directory and
issue `cmake -B build -DCMAKE_INSTALL_PREFIX=/usr`. If this fails, install any missing
dependencies and repeat until success.
dependencies and you may need to rinse and repeat until success.
Finally, issue `cmake --build build && sudo cmake --install build`.
Restart the xfce4 panel with `xfce4-panel -r`.
If the plugin does not show up, check if the installation location is indeed `/usr`;
the panel does only seek for plugins on a location hardcoded at the time of compilation
of xfce4 itself, so you `/usr/local` may be fine on the \*BSDs.

## Packagers
This plug-in is useless without an activatable D-Bus implementation of
Expand All @@ -41,9 +44,6 @@ If your distribution doesn't, maybe its time to push the issue.

The icon from hamster is reused as `org.gnome.Hamster.GUI`.

The generated .lo files are best purged since no linkage or development
packages are provided.

[![Packaging status](https://repology.org/badge/vertical-allrepos/xfce4-hamster-plugin.svg)](https://repology.org/project/xfce4-hamster-plugin/versions)

## Contributing
Expand All @@ -61,4 +61,8 @@ I'd like to thank the following translators:
- Nicolas Reynolds
- fauno


## Development
The Compilation steps are available within a convenience `Makefile`. If CPack is
installed, this Makefile may also generate `.deb` and `.rpm` packages
with the `deb` and `rpm` make targets. Keeping debug info is achieved with `make CMAKE_BUILD_TYPE=DEBUG`.
This will also make `DBG()` output visible in the console.
8 changes: 8 additions & 0 deletions panel-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ add_compile_definitions(
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
)

if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
message("Build DEBUG version")
add_compile_definitions(DEBUG=1)
endif()

target_include_directories(
hamster PUBLIC
${GTK_INCLUDE_DIRS}
Expand All @@ -45,6 +50,9 @@ target_link_directories(
hamster PUBLIC
${GTK_LIBRARY_DIRS}
)
target_compile_options(
hamster PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=."
)

target_link_libraries(
hamster ${GTK_LIBRARIES}
Expand Down
Loading