GLeaker

GLeaker Commit Details

Date:2013-04-10 13:45:05 (7 years 2 months ago)
Author:Nicola Fontana
Branch:master
Commit:eed9679a3f24db20ce3345ef7ac7a974f0ae751c
Parents: 45339ddd683a20ab1f8c52485d8d3be47cb6001d
Message:Added GtkBuilder loading

Changes:
Msrc/gleaker.c (2 diffs)

File differences

src/gleaker.c
4343
4444
4545
46
46
4747
4848
4949
......
5454
5555
5656
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
57113
58114
59115
60116
117
118
119
120
61121
62122
63123
124
125
126
127
128
129
130
131
132
133
134
135
64136
65137
gtk_init_with_args(p_argc, p_argv,
_("- An application for handling leak detection systems"),
entries, PACKAGE_NAME, &error);
entries, GETTEXT_PACKAGE, &error);
if (error != NULL) {
g_critical("%s", error->message);
return TRUE;
}
static GtkBuilder *
get_builder(const gchar *filename)
{
GtkBuilder *builder;
GError *error;
gchar *path;
error = NULL;
builder = gtk_builder_new();
path = g_strdup(filename);
gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);
gtk_builder_add_from_file(builder, path, &error);
g_free(path);
if (error != NULL) {
g_critical("%s", error->message);
g_error_free(error);
g_object_unref(builder);
return NULL;
}
return builder;
}
static GtkWidget *
get_widget(GtkBuilder *builder, const gchar *name)
{
GObject *object;
g_return_val_if_fail(GTK_IS_BUILDER(builder), NULL);
g_return_val_if_fail(name != NULL, NULL);
object = gtk_builder_get_object(builder, "wndMain");
if (object == NULL) {
g_critical(_("Widget '%s' not found in gleaker.ui"), name);
return NULL;
}
return GTK_WIDGET(object);
}
static GtkWidget *
get_main_window(GtkBuilder *builder)
{
GtkWidget *window;
window = get_widget(builder, "wndMain");
if (window == NULL)
return NULL;
g_signal_connect(window, "delete-event",
G_CALLBACK(gtk_main_quit), NULL);
return window;
}
gint
main(gint argc, gchar **argv)
{
gchar *path;
GtkBuilder *builder;
GtkWidget *window;
if (! parse_args(&argc, &argv))
return 1;
builder = get_builder("gleaker.ui");
if (builder == NULL)
return 2;
window = get_main_window(builder);
g_object_unref(builder);
if (window == NULL)
return 3;
gtk_widget_show_all(window);
gtk_main();
return 0;
}

Archive Download the corresponding diff file

Branches