Exemplo n.º 1
0
/**
 * go_gtk_builder_load_internal:
 * @uifile: the name of the file load
 * @domain: the translation domain
 * @gcc: #GOCmdContext
 *
 * Simple utility to open ui files
 *
 * Since: 0.9.6
 * Returns: (transfer full): a new #GtkBuilder or NULL
 *
 * Variant of go_gtk_builder_new that searchs goffice directories
 * for files.
 * @uifile should be one of these:
 *
 * res:NAME  -- data from resource manager
 * data:DATA -- data right here
 * filename  -- data from local file
 *
 * Data may be compressed, regardless of source.
**/
GtkBuilder *
go_gtk_builder_load_internal (char const *uifile,
			      char const *domain, GOCmdContext *gcc)
{
	char *f;
	GtkBuilder *res;

	if (g_path_is_absolute (uifile) ||
	    strncmp (uifile, "res:", 4) == 0 ||
	    strncmp (uifile, "data:", 5) == 0)
		return go_gtk_builder_load (uifile, domain, gcc);

	f = g_build_filename (go_sys_data_dir (), "ui", uifile, NULL);
	res = go_gtk_builder_load (f, domain, gcc);
	g_free (f);

	return res;
}
Exemplo n.º 2
0
/**
 * go_libglade_new :
 * @gcc : #GOCmdContext
 * @gladefile :
 *
 * Simple utility to open glade files
 **/
GladeXML *
go_libglade_new (char const *gladefile, char const *root,
		 char const *domain, GOCmdContext *gcc)
{
	GladeXML *gui;
	char *f;

	g_return_val_if_fail (gladefile != NULL, NULL);

	if (!g_path_is_absolute (gladefile))
		f = g_build_filename (go_sys_data_dir (), "glade", gladefile, NULL);
	else
		f = g_strdup (gladefile);

	gui = glade_xml_new (f, root, domain);
	if (gui == NULL && gcc != NULL) {
		char *msg = g_strdup_printf (_("Unable to open file '%s'"), f);
		go_cmd_context_error_system (gcc, msg);
		g_free (msg);
	}
	g_free (f);

	return gui;
}