mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-09-06 22:01:27 +00:00
frontend: Populate bulk of the UI
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
+113
-1
@@ -38,6 +38,12 @@ struct _LsiSettingsWindowClass {
|
||||
|
||||
G_DEFINE_TYPE(LsiSettingsWindow, lsi_settings_window, GTK_TYPE_WINDOW)
|
||||
|
||||
static void _align_label(GtkWidget *label);
|
||||
static void insert_grid(GtkWidget *grid, int *row, const char *title, const char *description,
|
||||
GtkWidget *widget);
|
||||
static GtkWidget *insert_grid_toggle(GtkWidget *grid, int *row, const char *title,
|
||||
const char *description);
|
||||
|
||||
/**
|
||||
* lsi_settings_window_new:
|
||||
*
|
||||
@@ -78,6 +84,10 @@ static void lsi_settings_window_class_init(LsiSettingsWindowClass *klazz)
|
||||
*/
|
||||
static void lsi_settings_window_init(LsiSettingsWindow *self)
|
||||
{
|
||||
GtkWidget *grid = NULL;
|
||||
GtkWidget *layout = NULL;
|
||||
int row = 0;
|
||||
|
||||
/* Ensure we correctly clean this up.. */
|
||||
memset(&self->config, 0, sizeof(LsiConfig));
|
||||
|
||||
@@ -94,9 +104,111 @@ static void lsi_settings_window_init(LsiSettingsWindow *self)
|
||||
gtk_window_set_icon_name(GTK_WINDOW(self), "steam");
|
||||
gtk_window_set_position(GTK_WINDOW(self), GTK_WIN_POS_CENTER);
|
||||
|
||||
/* TODO: Just about anything */
|
||||
/* Add main layout */
|
||||
layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add(GTK_CONTAINER(self), layout);
|
||||
|
||||
/* Start populating main grid with controls */
|
||||
grid = gtk_grid_new();
|
||||
gtk_box_pack_start(GTK_BOX(layout), grid, TRUE, TRUE, 0);
|
||||
|
||||
/* Start populating options into the UI */
|
||||
self->check_native = insert_grid_toggle(
|
||||
grid,
|
||||
&row,
|
||||
"Use native runtime",
|
||||
"Alternatively, the default Steam® runtime will be used, which may cause issues");
|
||||
self->check_emul32 = insert_grid_toggle(
|
||||
grid,
|
||||
&row,
|
||||
"Force 32-bit mode for Steam®",
|
||||
"This may workaround some broken games, but will in turn stop the Steam store working");
|
||||
|
||||
#ifdef HAVE_LIBINTERCEPT
|
||||
self->check_intercept =
|
||||
insert_grid_toggle(grid,
|
||||
&row,
|
||||
"Use the intercept library",
|
||||
"Override how library files are loaded to maximise "
|
||||
"compatibility, this option is recommended");
|
||||
#endif
|
||||
|
||||
/* Finally, make sure we're visible will we. */
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
}
|
||||
|
||||
static void _align_label(GtkWidget *label)
|
||||
{
|
||||
#if GTK_MINOR_VERSION <= 12
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
|
||||
#else
|
||||
gtk_widget_set_halign(label, GTK_ALIGN_START);
|
||||
#endif
|
||||
gtk_widget_set_hexpand(label, FALSE);
|
||||
gtk_widget_set_valign(label, GTK_ALIGN_START);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function to add titled description box with a custom widget into the grid.
|
||||
*/
|
||||
static void insert_grid(GtkWidget *grid, int *row, const char *title, const char *description,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *label = NULL;
|
||||
GtkWidget *desc = NULL;
|
||||
GtkStyleContext *style = NULL;
|
||||
|
||||
/* Sort out title label */
|
||||
label = gtk_label_new(title);
|
||||
_align_label(label);
|
||||
g_object_set(label, "margin-top", 12, "hexpand", TRUE, NULL);
|
||||
gtk_grid_attach(GTK_GRID(grid), label, 0, *row, 1, 1);
|
||||
|
||||
g_object_set(widget,
|
||||
"halign",
|
||||
GTK_ALIGN_END,
|
||||
"valign",
|
||||
GTK_ALIGN_END,
|
||||
"vexpand",
|
||||
FALSE,
|
||||
NULL);
|
||||
gtk_grid_attach(GTK_GRID(grid), widget, 1, *row, 1, 1);
|
||||
|
||||
*row += 1;
|
||||
|
||||
/* Sort out description label */
|
||||
desc = gtk_label_new(description);
|
||||
_align_label(desc);
|
||||
style = gtk_widget_get_style_context(desc);
|
||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_DIM_LABEL);
|
||||
#if GTK_MINOR_VERSION <= 12
|
||||
gtk_widget_set_margin_right(desc, 12);
|
||||
#else
|
||||
gtk_widget_set_margin_end(desc, 12);
|
||||
#endif
|
||||
/* Deprecated but line wrap is busted without it.. */
|
||||
g_object_set(desc, "xalign", 0.0, NULL);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(desc), TRUE);
|
||||
gtk_label_set_line_wrap_mode(GTK_LABEL(desc), PANGO_WRAP_WORD);
|
||||
|
||||
gtk_grid_attach(GTK_GRID(grid), desc, 0, *row, 1, 1);
|
||||
*row += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds on the insert_grid function to insert a GtkSwitch and return only the
|
||||
* switch widget.
|
||||
*/
|
||||
static GtkWidget *insert_grid_toggle(GtkWidget *grid, int *row, const char *title,
|
||||
const char *description)
|
||||
{
|
||||
GtkWidget *toggle = NULL;
|
||||
|
||||
/* Sort out widget */
|
||||
toggle = gtk_switch_new();
|
||||
insert_grid(grid, row, title, description, toggle);
|
||||
return toggle;
|
||||
}
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user