Skip to content

Commit

Permalink
Gtk3: ROM settings: use theme background for around widgets and in un…
Browse files Browse the repository at this point in the history
…used space

To avoid large white (light theme) or black (dark theme) areas we use CSS to
set the background color for the GtkListBoxes to the special `@theme_bg_color`
color.


git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@44968 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
Compyx committed Feb 5, 2024
1 parent 58f8f1c commit 55917b7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion vice/src/arch/gtk3/widgets/settings_rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@
#include "settings_rom.h"


/** \brief CSS for the GtkListBoxes used for the ROMs
*
* We use the theme background color to avoid ugly white (light theme) or
* black areas (dark theme) areas around the widgets and in the unused space
* of the GtkScrolledWindow.
*/
#define LISTBOX_CSS "list { background-color: @theme_bg_color; }"


/** \brief Array length helper
*
* \param[in] arr array
Expand Down Expand Up @@ -267,6 +276,9 @@ static gchar *last_directory;
/** \brief Last filename used in a ROM set file dialog */
static gchar *last_filename;

/** \brief CSS provided used for the GtkListBox widgets */
static GtkCssProvider *listbox_css_provider;


/* {{{ Event handlers */
/** \brief Callback for the ROM set open dialog
Expand Down Expand Up @@ -587,6 +599,8 @@ static GtkWidget *expandable_list_new(const char *title)
expander = gtk_expander_new(title);
list = gtk_list_box_new();

vice_gtk3_css_provider_add(list, listbox_css_provider);

gtk_container_add(GTK_CONTAINER(expander), list);
gtk_container_add(GTK_CONTAINER(listrow), expander);
return listrow;
Expand Down Expand Up @@ -790,12 +804,17 @@ GtkWidget *settings_rom_widget_create(GtkWidget *parent)
size_t i;
int row = 0;

listbox_css_provider = vice_gtk3_css_provider_new(LISTBOX_CSS);

grid = gtk_grid_new();
gtk_grid_set_column_spacing(GTK_GRID(grid), 16);
gtk_grid_set_row_spacing(GTK_GRID(grid), 8);

root_list = gtk_list_box_new();
gtk_widget_set_vexpand(root_list, TRUE);
scrolled = gtk_scrolled_window_new(NULL, NULL);
vice_gtk3_css_provider_add(root_list, listbox_css_provider);

if (machine_class == VICE_MACHINE_PET) {
/* We add a check button and buttons to load a chargen to xpet, so the
* scrolled window must be slightly less tall */
Expand Down Expand Up @@ -919,5 +938,7 @@ void settings_rom_widget_shutdown(void)
g_free(last_directory);
g_free(last_filename);
last_directory = NULL;
last_filename = NULL;
last_filename = NULL;
g_object_unref(listbox_css_provider);
listbox_css_provider = NULL;
}

0 comments on commit 55917b7

Please sign in to comment.