Enhancement: Fixes #242, Create sample application GTK3

This commit is contained in:
Rory Fewell
2023-11-28 22:31:39 +00:00
parent 3348861d71
commit 42371389a1
14 changed files with 322 additions and 1 deletions

8
base/README.MD Normal file
View File

@@ -0,0 +1,8 @@
# Base Components
This directory contains components that form parts of the base system itself.
## Structure
Each directory contains a generally standard CMake project, however due to the nature that each component targets different areas of the system, there is no absolutely standard structure like there is for typical programs.
## What's in here?
Things that are either build related (in the case of `bldtag`), or target key system services (Plymouth boot screen in `bootvid`, or the LightDM greeter in `logonui`).

8
private/README.MD Normal file
View File

@@ -0,0 +1,8 @@
# Private Sources
This directory contains components and samples that are private to the project (intended for development/testing purposes only).
## Structure
Each directory houses component(s) or sample(s) for testing or developing the project. In general programs will be logically stored according to their purpose, and structured as typical programs are within the project.
## Getting Started?
Interested in getting to grips with programs in the project? Have a look at samples, such as the 'hello world!' application under `/private/samples/gtk3/hello`.

View File

@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.5)
project(
wintc-hello
VERSION 1.0
DESCRIPTION "Windows Total Conversion 'Hello World' application."
LANGUAGES C
)
set(PROJECT_ANYARCH false)
set(PROJECT_FREESTATUS true)
set(PROJECT_MAINTAINER "Rory Fewell <roryf@oddmatics.uk>")
set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
include(GNUInstallDirs)
include(../../../../packaging/cmake-inc/common/CMakeLists.txt)
include(../../../../packaging/cmake-inc/linking/CMakeLists.txt)
include(../../../../packaging/cmake-inc/packaging/CMakeLists.txt)
wintc_resolve_library(glib-2.0 GLIB)
wintc_resolve_library(gtk+-3.0 GTK3)
wintc_resolve_library(wintc-comgtk WINTC_COMGTK)
add_executable(
wintc-hello
src/application.c
src/application.h
src/main.c
src/window.c
src/window.h
)
target_compile_options(
wintc-hello
PRIVATE ${WINTC_COMPILE_OPTIONS}
)
target_include_directories(
wintc-hello
SYSTEM
PRIVATE ${GLIB_INCLUDE_DIRS}
PRIVATE ${GTK3_INCLUDE_DIRS}
PRIVATE ${WINTC_COMGTK_INCLUDE_DIRS}
)
target_link_directories(
wintc-hello
PRIVATE ${GLIB_LIBRARY_DIRS}
PRIVATE ${GTK3_LIBRARY_DIRS}
PRIVATE ${WINTC_COMGTK_LIBRARY_DIRS}
)
target_link_libraries(
wintc-hello
PRIVATE ${GLIB_LIBRARIES}
PRIVATE ${GTK3_LIBRARIES}
PRIVATE ${WINTC_COMGTK_LIBRARIES}
)
# Installation
#
wintc_configure_and_install_packaging()
wintc_install_icons_into_package()
install(
FILES wintc-hello.desktop
DESTINATION share/applications
)
install(
TARGETS wintc-hello
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@@ -0,0 +1,4 @@
# hello
This directory contains the source code for the *Hello* sample program.
![image](https://github.com/rozniak/xfce-winxp-tc/assets/13258281/b78ba08f-c18d-4331-9d7f-072eb0090cca)

View File

@@ -0,0 +1,3 @@
bt,rt:glib2
bt,rt:gtk3
bt,rt:wintc-comgtk

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

View File

@@ -0,0 +1,72 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <wintc-comgtk.h>
#include "application.h"
#include "window.h"
//
// GTK OOP CLASS/INSTANCE DEFINITIONS
//
struct _WinTCHelloApplicationClass
{
GtkApplicationClass __parent__;
};
struct _WinTCHelloApplication
{
GtkApplication __parent__;
};
//
// FORWARD DECLARATIONS
//
static void wintc_hello_application_activate(
GApplication* application
);
//
// GTK TYPE DEFINITIONS & CTORS
//
G_DEFINE_TYPE(WinTCHelloApplication, wintc_hello_application, GTK_TYPE_APPLICATION)
static void wintc_hello_application_class_init(
WinTCHelloApplicationClass* klass
)
{
GApplicationClass* application_class = G_APPLICATION_CLASS(klass);
application_class->activate = wintc_hello_application_activate;
}
static void wintc_hello_application_init(
WINTC_UNUSED(WinTCHelloApplication* self)
) { }
//
// CLASS VIRTUAL METHODS
//
static void wintc_hello_application_activate(
GApplication* application
)
{
GtkWidget* new_window =
wintc_hello_window_new(WINTC_HELLO_APPLICATION(application));
gtk_widget_show_all(new_window);
}
//
// PUBLIC FUNCTIONS
//
WinTCHelloApplication* wintc_hello_application_new(void)
{
return WINTC_HELLO_APPLICATION(
g_object_new(
wintc_hello_application_get_type(),
"application-id", "uk.co.oddmatics.wintc.samples.hello",
NULL
)
);
}

View File

@@ -0,0 +1,27 @@
#ifndef __APPLICATION_H__
#define __APPLICATION_H__
#include <glib.h>
#include <gtk/gtk.h>
//
// GTK OOP BOILERPLATE
//
typedef struct _WinTCHelloApplicationClass WinTCHelloApplicationClass;
typedef struct _WinTCHelloApplication WinTCHelloApplication;
#define TYPE_WINTC_HELLO_APPLICATION (wintc_hello_application_get_type())
#define WINTC_HELLO_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_WINTC_HELLO_APPLICATION, WinTCHelloApplication))
#define WINTC_HELLO_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_WINTC_HELLO_APPLICATION, WinTCHelloApplicationClass))
#define IS_WINTC_HELLO_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_WINTC_HELLO_APPLICATION))
#define IS_WINTC_HELLO_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_WINTC_HELLO_APPLICATION))
#define WINTC_HELLO_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_WINTC_HELLO_APPLICATION, WinTCHelloApplicationClass))
GType wintc_hello_application_get_type(void) G_GNUC_CONST;
//
// PUBLIC FUNCTIONS
//
WinTCHelloApplication* wintc_hello_application_new(void);
#endif

View File

@@ -0,0 +1,20 @@
#include <glib.h>
#include "application.h"
int main(
int argc,
char* argv[]
)
{
WinTCHelloApplication* app = wintc_hello_application_new();
int status;
g_set_application_name("Hello");
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}

View File

@@ -0,0 +1,65 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <wintc-comgtk.h>
#include "application.h"
#include "window.h"
//
// GTK OOP CLASS/INSTANCE DEFINITIONS
//
struct _WinTCHelloWindowClass
{
GtkApplicationWindowClass __parent__;
};
struct _WinTCHelloWindow
{
GtkApplicationWindow __parent__;
};
//
// GTK TYPE DEFINITION & CTORS
//
G_DEFINE_TYPE(
WinTCHelloWindow,
wintc_hello_window,
GTK_TYPE_APPLICATION_WINDOW
)
static void wintc_hello_window_class_init(
WINTC_UNUSED(WinTCHelloWindowClass* klass)
) {}
static void wintc_hello_window_init(
WinTCHelloWindow* self
)
{
gtk_window_set_default_size(
GTK_WINDOW(self),
320,
200
);
gtk_container_add(
GTK_CONTAINER(self),
gtk_label_new("Hello Windows!")
);
}
//
// PUBLIC FUNCTIONS
//
GtkWidget* wintc_hello_window_new(
WinTCHelloApplication* app
)
{
return GTK_WIDGET(
g_object_new(
TYPE_WINTC_HELLO_WINDOW,
"application", GTK_APPLICATION(app),
"title", "Hello Windows!",
NULL
)
);
}

View File

@@ -0,0 +1,31 @@
#ifndef __WINDOW_H__
#define __WINDOW_H__
#include <glib.h>
#include <gtk/gtk.h>
#include "application.h"
//
// GTK OOP BOILERPLATE
//
typedef struct _WinTCHelloWindowClass WinTCHelloWindowClass;
typedef struct _WinTCHelloWindow WinTCHelloWindow;
#define TYPE_WINTC_HELLO_WINDOW (wintc_hello_window_get_type())
#define WINTC_HELLO_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_WINTC_HELLO_WINDOW, WinTCHelloWindow))
#define WINTC_HELLO_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_WINTC_HELLO_WINDOW, WinTCHelloWindowClass))
#define IS_WINTC_HELLO_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_WINTC_HELLO_WINDOW))
#define IS_WINTC_HELLO_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_WINTC_HELLO_WINDOW))
#define WINTC_HELLO_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_WINTC_HELLO_WINDOW, WinTCHelloWindowClass))
GType wintc_hello_window_get_type(void) G_GNUC_CONST;
//
// PUBLIC FUNCTIONS
//
GtkWidget* wintc_hello_window_new(
WinTCHelloApplication* app
);
#endif

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Hello (WinTC Sample)
Comment=WinTC demonstration hello program.
Exec=wintc-hello
Icon=wintc-hello
Terminal=false
StartupNotify=false
Type=Application
Categories=Utility;GTK;

View File

@@ -1,7 +1,7 @@
# libwintc-msgina
This directory contains the source-code for the GINA services (logon/security/auth related functions).
# Purpose
## Purpose
This library provides services related to security. At the moment this includes the APIs for performing user logon (via LightDM), and contains the 'classic' logon dialog.
In future this should be expanded to handle other forms of logon rather than just simple text based local auth, as well as things like the Windows Security dialog.