Enhancement: Fixes #498, wizard97 - initial implementation

This commit is contained in:
Rory Fewell
2026-01-22 19:56:28 +00:00
parent d2edd38e30
commit bb0ac39919
49 changed files with 2810 additions and 10 deletions

View File

@@ -70,6 +70,8 @@ add_library(
public/msgbox.h
src/profile.c
public/profile.h
src/radio.c
public/radio.h
src/regex.c
public/regex.h
public/shorthand.h

View File

@@ -13,9 +13,11 @@
* Destroys all child widgets of a container.
*
* @param container The container.
* @param destroy True to destroy, rather than just remove, the children.
*/
void wintc_container_clear(
GtkContainer* container
GtkContainer* container,
gboolean destroy
);
/**

View File

@@ -21,6 +21,7 @@
#include "@LIB_HEADER_DIR@/menu.h"
#include "@LIB_HEADER_DIR@/msgbox.h"
#include "@LIB_HEADER_DIR@/profile.h"
#include "@LIB_HEADER_DIR@/radio.h"
#include "@LIB_HEADER_DIR@/regex.h"
#include "@LIB_HEADER_DIR@/shorthand.h"
#include "@LIB_HEADER_DIR@/signals.h"

View File

@@ -0,0 +1,19 @@
#ifndef __COMGTK_RADIO_H__
#define __COMGTK_RADIO_H__
#include <gtk/gtk.h>
//
// PUBLIC FUNCTIONS
//
/**
* Retrieve the index of the active selection in a radio button group.
*
* @param group The radio button group.
*/
guint wintc_radio_group_get_selection(
GSList* group
);
#endif

View File

@@ -7,17 +7,29 @@
// PUBLIC FUNCTIONS
//
void wintc_container_clear(
GtkContainer* container
GtkContainer* container,
gboolean destroy
)
{
GList* children = gtk_container_get_children(container);
GList* iter = children;
while (iter)
if (destroy)
{
gtk_widget_destroy(GTK_WIDGET(iter->data));
iter = iter->next;
for (; iter; iter = iter->next)
{
gtk_widget_destroy(GTK_WIDGET(iter->data));
}
}
else
{
for (; iter; iter = iter->next)
{
gtk_container_remove(
container,
GTK_WIDGET(iter->data)
);
}
}
g_list_free(children);

31
shared/comgtk/src/radio.c Normal file
View File

@@ -0,0 +1,31 @@
#include <glib.h>
#include <gtk/gtk.h>
#include "../public/radio.h"
//
// PUBLIC FUNCTIONS
//
guint wintc_radio_group_get_selection(
GSList* group
)
{
GSList* iter = group;
for (guint i = 0; iter; iter = iter->next, i++)
{
if (
gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(iter->data)
)
)
{
// From GtkBuilder, it's in reverse
//
return g_slist_length(group) - i - 1;
}
}
g_critical("%s", "comgtk: no radio in group was active");
return 0;
}