-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yihuajack/main
Complete GtkDialog, GtkGrid, and XML UI for settings
- Loading branch information
Showing
7 changed files
with
224 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,2 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
.vscode | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
# stone_game_gtk4 | ||
|
||
Two players take stones from the stone heap in turns. | ||
Two players take stones from the stone heap in turns. | ||
The one who takes the last stone loses the game. | ||
|
||
### Compile and Run | ||
in msys2 mingw: | ||
install gtk4 | ||
run | ||
./make.sh | ||
./main.exe | ||
### Usage | ||
|
||
#### Windows MSYS2 MinGW-w64 | ||
|
||
[The GTK Project - A free and open-source cross-platform widget toolkit](https://www.gtk.org/docs/installations/windows/) | ||
|
||
- Install GTK4 | ||
|
||
```bash | ||
pacman -S mingw-w64-x86_64-gtk4 | ||
pacman -S mingw-w64-x86_64-python3-gobject | ||
``` | ||
|
||
- Compile by command | ||
|
||
```bash | ||
gcc `pkg-config --cflags gtk4` main_window.c -o main `pkg-config --libs gtk4` | ||
``` | ||
|
||
### Known Issue | ||
|
||
The given `settings.glade` is the XML UI file generated by Glade 3. However, `glade` does NOT support GTK 4, so is not applicable. Instead, use manually-written `settings.ui` for GTK Builder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
gcc `pkg-config --cflags gtk4` main_window.c player.c -o main `pkg-config --libs gtk4` | ||
gcc `pkg-config --cflags gtk4` main_window.c player.c -o main `pkg-config --libs gtk4` | ||
# https://stackoverflow.com/questions/26884574/questions-about-gcc-unrecognized-option-rdynamic | ||
# Use `-export-dynamic` instead of `-rdynamic` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Generated with glade 3.38.2 --> | ||
<interface> | ||
<requires lib="gtk+" version="3.24"/> | ||
<object class="GtkDialog" id="dialog"> | ||
<property name="name">dialog</property> | ||
<property name="can-focus">False</property> | ||
<property name="title" translatable="yes">设置 Settings</property> | ||
<property name="resizable">False</property> | ||
<property name="default-width">800</property> | ||
<property name="default-height">-1</property> | ||
<property name="type-hint">normal</property> | ||
<child internal-child="vbox"> | ||
<object class="GtkBox"> | ||
<property name="can-focus">False</property> | ||
<property name="orientation">vertical</property> | ||
<property name="spacing">2</property> | ||
<child internal-child="action_area"> | ||
<object class="GtkButtonBox"> | ||
<property name="can-focus">False</property> | ||
<property name="layout-style">end</property> | ||
<child> | ||
<object class="GtkButton" id="clear_button"> | ||
<property name="label" translatable="yes">清空</property> | ||
<property name="name">clear_button</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="receives-default">True</property> | ||
</object> | ||
<packing> | ||
<property name="expand">True</property> | ||
<property name="fill">True</property> | ||
<property name="position">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkButton" id="confirm_button"> | ||
<property name="label" translatable="yes">确认</property> | ||
<property name="name">confirm_button</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
<property name="receives-default">True</property> | ||
</object> | ||
<packing> | ||
<property name="expand">True</property> | ||
<property name="fill">True</property> | ||
<property name="position">1</property> | ||
</packing> | ||
</child> | ||
</object> | ||
<packing> | ||
<property name="expand">False</property> | ||
<property name="fill">False</property> | ||
<property name="position">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<!-- n-columns=2 n-rows=1 --> | ||
<object class="GtkGrid" id="grid"> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="halign">center</property> | ||
<property name="valign">center</property> | ||
<property name="margin-start">50</property> | ||
<property name="margin-end">50</property> | ||
<property name="row-spacing">50</property> | ||
<property name="column-spacing">50</property> | ||
<child> | ||
<object class="GtkLabel" id="number_label"> | ||
<property name="name">number_label</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">False</property> | ||
<property name="label" translatable="yes">请输入个数:</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">0</property> | ||
<property name="top-attach">0</property> | ||
</packing> | ||
</child> | ||
<child> | ||
<object class="GtkEntry" id="number_entry"> | ||
<property name="name">number_entry</property> | ||
<property name="visible">True</property> | ||
<property name="can-focus">True</property> | ||
</object> | ||
<packing> | ||
<property name="left-attach">1</property> | ||
<property name="top-attach">0</property> | ||
</packing> | ||
</child> | ||
</object> | ||
<packing> | ||
<property name="expand">False</property> | ||
<property name="fill">True</property> | ||
<property name="padding">100</property> | ||
<property name="position">1</property> | ||
</packing> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<interface> | ||
<object class="GtkDialog" id="dialog_settings"> | ||
<property name="title" translatable="yes">STONE_GAME_SETTING 设置</property> | ||
<property name="resizable">1</property> | ||
<property name="modal">1</property> | ||
<child internal-child="content_area"> | ||
<object class="GtkBox" id="content_area"> | ||
<child> | ||
<object class="GtkGrid" id="grid"> | ||
<property name="margin-start">12</property> | ||
<property name="margin-end">12</property> | ||
<property name="margin-top">12</property> | ||
<property name="margin-bottom">12</property> | ||
<property name="row-spacing">12</property> | ||
<property name="column-spacing">12</property> | ||
<child> | ||
<object class="GtkLabel" id="number_label"> | ||
<property name="label">请输入个数:</property> | ||
<property name="xalign">1</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="row">0</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkEntry" id="number_entry"> | ||
<layout> | ||
<property name="column">1</property> | ||
<property name="row">0</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkSeparator" id="midsep"> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="row">1</property> | ||
<property name="column-span">2</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkButton" id="clear_button"> | ||
<property name="label">清空</property> | ||
<layout> | ||
<property name="column">0</property> | ||
<property name="row">2</property> | ||
</layout> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkButton" id="confirm_button"> | ||
<property name="label">确认</property> | ||
<layout> | ||
<property name="column">1</property> | ||
<property name="row">2</property> | ||
</layout> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</interface> |