mirror of
https://github.com/rozniak/xfce-winxp-tc.git
synced 2026-01-26 11:39:44 +00:00
Enhancement: Fixes #131, Implement dialog button box widget in comctl lib - use in run and winver
This commit is contained in:
77
shared/comctl/CMakeLists.txt
Normal file
77
shared/comctl/CMakeLists.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(
|
||||
libwintc-comctl
|
||||
VERSION 1.0
|
||||
DESCRIPTION "Windows Total Conversion common controls library."
|
||||
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/libraries/CMakeLists.txt)
|
||||
include(../../packaging/cmake-inc/linking/CMakeLists.txt)
|
||||
include(../../packaging/cmake-inc/packaging/CMakeLists.txt)
|
||||
include(../../packaging/cmake-inc/resources/CMakeLists.txt)
|
||||
|
||||
wintc_resolve_library(glib-2.0 GLIB)
|
||||
wintc_resolve_library(gtk+-3.0 GTK3)
|
||||
|
||||
wintc_compile_resources()
|
||||
|
||||
add_library(
|
||||
libwintc-comctl
|
||||
src/resources.c
|
||||
src/style.c
|
||||
src/style.h
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
libwintc-comctl
|
||||
PROPERTIES
|
||||
PUBLIC_HEADER public/wintc-comctl.h
|
||||
SOVERSION 1
|
||||
VERSION ${PROJECT_VERSION}
|
||||
)
|
||||
|
||||
target_compile_options(
|
||||
libwintc-comctl
|
||||
PRIVATE ${WINTC_COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
libwintc-comctl
|
||||
SYSTEM
|
||||
PRIVATE ${GLIB_INCLUDE_DIRS}
|
||||
PRIVATE ${GTK3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_directories(
|
||||
libwintc-comctl
|
||||
PRIVATE ${GLIB_LIBRARY_DIRS}
|
||||
PRIVATE ${GTK3_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
libwintc-comctl
|
||||
PRIVATE ${GLIB_LIBRARIES}
|
||||
PRIVATE ${GTK3_LIBRARIES}
|
||||
)
|
||||
|
||||
# Installation
|
||||
#
|
||||
wintc_configure_and_install_packaging()
|
||||
wintc_add_pkgconfig_install()
|
||||
|
||||
install(
|
||||
TARGETS libwintc-comctl
|
||||
LIBRARY DESTINATION ${LIB_DIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
5
shared/comctl/README.MD
Normal file
5
shared/comctl/README.MD
Normal file
@@ -0,0 +1,5 @@
|
||||
# libwintc-comctl
|
||||
This directory contains the source code for the Common Controls library.
|
||||
|
||||
## Purpose
|
||||
This library provides common GTK widgets and widget style classes for use across the WinTC project.
|
||||
2
shared/comctl/deps
Normal file
2
shared/comctl/deps
Normal file
@@ -0,0 +1,2 @@
|
||||
bt,rt:glib2
|
||||
bt,rt:gtk3
|
||||
11
shared/comctl/public/wintc-comctl.h
Normal file
11
shared/comctl/public/wintc-comctl.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef __WINTC_COMCTL_H__
|
||||
#define __WINTC_COMCTL_H__
|
||||
|
||||
//
|
||||
// Default CSS stuff
|
||||
//
|
||||
#define WINTC_COMCTL_BUTTON_BOX_CLASS "wintc-button-box"
|
||||
|
||||
void wintc_comctl_install_default_styles(void);
|
||||
|
||||
#endif
|
||||
11
shared/comctl/src/res/default.css
Normal file
11
shared/comctl/src/res/default.css
Normal file
@@ -0,0 +1,11 @@
|
||||
box.wintc-button-box
|
||||
{
|
||||
margin: 0px 8px 10px;
|
||||
}
|
||||
|
||||
box.wintc-button-box button
|
||||
{
|
||||
margin-left: 8px;
|
||||
min-height: 15px;
|
||||
min-width: 51px;
|
||||
}
|
||||
6
shared/comctl/src/res/resources.xml
Normal file
6
shared/comctl/src/res/resources.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/uk/oddmatics/wintc/comctl">
|
||||
<file>default.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
33
shared/comctl/src/style.c
Normal file
33
shared/comctl/src/style.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "style.h"
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
void wintc_comctl_install_default_styles(void)
|
||||
{
|
||||
static gboolean already_done = FALSE;
|
||||
|
||||
if (already_done)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GtkCssProvider* css_default = gtk_css_provider_new();
|
||||
|
||||
gtk_css_provider_load_from_resource(
|
||||
css_default,
|
||||
"/uk/oddmatics/wintc/comctl/default.css"
|
||||
);
|
||||
|
||||
gtk_style_context_add_provider_for_screen(
|
||||
gdk_screen_get_default(),
|
||||
GTK_STYLE_PROVIDER(css_default),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK
|
||||
);
|
||||
|
||||
already_done = TRUE;
|
||||
}
|
||||
8
shared/comctl/src/style.h
Normal file
8
shared/comctl/src/style.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __STYLE_H__
|
||||
#define __STYLE_H__
|
||||
|
||||
#define WINTC_COMCTL_BUTTON_BOX_CSS_CLASS "wintc-button-box"
|
||||
|
||||
void wintc_comctl_install_default_styles(void);
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,7 @@ include(../../packaging/cmake-inc/packaging/CMakeLists.txt)
|
||||
wintc_resolve_library(gdk-3.0 GDK)
|
||||
wintc_resolve_library(glib-2.0 GLIB)
|
||||
wintc_resolve_library(gtk+-3.0 GTK3)
|
||||
wintc_resolve_library(wintc-comctl WINTC_COMCTL)
|
||||
wintc_resolve_library(wintc-comgtk WINTC_COMGTK)
|
||||
wintc_resolve_library(wintc-exec WINTC_EXEC)
|
||||
wintc_resolve_library(wintc-shllang WINTC_SHLLANG)
|
||||
@@ -58,6 +59,7 @@ target_include_directories(
|
||||
PRIVATE ${GDK_INCLUDE_DIRS}
|
||||
PRIVATE ${GLIB_INCLUDE_DIRS}
|
||||
PRIVATE ${GTK3_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_COMCTL_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_EXEC_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_SHLLANG_INCLUDE_DIRS}
|
||||
@@ -68,6 +70,7 @@ target_link_directories(
|
||||
PRIVATE ${GDK_LIBRARY_DIRS}
|
||||
PRIVATE ${GLIB_LIBRARY_DIRS}
|
||||
PRIVATE ${GTK3_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_COMCTL_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_EXEC_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_SHLLANG_LIBRARY_DIRS}
|
||||
@@ -78,6 +81,7 @@ target_link_libraries(
|
||||
PRIVATE ${GDK_LIBRARIES}
|
||||
PRIVATE ${GLIB_LIBRARIES}
|
||||
PRIVATE ${GTK3_LIBRARIES}
|
||||
PRIVATE ${WINTC_COMCTL_LIBRARIES}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARIES}
|
||||
PRIVATE ${WINTC_EXEC_LIBRARIES}
|
||||
PRIVATE ${WINTC_SHLLANG_LIBRARIES}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# run
|
||||
This directory contains the source code for the *Run* application.
|
||||
|
||||

|
||||

|
||||
|
||||
## Keyboard Shortcut
|
||||
You can add `run` to a keyboard shortcut on `Win`+`R`/`super`+`R` as follows:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
bt,rt:glib2
|
||||
bt,rt:gtk3
|
||||
bt,rt:wintc-comctl
|
||||
bt,rt:wintc-comgtk
|
||||
bt,rt:wintc-exec
|
||||
bt,rt:wintc-shllang
|
||||
|
||||
BIN
shell/run/preview.png
Normal file
BIN
shell/run/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -1,6 +1,7 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <wintc-comctl.h>
|
||||
#include <wintc-comgtk.h>
|
||||
|
||||
#include "application.h"
|
||||
@@ -28,25 +29,6 @@ static void wintc_run_application_activate(
|
||||
GApplication* application
|
||||
);
|
||||
|
||||
static void wintc_run_application_finalize(
|
||||
GObject* object
|
||||
);
|
||||
|
||||
static void wintc_run_application_open(
|
||||
GApplication* application,
|
||||
GFile** files,
|
||||
int n_files,
|
||||
const gchar* hint
|
||||
);
|
||||
|
||||
static void wintc_run_application_startup(
|
||||
GApplication* application
|
||||
);
|
||||
|
||||
static void wintc_run_application_shutdown(
|
||||
GApplication* application
|
||||
);
|
||||
|
||||
//
|
||||
// GTK TYPE DEFINITION & CTORS
|
||||
//
|
||||
@@ -57,30 +39,14 @@ static void wintc_run_application_class_init(
|
||||
)
|
||||
{
|
||||
GApplicationClass* application_class = G_APPLICATION_CLASS(klass);
|
||||
GObjectClass* object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
application_class->activate = wintc_run_application_activate;
|
||||
application_class->open = wintc_run_application_open;
|
||||
application_class->startup = wintc_run_application_startup;
|
||||
application_class->shutdown = wintc_run_application_shutdown;
|
||||
|
||||
object_class->finalize = wintc_run_application_finalize;
|
||||
}
|
||||
|
||||
static void wintc_run_application_init(
|
||||
WINTC_UNUSED(WinTCRunApplication* self)
|
||||
) {}
|
||||
|
||||
//
|
||||
// FINALIZE
|
||||
//
|
||||
static void wintc_run_application_finalize(
|
||||
GObject* object
|
||||
)
|
||||
{
|
||||
(*G_OBJECT_CLASS(wintc_run_application_parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
@@ -109,32 +75,14 @@ static void wintc_run_application_activate(
|
||||
{
|
||||
WinTCRunApplication* run_app = WINTC_RUN_APPLICATION(application);
|
||||
|
||||
wintc_comctl_install_default_styles();
|
||||
|
||||
if (run_app->main_window == NULL)
|
||||
{
|
||||
run_app->main_window = wintc_run_dialog_new(run_app);
|
||||
|
||||
gtk_widget_show_all(run_app->main_window);
|
||||
}
|
||||
|
||||
wintc_focus_window(GTK_WINDOW(run_app->main_window));
|
||||
}
|
||||
|
||||
static void wintc_run_application_open(
|
||||
WINTC_UNUSED(GApplication* application),
|
||||
WINTC_UNUSED(GFile** files),
|
||||
WINTC_UNUSED(int n_files),
|
||||
WINTC_UNUSED(const gchar* hint)
|
||||
) {}
|
||||
|
||||
static void wintc_run_application_startup(
|
||||
GApplication* application
|
||||
)
|
||||
{
|
||||
WinTCRunApplication* run_app = WINTC_RUN_APPLICATION(application);
|
||||
|
||||
(G_APPLICATION_CLASS(wintc_run_application_parent_class))->startup(application);
|
||||
|
||||
run_app->main_window = wintc_run_dialog_new(run_app);
|
||||
|
||||
gtk_widget_show_all(run_app->main_window);
|
||||
}
|
||||
|
||||
static void wintc_run_application_shutdown(
|
||||
GApplication* application
|
||||
)
|
||||
{
|
||||
(G_APPLICATION_CLASS(wintc_run_application_parent_class))->shutdown(application);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <wintc-comctl.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-exec.h>
|
||||
#include <wintc-shllang.h>
|
||||
@@ -217,6 +218,11 @@ static void wintc_run_dialog_init(
|
||||
gtk_box_pack_end(GTK_BOX(box_buttons), button_ok, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box_outer), box_buttons, FALSE, FALSE, 0);
|
||||
|
||||
wintc_widget_add_style_class(
|
||||
box_buttons,
|
||||
WINTC_COMCTL_BUTTON_BOX_CLASS
|
||||
);
|
||||
|
||||
// Set OK button as default widget
|
||||
//
|
||||
gtk_window_set_default(GTK_WINDOW(self), button_ok);
|
||||
@@ -225,6 +231,7 @@ static void wintc_run_dialog_init(
|
||||
//
|
||||
// FIXME: This should not be done here, use screen CSS instead!
|
||||
//
|
||||
wintc_widget_add_css(box_buttons, "box { margin: 0px; }");
|
||||
wintc_widget_add_css(box_outer, "box { margin: 18px 11px 0px; }");
|
||||
wintc_widget_add_css(box_instructions, "box { margin-bottom: 13px; }");
|
||||
wintc_widget_add_css(box_input, "box { margin-bottom: 34px; }");
|
||||
|
||||
@@ -22,6 +22,7 @@ include(../../packaging/cmake-inc/packaging/CMakeLists.txt)
|
||||
wintc_resolve_library(gdk-pixbuf-2.0 GDK_PIXBUF)
|
||||
wintc_resolve_library(glib-2.0 GLIB)
|
||||
wintc_resolve_library(gtk+-3.0 GTK3)
|
||||
wintc_resolve_library(wintc-comctl WINTC_COMCTL)
|
||||
wintc_resolve_library(wintc-comgtk WINTC_COMGTK)
|
||||
wintc_resolve_library(wintc-winbrand WINTC_WINBRAND)
|
||||
|
||||
@@ -47,6 +48,7 @@ target_include_directories(
|
||||
PRIVATE ${GDK_PIXBUF_INCLUDE_DIRS}
|
||||
PRIVATE ${GLIB_INCLUDE_DIRS}
|
||||
PRIVATE ${GTK3_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_COMCTL_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_INCLUDE_DIRS}
|
||||
PRIVATE ${WINTC_WINBRAND_INCLUDE_DIRS}
|
||||
)
|
||||
@@ -56,6 +58,7 @@ target_link_directories(
|
||||
PRIVATE ${GDK_PIXBUF_LIBRARY_DIRS}
|
||||
PRIVATE ${GLIB_LIBRARY_DIRS}
|
||||
PRIVATE ${GTK3_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_COMCTL_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARY_DIRS}
|
||||
PRIVATE ${WINTC_WINBRAND_LIBRARY_DIRS}
|
||||
)
|
||||
@@ -65,6 +68,7 @@ target_link_libraries(
|
||||
PRIVATE ${GDK_PIXBUF_LIBRARIES}
|
||||
PRIVATE ${GLIB_LIBRARIES}
|
||||
PRIVATE ${GTK3_LIBRARIES}
|
||||
PRIVATE ${WINTC_COMCTL_LIBRARIES}
|
||||
PRIVATE ${WINTC_COMGTK_LIBRARIES}
|
||||
PRIVATE ${WINTC_WINBRAND_LIBRARIES}
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
bt,rt:gdk-pixbuf2
|
||||
bt,rt:glib2
|
||||
bt,rt:gtk3
|
||||
bt,rt:wintc-comctl
|
||||
bt,rt:wintc-comgtk
|
||||
bt,rt:wintc-winbrand
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <wintc-comctl.h>
|
||||
#include <wintc-comgtk.h>
|
||||
#include <wintc-winbrand.h>
|
||||
|
||||
@@ -60,6 +61,8 @@ int main(
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
wintc_comctl_install_default_styles();
|
||||
|
||||
// Create the window
|
||||
//
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
@@ -160,11 +163,6 @@ int main(
|
||||
//
|
||||
button_ok = gtk_button_new_with_label("OK");
|
||||
|
||||
apply_box_model_style(button_ok, "margin", "right", 8);
|
||||
apply_box_model_style(button_ok, "margin", "bottom", 10);
|
||||
apply_box_model_style(button_ok, "padding", "left", 26);
|
||||
apply_box_model_style(button_ok, "padding", "right", 26);
|
||||
|
||||
g_signal_connect(
|
||||
button_ok,
|
||||
"clicked",
|
||||
@@ -191,6 +189,11 @@ int main(
|
||||
|
||||
gtk_box_pack_end(GTK_BOX(box), box_buttons, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end(GTK_BOX(box_buttons), button_ok, FALSE, FALSE, 0);
|
||||
|
||||
wintc_widget_add_style_class(
|
||||
box_buttons,
|
||||
WINTC_COMCTL_BUTTON_BOX_CLASS
|
||||
);
|
||||
|
||||
// Clear mem
|
||||
//
|
||||
|
||||
@@ -7,6 +7,7 @@ msgfmt-->bt,rt-->gettext
|
||||
plymouth-->bt,rt-->plymouth
|
||||
python3-venv-->bt,rt-->python3
|
||||
sass-->bt,rt-->ruby-sass
|
||||
wintc-comctl-->bt,rt-->wintc-comctl
|
||||
wintc-comgtk-->bt,rt-->wintc-comgtk
|
||||
wintc-exec-->bt,rt-->wintc-exec
|
||||
wintc-shelldpa-->bt,rt-->wintc-shelldpa
|
||||
|
||||
@@ -12,6 +12,7 @@ msgfmt-->bt,rt-->gettext
|
||||
plymouth-->bt,rt-->plymouth
|
||||
python3-venv-->bt,rt-->python3-venv
|
||||
sass-->bt,rt-->ruby-sass
|
||||
wintc-comctl-->bt,rt-->libwintc-comctl
|
||||
wintc-comgtk-->bt,rt-->libwintc-comgtk
|
||||
wintc-exec-->bt,rt-->libwintc-exec
|
||||
wintc-shelldpa-->bt,rt-->libwintc-shelldpa
|
||||
|
||||
Reference in New Issue
Block a user