Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions meson-tutorial-gtk/glade-example-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <gtk/gtk.h>

// Roughly following https://prognotes.net/2016/03/gtk-3-c-code-hello-world-tutorial-using-glade-3/

GtkWidget *g_label_hello;
GtkWidget *g_button_count;

void on_button_hello_clicked()
{
static unsigned int count = 0;
char str_count[30] = {0};

count++;
snprintf(str_count, 30, "%d", count);
gtk_label_set_text(GTK_LABEL(g_label_hello), str_count);
}

// called when window is closed
void on_window_main_destroy()
{
gtk_main_quit();
}

int main(int argc, char **argv)
{
GtkBuilder *builder;
GtkWidget *window;

gtk_init(&argc, &argv);

builder = gtk_builder_new();
GError *error = NULL;
if (0 == gtk_builder_add_from_file(builder, "glade-example.glade", &error))
{
g_printerr("Error loading file: %s\n", error->message);
g_clear_error(&error);
return 1;
}

window = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));
gtk_builder_connect_signals(builder, NULL);

// get pointers to the two labels
g_label_hello = GTK_WIDGET(gtk_builder_get_object(builder, "label_hello"));

g_object_unref(builder);

gtk_widget_show(window);
gtk_main();

return 0;
}
63 changes: 63 additions & 0 deletions meson-tutorial-gtk/glade-example.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkWindow">
<property name="name">window_main</property>
<property name="can_focus">False</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="button_hello">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_button_hello_clicked" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_hello">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>
22 changes: 22 additions & 0 deletions meson-tutorial-gtk/gtkmain.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <gtk/gtk.h>

void button_event(GtkWidget *widget, gpointer *data) {
g_print("Button clicked\n");
gtk_button_set_label(GTK_BUTTON(widget), "It worked!");
}

int main(int argc, char **argv) {
GtkWidget *win;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win), "Hello there");
g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *button = gtk_button_new_with_mnemonic("_Click me!");
gtk_widget_show(button);
g_signal_connect(button, "pressed", G_CALLBACK(button_event), NULL);
gtk_container_add(GTK_CONTAINER(win), button);

gtk_widget_show(win);
gtk_main();
}
6 changes: 6 additions & 0 deletions meson-tutorial-gtk/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main(int argc, char **argv) {
printf("Hello there.\n");
return 0;
}
11 changes: 11 additions & 0 deletions meson-tutorial-gtk/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project('tutorial', 'c')
# project('tutorial', 'c', default_options: ['c_link_args=-static'])

# executable('demo', 'main.c')
executable('demo', 'main.c', link_args: '-static', install: true)

gtkdep = dependency('gtk+-3.0', static: true)

executable('demo-gtk', 'gtkmain.c', dependencies: gtkdep, install: true, link_args: '-static')

executable('demo-glade', 'glade-example-main.c', dependencies: gtkdep, install: true, link_args: '-static')
2 changes: 1 addition & 1 deletion nixpkgs
Submodule nixpkgs updated 36 files
+1 −1 pkgs/applications/misc/xterm/default.nix
+7 −0 pkgs/desktops/gnome-3/core/dconf/default.nix
+12 −2 pkgs/development/libraries/SDL2/default.nix
+13 −0 pkgs/development/libraries/at-spi2-atk/default.nix
+9 −0 pkgs/development/libraries/epoxy/default.nix
+1 −1 pkgs/development/libraries/gamin/default.nix
+12 −0 pkgs/development/libraries/gtk/3.x.nix
+5 −0 pkgs/development/libraries/harfbuzz/default.nix
+5 −1 pkgs/development/libraries/libblockdev/default.nix
+7 −1 pkgs/development/libraries/libcdio/default.nix
+3 −3 pkgs/development/libraries/libexecinfo/default.nix
+6 −1 pkgs/development/libraries/libgudev/default.nix
+2 −2 pkgs/development/libraries/libjpeg-turbo/default.nix
+4 −2 pkgs/development/libraries/libndctl/default.nix
+63 −16 pkgs/development/libraries/mesa/default.nix
+42 −4 pkgs/development/libraries/silgraphite/graphite2.nix
+6 −0 pkgs/development/libraries/wayland/default.nix
+2 −10 pkgs/development/tools/build-managers/meson/default.nix
+0 −22 pkgs/development/tools/build-managers/meson/fix-objc-linking.patch
+30 −17 pkgs/development/tools/build-managers/meson/fix-rpath.patch
+3 −3 pkgs/development/tools/build-managers/meson/gir-fallback-path.patch
+2 −2 pkgs/os-specific/linux/apparmor/default.nix
+7 −0 pkgs/os-specific/linux/fuse/common.nix
+8 −2 pkgs/os-specific/linux/libatasmart/default.nix
+17 −7 pkgs/os-specific/linux/lvm2/default.nix
+2 −2 pkgs/os-specific/linux/musl/default.nix
+2 −2 pkgs/os-specific/linux/pam/default.nix
+1 −1 pkgs/os-specific/linux/powertop/default.nix
+7 −4 pkgs/os-specific/linux/udisks/2-default.nix
+9 −4 pkgs/os-specific/linux/util-linux/default.nix
+1 −1 pkgs/servers/monitoring/net-snmp/default.nix
+31 −5 pkgs/servers/samba/4.x.nix
+1 −1 pkgs/shells/tcsh/default.nix
+1 −1 pkgs/tools/misc/figlet/default.nix
+1 −1 pkgs/tools/networking/vde2/default.nix
+13 −5 pkgs/tools/security/pcsclite/default.nix
2 changes: 1 addition & 1 deletion nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if builtins.getEnv "STATIC_HASKELL_NIX_CI_NIXPKGS_UNSTABLE_BUILD" == "1"
if builtins.pathExists ./nixpkgs/pkgs
then import ./nixpkgs {}
# Pinned nixpkgs version; should be kept up-to-date with our submodule.
else import (fetchTarball https://github.com/nh2/nixpkgs/archive/5e6603fbba334804beaad21c9859a7a4347c1242.tar.gz) {}
else import (fetchTarball https://github.com/nh2/nixpkgs/archive/11aa987ea5b5a593c9ca7a38b391804959f905e5.tar.gz) {}
Loading