Add gedit_utils_get_ui_objects_with_translation_domain.

This is needed for C plugins that are not contained in the gedit module.
parent cb5829d8
......@@ -1027,33 +1027,16 @@ handle_builder_error (const gchar *message, ...)
return label;
}
/* FIXME this is an issue for introspection */
/**
* gedit_utils_get_ui_objects:
* @filename: the path to the gtk builder file
* @root_objects: a %NULL terminated list of root objects to load or NULL to
* load all objects
* @error_widget: a pointer were a #GtkLabel
* @object_name: the name of the first object
* @...: a pointer were the first object is returned, followed by more
* name / object pairs and terminated by %NULL.
*
* This function gets the requested objects from a GtkBuilder ui file. In case
* of error it returns %FALSE and sets error_widget to a GtkLabel containing
* the error message to display.
*
* Returns: %FALSE if an error occurs, %TRUE on success.
*/
gboolean
gedit_utils_get_ui_objects (const gchar *filename,
gchar **root_objects,
GtkWidget **error_widget,
const gchar *object_name,
...)
/* TODO: just add a translation_doamin arg to get_ui_objects method */
static gboolean
get_ui_objects_with_translation_domain (const gchar *filename,
const gchar *translation_domain,
gchar **root_objects,
GtkWidget **error_widget,
const gchar *object_name,
va_list args)
{
GtkBuilder *builder;
va_list args;
const gchar *name;
GError *error = NULL;
gchar *filename_markup;
......@@ -1068,6 +1051,11 @@ gedit_utils_get_ui_objects (const gchar *filename,
builder = gtk_builder_new ();
if (translation_domain != NULL)
{
gtk_builder_set_translation_domain (builder, translation_domain);
}
if (root_objects != NULL)
{
gtk_builder_add_objects_from_file (builder,
......@@ -1094,8 +1082,7 @@ gedit_utils_get_ui_objects (const gchar *filename,
return FALSE;
}
va_start (args, object_name);
for (name = object_name; name; name = va_arg (args, const gchar *) )
for (name = object_name; name; name = va_arg (args, const gchar *))
{
GObject **gobj;
......@@ -1126,7 +1113,6 @@ gedit_utils_get_ui_objects (const gchar *filename,
}
}
}
va_end (args);
g_free (filename_markup);
g_object_unref (builder);
......@@ -1134,6 +1120,84 @@ gedit_utils_get_ui_objects (const gchar *filename,
return ret;
}
/**
* gedit_utils_get_ui_objects:
* @filename: the path to the gtk builder file
* @root_objects: a %NULL terminated list of root objects to load or NULL to
* load all objects
* @error_widget: a pointer were a #GtkLabel
* @object_name: the name of the first object
* @...: a pointer were the first object is returned, followed by more
* name / object pairs and terminated by %NULL.
*
* This function gets the requested objects from a GtkBuilder ui file. In case
* of error it returns %FALSE and sets error_widget to a GtkLabel containing
* the error message to display.
*
* Returns: %FALSE if an error occurs, %TRUE on success.
*/
gboolean
gedit_utils_get_ui_objects (const gchar *filename,
gchar **root_objects,
GtkWidget **error_widget,
const gchar *object_name,
...)
{
gboolean ret;
va_list args;
va_start (args, object_name);
ret = get_ui_objects_with_translation_domain (filename,
NULL,
root_objects,
error_widget,
object_name,
args);
va_end (args);
return ret;
}
/**
* gedit_utils_get_ui_objects_with_translation_domain:
* @filename: the path to the gtk builder file
* @translation_domain: the specific translation domain
* @root_objects: a %NULL terminated list of root objects to load or NULL to
* load all objects
* @error_widget: a pointer were a #GtkLabel
* @object_name: the name of the first object
* @...: a pointer were the first object is returned, followed by more
* name / object pairs and terminated by %NULL.
*
* This function gets the requested objects from a GtkBuilder ui file. In case
* of error it returns %FALSE and sets error_widget to a GtkLabel containing
* the error message to display.
*
* Returns: %FALSE if an error occurs, %TRUE on success.
*/
gboolean
gedit_utils_get_ui_objects_with_translation_domain (const gchar *filename,
const gchar *translation_domain,
gchar **root_objects,
GtkWidget **error_widget,
const gchar *object_name,
...)
{
gboolean ret;
va_list args;
va_start (args, object_name);
ret = get_ui_objects_with_translation_domain (filename,
translation_domain,
root_objects,
error_widget,
object_name,
args);
va_end (args);
return ret;
}
gchar *
gedit_utils_make_canonical_uri_from_shell_arg (const gchar *str)
{
......
......@@ -124,6 +124,14 @@ gboolean gedit_utils_get_ui_objects (const gchar *filename,
const gchar *object_name,
...) G_GNUC_NULL_TERMINATED;
gboolean gedit_utils_get_ui_objects_with_translation_domain
(const gchar *filename,
const gchar *translation_domain,
gchar **root_objects,
GtkWidget **error_widget,
const gchar *object_name,
...) G_GNUC_NULL_TERMINATED;
/* Return NULL if str is not a valid URI and/or filename */
gchar *gedit_utils_make_canonical_uri_from_shell_arg
(const gchar *str);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment