Skip to content

Commit

Permalink
static gtk: Add failing glade example.
Browse files Browse the repository at this point in the history
See #50 (comment)

It currently fails with:

    (demo-glade:8872): GModule-CRITICAL **: 22:19:02.953: g_module_symbol: assertion 'module != NULL' failed

    (demo-glade:8872): GModule-CRITICAL **: 22:19:02.986: g_module_close: assertion 'module != NULL' failed
    Dynamic loading not supported
    Failed to load module: /nix/store/88gpkpcfjbgihn3fl8b8vk5ggfs8wn73-dconf-0.36.0-lib/lib/gio/modules/libdconfsettings.so
    Dynamic loading not supported
    Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiolibproxy.so
    Dynamic loading not supported
    Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiognutls.so
    Dynamic loading not supported
    Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiognomeproxy.so
    Dynamic loading not supported
    Failed to load module: /nix/store/bkjpypri81svkgq5rdfd4mdn33ic1pja-gvfs-1.44.1/lib/gio/modules/libgioremote-volume-monitor.so
    Dynamic loading not supported
    Failed to load module: /nix/store/bkjpypri81svkgq5rdfd4mdn33ic1pja-gvfs-1.44.1/lib/gio/modules/libgvfsdbus.so

    (demo-glade:8872): GModule-CRITICAL **: 22:19:03.183: g_module_symbol: assertion 'module != NULL' failed

    (demo-glade:8872): Gtk-ERROR **: 22:19:03.186: gtk_builder_connect_signals() requires working GModule
  • Loading branch information
nh2 committed Nov 23, 2020
1 parent 19a1b4a commit 27511ee
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
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>
2 changes: 2 additions & 0 deletions meson-tutorial-gtk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ 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')

0 comments on commit 27511ee

Please sign in to comment.