anjuta r4623 - in trunk: . plugins/scratchbox



Author: sgranjoux
Date: Wed Jan 21 19:54:52 2009
New Revision: 4623
URL: http://svn.gnome.org/viewvc/anjuta?rev=4623&view=rev

Log:
	* plugins/editor/print.h,
	plugins/editor/aneditor.cxx,
	plugins/editor/print.c,
	configure.in:
	Fix #564659 â Port anjuta to use Gtk+ print instead of deprecated
	gnomeprint

	* plugins/editor/text_editor.c:
	Fix one debugging error message

	* plugins/editor/Makefile.am:
	Add log domain


Added:
   trunk/plugins/scratchbox/anjuta-scratchbox-panel.png   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/plugins/scratchbox/Makefile.am
   trunk/plugins/scratchbox/anjuta-scratchbox-48.png
   trunk/plugins/scratchbox/anjuta-scratchbox.glade
   trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in
   trunk/plugins/scratchbox/plugin.c

Modified: trunk/plugins/scratchbox/Makefile.am
==============================================================================
--- trunk/plugins/scratchbox/Makefile.am	(original)
+++ trunk/plugins/scratchbox/Makefile.am	Wed Jan 21 19:54:52 2009
@@ -1,6 +1,7 @@
 # Plugin glade file
 anjuta_gladedir = $(anjuta_glade_dir)
-anjuta_glade_DATA = anjuta-scratchbox.glade
+anjuta_glade_DATA = anjuta-scratchbox.glade \
+		    anjuta-scratchbox-panel.png
 
 # Plugin Icon file
 anjuta_pixmapsdir = $(anjuta_image_dir)

Modified: trunk/plugins/scratchbox/anjuta-scratchbox-48.png
==============================================================================
Binary files. No diff available.

Added: trunk/plugins/scratchbox/anjuta-scratchbox-panel.png
==============================================================================
Binary file. No diff available.

Modified: trunk/plugins/scratchbox/anjuta-scratchbox.glade
==============================================================================
--- trunk/plugins/scratchbox/anjuta-scratchbox.glade	(original)
+++ trunk/plugins/scratchbox/anjuta-scratchbox.glade	Wed Jan 21 19:54:52 2009
@@ -18,36 +18,120 @@
             <property name="yalign">0</property>
             <property name="left_padding">12</property>
             <child>
-              <widget class="GtkVBox" id="vbox2">
+              <widget class="GtkTable" id="table1">
                 <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="column_spacing">5</property>
+                <property name="row_spacing">5</property>
                 <child>
-                  <widget class="GtkHBox" id="hbox1">
+                  <widget class="GtkHSeparator" id="hseparator2">
                     <property name="visible">True</property>
-                    <child>
-                      <widget class="GtkLabel" id="label1">
-                        <property name="visible">True</property>
-                        <property name="xpad">5</property>
-                        <property name="label" translatable="yes">Scratchbox directory:</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkFileChooserButton" id="preferences_folder:text:/scratchbox:0:build.scratchbox.path">
-                        <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
-                        <property name="title" translatable="yes">Select Scratchbox Folder</property>
-                      </widget>
-                      <packing>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
                   </widget>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
+                    <property name="right_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHSeparator" id="hseparator1">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">Scratchbox directory:</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Scratchbox version:</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="preferences_combo:text:Sbox1,Sbox2:0:scratchbox.version">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="items">Sbox1
+Sbox2</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkFileChooserButton" id="preferences_folder:text:/scratchbox:0:build.scratchbox.path">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="preview_widget_active">False</property>
+                    <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+                    <property name="title" translatable="yes">Select Scratchbox Folder</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Scratchbox target:</property>
+                    <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combo_target">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="items">host</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
               </widget>
@@ -55,13 +139,35 @@
           </widget>
         </child>
         <child>
-          <widget class="GtkLabel" id="label106">
+          <widget class="GtkTable" id="table2">
             <property name="visible">True</property>
-            <property name="xalign">0</property>
-            <property name="yalign">0</property>
-            <property name="label" translatable="yes">&lt;b&gt;Scratchbox Options&lt;/b&gt;
+            <property name="homogeneous">True</property>
+            <child>
+              <widget class="GtkLabel" id="label106">
+                <property name="visible">True</property>
+                <property name="xalign">1</property>
+                <property name="yalign">0</property>
+                <property name="ypad">14</property>
+                <property name="label" translatable="yes">&lt;b&gt;Scratchbox Options&lt;/b&gt;
 </property>
-            <property name="use_markup">True</property>
+                <property name="use_markup">True</property>
+                <property name="justify">GTK_JUSTIFY_FILL</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkImage" id="anjuta-scratchbox-panel">
+                <property name="visible">True</property>
+                <property name="pixbuf">anjuta-scratchbox-panel.png</property>
+              </widget>
+              <packing>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
           </widget>
           <packing>
             <property name="type">label_item</property>

Modified: trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in
==============================================================================
--- trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in	(original)
+++ trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in	Wed Jan 21 19:54:52 2009
@@ -1,6 +1,6 @@
 [Anjuta Plugin]
 _Name=Scratchbox
-_Description=Change build commands to use scratchbox 1
+_Description=Change build commands to use scratchbox 1 or 2
 Location=anjuta-scratchbox:ScratchboxPlugin
 Icon=anjuta-scratchbox-48.png
 Interfaces=IAnjutaEnvironment

Modified: trunk/plugins/scratchbox/plugin.c
==============================================================================
--- trunk/plugins/scratchbox/plugin.c	(original)
+++ trunk/plugins/scratchbox/plugin.c	Wed Jan 21 19:54:52 2009
@@ -27,6 +27,7 @@
 
 #include "plugin.h"
 
+#include <libanjuta/anjuta-launcher.h>
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/interfaces/ianjuta-environment.h>
 #include <libanjuta/interfaces/ianjuta-preferences.h>
@@ -38,8 +39,11 @@
 #define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-scratchbox.glade"
 
 #define SB_ENTRY "preferences_folder:text:/scratchbox:0:build.scratchbox.path"
+#define SB_TARGET_ENTRY "combo_target"
+#define SB_SBOX_ENTRY "preferences_combo:text:Sbox1,Sbox2:0:scratchbox.version"
 
 #define PREF_SB_PATH "build.scratchbox.path"
+#define PREF_SB_VERSION "scratchbox.version"
 
 /* Type defintions
  *---------------------------------------------------------------------------*/
@@ -52,10 +56,36 @@
 struct _ScratchboxPlugin
 {
 	AnjutaPlugin parent;
-	
+	AnjutaLauncher *launcher;
+
+	/* Plugin Data */
 	gchar *user_dir;
+	gchar **target_list;
+	gchar *sb_dir;
+	gchar *target;
+	gint id;
+	gint combo_element;
+	GString *buffer;
 };
 
+GladeXML *gxml;
+
+#define EXECUTE_CMD	0
+#define TARGET_LIST	1
+
+static gchar *
+sbox2_commands_args[][2] = {
+	{ "bin/sb2", "-t" },	/* execute command */
+	{ "bin/sb2-config", "-l"},	/* target list */
+	{ NULL, NULL },
+};
+
+static gchar *
+sbox1_commands_args[][2] = {
+	{ "bin/login", "-d" },
+	{ "bin/sb-conf", "--list" },	/* target list */
+	{ NULL, NULL },
+};
 
 /* Callback for saving session
  *---------------------------------------------------------------------------*/
@@ -63,15 +93,177 @@
 static void
 on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, ScratchboxPlugin *self)
 {
+	if (phase != ANJUTA_SESSION_PHASE_NORMAL)
+		return;
 }
 
 static void on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, ScratchboxPlugin *self)
 {
+	if (phase != ANJUTA_SESSION_PHASE_NORMAL)
+		return;
 }
 
 /* Callbacks
  *---------------------------------------------------------------------------*/
 
+static void on_list_terminated (AnjutaLauncher *launcher, gint child_pid,
+                                gint status, gulong time_taken, gpointer data)
+{
+	g_return_if_fail (launcher != NULL);
+	
+	ScratchboxPlugin* plugin = ANJUTA_PLUGIN_SCRATCHBOX (data);
+
+	if (!(status != 0 || !plugin->buffer)) {
+		/* Program terminate normaly */
+		gint str_splitted_length;
+		gint i;
+		plugin->target_list = g_strsplit (plugin->buffer->str, "\n", 0);
+		str_splitted_length = g_strv_length (plugin->target_list) - 1;
+		
+		GtkWidget* combo_target_entry;
+		combo_target_entry = glade_xml_get_widget(gxml,
+							  SB_TARGET_ENTRY);
+
+		for (i = 1; i < plugin->combo_element; i++)
+			gtk_combo_box_remove_text(GTK_COMBO_BOX(combo_target_entry), 1);
+		plugin->combo_element = 1;
+
+		for (i = 0; i < str_splitted_length; i++) {
+			gtk_combo_box_append_text(GTK_COMBO_BOX(combo_target_entry), plugin->target_list[i]);
+			plugin->combo_element++;
+		}
+                
+		/* enable target combo box */
+		gtk_combo_box_set_active (GTK_COMBO_BOX(combo_target_entry),
+					  plugin->id);
+                gtk_widget_set_sensitive(combo_target_entry, TRUE);
+		g_strfreev (plugin->target_list);
+	}
+
+	plugin->target_list = NULL;
+}
+
+static void on_target (AnjutaLauncher *launcher, AnjutaLauncherOutputType out,
+		       const gchar* line, gpointer data)
+{
+	ScratchboxPlugin* plugin = ANJUTA_PLUGIN_SCRATCHBOX (data);
+	g_return_if_fail (line != NULL);
+	g_return_if_fail (plugin != NULL);
+
+	g_string_append (plugin->buffer, line);
+	
+}
+
+static void
+on_change_target(GtkComboBox *combo, ScratchboxPlugin *plugin)
+{
+	AnjutaShell* shell = ANJUTA_PLUGIN (plugin)->shell;
+	gint id;
+	
+	g_return_if_fail (plugin != NULL);
+	id = gtk_combo_box_get_active (combo);
+	if (plugin->target) {
+		g_free(plugin->target);
+		plugin->target = NULL;
+	}
+	plugin->target = gtk_combo_box_get_active_text (combo);
+	plugin->id = id > 0 ? id :0;
+
+	anjuta_preferences_set_int (anjuta_shell_get_preferences (shell, NULL),
+                                SB_TARGET_ENTRY,
+                                plugin->id);
+}
+
+static void
+on_update_target(GtkComboBox *combo, ScratchboxPlugin *plugin)
+{
+	AnjutaPreferences* prefs;
+	GString* command = g_string_new (NULL);
+	gchar* sbox_commands;
+	gchar* sbox_args;
+	gchar* sb_dir;
+	gchar* sb_ver;
+
+	g_return_if_fail (plugin != NULL);
+
+	prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell,
+						NULL);
+        sb_ver = anjuta_preferences_get(prefs, PREF_SB_VERSION);
+
+	sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH);
+
+        if (!sb_dir)
+                return;
+
+        g_string_printf (command, "%s%s", sb_dir, G_DIR_SEPARATOR_S);
+
+        if (!strcmp(sb_ver, "Sbox1")) {
+		sbox_commands = sbox1_commands_args[TARGET_LIST][0];
+		sbox_args = sbox1_commands_args[TARGET_LIST][1];
+        } else {
+		sbox_commands = sbox2_commands_args[TARGET_LIST][0];
+		sbox_args = sbox2_commands_args[TARGET_LIST][1];
+	}
+
+	g_string_append_printf(command, sbox_commands);
+
+	if (g_file_test (command->str, G_FILE_TEST_EXISTS) == FALSE)
+        {
+		anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell),
+					_("Program '%s' does not exists"), command->str);
+		return;
+        }
+
+	g_string_append_printf(command, " %s", sbox_args);
+	
+	if (!anjuta_launcher_is_busy (plugin->launcher))
+	{
+		GtkWidget* combo_target_entry;
+		
+		if (plugin->buffer != NULL) {
+			g_string_free (plugin->buffer, TRUE);
+			plugin->buffer = NULL;
+		}
+		
+		plugin->buffer = g_string_new(NULL);
+
+		combo_target_entry = glade_xml_get_widget(gxml,
+							  SB_TARGET_ENTRY);
+		/* disable target combo box */
+		gtk_widget_set_sensitive(combo_target_entry, FALSE);
+
+		anjuta_launcher_execute (plugin->launcher, command->str,
+					(AnjutaLauncherOutputCallback)on_target,
+					plugin);
+	}
+
+	g_string_free(command, TRUE);
+
+}
+
+static void
+on_change_directory(GtkFileChooserButton *FileChooser, gpointer user_data)
+{
+	ScratchboxPlugin *plugin = (ScratchboxPlugin *) user_data;
+	GtkWidget* combo_sbox_entry;
+	gchar *old_dir;
+
+	combo_sbox_entry = glade_xml_get_widget(gxml,
+						  SB_SBOX_ENTRY);
+	old_dir = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER(FileChooser));
+
+	if (!plugin->user_dir || strcmp(old_dir, plugin->user_dir) != 0) {
+		if (plugin->user_dir)
+			g_free(plugin->user_dir);
+		plugin->user_dir = g_strdup(old_dir);
+	} else
+		return;
+
+	g_free(old_dir);
+
+	on_update_target(GTK_COMBO_BOX(combo_sbox_entry), plugin);
+}
+
 /* Actions table
  *---------------------------------------------------------------------------*/
 
@@ -83,13 +275,19 @@
 {
 	ScratchboxPlugin *self = ANJUTA_PLUGIN_SCRATCHBOX (plugin);
 	
-	DEBUG_PRINT ("%s", "Scratchbox 1 Plugin: Activating plugin...");
+	DEBUG_PRINT ("%s", "Scratchbox 1 and 2 Plugin: Activating plugin...");
+
+	self->launcher = anjuta_launcher_new ();
 
 	/* Connect to session signal */
 	g_signal_connect (plugin->shell, "save-session",
 					  G_CALLBACK (on_session_save), self);
-    g_signal_connect (plugin->shell, "load-session",
+	g_signal_connect (plugin->shell, "load-session",
 					  G_CALLBACK (on_session_load), self);
+
+	/* Connect launcher signal */
+	g_signal_connect (self->launcher, "child-exited",
+                          G_CALLBACK (on_list_terminated), self);
 	
 	return TRUE;
 }
@@ -102,31 +300,64 @@
 	DEBUG_PRINT ("%s", "Scratchbox 1 Plugin: Deactivating plugin...");
 	
 	g_signal_handlers_disconnect_by_func (plugin->shell, G_CALLBACK (on_session_save), self);
-    g_signal_handlers_disconnect_by_func (plugin->shell, G_CALLBACK (on_session_load), self);
+	g_signal_handlers_disconnect_by_func (plugin->shell, G_CALLBACK (on_session_load), self);
 	
 	return TRUE;
 }
 
-/* IAnjutaEnvironment implementation
- *---------------------------------------------------------------------------*/
-
-static gboolean
-ienvironment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err)
+void
+sbox2_environment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err)
 {
 	ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment);
 	AnjutaPreferences* prefs;
+	gchar **new_argv;
 	gchar* sb_dir;
 	gsize len;
 
+	if (plugin->target == NULL || !strcmp(plugin->target, "host"))
+		return;
+
 	prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL);
 	sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH);
 
 	if (plugin->user_dir) g_free (plugin->user_dir);
+	plugin->user_dir = g_strconcat (sb_dir, G_DIR_SEPARATOR_S, NULL);
+
+	/* Build in scratchbox environment */
+	gsize len_argv = g_strv_length (*argvp);
+
+	/* Add scratchbox login */
+	new_argv = g_new (gchar*, len_argv + 4);
+	memcpy (new_argv + 3, *argvp, sizeof(gchar *) * (len_argv + 1));
+	new_argv[0] = g_strconcat (sb_dir, G_DIR_SEPARATOR_S,
+				   sbox2_commands_args[EXECUTE_CMD][0],
+				   NULL);
+	new_argv[1] = g_strconcat (sbox2_commands_args[EXECUTE_CMD][1], NULL);
+	new_argv[2] = g_strconcat (plugin->target, NULL);
+	
+	g_free (*argvp);
+	*argvp = new_argv;
+	g_free(sb_dir);
+}
+static void
+sbox1_environment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err)
+{
+	ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment);
+	AnjutaPreferences* prefs;
+	gchar* sb_dir;
+	gsize len;
+
+	prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL);
+
+	sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH);
+	
+	if (plugin->user_dir) g_free (plugin->user_dir);
 	plugin->user_dir = g_strconcat (sb_dir, G_DIR_SEPARATOR_S,
 						   "users", G_DIR_SEPARATOR_S,
 						   g_get_user_name(), NULL);
 	
 	len = strlen (plugin->user_dir);
+
 	if (strncmp (*dir, plugin->user_dir, len) == 0)
 	{
 		/* Build in scratchbox environment */
@@ -136,14 +367,42 @@
 		/* Add scratchbox login */
 		new_argv = g_new (gchar*, len_argv + 3);
 		memcpy (new_argv + 2, *argvp, sizeof(gchar *) * (len_argv + 1));
-		new_argv[0] = g_strconcat (sb_dir, G_DIR_SEPARATOR_S, "login", NULL);
-		new_argv[1] = g_strconcat ("-d ", (*dir) + len, NULL);
+		new_argv[0] = g_strconcat (sb_dir, G_DIR_SEPARATOR_S,
+					   sbox1_commands_args[EXECUTE_CMD][0],
+					   NULL);
+		new_argv[1] = g_strconcat (sbox1_commands_args[EXECUTE_CMD][1],
+					   (*dir) + len, NULL);
 		
 		g_free (*argvp);
 		*argvp = new_argv;
 	}
+
 	g_free (sb_dir);
-	
+}
+
+/* IAnjutaEnvironment implementation
+ *---------------------------------------------------------------------------*/
+
+static gboolean
+ienvironment_override (IAnjutaEnvironment* environment, gchar **dir, gchar ***argvp, gchar ***envp, GError** err)
+{
+	ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment);
+	AnjutaPreferences* prefs;
+	gchar* sb_dir;
+	gchar* sb_ver;
+
+	prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN (plugin)->shell, NULL);
+	sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH);
+
+	if (!sb_dir)
+		return FALSE;
+
+	sb_ver = anjuta_preferences_get(prefs, PREF_SB_VERSION);
+	if (!strcmp(sb_ver, "Sbox1"))
+		sbox1_environment_override(environment, dir, argvp, envp, err);
+	else
+		sbox2_environment_override(environment, dir, argvp, envp, err);
+
 	return TRUE;
 }
 
@@ -177,18 +436,36 @@
 /* IAnjutaPreferences implementation
  *---------------------------------------------------------------------------*/
 
-static GladeXML *gxml;
-
 static void
 ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
 {
-	GtkWidget *sb_entry;
-		
+	ScratchboxPlugin* plugin = ANJUTA_PLUGIN_SCRATCHBOX (ipref);
+	GtkWidget* combo_target_entry;
+	GtkWidget *combo_sbox_entry;
+	GtkWidget *chooser_dir_entry;
+
 	/* Create the preferences page */
-	gxml = glade_xml_new (GLADE_FILE, "preferences_dialog_scratchbox", NULL);
-	sb_entry = glade_xml_get_widget(gxml, SB_ENTRY);
+	gxml = glade_xml_new (GLADE_FILE,
+					"preferences_dialog_scratchbox", NULL);
+	combo_target_entry = glade_xml_get_widget(gxml, SB_TARGET_ENTRY);
+	combo_sbox_entry = glade_xml_get_widget(gxml, SB_SBOX_ENTRY);
+	chooser_dir_entry = glade_xml_get_widget(gxml, SB_ENTRY);
 	
+	plugin->id = anjuta_preferences_get_int(prefs, SB_TARGET_ENTRY);
+
 	anjuta_preferences_add_page (prefs, gxml, "Scratchbox", _("Scratchbox"),  ICON_FILE);
+	g_signal_connect(chooser_dir_entry, "current-folder-changed",
+			 G_CALLBACK(on_change_directory),
+			 plugin);
+	g_signal_connect(combo_sbox_entry, "changed",
+			 G_CALLBACK(on_update_target), plugin);
+
+	g_signal_connect(combo_target_entry,
+			 "changed", G_CALLBACK(on_change_target),
+			 plugin);
+
+        plugin->target = gtk_combo_box_get_active_text (combo_target_entry);
+
 }
 
 static void
@@ -222,6 +499,12 @@
 	ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (obj);
 	
 	plugin->user_dir = NULL;
+	plugin->target_list = NULL;
+	plugin->buffer = NULL;
+	plugin->combo_element = 1;
+	plugin->launcher = NULL;
+	plugin->id = 0;
+	plugin->target = NULL;
 }
 
 /* dispose is used to unref object created with instance_init */



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