anjuta r4004 - in trunk: . libanjuta libanjuta/interfaces plugins plugins/build-basic-autotools plugins/scratchbox
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4004 - in trunk: . libanjuta libanjuta/interfaces plugins plugins/build-basic-autotools plugins/scratchbox
- Date: Thu, 12 Jun 2008 20:08:19 +0000 (UTC)
Author: sgranjoux
Date: Thu Jun 12 20:08:19 2008
New Revision: 4004
URL: http://svn.gnome.org/viewvc/anjuta?rev=4004&view=rev
Log:
* libanjuta/interfaces/libanjuta.idl,
libanjuta/anjuta-plugin-manager.c,
libanjuta/anjuta-plugin-manager.h:
Add new IAnjutaEnvironment interface
* plugins/build-basic-autotools/build-basic-autotools.c,
plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade:
Remove scratchbox 1 support from build plugin
Use new IAnjutaEnvironment interface
* (added) plugins/scratchbox/plugin.c,
(added) plugins/scratchbox/plugin.h,
(added) plugins/scratchbox/anjuta-scratchbox.plugin.in,
(added) plugins/scratchbox/anjuta-scratchbox.glade,
(added) plugins/scratchbox/anjuta-scratchbox-48.png,
(added) plugins/scratchbox/Makefile.am,
plugins/Makefile.am,
configure.in:
Add new scratchbox 1 plugin implementing IAnjutaEnvironment
Added:
trunk/plugins/scratchbox/
trunk/plugins/scratchbox/Makefile.am
trunk/plugins/scratchbox/anjuta-scratchbox-48.png (contents, props changed)
trunk/plugins/scratchbox/anjuta-scratchbox.glade
trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in
trunk/plugins/scratchbox/plugin.c (contents, props changed)
trunk/plugins/scratchbox/plugin.h (contents, props changed)
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libanjuta/anjuta-plugin-manager.c
trunk/libanjuta/anjuta-plugin-manager.h
trunk/libanjuta/interfaces/libanjuta.idl
trunk/plugins/Makefile.am
trunk/plugins/build-basic-autotools/anjuta-build-basic-autotools-plugin.glade
trunk/plugins/build-basic-autotools/build-basic-autotools.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Jun 12 20:08:19 2008
@@ -1185,6 +1185,7 @@
plugins/project-wizard/templates/sdl/po/Makefile
plugins/language-support-cpp-java/Makefile
plugins/run-program/Makefile
+plugins/scratchbox/Makefile
anjuta.desktop.in
manuals/Makefile
manuals/reference/Makefile
Modified: trunk/libanjuta/anjuta-plugin-manager.c
==============================================================================
--- trunk/libanjuta/anjuta-plugin-manager.c (original)
+++ trunk/libanjuta/anjuta-plugin-manager.c Thu Jun 12 20:08:19 2008
@@ -1363,6 +1363,55 @@
return NULL;
}
+static void
+on_is_active_plugins_foreach (gpointer key, gpointer data, gpointer user_data)
+{
+ AnjutaPluginHandle *handle = ANJUTA_PLUGIN_HANDLE (key);
+ gchar const **search_iface = (gchar const **)user_data;
+
+ if (*search_iface != NULL)
+ {
+ GList *interfaces;
+ GList *found;
+
+ interfaces = anjuta_plugin_handle_get_interfaces (handle);
+
+ for (found = g_list_first (interfaces); found != NULL; found = g_list_next (found))
+ {
+ }
+
+ found = g_list_find_custom (interfaces, *search_iface, (GCompareFunc)strcmp);
+
+ if (found != NULL) *search_iface = NULL;
+ }
+}
+
+/**
+ * anjuta_plugin_manager_is_active_plugin:
+ * @plugin_manager: A #AnjutaPluginManager object
+ * @iface_name: The interface implemented by the object to be found
+ *
+ * Searches if a currently loaded plugins implements
+ * the given interface.
+ *
+ * Return value: True is the plugin is currently loaded.
+ */
+
+gboolean
+anjuta_plugin_manager_is_active_plugin (AnjutaPluginManager *plugin_manager,
+ const gchar *iface_name)
+{
+ const gchar *search_iface = iface_name;
+
+ g_return_val_if_fail (ANJUTA_IS_PLUGIN_MANAGER (plugin_manager), FALSE);
+
+ g_hash_table_foreach (plugin_manager->priv->activated_plugins,
+ on_is_active_plugins_foreach,
+ &search_iface);
+
+ return search_iface == NULL;
+}
+
/**
* anjuta_plugin_manager_get_plugin:
* @plugin_manager: A #AnjutaPluginManager object
Modified: trunk/libanjuta/anjuta-plugin-manager.h
==============================================================================
--- trunk/libanjuta/anjuta-plugin-manager.h (original)
+++ trunk/libanjuta/anjuta-plugin-manager.h Thu Jun 12 20:08:19 2008
@@ -72,6 +72,8 @@
GList* plugin_search_paths);
/* Plugin activation, deactivation and retrival */
+gboolean anjuta_plugin_manager_is_active_plugin (AnjutaPluginManager *plugin_manager,
+ const gchar *iface_name);
GObject* anjuta_plugin_manager_get_plugin (AnjutaPluginManager *plugin_manager,
const gchar *iface_name);
GObject* anjuta_plugin_manager_get_plugin_by_id (AnjutaPluginManager *plugin_manager,
Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl (original)
+++ trunk/libanjuta/interfaces/libanjuta.idl Thu Jun 12 20:08:19 2008
@@ -623,6 +623,51 @@
}
/**
+ * SECTION:ianjuta-environment
+ * @title: IAnjutaEnvironment
+ * @short_description: Implemented by plugins doing cross compilation
+ * @see_also:
+ * @stability: Unstable
+ * @include: libanjuta/interfaces/ianjuta-environment.h
+ *
+ */
+interface IAnjutaEnvironment
+{
+ /**
+ * ianjuta_environment_override:
+ * @obj: Self
+ * @dirp: a pointer on the working directory
+ * @argvp: a pointer on a NULL terminated string array
+ * containing the command name in argv[0] and all
+ * its argument
+ * @envp: a pointer on a NULL terminated string array
+ * containing all additional environment variable
+ * used by the command
+ * @err: Error propagation and reporting.
+ *
+ * Override a command to work in another build environment
+ *
+ * Returns: FALSE if there is an error.
+ */
+ gboolean override (gchar **dir, gchar ***argv, gchar ***envp);
+
+ /**
+ * ianjuta_environment_get_real_directory:
+ * @obj: Self
+ * @dir: A directory path in the environment
+ * @err: Error propagation and reporting.
+ *
+ * Convert a directory in the environment to a directory outside.
+ * It is useful when the environment use chroot. Take care that
+ * the input directory string is freed using g_free but and you need to
+ * free the output string when not needed.
+ *
+ * Returns: The directory path outside the environment
+ */
+ gchar* get_real_directory (gchar *dir);
+}
+
+/**
* SECTION:ianjuta-buildable
* @title: IAnjutaBuildable
* @short_description: Implemented by plugins that can build
Modified: trunk/plugins/Makefile.am
==============================================================================
--- trunk/plugins/Makefile.am (original)
+++ trunk/plugins/Makefile.am Thu Jun 12 20:08:19 2008
@@ -33,7 +33,8 @@
symbol-db \
symbol-browser \
sourceview \
- run-program
+ run-program \
+ scratchbox
# indent
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 Thu Jun 12 20:08:19 2008
@@ -213,94 +213,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkFrame" id="sb_frame">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <child>
- <widget class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <widget class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">12</property>
- <child>
- <widget class="GtkCheckButton" id="preferences_toggle:bool:0:0:build.use_scratchbox">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Use scratchbox</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry" id="preferences_entry:text:/scratchbox:0:build.scratchbox.path">
- <property name="visible">True</property>
- <property name="editable">False</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>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="xpad">5</property>
- <property name="label" translatable="yes">Path:</property>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="ypad">5</property>
- <property name="label" translatable="yes"><b>Scratchbox Options</b></property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">12</property>
- <property name="position">3</property>
- </packing>
- </child>
</widget>
<packing>
<property name="expand">False</property>
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 Thu Jun 12 20:08:19 2008
@@ -26,10 +26,12 @@
#include <libanjuta/anjuta-launcher.h>
#include <libanjuta/anjuta-utils.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-plugin-manager.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-file-loader.h>
#include <libanjuta/interfaces/ianjuta-buildable.h>
#include <libanjuta/interfaces/ianjuta-builder.h>
+#include <libanjuta/interfaces/ianjuta-environment.h>
#include <libanjuta/interfaces/ianjuta-message-manager.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
#include <libanjuta/interfaces/ianjuta-file-savable.h>
@@ -48,13 +50,9 @@
#define PREF_INDICATORS_AUTOMATIC "indicators.automatic"
#define PREF_INSTALL_ROOT "build.install.root"
#define PREF_INSTALL_ROOT_COMMAND "build.install.root.command"
-#define PREF_USE_SB "build.use_scratchbox"
-#define PREF_SB_PATH "build.scratchbox.path"
#define CHECK_BUTTON "preferences_toggle:bool:0:0:build.install.root"
#define ENTRY "preferences_entry:text:sudo:0:build.install.root.command"
-#define SB_CHECK "preferences_toggle:bool:0:0:build.use_scratchbox"
-#define SB_ENTRY "preferences_entry:text:/scratchbox:0:build.scratchbox.path"
#define DEFAULT_COMMAND_COMPILE "make"
#define DEFAULT_COMMAND_BUILD "make"
@@ -113,6 +111,9 @@
/* Editors in which indicators have been updated */
GHashTable *indicators_updated_editors;
+
+ /* Environment */
+ IAnjutaEnvironment *environment;
} BuildContext;
/* Declarations */
@@ -146,12 +147,6 @@
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button)));
}
-static void on_sb_check_toggled(GtkWidget* toggle_button, GtkWidget* entry)
-{
- gtk_widget_set_sensitive(entry,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button)));
-}
-
static gchar*
get_root_install_command(BasicAutotoolsPlugin *bplugin)
{
@@ -312,6 +307,12 @@
context->launcher = NULL;
}
+ if (context->environment)
+ {
+ g_object_unref (context->environment);
+ context->environment = NULL;
+ }
+
g_free (context->command);
context->command = NULL;
@@ -653,26 +654,6 @@
return FALSE;
}
-static gchar* get_real_directory(BuildContext* context, gchar* dir)
-{
- AnjutaPreferences* prefs = anjuta_shell_get_preferences (context->plugin->shell, NULL);
- gchar* real_dir = dir;
- if (anjuta_preferences_get_int (prefs, PREF_USE_SB))
- {
- gchar* username = getenv("USERNAME");
- if (!username || strlen(username) == 0)
- username = getenv("USER");
- if (!username || strlen(username) == 0)
- return real_dir;
-
- const gchar* sb_dir = anjuta_preferences_get(prefs, PREF_SB_PATH);
- real_dir = g_strdup_printf("%s/users/%s%s", sb_dir, username, dir);
- g_free(dir);
- DEBUG_PRINT("sb_dir = %s", real_dir);
- }
- return real_dir;
-}
-
static void
on_build_mesg_format (IAnjutaMessageView *view, const gchar *one_line,
BuildContext *context)
@@ -715,7 +696,8 @@
gchar *summary;
dir = g_match_info_fetch (match_info, 2);
- dir = get_real_directory(context, dir);
+ dir = context->environment ? ianjuta_environment_get_real_directory(context->environment, dir, NULL)
+ : dir;
build_context_push_dir (context, "default", dir);
summary = g_strdup_printf(_("Entering: %s"), dir);
ianjuta_message_view_append (view, IANJUTA_MESSAGE_VIEW_TYPE_INFO,
@@ -750,7 +732,8 @@
gchar *summary;
dir = g_match_info_fetch (match_info, 2);
- dir = get_real_directory(context, dir);
+ dir = context->environment ? ianjuta_environment_get_real_directory(context->environment, dir, NULL)
+ : dir;
build_context_pop_dir (context, "default", dir);
summary = g_strdup_printf(_("Leaving: %s"), dir);
ianjuta_message_view_append (view, IANJUTA_MESSAGE_VIEW_TYPE_INFO,
@@ -1083,6 +1066,7 @@
IAnjutaBuilderCallback callback, gpointer user_data)
{
BuildContext *context = NULL;
+ AnjutaPluginManager *plugin_manager;
if (with_view)
{
@@ -1096,6 +1080,25 @@
context->plugin = ANJUTA_PLUGIN(plugin);
}
+ plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (plugin)->shell, NULL);
+
+ if (context->environment != NULL)
+ {
+ g_object_unref (context->environment);
+ }
+ if (anjuta_plugin_manager_is_active_plugin (plugin_manager, "IAnjutaEnvironment"))
+ {
+ IAnjutaEnvironment *env = IANJUTA_ENVIRONMENT (anjuta_shell_get_object (ANJUTA_PLUGIN (plugin)->shell,
+ "IAnjutaEnvironment", NULL));
+
+ g_object_ref (env);
+ context->environment = env;
+ }
+ else
+ {
+ context->environment = NULL;
+ }
+
context->callback = callback;
context->user_data = user_data;
context->command = g_strdup (command);
@@ -1126,12 +1129,12 @@
}
}
-static void build_set_env (gpointer key, gpointer value, gpointer user_data)
+static void add_env_var (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);
+ gchar ***var = (gchar ***)user_data;
+
+ **var = g_strconcat (key, "=", value, NULL);
+ *var = (*var)++;
}
static BuildContext*
@@ -1142,33 +1145,60 @@
GError **err)
{
AnjutaPlugin* plugin = ANJUTA_PLUGIN(bplugin);
- AnjutaPreferences* prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
+ gchar **argv;
+ gchar **envv;
+ gchar **var;
+ gchar *real_dir;
BuildContext *context;
- gchar* real_command;
g_return_val_if_fail (command != NULL, NULL);
- if (save_file)
- save_all_files (ANJUTA_PLUGIN (plugin));
-
- context = build_get_context (bplugin, dir, with_view, command, callback, user_data);
-
- if (anjuta_preferences_get_int (prefs , PREF_USE_SB))
+ /* Store args and environment variables as string array */
+ if (!g_shell_parse_argv (command, NULL, &argv, NULL))
+ return NULL;
+
+ if (env)
{
- const gchar* sb_path = anjuta_preferences_get(prefs, PREF_SB_PATH);
- /* we need to skip the /scratchbox/users part, maybe could be done more clever */
- const gchar* real_dir = strstr(dir, "/home");
- real_command = g_strdup_printf("%s/login -d %s \"%s\"", sb_path,
- real_dir, command);
+ gchar **var;
+
+ envv = g_new0 (gchar*, g_hash_table_size (env) + 1);
+
+ var = envv;
+ g_hash_table_foreach (env, add_env_var, &var);
}
else
{
- real_command = g_strdup(command);
+ envv = NULL;
}
- if (env)
+ real_dir = g_strdup (dir);
+
+ if (save_file)
+ save_all_files (ANJUTA_PLUGIN (plugin));
+
+ context = build_get_context (bplugin, dir, with_view, command, callback, user_data);
+
+ if (context->environment)
+ {
+ if (!ianjuta_environment_override (context->environment, &real_dir, &argv, &envv, NULL))
+ {
+ g_object_unref (context->environment);
+ context->environment = NULL;
+ }
+ }
+
+ /* Set environment variable */
+ if (envv)
{
- g_hash_table_foreach (env, build_set_env, context->launcher);
+ for (var = envv; *var != NULL; var++)
+ {
+ gchar *val = strchr (*var, '=');
+
+ if (val != NULL) *val++ = '\0';
+
+ anjuta_launcher_set_env (context->launcher, *var, val);
+ }
+ g_strfreev (envv);
}
if (context->message_view)
@@ -1180,15 +1210,15 @@
ianjuta_message_view_buffer_append (context->message_view, command, NULL);
ianjuta_message_view_buffer_append (context->message_view, "\n", NULL);
- anjuta_launcher_execute (context->launcher, real_command,
+ anjuta_launcher_execute_v (context->launcher, argv,
on_build_mesg_arrived, context);
}
else
{
- anjuta_launcher_execute (context->launcher, real_command,
+ anjuta_launcher_execute_v (context->launcher, argv,
NULL, NULL);
}
- g_free(real_command);
+ g_strfreev (argv);
return context;
}
@@ -2686,20 +2716,14 @@
ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
{
GtkWidget *root_check;
- GtkWidget *sb_check;
GtkWidget *entry;
- GtkWidget *sb_entry;
/* Create the preferences page */
gxml = glade_xml_new (GLADE_FILE, "preferences_dialog_build", NULL);
root_check = glade_xml_get_widget(gxml, CHECK_BUTTON);
- sb_check = glade_xml_get_widget(gxml, SB_CHECK);
entry = glade_xml_get_widget(gxml, ENTRY);
- sb_entry = glade_xml_get_widget(gxml, SB_ENTRY);
g_signal_connect(G_OBJECT(root_check), "toggled", G_CALLBACK(on_root_check_toggled), entry);
- g_signal_connect(G_OBJECT(sb_check), "toggled", G_CALLBACK(on_sb_check_toggled), sb_entry);
-
anjuta_preferences_add_page (prefs, gxml, "Build", _("Build Autotools"), ICON_FILE);
}
@@ -2708,18 +2732,12 @@
ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
{
GtkWidget *root_check;
- GtkWidget *sb_check;
GtkWidget *entry;
- GtkWidget *sb_entry;
root_check = glade_xml_get_widget(gxml, CHECK_BUTTON);
- sb_check = glade_xml_get_widget(gxml, SB_CHECK);
entry = glade_xml_get_widget(gxml, ENTRY);
- sb_entry = glade_xml_get_widget(gxml, SB_ENTRY);
g_signal_handlers_disconnect_by_func(G_OBJECT(root_check),
G_CALLBACK(on_root_check_toggled), entry);
- g_signal_handlers_disconnect_by_func(G_OBJECT(root_check),
- G_CALLBACK(on_sb_check_toggled), sb_entry);
anjuta_preferences_remove_page(prefs, _("Build Autotools"));
Added: trunk/plugins/scratchbox/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/plugins/scratchbox/Makefile.am Thu Jun 12 20:08:19 2008
@@ -0,0 +1,43 @@
+# Plugin glade file
+anjuta_gladedir = $(anjuta_glade_dir)
+anjuta_glade_DATA = anjuta-scratchbox.glade
+
+# Plugin Icon file
+anjuta_pixmapsdir = $(anjuta_image_dir)
+anjuta_pixmaps_DATA = \
+ anjuta-scratchbox-48.png
+
+# Plugin description file
+plugin_in_files = anjuta-scratchbox.plugin.in
+%.plugin: %.plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+anjuta_plugindir = $(anjuta_plugin_dir)
+anjuta_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
+
+# Where to install the plugin
+plugindir = $(anjuta_plugin_dir)
+plugin_LTLIBRARIES = libanjuta-scratchbox.la
+
+# Include paths
+AM_CPPFLAGS = \
+ $(WARN_CFLAGS) \
+ $(DEPRECATED_FLAGS) \
+ $(LIBANJUTA_CFLAGS)
+
+libanjuta_scratchbox_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
+
+# Plugin dependencies
+libanjuta_scratchbox_la_LIBADD = \
+ $(GLADE_LIBS) \
+ $(GNOME_LIBS) \
+ $(LIBANJUTA_LIBS)
+
+# Plugin sources
+libanjuta_scratchbox_la_SOURCES = \
+ plugin.c
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ $(anjuta_pixmaps_DATA) \
+ $(anjuta_plugin_DATA) \
+ $(anjuta_glade_DATA)
Added: trunk/plugins/scratchbox/anjuta-scratchbox-48.png
==============================================================================
Binary file. No diff available.
Added: trunk/plugins/scratchbox/anjuta-scratchbox.glade
==============================================================================
--- (empty file)
+++ trunk/plugins/scratchbox/anjuta-scratchbox.glade Thu Jun 12 20:08:19 2008
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkWindow" id="preferences_dialog_scratchbox">
+ <property name="title" translatable="yes">window1</property>
+ <child>
+ <widget class="GtkFrame" id="Scratchbox">
+ <property name="visible">True</property>
+ <property name="border_width">10</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <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">SÃlectionner un dossier</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label106">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes"><b>Scratchbox Options</b>
+</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Added: trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in
==============================================================================
--- (empty file)
+++ trunk/plugins/scratchbox/anjuta-scratchbox.plugin.in Thu Jun 12 20:08:19 2008
@@ -0,0 +1,6 @@
+[Anjuta Plugin]
+_Name=Scratchbox
+_Description=Change build commands to use scratchbox 1
+Location=anjuta-scratchbox:ScratchboxPlugin
+Icon=anjuta-scratchbox-48.png
+Interfaces=IAnjutaEnvironment
Added: trunk/plugins/scratchbox/plugin.c
==============================================================================
--- (empty file)
+++ trunk/plugins/scratchbox/plugin.c Thu Jun 12 20:08:19 2008
@@ -0,0 +1,280 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.c
+ Copyright (C) 2008 SÃbastien Granjoux
+
+ 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 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
+*/
+
+/*
+ * Plugins functions
+ *
+ *---------------------------------------------------------------------------*/
+
+#include <config.h>
+
+#include "plugin.h"
+
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-environment.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+
+/* Constantes
+ *---------------------------------------------------------------------------*/
+
+#define ICON_FILE "anjuta-scratchbox-48.png"
+#define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-scratchbox.glade"
+
+#define SB_ENTRY "preferences_folder:text:/scratchbox:0:build.scratchbox.path"
+
+#define PREF_SB_PATH "build.scratchbox.path"
+
+/* Type defintions
+ *---------------------------------------------------------------------------*/
+
+struct _ScratchboxPluginClass
+{
+ AnjutaPluginClass parent_class;
+};
+
+struct _ScratchboxPlugin
+{
+ AnjutaPlugin parent;
+
+ gchar *user_dir;
+};
+
+
+/* Callback for saving session
+ *---------------------------------------------------------------------------*/
+
+static void
+on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, ScratchboxPlugin *self)
+{
+}
+
+static void on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, ScratchboxPlugin *self)
+{
+}
+
+/* Callbacks
+ *---------------------------------------------------------------------------*/
+
+/* Actions table
+ *---------------------------------------------------------------------------*/
+
+/* AnjutaPlugin functions
+ *---------------------------------------------------------------------------*/
+
+static gboolean
+scratchbox_plugin_activate (AnjutaPlugin *plugin)
+{
+ ScratchboxPlugin *self = ANJUTA_PLUGIN_SCRATCHBOX (plugin);
+
+ DEBUG_PRINT ("Scratchbox 1 Plugin: Activating plugin...");
+
+ /* 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_CALLBACK (on_session_load), self);
+
+ return TRUE;
+}
+
+static gboolean
+scratchbox_plugin_deactivate (AnjutaPlugin *plugin)
+{
+ ScratchboxPlugin *self = ANJUTA_PLUGIN_SCRATCHBOX (plugin);
+
+ DEBUG_PRINT ("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);
+
+ return TRUE;
+}
+
+/* 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;
+ 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 */
+ gchar **new_argv;
+ gsize len_argv = g_strv_length (*argvp);
+
+ /* 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);
+
+ g_free (*argvp);
+ *argvp = new_argv;
+ }
+ g_free (sb_dir);
+
+ return TRUE;
+}
+
+static gchar*
+ienvironment_get_real_directory (IAnjutaEnvironment* environment, gchar *dir, GError** err)
+{
+ ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (environment);
+
+ if (plugin->user_dir)
+ {
+ gchar *real_dir;
+
+ real_dir = g_strconcat(plugin->user_dir, dir, NULL);
+ g_free (dir);
+
+ return real_dir;
+ }
+ else
+ {
+ return dir;
+ }
+}
+
+static void
+ienvironment_iface_init(IAnjutaEnvironmentIface* iface)
+{
+ iface->override = ienvironment_override;
+ iface->get_real_directory = ienvironment_get_real_directory;
+}
+
+/* IAnjutaPreferences implementation
+ *---------------------------------------------------------------------------*/
+
+static GladeXML *gxml;
+
+static void
+ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
+{
+ GtkWidget *sb_entry;
+
+ /* Create the preferences page */
+ gxml = glade_xml_new (GLADE_FILE, "preferences_dialog_scratchbox", NULL);
+ sb_entry = glade_xml_get_widget(gxml, SB_ENTRY);
+
+ anjuta_preferences_add_page (prefs, gxml, "Scratchbox", _("Scratchbox"), ICON_FILE);
+}
+
+static void
+ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
+{
+ GtkWidget *sb_entry;
+
+ sb_entry = glade_xml_get_widget(gxml, SB_ENTRY);
+
+ anjuta_preferences_remove_page(prefs, _("Scratchbox"));
+
+ g_object_unref (gxml);
+}
+
+static void
+ipreferences_iface_init(IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+/* GObject functions
+ *---------------------------------------------------------------------------*/
+
+/* Used in dispose and finalize */
+static gpointer parent_class;
+
+static void
+scratchbox_plugin_instance_init (GObject *obj)
+{
+ ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (obj);
+
+ plugin->user_dir = NULL;
+}
+
+/* dispose is used to unref object created with instance_init */
+
+static void
+scratchbox_plugin_dispose (GObject *obj)
+{
+ ScratchboxPlugin *plugin = ANJUTA_PLUGIN_SCRATCHBOX (obj);
+
+ /* Warning this function could be called several times */
+
+ if (plugin->user_dir)
+ {
+ g_free (plugin->user_dir);
+ plugin->user_dir = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+scratchbox_plugin_finalize (GObject *obj)
+{
+ /*ScratchboxPlugin *self = ANJUTA_PLUGIN_SCRATCHBOX (obj);*/
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+/* finalize used to free object created with instance init is not used */
+
+static void
+scratchbox_plugin_class_init (GObjectClass *klass)
+{
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ plugin_class->activate = scratchbox_plugin_activate;
+ plugin_class->deactivate = scratchbox_plugin_deactivate;
+ klass->dispose = scratchbox_plugin_dispose;
+ klass->finalize = scratchbox_plugin_finalize;
+}
+
+/* AnjutaPlugin declaration
+ *---------------------------------------------------------------------------*/
+
+ANJUTA_PLUGIN_BEGIN (ScratchboxPlugin, scratchbox_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE (ienvironment, IANJUTA_TYPE_ENVIRONMENT);
+ANJUTA_PLUGIN_ADD_INTERFACE (ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (ScratchboxPlugin, scratchbox_plugin);
+
+/* Public functions
+*---------------------------------------------------------------------------*/
+
Added: trunk/plugins/scratchbox/plugin.h
==============================================================================
--- (empty file)
+++ trunk/plugins/scratchbox/plugin.h Thu Jun 12 20:08:19 2008
@@ -0,0 +1,37 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ plugin.h
+ Copyright (C) 2008 SÃbastien Granjoux
+
+ 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 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 _PLUGIN_H_
+#define _PLUGIN_H_
+
+#include <libanjuta/anjuta-plugin.h>
+
+extern GType scratchbox_plugin_get_type (GTypeModule *module);
+#define ANJUTA_TYPE_PLUGIN_SCRATCHBOX (scratchbox_plugin_get_type (NULL))
+#define ANJUTA_PLUGIN_SCRATCHBOX(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN_SCRATCHBOX, ScratchboxPlugin))
+#define ANJUTA_PLUGIN_SCRATCHBOX_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ANJUTA_TYPE_PLUGIN_SCRATCHBOX, ScratchboxPluginClass))
+#define ANJUTA_IS_PLUGIN_SCRATCHBOX(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN_SCRATCHBOX))
+#define ANJUTA_IS_PLUGIN_SCRATCHBOX_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN_SCRATCHBOX))
+#define ANJUTA_PLUGIN_SCRATCHBOX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN_SCRATCHBOX, ScratchboxPluginClass))
+
+typedef struct _ScratchboxPlugin ScratchboxPlugin;
+typedef struct _ScratchboxPluginClass ScratchboxPluginClass;
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]