Fix minesweeper and scores win

This commit is contained in:
daleclack 2024-03-02 22:48:54 +08:00
parent fa91808af2
commit 4fff43b76a
4 changed files with 17 additions and 2 deletions

View File

@ -53,6 +53,7 @@ set(RESOURCE_LIST
final_approach.png
style.css
style_dark.css
mine_app.css
folder.svg
folder-images.svg
image_file.svg

View File

@ -0,0 +1,3 @@
.mine_app grid{
background-color:#888a85;
}

View File

@ -36,6 +36,9 @@ struct _MineSweeper
// InputBox for game win
InputBox *input_box;
// Theme for Mine Cells
GtkCssProvider *provider;
};
G_DEFINE_TYPE(MineSweeper, mine_sweeper, GTK_TYPE_APPLICATION_WINDOW)
@ -365,6 +368,14 @@ static void mine_sweeper_init(MineSweeper *self)
g_signal_connect(self->btn_show, "clicked", G_CALLBACK(btnshow_clicked), self);
g_signal_connect_swapped(self->btn_exit, "clicked", G_CALLBACK(gtk_window_close), self);
// Add css theme for Mine Cells
self->provider = gtk_css_provider_new();
gtk_css_provider_load_from_resource(self->provider, "/org/gtk/daleclack/mine_app.css");
gtk_widget_add_css_class(self->main_box, "mine_app");
gtk_style_context_add_provider_for_display(gtk_widget_get_display(self->main_box),
GTK_STYLE_PROVIDER(self->provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
// Create mine cells
mine_sweeper_cells_init(self, 7, 7);
gtk_widget_set_halign(self->time_label, GTK_ALIGN_CENTER);

View File

@ -13,7 +13,7 @@ struct _ScoresWin
// List widgets
GtkWidget *list_view;
GtkSingleSelection *selection;
GtkNoSelection *selection;
GtkListItemFactory *factory_name, *factory_time;
GtkColumnViewColumn *column_name, *column_time;
GListStore *store;
@ -118,7 +118,7 @@ static void scores_win_init(ScoresWin *self)
// Create store
self->store = g_list_store_new(scores_item_get_type());
self->selection = gtk_single_selection_new(G_LIST_MODEL(self->store));
self->selection = gtk_no_selection_new(G_LIST_MODEL(self->store));
// Create Column View
self->list_view = gtk_column_view_new(GTK_SELECTION_MODEL(self->selection));