Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
misterabdul committed Jul 23, 2021
2 parents e0cdfb5 + b85b9a8 commit a6a5843
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

112 changes: 112 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
cmake_minimum_required(VERSION 3.9)

# Project description
project(
kbbi-gtk
VERSION 1.0.0
DESCRIPTION "KBBI Offline with GTK3"
)

# Check required package & libraries
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT2GTK4 REQUIRED webkit2gtk-4.0)
pkg_check_modules(LIBKBBI REQUIRED libkbbi)

# Set C standard
set(CMAKE_C_STANDARD 99)

# Targets
add_executable(
${PROJECT_NAME}
src/main.c
src/ui.c
)

# Properties
set_target_properties(
${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
)

# Includes
target_include_directories(
${PROJECT_NAME}
PRIVATE src
)

# Link required libraries
target_link_libraries(
${PROJECT_NAME}
${GTK3_LIBRARIES}
${WEBKIT2GTK4_LIBRARIES}
${LIBKBBI_LIBRARIES}
)

# Include library's public header directory
target_include_directories(
${PROJECT_NAME}
PUBLIC ${GTK_INCLUDE_DIRS}
PUBLIC ${WEBKIT2GTK4_INCLUDE_DIRS}
PUBLIC ${LIBKBBI_INCLUDE_DIRS}
)

# Add library's extra compiler flags
target_compile_options(
${PROJECT_NAME}
PUBLIC ${GTK3_CLFAGS_OTHER}
PUBLIC ${WEBKIT2GTK4_CLFAGS_OTHER}
PUBLIC ${LIBKBBI_CLFAGS_OTHER}
)

# CMake setup
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_C_FLAGS "-Wall -Wextra -fvisibility=hidden")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O3")

set(DESKTOP_PATH "share/applications/")
set(DESKTOP_ICON_PATH "share/icons/hicolor/128x128/apps")
set(DESKTOP_NAME "KBBI Offline")
set(DESKTOP_EXEC ${PROJECT_NAME})
set(DESKTOP_ICON_REF "${CMAKE_INSTALL_PREFIX}/${DESKTOP_ICON_PATH}/${PROJECT_NAME}.png")

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/application.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/icon.png"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.png"
COPYONLY
)

# Install the file
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop
DESTINATION ${DESKTOP_PATH}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.png
DESTINATION ${DESKTOP_ICON_PATH}
)

# Expand uninstall script
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY
)

# Add uninstall target
add_custom_target(
uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake
)
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,29 @@ KBBI offline remake with GTK3.
This is my hobby project to learn more about C programming, widget programming using GTK, and dynamic library. Feel free to explore, fork, or create a pull request if you interested.

![Alt text](./assets/screenshots/screenshot_1.png "KBBI Offline")

## Todo

- [ ] AppImage packaging
- [ ] Unit testing with CMake (?)

## Building

```sh
# Create build directory
$ mkdir -p build
$ cd build

# Run cmake to generate build files
$ cmake ..

# Run make to start building
$ make

# Optional: run install script to install the apps
$ sudo make install

# Optional: run uninstall script to uninstall the apps
$ sudo make uninstall

```
7 changes: 7 additions & 0 deletions application.desktop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=@DESKTOP_NAME@
Exec=@DESKTOP_EXEC@
Icon=@DESKTOP_ICON_REF@
Categories=Utility;
Binary file added assets/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions bin/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion lib/libkbbi
Submodule libkbbi deleted from 0c1af3
42 changes: 0 additions & 42 deletions makefile

This file was deleted.

2 changes: 0 additions & 2 deletions obj/.gitignore

This file was deleted.

157 changes: 0 additions & 157 deletions src/lib.c

This file was deleted.

Loading

0 comments on commit a6a5843

Please sign in to comment.