[vinagre] Rewrite of vinagre_utils_get_builder(), accepting a plugin as parameter
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vinagre] Rewrite of vinagre_utils_get_builder(), accepting a plugin as parameter
- Date: Tue, 29 Sep 2009 14:53:03 +0000 (UTC)
commit 6d8a8c721d29efc43a192cc7328b89d358da8250
Author: Jonh Wendell <jwendell gnome org>
Date: Tue Sep 29 11:47:26 2009 -0300
Rewrite of vinagre_utils_get_builder(), accepting a plugin as parameter
vinagre/vinagre-utils.c | 43 ++++++++++++++++++++++++++++++++++++++-----
vinagre/vinagre-utils.h | 3 ++-
2 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/vinagre/vinagre-utils.c b/vinagre/vinagre-utils.c
index 4294bed..ed96055 100644
--- a/vinagre/vinagre-utils.c
+++ b/vinagre/vinagre-utils.c
@@ -136,23 +136,56 @@ vinagre_utils_get_ui_xml_filename (void)
return VINAGRE_DATADIR "/" VINAGRE_UI_XML_FILE;
}
+/**
+ * vinagre_utils_get_builder:
+ * @plugin: a #VinagrePlugin or NULL
+ * @filename: the filename of the UI file for the plugin, or NULL if plugin is NULL
+ *
+ * This function gets a #GtkBuilder object for a UI file.
+ * Supply a plugin and a filename in order to get a #GtkBuilder for the plugin.
+ * Supply NULL to both arguments to get the main Vinagre #GtkBuilder
+ *
+ * Returns a #GtkBuilder on success (free with #g_object_unref) or NULL
+ * if the file cannot be found. In this case an error dialog will be shown.
+ */
GtkBuilder *
-vinagre_utils_get_builder (void)
+vinagre_utils_get_builder (VinagrePlugin *plugin, const gchar *filename)
{
- GtkBuilder *xml;
+ GtkBuilder *xml = NULL;
GError *error = NULL;
+ gchar *actual_filename, *plugin_datadir;
+
+ if (plugin)
+ {
+ plugin_datadir = vinagre_plugin_get_data_dir (plugin);
+ actual_filename = g_build_filename (plugin_datadir, filename, NULL);
+ g_free (plugin_datadir);
+ }
+ else
+ actual_filename = g_strdup (vinagre_utils_get_ui_filename ());
xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (xml,
- vinagre_utils_get_ui_filename (),
+ actual_filename,
&error))
{
- g_error (_("Could not load builder file: %s"), error->message);
+ GString *str = g_string_new (NULL);
+
+ if (plugin)
+ g_string_append (str, _("A plugin tried to open an UI file but did not succeed, with the error message:"));
+ else
+ g_string_append (str, _("The program tried to open an UI file but did not succeed, with the error message:"));
+
+ g_string_append_printf (str, "\n\n%s\n\n", error->message);
+ g_string_append (str, _("Please check your installation."));
+ vinagre_utils_show_error (_("Error loading UI file"), str->str, NULL);
g_error_free (error);
+ g_string_free (str, TRUE);
g_object_unref (xml);
- return NULL;
+ xml = NULL;
}
+ g_free (actual_filename);
return xml;
}
diff --git a/vinagre/vinagre-utils.h b/vinagre/vinagre-utils.h
index 5b232db..785e856 100644
--- a/vinagre/vinagre-utils.h
+++ b/vinagre/vinagre-utils.h
@@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include <glib.h>
+#include "vinagre-plugin.h"
/* useful macro */
#define GBOOLEAN_TO_POINTER(i) ((gpointer) ((i) ? 2 : 1))
@@ -45,7 +46,7 @@ void vinagre_utils_toggle_widget_visible (GtkWidget *widget);
const gchar *vinagre_utils_get_ui_filename (void);
const gchar *vinagre_utils_get_ui_xml_filename (void);
-GtkBuilder *vinagre_utils_get_builder (void);
+GtkBuilder *vinagre_utils_get_builder (VinagrePlugin *plugin, const gchar *filename);
gchar *vinagre_utils_escape_underscores (const gchar *text,
gssize length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]