-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
static gtk: Add failing glade example.
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
Showing
3 changed files
with
117 additions
and
0 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 |
---|---|---|
@@ -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; | ||
} |
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,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> |
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