Skip to content

Instantly share code, notes, and snippets.

View angstyloop's full-sized avatar

Sean Allen angstyloop

View GitHub Profile
@angstyloop
angstyloop / tooltip.c
Created March 30, 2023 06:56
GTK4 tooltip example
/** tooltip.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o tooltip tooltip.c `pkg-config --libs gtk4`
*
* RUN
*
* ./tooltip
*/
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object id="window" class="GtkWindow">
<property name="title">Grid</property>
<child>
<object id="grid" class="GtkGrid">
<child>
<object id="button1" class="GtkButton">
<property name="label">Button1</property>
<layout>
/** example-3.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o example-3 example-3.c `pkg-config --libs gtk4`
*
* EXAMPLE
*
* ./example-3
*
/** example-2.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o example-2 example-2.c `pkg-config --libs gtk4`
*
* EXAMPLE
*
* ./example-2
*
/** example-1.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o example-1 example-1.c `pkg-config --libs gtk4`
*
* EXAMPLE
*
* ./example-1
*
/** example-0.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o example-0 example-0.c `pkg-config --libs gtk4`
*
* EXAMPLE
*
* ./example-0
*
@angstyloop
angstyloop / import_file.c
Created March 7, 2023 09:41
Select a file using a GTK file chooser, and copy it into /tmp (Unix only) using copy_file_range.
/** import_file.c
*
* Import a file to be used by threshold.c and friends.
*
* COMPILE
* gcc -Wall -o import_file import_file.c `pkg-config gtk+-3.0 --libs --cflags`
*
* EXAMPLE
* ./import_file source.png
*/
@angstyloop
angstyloop / copy.c
Created March 7, 2023 08:19
Copy a file using copy_file_range
/* copy.c
*
* Compile with:
*
* gcc copy.c -o copy -Wall -g
*
* Defines function copy:
*
* Copy a source file to a destination file. If the destination file already
* exists, this clobbers it. If the destination file does not exist, it is
@angstyloop
angstyloop / file_chooser_dialog.c
Created March 7, 2023 06:22
Open a file chooser with GTK 3.
/** file_chooser_dialog.c
*
* Open a file chooser with GTK 3.
*
* COMPILE
* gcc -Wall -o file_chooser_dialog file_chooser_dialog.c `pkg-config gtk+-3.0 --libs --cflags`
*
* EXAMPLE
* ./file_chooser_dialog
*/
@angstyloop
angstyloop / file_chooser_native.c
Created March 7, 2023 06:21
Open a native file chooser with GTK 3 if one is available.
/** file_chooser_native.c
*
* Open a native file chooser with GTK 3 if one is available.
*
* COMPILE
* gcc -Wall -o file_chooser_native file_chooser_native.c `pkg-config gtk+-3.0 --libs --cflags`
*
* EXAMPLE
* ./file_chooser_native
*/