aboutsummaryrefslogtreecommitdiff
path: root/src/lib/glade.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/glade.c')
-rw-r--r--src/lib/glade.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lib/glade.c b/src/lib/glade.c
new file mode 100644
index 00000000..386a676b
--- /dev/null
+++ b/src/lib/glade.c
@@ -0,0 +1,85 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/lib/glade.c
23 * @brief code for integration with glade
24 * @author Christian Grothoff
25 */
26#include "gnunet_gtk_config.h"
27#include "gnunet_gtk.h"
28
29
30/**
31 * Get the name of the directory where all of our package
32 * data is stored ($PREFIX/share/)
33 *
34 * @return name of the data directory
35 */
36const char *
37GNUNET_GTK_get_data_dir ()
38{
39 static char *dd;
40
41 if (dd == NULL)
42 dd = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR);
43 return dd;
44}
45
46
47/**
48 * Create an initialize a new builder based on the
49 * GNUnet-GTK glade file.
50 *
51 * @param filename name of the resource file to load
52 * @return NULL on error
53 */
54GtkBuilder *
55GNUNET_GTK_get_new_builder (const char *filename)
56{
57 char *glade_path;
58 GtkBuilder *ret;
59 GError *error;
60
61 ret = gtk_builder_new ();
62 gtk_builder_set_translation_domain (ret, "gnunet-gtk");
63 GNUNET_asprintf (&glade_path,
64 "%s%s",
65 GNUNET_GTK_get_data_dir (),
66 filename);
67 error = NULL;
68 if (0 == gtk_builder_add_from_file (ret, glade_path, &error))
69 {
70 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
71 _("Failed to load `%s': %s\n"),
72 glade_path,
73 error->message);
74 g_error_free (error);
75 GNUNET_free (glade_path);
76 return NULL;
77 }
78 gtk_builder_connect_signals (ret, NULL);
79 GNUNET_free (glade_path);
80 return ret;
81}
82
83
84
85/* end of glade.c */