diff --git a/.gitignore b/.gitignore index 4f7d8d9..a4cb815 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ autom4te.cache /autoscan.log /autoscan-*.log /aclocal.m4 +build /compile /config.cache /config.guess @@ -30,7 +31,22 @@ autom4te.cache /stamp-h1 configure~ build-aux -build +build/ +cmake_install.cmake +CTestTestfile.cmake +CMakeFiles/ +CMakeCache.txt +CMakeDoxyfile.in +CMakeDoxygenDefaults.cmake +CPackConfig.cmake +CPackSourceConfig.cmake +vendors/drogon/Doxyfile.doc_drogon +vendors/drogon/DrogonConfigVersion.cmake +vendors/drogon/drogon/ +vendors/drogon/exports/ +vendors/drogon/trantor/Doxyfile.doc_trantor +vendors/drogon/trantor/TrantorConfigVersion.cmake +vendors/drogon/trantor/exports/ # https://www.gnu.org/software/libtool/ @@ -51,6 +67,9 @@ m4/lt~obsolete.m4 # exclude executables /drogon_dashboard +/DrogonCMS +vendors/drogon/local-api-server/local-drogon-api-server +vendors/drogon/local-api-server/test/local-server_test # Generated Makefile # (meta build system like autotools, diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..65b424b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,175 @@ +# This is a Drogon Content Management System(CMS) built on GTK4. +# Copyright (C) 2024-PRESENT SHARPETRONICS, LLC +# Copyright (C) 2024-PRESENT ODINZU WENKI(CHARLES) + +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Under Section 7 of GPL version 3, you are granted additional +# permissions described in the GCC Runtime Library Exception, version +# 3.1, as published by the Free Software Foundation. +# +# You should have received a copy of the GNU General Public License along with +# this program; see the files LICENSE and LICENSE_EXCEPTION respectively. +# If not, see . +#=============================================================================== +# AUTHORED DATE: 01.14.2024 + +# Almost all CMake files should start with this +# You should always specify a range with the newest +# and oldest tested versions of CMake. This will ensure +# you pick up the best policies. +cmake_minimum_required(VERSION 3.1...3.28) + +# If you set any CMAKE_ variables, that can go here. +# (But usually don't do this, except maybe for C++ standard) +set(CMAKE_PROJECT_DESCRIPTION "A GTK / Drogon CMS") +set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/odinzu/drogoncms") + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# This is your project statement. You should always list languages; +# Listing the version is nice here since it sets lots of useful variables +# we removed LANGUAGES C from project to allow for automatic compiler/linker checks; we will use C and C++ libraries for this project. +project( + DrogonCMS + VERSION 1.0 +) + +#=============================================================================== +# Setting compilation flags for various compilers and build types: +#=============================================================================== + +# some test warning levels for GCC +set(WARNING_LEVELS_GCC + #-Werror +) +set(WARNING_LEVELS_GCC_DEBUG + #-Wfloat-equal + #-Wextra + -Wall + -Wdeprecated-declarations + #-Wundef + #-Wshadow + #-Wpointer-arith + #-Wcast-align + #-Wstrict-overflow=5 + #-Wwrite-strings + #-Waggregate-return + #-Wcast-qual + #-Wswitch-default + #-Wswitch-enum + #-Wconversion +) + +# Print system, compiler CMake ID, version and path: +#message(STATUS "System: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}") +#message(STATUS "Compiler: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION} ${CMAKE_Fortran_COMPILER}") +#message(STATUS "Build type is: ${CMAKE_BUILD_TYPE}") + +#=============================================================================== +# Default build type is release +# Uncomment this to debug or use "cmake -D CMAKE_BUILD_TYPE=debug .." +#=============================================================================== +# set(CMAKE_BUILD_TYPE debug) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose build type: None Debug Release" + FORCE) +endif() + +# Find packages go here. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK4 REQUIRED gtk4>=4.0) +pkg_check_modules(ADW REQUIRED libadwaita-1>=1.3.5) + +# Setup CMake to use GTK+, tell the compiler where to look for headers +# and to the linker where to look for libraries +include_directories(${GTK4_INCLUDE_DIRS} ${ADW_INCLUDE_DIRS}) +link_directories(${GTK4_LIBRARY_DIRS} ${ADW_LIBRARY_DIRS}) +add_definitions(${GTK4_CFLAGS_OTHER} ${ADW_CFLAGS_OTHER}) + +# Adding something we can run - Output name matches target name +add_executable(DrogonCMS src/base.c) + +# Include drogon source code locally +add_subdirectory(vendors/drogon/local-api-server/) + +# This is a "default" library, and will match the *** variable setting. +# Other common choices are STATIC, SHARED, and MODULE +# Including header files here helps IDEs but is not required. +# Output libname matches target name, with the usual extensions on your system +#add_library(MyLibExample simple_lib.cpp simple_lib.hpp) + +# Link each target with other targets or add options, etc. +# Make sure you link your targets with this command. It can also link libraries and +# even flags, so linking a target that does not exist will not give a configure-time error. +target_include_directories(${PROJECT_NAME} PUBLIC ${GTK4_LIBRARIES} ${ADW_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${GTK4_LIBRARIES} ${ADW_LIBRARIES} ${DROGON_LIBRARIES}) + +# Target Compile Options +target_compile_options(${PROJECT_NAME} PRIVATE ${WARNING_LEVELS_GCC} $<$:${WARNING_LEVELS_GCC_DEBUG}>) + +# This part is so the Modern CMake book can verify this example builds. For your code, +# you'll probably want tests too +enable_testing() +#add_test(NAME MyExample COMMAND MyExample) + +#=============================================================================== +# Package generation: +#=============================================================================== +#set(CPACK_PACKAGE_CHECKSUM SHA256) +#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +#set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") +#set(CPACK_GENERATOR "TGZ") +#set(CPACK_SOURCE_GENERATOR "TGZ") +#include(CPack) + +#=============================================================================== +# Add subdirectories to build: +#=============================================================================== +#add_subdirectory(src) + +# include directory for third party libraries +include_directories(vendors/) + +############################################################################### +## PACKAGING ################################################################## +############################################################################### + +# all install commands get the same destination. this allows us to use paths +# relative to the executable. +#install(TARGETS example DESTINATION example_destination) +# this is basically a repeat of the file copy instruction that copies the +# resources in the build directory, but here we tell CMake that we want it +# in the package +#install(DIRECTORY resources DESTINATION example_destination) + +#set(CPACK_PACKAGE_CHECKSUM SHA256) +#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +#set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") +#set(CPACK_GENERATOR "TGZ") +#set(CPACK_SOURCE_GENERATOR "TGZ") + +# now comes everything we need, to create a package +# there are a lot more variables you can set, and some +# you need to set for some package types, but we want to +# be minimal here +#set(CPACK_PACKAGE_NAME "MyExample") +#set(CPACK_PACKAGE_VERSION "1.0.0") + +# we don't want to split our program up into several things +#set(CPACK_MONOLITHIC_INSTALL 1) + +# This must be last +#include(CPack) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 66c88eb..0000000 --- a/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -# TODO: organize files more - -# reduce warnings/errors for subdirectory objects -AUTOMAKE_OPTIONS = subdir-objects - -# the name of the binary file -bin_PROGRAMS = drogon_dashboard - -# Uses shell pkg-config CLI to find and include required libs -AM_CFLAGS = $(shell pkg-config --cflags gtk4) -LIBS = $(shell pkg-config --libs libadwaita-1 gtk4) - -# various *.cpp and *.hpp files for the root project; the '\' implies a *newline* -drogon_dashboard_SOURCES = \ - src/base.c - diff --git a/README.md b/README.md index b582e51..2110b91 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,48 @@ -## A Drogon Dashboard built with C, Drogon, GNU Autotools, Adwaita and Gtk4. +## A Drogon CMS built with C, Drogon, CMake, Adwaita and Gtk4 This software creates a local/remote Drogon content management system (CMS) application. ### License * GPL-3.0 -### Developer Environment Requirements +### Developer Dependency Requirements * GCC (GNU C/C++ Compiler) 13.2.1 -* GNU Autotools -* GNU Make 4.4.1 -* Pkg-Config 1.8.1 +* CMake >= 3.28 +* Drogon >= 1.9.1 [SEE REQUIREMENTS] +* Pkg-Config >= 1.8.1 * Gtk4 >= 4.0 * Adwaita >= 1.3.5 * *Optional* Cambalache >= 0.14 (Gtk4 Editor) [SEE REQUIREMENTS] * *Optional* Geany IDE -* Basic CLI Experience +* CLI Experience -### Steps to build the Drogon Dashboard Application +*Note: This has been built and tested on Arch Linux* -1. Run `autoreconf -vi`. **Tip:** Run this command each time you modify configure.ac -2. Create a `build` directory and auto configure the app `cd build && ../configure`. -3. Compile the app with `make`. **Tip:** Be certain you are in the **build** directory -4. Run the app with `./drogon_dashboard`. -5. *Optional:* Install the app to core system `make install`. **Tip:** Root permissions may be needed depending on where you --prefix the install directory -6. *Optional:* `make dist` creates and packages the binaries for **distribution**. +### Steps to build DrogonCMS from Source code + +0. Clone the repository `git clone https://git.sharpetronics.com/sharpetronics/DrogonCMS` and `cd DrogonCMS/` +1. *optional* checkout correct branch e.g. `git checkout drogonCMS-cmake` +2. Run `cmake -D CMAKE_BUILD_TYPE=Release .` +3. Then, to build the executable, we do `cmake --build .` +4. Run the app with `./DrogonCMS` ## Development & Contributing ### Requirements +Drogon framework compile/build dependencies. +* Drogon >= 1.9.1 https://github.com/drogonframework/drogon/wiki/ENG-02-Installation#System-Preparation-Examples + +### Recommendations + A GTK4 editor is a recommended tool for this project; all UI's and project files **.cmb** are stored in `./src/ui/`. * Cambalache >= 0.14 https://gitlab.gnome.org/jpu/cambalache An optional recommendation is Geany IDE. * Geany IDE https://www.geany.org/ -### Note: Update your build commands via `Build -> Set Build Commands`. +### IDE build commands via Geany `Build -> Set Build Commands` -This is what my build commands look like in Geany IDE. +#### This is what my build commands look like in Geany IDE with **GNU Automake Tools**. | Name | Command | Working Directory | | ----------- | ------------------ | -------------------------------------------------------------------- | @@ -46,14 +52,23 @@ This is what my build commands look like in Geany IDE. | Run | ./drogon_dashboard | /home/username/Desktop/Local-Development/cplusplus/drogon-dash/build | | Make Bins | make dist | /home/username/Desktop/Local-Development/cplusplus/drogon-dash/build | +#### This is what my build commands look like in Geany IDE with **BSD CMake Tools**. + +| Name | Command | Working Directory | +| ----------- | ------------------ | -------------------------------------------------------------------- | +| Configure | cmake -D CMAKE_BUILD_TYPE=Release | /home/username/Desktop/Local-Development/cplusplus/DrogonCMS | +| Build | cmake --build | /home/username/Desktop/Local-Development/cplusplus/DrogonCMS | +| Run | ./DrogonCMS | /home/username/Desktop/Local-Development/cplusplus/DrogonCMS | +| Install | cmake --install | /home/username/Desktop/Local-Development/cplusplus/DrogonCMS | + ## Authors -* SharpeTronics, Inc. -* oDinZu WenKi +* SharpeTronics, LLC +* oDinZu WenKi(Charles) ## Financial Support & Donations -oDinZu WenKi https://liberapay.com/oDinZu/ +oDinZu WenKi(Charles) https://liberapay.com/oDinZu/ * Liberapay is a recurrent donations platform * Run by a non-profit organization @@ -65,6 +80,7 @@ oDinZu WenKi https://liberapay.com/oDinZu/ * Adawaita Documentation https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/index.html * Cambalache https://gitlab.gnome.org/jpu/cambalache * C References https://en.cppreference.com/w/c +* CMake Documentation https://cmake.org/cmake/help/book/mastering-cmake/index.html * Drogon Web Server https://github.com/drogonframework/drogon * Geany IDE https://www.geany.org/ * Gio Documentation https://docs.gtk.org/gio/index.html @@ -72,6 +88,5 @@ oDinZu WenKi https://liberapay.com/oDinZu/ * GObject Documentation https://docs.gtk.org/gobject/index.html * GTK 4 Demos https://gitlab.gnome.org/GNOME/gtk/-/tree/main/demos * GTK 4 Documentation https://docs.gtk.org/gtk4/ -* GNU Autotools Documentation https://www.gnu.org/software/automake/manual/automake.html#Autotools-Introduction -Notice: We focus implementation with the C programming language and only add various features of C ++ code. +*Notice: We focus implementation with the C programming language and only add various features of C ++ code.* diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 08026b7..0000000 --- a/configure.ac +++ /dev/null @@ -1,33 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.71]) -AC_INIT([drogon_dashboard], [0.0.1], [odinzu@sharpetronics.com]) - -# When a package contains more than a few tests that define C preprocessor symbols, the command lines to pass -D options to the compiler can get quite long. -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_SRCDIR([src/base.c]) - -# Organize root project build-aux files -AC_CONFIG_AUX_DIR([build-aux]) - -# USED by automake to work with autoconf; Enables all warnings, plus foreign disables warnings/errors for mandatory files like README.md -AM_INIT_AUTOMAKE([-Wall -Wdeprecated-declarations foreign]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. - -# Checks for header files. - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. - -# Checks for all the given modules, setting a variety of result variables in the calling scope. -PKG_CHECK_MODULES([GTK4], [gtk4 >= 4.0]) -PKG_CHECK_MODULES([ADWAITA], [libadwaita-1 >= 1.3.5]) - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/src/base.c b/src/base.c index 92390a2..614011a 100644 --- a/src/base.c +++ b/src/base.c @@ -2,9 +2,9 @@ # This software creates a local/remote Drogon content management system (CMS) application with Gtk-4.0 GUI and the Drogon framework. # A Drogon Dashboard built with C, Drogon, GNU Autotools, Adwaita and Gtk4. # -# Copyright (C) SharpeTronics, Inc. - 2013-PRESENT +# Copyright (C) SharpeTronics, LLC. - 2013-PRESENT # -# Author(s): SharpeTronics, Inc. +# Author(s): SharpeTronics, LLC. # oDinZu WenKi # # License: GPL-3.0 @@ -32,38 +32,81 @@ */ #include +#include +#include +/*#include */ + +/* + Static Variables + */ +static GtkWidget *p_input; +static GtkWidget *p_input_confirm; +static GtkWidget *register_button; /* Functions */ + + +/* Compare password entries for admin registration confirmation */ +static void +update_register_button(GObject *object, + GParamSpec *pspec, + gpointer data) +{ + const char *text = gtk_editable_get_text(GTK_EDITABLE(p_input)); + const char *text2 = gtk_editable_get_text(GTK_EDITABLE(p_input_confirm)); + + //PLACEHOLDER Thish widget set needs to work with GtkBuilder. + //This can be done easily but may need a condiontal statement. + //Another issue is to use the gtkbuilder, I would have to duplicate code here or learn how to arrange each iteration in a module or easy to use function. + //gtk_widget_set_sensitive (register_button, + //text[0] != '\0' && g_str_equal (text, text2)); +} /* Launch the application from activate */ static void -activate (GtkApplication *app, - gpointer user_data) +activate(GtkApplication *app, + gpointer user_data) { /* Construct a GtkBuilder instance */ GtkBuilder *builder = gtk_builder_new(); /* Loads the UI objects */ - gtk_builder_add_from_file(builder, "../src/ui/admin-register.ui", NULL); + gtk_builder_add_from_file(builder, "src/ui/admin-register.ui", NULL); - /* Register the ID of gtk_object from admin-register.ui */ + /* Register the ID's of gtk_object from admin-register.ui */ GObject *window = gtk_builder_get_object(builder, "register_window"); + + p_input = gtk_builder_get_object(builder, "p_input"); + GObject *p_input_confirm = gtk_builder_get_object(builder, "p_input_confirm"); + GObject *register_button = gtk_builder_get_object(builder, "register_button"); /* Connect the actions of XML UI objects's with Gtk Signals */ - + /* In Gtk_builder, we edit the specific widget; Gtk_builder contains all widgets created from Cambalache UI's */ + + /* Connect input text with update_button compariative function */ + g_signal_connect(p_input, "notify::text", G_CALLBACK(update_register_button), NULL); + g_signal_connect(p_input_confirm, "notify::text", G_CALLBACK(update_register_button), NULL); /* Sets the app window with *app GtkApplication */ gtk_window_set_application(GTK_WINDOW(window), app); /* Display the Gtk GUI */ gtk_widget_set_visible(window, TRUE); + + /* + * Adds a weak reference from weak_pointer object to indicate that the + * pointer located at weak_pointer_location is only valid during the lifetime of object. + * When the object is finalized, weak_pointer will be set to NULL. + */ + g_object_add_weak_pointer(G_OBJECT (window), (gpointer *)&window); - /* Dereference and free computer memory */ + /* Dereference and free the computer memory */ g_object_unref(builder); } + /* Main program begins here */ diff --git a/src/ui/admin-register.ui b/src/ui/admin-register.ui index 979cfcb..9e75d1f 100644 --- a/src/ui/admin-register.ui +++ b/src/ui/admin-register.ui @@ -27,7 +27,7 @@ oDinZu WenKi -->