[anjuta] Use new anjuta_util_builder function in build-basic-autotools plugin



commit 5efb91b086428dc95f1d101b281d24a05ecf72ee
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Jul 5 22:09:31 2009 +0200

    Use new anjuta_util_builder function in build-basic-autotools plugin

 plugins/build-basic-autotools/build-options.c |   24 +++++------
 plugins/build-basic-autotools/executer.c      |   24 +++++------
 plugins/build-basic-autotools/plugin.c        |   53 +++++++++----------------
 3 files changed, 41 insertions(+), 60 deletions(-)
---
diff --git a/plugins/build-basic-autotools/build-options.c b/plugins/build-basic-autotools/build-options.c
index 9e62e87..6c10be2 100644
--- a/plugins/build-basic-autotools/build-options.c
+++ b/plugins/build-basic-autotools/build-options.c
@@ -24,6 +24,7 @@
 #include <gio/gio.h>
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-utils.h>
 #include <string.h>
 
 /* Constants
@@ -305,25 +306,22 @@ fill_dialog (BuildConfigureDialog *dlg)
 gboolean
 build_dialog_configure (GtkWindow* parent, const gchar *project_root_uri, BuildConfigurationList *config_list, gboolean *run_autogen)
 {
-	GError* error = NULL;
 	GtkBuilder* bxml;
 	BuildConfigureDialog dlg;
 	BuildConfiguration *cfg = NULL;
 	gint response;
 	
 	/* Get all dialog widgets */
-	bxml = gtk_builder_new();
-	if (!gtk_builder_add_from_file (bxml, BUILDER_FILE, &error))
-	{
-		g_warning ("Couldn't load builder file: %s", error->message);
-		g_error_free (error);
-	}
-	dlg.win = GTK_WIDGET (gtk_builder_get_object (bxml, CONFIGURE_DIALOG));
-	dlg.combo = GTK_WIDGET (gtk_builder_get_object (bxml, CONFIGURATION_COMBO));
-	dlg.autogen = GTK_WIDGET (gtk_builder_get_object (bxml, RUN_AUTOGEN_CHECK));
-	dlg.build_dir_chooser = GTK_WIDGET (gtk_builder_get_object (bxml, BUILD_DIR_CHOOSER));
-	dlg.args = GTK_WIDGET (gtk_builder_get_object (bxml, CONFIGURE_ARGS_ENTRY));
-	dlg.ok = GTK_WIDGET (gtk_builder_get_object (bxml, OK_BUTTON));
+	bxml = anjuta_util_builder_new (BUILDER_FILE, NULL);
+	if (bxml == NULL) return FALSE;
+	anjuta_util_builder_get_objects (bxml,
+	    CONFIGURE_DIALOG, &dlg.win,
+	    CONFIGURATION_COMBO, &dlg.combo,
+	    RUN_AUTOGEN_CHECK, &dlg.autogen,
+	    BUILD_DIR_CHOOSER, &dlg.build_dir_chooser,
+	    CONFIGURE_ARGS_ENTRY, &dlg.args,
+	    OK_BUTTON, &dlg.ok,
+	    NULL);
 	g_object_unref (bxml);
 	
 	dlg.config_list = config_list;
diff --git a/plugins/build-basic-autotools/executer.c b/plugins/build-basic-autotools/executer.c
index 3eeb51a..c012a2b 100644
--- a/plugins/build-basic-autotools/executer.c
+++ b/plugins/build-basic-autotools/executer.c
@@ -44,7 +44,6 @@ get_program_parameters (BasicAutotoolsPlugin *plugin,
 						gchar **program_args,
 						gboolean *run_in_terminal)
 {
-	GError* error = NULL;
 	GtkBuilder *bxml;
 	GtkWidget *dlg, *treeview, *use_terminal_check, *arguments_entry;
 	GtkWidget *treeview_frame;
@@ -79,17 +78,16 @@ get_program_parameters (BasicAutotoolsPlugin *plugin,
 		exec_targets = NULL;
 	}
 
-	bxml = gtk_builder_new();
-	if (!gtk_builder_add_from_file (bxml, BUILDER_FILE, &error))
-	{
-		g_warning ("Couldn't load builder file: %s", error->message);
-		g_error_free (error);
-	}		
-	dlg = GTK_WIDGET (gtk_builder_get_object (bxml, "execute_dialog"));
-	treeview = GTK_WIDGET (gtk_builder_get_object (bxml, "programs_treeview"));
-	treeview_frame = GTK_WIDGET (gtk_builder_get_object (bxml, "treeview_frame"));
-	use_terminal_check = GTK_WIDGET (gtk_builder_get_object (bxml, "program_run_in_terminal"));
-	arguments_entry = GTK_WIDGET (gtk_builder_get_object (bxml, "program_arguments"));
+	bxml = anjuta_util_builder_new (BUILDER_FILE, NULL);
+	if (bxml == NULL) return FALSE;
+	anjuta_util_builder_get_objects (bxml,
+	    "execute_dialog", &dlg,
+	    "programs_treeview", &treeview,
+	    "treeview_frame", &treeview_frame,
+	    "program_run_in_terminal", &use_terminal_check,
+	    "program_arguments", &arguments_entry,
+	    NULL);
+	g_object_unref (bxml);
 	
 	gtk_window_set_transient_for (GTK_WINDOW (dlg),
 								  GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell));
@@ -214,7 +212,7 @@ get_program_parameters (BasicAutotoolsPlugin *plugin,
 		}
 	}
 	gtk_widget_destroy (dlg);
-	g_object_unref (bxml);
+	
 	return success;
 }
 
diff --git a/plugins/build-basic-autotools/plugin.c b/plugins/build-basic-autotools/plugin.c
index 76e9a6f..952d273 100644
--- a/plugins/build-basic-autotools/plugin.c
+++ b/plugins/build-basic-autotools/plugin.c
@@ -3343,56 +3343,41 @@ ibuilder_iface_init (IAnjutaBuilderIface *iface)
 /* IAnjutaPreferences implementation
  *---------------------------------------------------------------------------*/
 
-static GtkBuilder *bxml;
-
 static void
 ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
 {
-	GError* error = NULL;
 	GtkWidget *root_check;
-	GtkWidget *entry;
+	GtkWidget *make_check;
+	GtkWidget *root_entry;
+	GtkWidget *make_entry;
+	GtkBuilder *bxml;
 		
 	/* Create the preferences page */
-	bxml =  gtk_builder_new();
-
-	if (!gtk_builder_add_from_file (bxml, BUILDER_FILE, &error))
-	{
-		g_warning ("Couldn't load builder file: %s", error->message);
-		g_error_free (error);
-	}
+	bxml =  anjuta_util_builder_new (BUILDER_FILE, NULL);
+	if (!bxml) return;
 
-	root_check = GTK_WIDGET (gtk_builder_get_object (bxml, INSTALL_ROOT_CHECK));
-	entry = GTK_WIDGET (gtk_builder_get_object (bxml, INSTALL_ROOT_ENTRY));
-	g_signal_connect(G_OBJECT(root_check), "toggled", G_CALLBACK(on_root_check_toggled), entry);
-	on_root_check_toggled (root_check, entry);
+	anjuta_util_builder_get_objects (bxml,
+	    INSTALL_ROOT_CHECK, &root_check,
+	    INSTALL_ROOT_ENTRY, &root_entry,
+	    PARALLEL_MAKE_CHECK, &make_check,
+	    PARALLEL_MAKE_SPIN, &make_entry,
+	    NULL);
+	
+	g_signal_connect(G_OBJECT(root_check), "toggled", G_CALLBACK(on_root_check_toggled), root_entry);
+	on_root_check_toggled (root_check, root_entry);
 
-	root_check = GTK_WIDGET (gtk_builder_get_object (bxml, PARALLEL_MAKE_CHECK));
-	entry = GTK_WIDGET (gtk_builder_get_object (bxml, PARALLEL_MAKE_SPIN));
-	g_signal_connect(G_OBJECT(root_check), "toggled", G_CALLBACK(on_root_check_toggled), entry);
-	on_root_check_toggled (root_check, entry);
+	g_signal_connect(G_OBJECT(make_check), "toggled", G_CALLBACK(on_root_check_toggled), make_entry);
+	on_root_check_toggled (make_check, make_entry);
 	
 	anjuta_preferences_add_from_builder (prefs, bxml, BUILD_PREFS_ROOT, _("Build Autotools"),  ICON_FILE);
+	
+	g_object_unref (bxml);
 }
 
 static void
 ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
 {
-	GtkWidget *root_check;
-	GtkWidget *entry;
-
-	root_check = GTK_WIDGET (gtk_builder_get_object (bxml, INSTALL_ROOT_CHECK));
-	entry = GTK_WIDGET (gtk_builder_get_object (bxml, INSTALL_ROOT_ENTRY));
-	g_signal_handlers_disconnect_by_func(G_OBJECT(root_check),
-		G_CALLBACK(on_root_check_toggled), entry);
-
-	root_check = GTK_WIDGET (gtk_builder_get_object (bxml, PARALLEL_MAKE_CHECK));
-	entry = GTK_WIDGET (gtk_builder_get_object (bxml, PARALLEL_MAKE_SPIN));
-	g_signal_handlers_disconnect_by_func(G_OBJECT(root_check),
-		G_CALLBACK(on_root_check_toggled), entry);
-		
 	anjuta_preferences_remove_page(prefs, _("Build Autotools"));
-	
-	g_object_unref (bxml);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]