anjuta r3765 - in trunk: . libanjuta plugins/build-basic-autotools plugins/language-support-cpp-java plugins/sourceview po



Author: jhs
Date: Tue Mar 11 13:36:44 2008
New Revision: 3765
URL: http://svn.gnome.org/viewvc/anjuta?rev=3765&view=rev

Log:
2008-03-11  Johannes Schmid  <jhs gnome org>

	* plugins/language-support-cpp-java/anjuta-language-cpp-java.glade:
	* plugins/language-support-cpp-java/cpp-java-utils.c:
	* plugins/language-support-cpp-java/plugin.c
	(get_line_indentation_base), (on_editor_char_inserted_cpp):
	520415 â [PATCH] Problems in auto indentatation code,
	520766 â Brace autocompletion (Patch from Ignacio Casal Quinteiro <nacho gnome org>)
	
	* plugins/sourceview/anjuta-view.c (anjuta_view_key_press_event),
	(anjuta_view_button_press_event):
	* plugins/sourceview/sourceview.c (on_insert_text),
	(sourceview_adjustment_changed), (sourceview_new):
	#520761 â Weirz behavior with popup

2008-03-03  Johannes Schmid  <jhs gnome org>

	* libanjuta/anjuta-launcher.c (anjuta_launcher_initialize),
	(anjuta_launcher_dispose), (anjuta_launcher_finalize),
	(anjuta_launcher_set_env), (anjuta_launcher_fork_setenv),
	(anjuta_launcher_fork):
	* libanjuta/anjuta-launcher.h:
	Add API to set environment variables for the forked process
	
	* plugins/build-basic-autotools/Makefile.am:
	* plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin
	.glade:
	* plugins/build-basic-autotools/build-basic-autotools.c
	(build_set_env), (build_execute_command_full),
	(build_execute_command), (build_configure_project),
	(build_autogen_project):
	* plugins/build-basic-autotools/build-basic-autotools.h:
	* plugins/build-basic-autotools/build-options.c
	(fill_options_combo), (build_dialog_configure):
	* plugins/build-basic-autotools/build-options.h:
	Use new launcher API to set CFLAGS when running configure. New configure dialog
	which has predefined CFLAGS settings.

	Fixes 520076 â [PATCH] Add support for setting custom CFLAGS from the UI


Added:
   trunk/plugins/build-basic-autotools/build-options.c
   trunk/plugins/build-basic-autotools/build-options.h
Modified:
   trunk/ChangeLog
   trunk/libanjuta/anjuta-launcher.c
   trunk/libanjuta/anjuta-launcher.h
   trunk/plugins/build-basic-autotools/Makefile.am
   trunk/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade
   trunk/plugins/build-basic-autotools/build-basic-autotools.c
   trunk/plugins/build-basic-autotools/build-basic-autotools.h
   trunk/plugins/language-support-cpp-java/anjuta-language-cpp-java.glade
   trunk/plugins/language-support-cpp-java/cpp-java-utils.c
   trunk/plugins/language-support-cpp-java/plugin.c
   trunk/plugins/sourceview/anjuta-view.c
   trunk/plugins/sourceview/sourceview.c
   trunk/po/ChangeLog
   trunk/po/POTFILES.in

Modified: trunk/libanjuta/anjuta-launcher.c
==============================================================================
--- trunk/libanjuta/anjuta-launcher.c	(original)
+++ trunk/libanjuta/anjuta-launcher.c	Tue Mar 11 13:36:44 2008
@@ -141,6 +141,9 @@
 	/* Encondig */
 	gboolean custom_encoding;
 	gchar* encoding;
+	
+	/* Env */
+	GHashTable* env;
 };
 
 enum
@@ -212,6 +215,10 @@
 	/* Encoding */
 	obj->priv->custom_encoding = FALSE;
 	obj->priv->encoding = NULL;
+	
+	/* Env */
+	obj->priv->env = g_hash_table_new_full (g_str_hash, g_str_equal,
+											g_free, g_free);
 }
 
 GType
@@ -257,8 +264,6 @@
 		kill (child_pid_save, SIGTERM);
 		launcher->priv->busy = FALSE;
 		
-		if (launcher->priv->custom_encoding && launcher->priv->encoding)
-			g_free (launcher->priv->encoding);
 	}
 	GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
 }
@@ -267,6 +272,11 @@
 anjuta_launcher_finalize (GObject *obj)
 {
 	AnjutaLauncher *launcher = ANJUTA_LAUNCHER (obj);	
+	if (launcher->priv->custom_encoding && launcher->priv->encoding)
+		g_free (launcher->priv->encoding);
+	
+	g_hash_table_destroy (launcher->priv->env);
+	
 	g_free (launcher->priv);
 	GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (obj));
 }
@@ -1083,6 +1093,35 @@
 	  launcher->priv->encoding = NULL;		
 }
 
+/**
+ * anjuta_launcher_set_env:
+ * @launcher: a #AnjutaLancher object.
+ * @name: Name of the environment variable to set
+ * @value: Value of the environment variable to set
+ * 
+ * Set an environment variable for the forked process
+ *
+ */ 
+void
+anjuta_launcher_set_env (AnjutaLauncher *launcher,
+						 const gchar *name,
+						 const gchar *value)
+{
+	g_return_if_fail (launcher && ANJUTA_IS_LAUNCHER(launcher));
+	g_return_if_fail (name != NULL);
+	g_return_if_fail (value != NULL);
+	
+	g_hash_table_insert (launcher->priv->env,
+						 g_strdup(name),
+						 g_strdup(value));
+}
+
+static void
+anjuta_launcher_fork_setenv (const gchar* name, const gchar* value)
+{
+	setenv (name, value, TRUE);
+}
+
 static pid_t
 anjuta_launcher_fork (AnjutaLauncher *launcher, gchar *const args[])
 {
@@ -1122,6 +1161,11 @@
 		if ((md = fcntl (stderr_pipe[1], F_GETFL)) != -1)
 			fcntl (stderr_pipe[1], F_SETFL, O_SYNC | md);
 		
+		/* Set up environment */
+		g_hash_table_foreach (launcher->priv->env,
+							  (GHFunc) anjuta_launcher_fork_setenv,
+							  NULL);
+		
 		execvp (args[0], args);
 		g_warning (_("Cannot execute command: \"%s\""), args[0]);
 		perror(_("execvp failed"));

Modified: trunk/libanjuta/anjuta-launcher.h
==============================================================================
--- trunk/libanjuta/anjuta-launcher.h	(original)
+++ trunk/libanjuta/anjuta-launcher.h	Tue Mar 11 13:36:44 2008
@@ -89,6 +89,11 @@
 									gpointer callback_data);
 void anjuta_launcher_set_encoding (AnjutaLauncher *launcher,
 									   const gchar *charset);
+
+void anjuta_launcher_set_env (AnjutaLauncher *launcher,
+							  const gchar *name,
+							  const gchar *value);
+
 void anjuta_launcher_send_stdin (AnjutaLauncher *launcher,
 								 const gchar *input_str);
 void anjuta_launcher_send_stdin_eof (AnjutaLauncher *launcher);

Modified: trunk/plugins/build-basic-autotools/Makefile.am
==============================================================================
--- trunk/plugins/build-basic-autotools/Makefile.am	(original)
+++ trunk/plugins/build-basic-autotools/Makefile.am	Tue Mar 11 13:36:44 2008
@@ -42,7 +42,9 @@
 	build-basic-autotools.c \
 	build-basic-autotools.h \
 	executer.c \
-	executer.h 
+	executer.h \
+	build-options.c \
+	build-options.h
 
 # Plugin dependencies
 libanjuta_build_basic_autotools_la_LIBADD = \

Modified: trunk/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade
==============================================================================
--- trunk/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade	(original)
+++ trunk/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade	Tue Mar 11 13:36:44 2008
@@ -326,4 +326,140 @@
       </widget>
     </child>
   </widget>
+  <widget class="GtkDialog" id="configure_dialog">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="border_width">5</property>
+    <property name="title">configure_dialog</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="default_width">450</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox2">
+        <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="spacing">2</property>
+        <child>
+          <widget class="GtkVBox" id="vbox4">
+            <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>
+            <child>
+              <widget class="GtkFrame" id="frame2">
+                <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_xalign">0</property>
+                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment3">
+                    <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="left_padding">12</property>
+                    <child>
+                      <widget class="GtkComboBoxEntry" id="build_options_combo">
+                        <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>
+                        <child internal-child="entry">
+                          <widget class="GtkEntry" id="comboboxentry-entry1">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label4">
+                    <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">&lt;b&gt;Build Options:&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkFrame" id="frame3">
+                <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_xalign">0</property>
+                <property name="shadow_type">GTK_SHADOW_NONE</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment4">
+                    <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="left_padding">12</property>
+                    <child>
+                      <widget class="GtkEntry" id="configure_args_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label5">
+                    <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">&lt;b&gt;Configure Options:&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area2">
+            <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="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">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">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">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">gtk-apply</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-5</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: trunk/plugins/build-basic-autotools/build-basic-autotools.c
==============================================================================
--- trunk/plugins/build-basic-autotools/build-basic-autotools.c	(original)
+++ trunk/plugins/build-basic-autotools/build-basic-autotools.c	Tue Mar 11 13:36:44 2008
@@ -37,6 +37,7 @@
 #include <libanjuta/interfaces/ianjuta-preferences.h>
 
 #include "build-basic-autotools.h"
+#include "build-options.h"
 #include "executer.h"
 
 #define ICON_FILE "anjuta-build-basic-autotools-plugin-48.png"
@@ -915,10 +916,19 @@
 	}
 }
 
+static void build_set_env (gpointer key, gpointer value, gpointer user_data)
+{
+	AnjutaLauncher* launcher = ANJUTA_LAUNCHER (user_data);
+	const gchar* name = key;
+	const gchar* env_value = value;
+	anjuta_launcher_set_env (launcher, name, env_value);
+}
+
 static void
-build_execute_command (BasicAutotoolsPlugin* bplugin, const gchar *dir,
-					   const gchar *command,
-					   gboolean save_file)
+build_execute_command_full (BasicAutotoolsPlugin* bplugin, const gchar *dir,
+							const gchar *command,
+							gboolean save_file,
+							GHashTable* env)
 {
 	AnjutaPlugin* plugin = ANJUTA_PLUGIN(bplugin);
 	AnjutaPreferences* prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
@@ -945,6 +955,11 @@
 		real_command = g_strdup(command);
 	}
 	
+	if (env)
+	{
+		g_hash_table_foreach (env, build_set_env, context->launcher);
+	}
+	
 	ianjuta_message_view_buffer_append (context->message_view,
 										"Building in directory: ", NULL);
 	ianjuta_message_view_buffer_append (context->message_view, dir, NULL);
@@ -957,6 +972,15 @@
 	g_free(real_command);
 }
 
+
+static void
+build_execute_command (BasicAutotoolsPlugin* bplugin, const gchar *dir,
+					   const gchar *command,
+					   gboolean save_file)
+{
+	build_execute_command_full (bplugin, dir, command, save_file, NULL);
+}
+
 static gboolean
 build_compile_file_real (BasicAutotoolsPlugin *plugin, const gchar *file)
 {
@@ -1062,11 +1086,14 @@
 	gint response;
 	GtkWindow *parent;
 	gchar *input = NULL;
+	GHashTable* build_options = NULL;
 	
 	parent = GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell);
 	/* Configure = ./configure script */
-	response = anjuta_util_dialog_input (parent, _("Configure Parameters:"),
-										 plugin->configure_args, &input);
+	response = build_dialog_configure (parent, _("Configure"),
+									   &build_options, 
+									   plugin->configure_args, 
+									   &input);
 	if (response)
 	{
 		gchar *cmd;
@@ -1081,8 +1108,10 @@
 		{
 			cmd = g_strdup (CHOOSE_COMMAND (plugin, CONFIGURE));
 		}
-		build_execute_command (plugin, plugin->project_root_dir, cmd, TRUE);
+		build_execute_command_full (plugin, plugin->project_root_dir, 
+							   cmd, TRUE, build_options);
 		g_free (cmd);
+		g_hash_table_destroy (build_options);
 	}
 }
 
@@ -1092,10 +1121,13 @@
 	gint response;
 	GtkWindow *parent;
 	gchar *input = NULL;
+	GHashTable* build_options = NULL;
 	
 	parent = GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell);
-	response = anjuta_util_dialog_input (parent, _("Configure Parameters:"),
-										 plugin->configure_args, &input);
+	response = build_dialog_configure (parent, _("Autogenerate"),
+									   &build_options, 
+									   plugin->configure_args, 
+									   &input);
 	if (response)
 	{
 		gboolean has_autogen = directory_has_file (plugin->project_root_dir,
@@ -1119,8 +1151,10 @@
 			else /* FIXME: Get override command for this too */
 				cmd = g_strdup ("autoreconf -i --force");
 		}
-		build_execute_command (plugin, plugin->project_root_dir, cmd, TRUE);
+		build_execute_command_full (plugin, plugin->project_root_dir, 
+									cmd, TRUE, build_options);
 		g_free (cmd);
+		g_hash_table_destroy (build_options);
 	}
 }
 

Modified: trunk/plugins/build-basic-autotools/build-basic-autotools.h
==============================================================================
--- trunk/plugins/build-basic-autotools/build-basic-autotools.h	(original)
+++ trunk/plugins/build-basic-autotools/build-basic-autotools.h	Tue Mar 11 13:36:44 2008
@@ -66,6 +66,7 @@
 	
 	/* Build parameters */
 	gchar *configure_args;
+	gchar *build_options;
 	
 	/* Execution parameters */
 	gchar *program_args;

Added: trunk/plugins/build-basic-autotools/build-options.c
==============================================================================
--- (empty file)
+++ trunk/plugins/build-basic-autotools/build-options.c	Tue Mar 11 13:36:44 2008
@@ -0,0 +1,132 @@
+/***************************************************************************
+ *            build-options.c
+ *
+ *  Sat Mar  1 20:47:23 2008
+ *  Copyright  2008  Johannes Schmid
+ *  <jhs gnome org>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+ 
+
+#include "build-options.h"
+#include <glib/gi18n.h>
+#include <glade/glade-xml.h>
+#include <libanjuta/anjuta-debug.h>
+#include <string.h>
+
+#define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-build-basic-autotools-plugin.glade"
+
+typedef struct
+{
+	gchar* label;
+	gchar* options;
+} Options;
+
+const Options gcc[] = {
+	{N_("Default"), ""},
+	{N_("Debug"), "-g -O0"},
+	{N_("Profiling"), "-g -pg"},
+	{N_("Optimized"), "-O2"}
+};
+
+enum
+{
+	COLUMN_LABEL,
+	COLUMN_OPTIONS,
+	N_COLUMNS
+};
+
+static void 
+fill_options_combo (GtkComboBoxEntry* combo)
+{
+	GtkCellRenderer* renderer_label = gtk_cell_renderer_text_new ();
+	GtkCellRenderer* renderer_options = gtk_cell_renderer_text_new ();
+	
+	GtkListStore* store = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+	gint i;
+		
+	for (i = 0; i < G_N_ELEMENTS(gcc); i++)
+	{
+		GtkTreeIter iter;
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter, 
+												COLUMN_LABEL, gcc[i].label,
+												COLUMN_OPTIONS, gcc[i].options, -1);
+	}
+	gtk_combo_box_set_model (GTK_COMBO_BOX(combo), GTK_TREE_MODEL(store));
+	gtk_combo_box_entry_set_text_column (combo, 1);
+
+	gtk_cell_layout_clear (GTK_CELL_LAYOUT(combo));
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo), renderer_label, TRUE);
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo), renderer_options, FALSE);
+	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo), renderer_label,
+																 "text", COLUMN_LABEL);
+	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo), renderer_options,
+																 "text", COLUMN_OPTIONS);
+	g_object_set (renderer_label,
+								"style", PANGO_STYLE_ITALIC, NULL);
+}
+
+gboolean
+build_dialog_configure (GtkWindow* parent, const gchar* dialog_title,
+												GHashTable** build_options,
+												const gchar* default_args, gchar** args)
+{
+	GladeXML* gxml = glade_xml_new (GLADE_FILE, "configure_dialog", NULL);
+	GtkDialog* dialog = GTK_DIALOG (glade_xml_get_widget (gxml, "configure_dialog"));
+	GtkComboBoxEntry* combo
+		= GTK_COMBO_BOX_ENTRY (glade_xml_get_widget(gxml, "build_options_combo"));
+	GtkEntry* entry_args = GTK_ENTRY (glade_xml_get_widget (gxml, "configure_args_entry"));
+	
+	gtk_window_set_title (GTK_WINDOW(dialog), dialog_title);
+	
+	if (default_args)
+		gtk_entry_set_text (entry_args, default_args);
+	fill_options_combo(combo);
+	
+	int response = gtk_dialog_run (dialog);
+	if (response != GTK_RESPONSE_OK)
+	{
+		*build_options = NULL;
+		*args = NULL;
+		gtk_widget_destroy (GTK_WIDGET(dialog));
+		return FALSE;
+	}
+	else
+	{
+		GtkEntry* build_options_entry = GTK_ENTRY(gtk_bin_get_child (GTK_BIN(combo)));
+		const gchar* options = gtk_entry_get_text (build_options_entry);
+		*args = g_strdup (gtk_entry_get_text (entry_args));
+		*build_options = g_hash_table_new_full (g_str_hash, g_str_equal,
+																						NULL, g_free);
+		if (strlen(options))
+		{
+			/* set options for all languages */
+			g_hash_table_insert (*build_options,
+								 "CFLAGS", g_strdup(options));
+			g_hash_table_insert (*build_options,
+								 "CXXFLAGS", g_strdup(options));
+			g_hash_table_insert (*build_options,
+								 "JFLAGS", g_strdup(options));
+			g_hash_table_insert (*build_options,
+								 "FFLAGS", g_strdup(options));
+		}
+		gtk_widget_destroy (GTK_WIDGET(dialog));
+		return TRUE;
+	}
+}

Added: trunk/plugins/build-basic-autotools/build-options.h
==============================================================================
--- (empty file)
+++ trunk/plugins/build-basic-autotools/build-options.h	Tue Mar 11 13:36:44 2008
@@ -0,0 +1,35 @@
+/***************************************************************************
+ *            build-options.h
+ *
+ *  Sat Mar  1 20:47:23 2008
+ *  Copyright  2008  Johannes Schmid
+ *  <jhs gnome org>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+ 
+#ifndef BUILD_OPTIONS_H
+#define BUILD_OPTIONS_H
+
+#include <gtk/gtk.h>
+
+gboolean build_dialog_configure (GtkWindow* parent, const gchar* dialog_title,
+																 GHashTable** build_options,
+																 const gchar* default_args, gchar** args);
+
+
+#endif /* BUILD_OPTIONS_H */

Modified: trunk/plugins/language-support-cpp-java/anjuta-language-cpp-java.glade
==============================================================================
--- trunk/plugins/language-support-cpp-java/anjuta-language-cpp-java.glade	(original)
+++ trunk/plugins/language-support-cpp-java/anjuta-language-cpp-java.glade	Tue Mar 11 13:36:44 2008
@@ -290,6 +290,20 @@
                         <property name="position">3</property>
                       </packing>
                     </child>
+                    <child>
+                      <widget class="GtkCheckButton" id="preferences_toggle:bool:1:1:language.cpp.brace.autocompletion">
+                        <property name="visible">True</property>
+                        <property name="can_focus">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="border_width">5</property>
+                        <property name="label" translatable="yes">Enable smart brace completion</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
                   </widget>
                 </child>
                 <child>

Modified: trunk/plugins/language-support-cpp-java/cpp-java-utils.c
==============================================================================
--- trunk/plugins/language-support-cpp-java/cpp-java-utils.c	(original)
+++ trunk/plugins/language-support-cpp-java/cpp-java-utils.c	Tue Mar 11 13:36:44 2008
@@ -1,4 +1,4 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*-*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
     cpp-java-utils.c
     Copyright (C) 2000 Naba Kumar  <naba gnome org>

Modified: trunk/plugins/language-support-cpp-java/plugin.c
==============================================================================
--- trunk/plugins/language-support-cpp-java/plugin.c	(original)
+++ trunk/plugins/language-support-cpp-java/plugin.c	Tue Mar 11 13:36:44 2008
@@ -54,6 +54,7 @@
 #define PREF_INDENT_TAB_INDENTS "language.cpp.indent.tab.indents"
 #define PREF_INDENT_STATEMENT_SIZE "language.cpp.indent.statement.size"
 #define PREF_INDENT_BRACE_SIZE "language.cpp.indent.brace.size"
+#define PREF_BRACE_AUTOCOMPLETION "language.cpp.brace.autocompletion"
 
 #define TAB_SIZE (ianjuta_editor_get_tabsize (editor, NULL))
 
@@ -871,25 +872,26 @@
 												 NULL);
 
 		/* DEBUG_PRINT("point_ch = %c", point_ch); */
-		/* Check if we are inside a comment */
+		
+		/* Check for line comment comment */
 		if (!line_checked_for_comment && !isspace(point_ch))
 		{
 			gboolean comment = FALSE;
-			gboolean comment_end = FALSE;
 			IAnjutaIterable* new_iter = ianjuta_iterable_clone (iter, NULL);
 			do
 			{
 				gchar c;
 				c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (new_iter), 0,
 												  NULL);
-				if (!comment_end && iter_is_newline (new_iter, c))
+				if (iter_is_newline (new_iter, c))
 				{
 					line_checked_for_comment = TRUE;
 					break;
 				}
 				if (c == '/')
 				{
-					ianjuta_iterable_previous (new_iter, NULL);
+					if (!ianjuta_iterable_previous (new_iter, NULL))
+						break;
 					c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (new_iter), 0,
 													  NULL);
 					if (c == '/')
@@ -899,6 +901,31 @@
 						break;
 					}
 				}
+			} while (ianjuta_iterable_previous (new_iter, NULL));
+			if (comment)
+			{
+				ianjuta_iterable_set_position (iter,
+											   ianjuta_iterable_get_position (new_iter, NULL) - 1, 
+											   NULL);
+				g_object_unref (new_iter);
+				continue;
+			}
+			g_object_unref (new_iter);
+		}
+		/* Check if we are inside a comment */
+		if (point_ch == '/' || point_ch == '*')
+		{
+			gboolean comment = FALSE;
+			gboolean comment_end = FALSE;
+			IAnjutaIterable* new_iter = ianjuta_iterable_clone (iter, NULL);
+			do
+			{
+				gchar c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(new_iter),
+												  0, NULL);
+				if (!comment_end && iter_is_newline (new_iter, c))
+				{
+					break;
+				}
 				if (c == '*')
 				{
 					IAnjutaIterable* prev = ianjuta_iterable_clone (new_iter, NULL);
@@ -910,20 +937,31 @@
 					gchar next_c = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (next), 0,
 													  NULL);					
 					if (prev_c == '/')
-					{
+					{		 
 						/* starts comment */
 						comment = TRUE;
-						DEBUG_PRINT ("Starts comment");
 						if (!comment_end)
+						{
 							extra_indent++;
+							/* In the middle of a comment we can't know
+						     * if the statement is incomplete
+							 */
+							*incomplete_statement = -1;
+							/* ":" have to be ignored inside comments */
+							if (*colon_indent)
+							{
+								*colon_indent = FALSE;
+								extra_indent -= INDENT_SIZE;
+							}
+						}
 						g_object_unref (prev);
 						g_object_unref (next);
 						break;
+						
 					}
 					else if (next_c == '/')
 					{
-						/* ends comment */
-						DEBUG_PRINT ("Ends comment");
+						/* ends comment: */
 						comment_end = TRUE;
 						g_object_unref (prev);
 						g_object_unref (next);
@@ -1113,8 +1151,11 @@
 				*incomplete_statement = 1;
 		}
 	}
-	if (ianjuta_iterable_first (iter, NULL))
+	if (!line_indent && extra_indent)
+	{
+		DEBUG_PRINT ("Adding special indent");
 		line_indent += extra_indent;
+	}
 	g_object_unref (iter);
 	
 	return line_indent;
@@ -1287,74 +1328,145 @@
 	IAnjutaEditorAttribute attrib;
 	IAnjutaIterable *iter;
 	gboolean should_auto_indent = FALSE;
-	
-	/* Do nothing if automatic indentation is not enabled */
-	if (!anjuta_preferences_get_int (plugin->prefs, PREF_INDENT_AUTOMATIC))
-		return;
-	
-	/* DEBUG_PRINT ("Char added at position %d: '%c'", insert_pos, ch); */
-	
+	static GString *stack = NULL;
+
 	iter = ianjuta_iterable_clone (insert_pos, NULL);
 	
-	if (iter_is_newline (iter, ch))
-	{
-		skip_iter_to_newline_head (iter, ch);
-		/* All newline entries means enable indenting */
-		should_auto_indent = TRUE;
-	}
-	else if (ch == '{' || ch == '}' || ch == '#')
+	/* If autoindent is enabled*/
+	if (anjuta_preferences_get_int (plugin->prefs, PREF_INDENT_AUTOMATIC))
 	{
-		/* Indent only when it's the first non-white space char in the line */
-		
-		/* Don't bother if we are inside string */
-		attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter),
-													NULL);
-		if (attrib != IANJUTA_EDITOR_STRING)
+	
+		/* DEBUG_PRINT ("Char added at position %d: '%c'", insert_pos, ch); */	
+	
+		if (iter_is_newline (iter, ch))
 		{
-			/* Iterate backwards till the begining of the line and disable
-			 * indenting if any non-white space char is encountered
-			 */
-			
-			/* Begin by assuming it should be indented */
+			skip_iter_to_newline_head (iter, ch);
+			/* All newline entries means enable indenting */
 			should_auto_indent = TRUE;
-			
-			while (ianjuta_iterable_previous (iter, NULL))
+		}
+		else if (ch == '{' || ch == '}' || ch == '#')
+		{
+			/* Indent only when it's the first non-white space char in the line */
+		
+			/* Don't bother if we are inside string */
+			attrib = ianjuta_editor_cell_get_attribute (IANJUTA_EDITOR_CELL (iter),
+														NULL);
+			if (attrib != IANJUTA_EDITOR_STRING)
 			{
-				ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
-												   0, NULL);
+				/* Iterate backwards till the begining of the line and disable
+				 * indenting if any non-white space char is encountered
+				 */
+			
+				/* Begin by assuming it should be indented */
+				should_auto_indent = TRUE;
+			
+				while (ianjuta_iterable_previous (iter, NULL))
+				{
+					ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL (iter),
+													   0, NULL);
 				
-				//DEBUG_PRINT ("Looking at char '%c'", ch);
+					//DEBUG_PRINT ("Looking at char '%c'", ch);
 				
-				/* Break on begining of line (== end of previous line) */
-				if (iter_is_newline (iter, ch))
-				{
-					skip_iter_to_newline_head (iter, ch);
-					break;
-				}
-				/* If a non-white space char is encountered, disabled indenting */
-				if (!isspace (ch))
-				{
-					should_auto_indent = FALSE;
-					break;
+					/* Break on begining of line (== end of previous line) */
+					if (iter_is_newline (iter, ch))
+					{
+						skip_iter_to_newline_head (iter, ch);
+						break;
+					}
+					/* If a non-white space char is encountered, disabled indenting */
+					if (!isspace (ch))
+					{
+						should_auto_indent = FALSE;
+						break;
+					}
 				}
 			}
 		}
+		else if (ch == ':')
+		{
+			should_auto_indent = TRUE;
+		}
+		if (should_auto_indent)
+		{
+			gint insert_line;
+			gint line_indent;
+		
+			ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+			initialize_indentation_params (plugin);
+			insert_line = ianjuta_editor_get_lineno (editor, NULL);
+			line_indent = get_line_auto_indentation (plugin, editor, insert_line);
+			set_line_indentation (editor, insert_line, line_indent);
+			ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+		}
 	}
-	else if (ch == ':')
-	{
-		should_auto_indent = TRUE;
-	}
-	if (should_auto_indent)
+	
+	if (anjuta_preferences_get_int (plugin->prefs, PREF_BRACE_AUTOCOMPLETION))
 	{
-		gint insert_line;
-		gint line_indent;
+		if (!stack)
+			stack = g_string_new ("");
+	
+		if (ch == '[' || ch == '(')
+		{
+			ianjuta_iterable_next (iter, NULL);
 		
-		ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);
-		initialize_indentation_params (plugin);
-		insert_line = ianjuta_editor_get_lineno (editor, NULL);
-		line_indent = get_line_auto_indentation (plugin, editor, insert_line);
-		set_line_indentation (editor, insert_line, line_indent);
-		ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
+			switch (ch)
+			{
+				case '[': ianjuta_editor_insert (editor, iter,
+												 "]", 1, NULL);
+						  g_string_prepend_c (stack, ']');
+						  break;
+				case '(': ianjuta_editor_insert (editor, iter,
+												 ")", 1, NULL);
+						  g_string_prepend_c (stack, ')');
+						  break;
+				default: break;
+			}
+
+			ianjuta_iterable_previous (iter, NULL);
+			ianjuta_editor_goto_position (editor, iter, NULL);
+		}
+		else if (ch == ']' || ch == ')' || ch == '"')
+		{
+			gchar *str = stack->str;
+			gchar *next_char;
+			IAnjutaIterable *end;
+
+			/* First iter*/
+			ianjuta_iterable_next (iter, NULL);
+		
+			/*
+			 * If the character is " we have to decide if we need insert
+			 * another " or we have to skip the character
+			 */
+			if (ch == '"' && *str != '"')
+			{
+				ianjuta_editor_insert (editor, iter,
+									 "\"", 1, NULL);
+				g_string_prepend_c (stack, '"');
+			
+				ianjuta_iterable_previous (iter, NULL);
+				ianjuta_editor_goto_position (editor, iter, NULL);
+				g_object_unref (iter);
+				return;
+			}
+		
+			/* End iter*/
+			end = ianjuta_iterable_clone (iter, NULL);
+			ianjuta_iterable_next (end, NULL);
+		
+			next_char = ianjuta_editor_get_text (editor, iter, end, NULL);
+		
+			if (ch == *str && ch == *next_char)
+			{
+				g_string_erase (stack, 0, 1);
+				ianjuta_editor_erase (editor, iter, end, NULL);
+			}
+			else {
+				g_string_free (stack, TRUE);
+				stack = g_string_new ("");
+			}
+			g_object_unref (end);
+		}
 	}
 	g_object_unref (iter);
 }

Modified: trunk/plugins/sourceview/anjuta-view.c
==============================================================================
--- trunk/plugins/sourceview/anjuta-view.c	(original)
+++ trunk/plugins/sourceview/anjuta-view.c	Tue Mar 11 13:36:44 2008
@@ -752,7 +752,7 @@
       case GDK_Down:
       case GDK_Page_Up:
       case GDK_Page_Down:
-        gtk_widget_destroy (GTK_WIDGET(view->priv->sv->priv->assist_tip));
+        gtk_widget_destroy (GTK_WIDGET(assist_tip));
         break;
 		}
 	}
@@ -764,6 +764,18 @@
 {
 	AnjutaView* view = ANJUTA_VIEW(widget);
 	
+  /* If we have a calltip shown - hide it */
+  AssistTip* assist_tip = view->priv->sv->priv->assist_tip;
+  AssistWindow* assist_win = view->priv->sv->priv->assist_win;
+  if (assist_win)
+  {
+    gtk_widget_destroy (GTK_WIDGET (assist_win));
+  }
+	if (assist_tip)
+	{
+    gtk_widget_destroy (GTK_WIDGET (assist_tip));
+  }
+  
 	switch(event->button)
 	{
 		case 3: /* Right Button */

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Tue Mar 11 13:36:44 2008
@@ -80,6 +80,7 @@
 static void sourceview_instance_init(Sourceview *sv);
 static void sourceview_finalize(GObject *object);
 static void sourceview_dispose(GObject *object);
+
 static GObjectClass *parent_class = NULL;
 
 #if HAVE_TOOLTIP_API
@@ -125,10 +126,11 @@
 							Sourceview* sv)
 {
 	/* We only want ascii characters */
-	if (len > 1)
+	if (len > 1 || strlen(text) > 1)
 		return;
 	else
 	{
+		DEBUG_PRINT ("insert_text");
 		int offset = gtk_text_iter_get_offset (location);
 		SourceviewCell* cell = sourceview_cell_new (location, 
 													GTK_TEXT_VIEW(sv->priv->view));
@@ -423,6 +425,18 @@
 }
 
 static void 
+sourceview_adjustment_changed(GtkAdjustment* ad, Sourceview* sv)
+{
+	DEBUG_PRINT (__FUNCTION__);
+	/* Hide assistance windows when scrolling vertically */
+
+	if (sv->priv->assist_win)
+		gtk_widget_destroy (GTK_WIDGET (sv->priv->assist_win));
+	if (sv->priv->assist_tip)
+		gtk_widget_destroy (GTK_WIDGET (sv->priv->assist_tip));
+}
+
+static void 
 sourceview_instance_init(Sourceview* sv)
 {
 	sv->priv = g_slice_new0 (SourceviewPrivate);
@@ -432,7 +446,7 @@
 sourceview_class_init(SourceviewClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
+	
 	parent_class = g_type_class_peek_parent(klass);
 	object_class->dispose = sourceview_dispose;
 	object_class->finalize = sourceview_finalize;
@@ -580,6 +594,7 @@
 sourceview_new(const gchar* uri, const gchar* filename, AnjutaPlugin* plugin)
 {
 	AnjutaShell* shell;
+	GtkAdjustment* v_adj;
 	
 	Sourceview *sv = ANJUTA_SOURCEVIEW(g_object_new(ANJUTA_TYPE_SOURCEVIEW, NULL));
 	
@@ -628,6 +643,8 @@
 				      GTK_POLICY_AUTOMATIC);
 	gtk_container_add(GTK_CONTAINER(sv), GTK_WIDGET(sv->priv->view));
 	gtk_widget_show_all(GTK_WIDGET(sv));
+	v_adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sv));
+	g_signal_connect (v_adj, "value-changed", G_CALLBACK (sourceview_adjustment_changed), sv);
 	
 	if (uri != NULL && strlen(uri) > 0)
 	{

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Tue Mar 11 13:36:44 2008
@@ -25,6 +25,7 @@
 libanjuta/resources.c
 plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade
 plugins/build-basic-autotools/build-basic-autotools.c
+plugins/build-basic-autotools/build-options.c
 plugins/build-basic-autotools/executer.c
 plugins/class-inheritance/class-inherit.c
 plugins/class-inheritance/plugin.c



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