[gedit] Add gedit_utils_get_ui_objects_with_translation_domain.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Add gedit_utils_get_ui_objects_with_translation_domain.
- Date: Sat, 8 Oct 2011 14:28:56 +0000 (UTC)
commit 5ffa0457100c6135e4764d1fb6221543f6f4278d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Oct 8 16:28:10 2011 +0200
Add gedit_utils_get_ui_objects_with_translation_domain.
This is needed for C plugins that are not contained in the gedit module.
gedit/gedit-utils.c | 120 +++++++++++++++++++++++++++++++++++++++------------
gedit/gedit-utils.h | 8 +++
2 files changed, 100 insertions(+), 28 deletions(-)
---
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index e03da37..6ea8b1c 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -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)
{
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index 7a73e61..18bda01 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]