Re: [Planner Dev] Planner 0.12 Export as Planner v0.11 feature.





Updated patch for this feature. I think I've got it right
this time. Also added the missing POTFILES.in entries.

Files go into usual places.  Diff is agsint CVS as of
18th June so should build OK.

Rgds,
Lincoln.

Richard Hult wrote:
On ons, 2004-06-02 at 08:56 +0100, lincoln phipps openmutual net wrote:

All ,
	attached is the following,


Nice, thanks!

diff -u -B -b -p -r1.5 main-window.ui
--- a/data/ui/main-window.ui    17 Apr 2004 15:02:27 -0000      1.5
+++ b/data/ui/main-window.ui    2 Jun 2004 07:41:35 -0000
@@ -32,7 +32,10 @@
       <separator/>
       <menuitem    name="FileSave"         verb=""  accel="*Control*s"/

       <menuitem    name="FileSaveAs"       verb=""/>
-      <placeholder name="Export placeholder" delimit="top"/>
+      <submenu    name="Export" _label="E_xport...">
+      <placeholder name="Export HTML placeholder" delimit="top"/>
+      <placeholder name="Export XML Planner placeholder" delimit="top"/

+      </submenu>
       <separator/>
       <menuitem    name="FilePrint"        verb=""  accel="*Control*p"/

       <menuitem    name="FilePrintPreview" verb=""/>


This is not entirely correct. The placeholder was right before, and
should be used to inject menu items into, something like:

   <submenu    name="Export" _label="E_xport...">
       <placeholder name="Export placeholder" delimit="top"/>
   </submenu>

and then the new ui file just does the same as the HTML export one does.
That should put both menu items in the export submenu.

/Richard

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>

<glade-interface>
<requires lib="gnome"/>

<widget class="GtkDialog" id="xml_planner_dialog">
  <property name="border_width">5</property>
  <property name="title" translatable="yes">Export to XML Planner</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
  <property name="has_separator">False</property>

  <child internal-child="vbox">
    <widget class="GtkVBox" id="dialog-vbox3">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">2</property>

      <child internal-child="action_area">
	<widget class="GtkHButtonBox" id="dialog-action_area4">
	  <property name="visible">True</property>
	  <property name="layout_style">GTK_BUTTONBOX_END</property>

	  <child>
	    <widget class="GtkButton" id="cancel_button">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-cancel</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="focus_on_click">True</property>
	      <property name="response_id">-6</property>
	    </widget>
	  </child>

	  <child>
	    <widget class="GtkButton" id="ok_button">
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-save</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="focus_on_click">True</property>
	      <property name="response_id">-5</property>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">True</property>
	  <property name="pack_type">GTK_PACK_END</property>
	</packing>
      </child>

      <child>
	<widget class="GtkVBox" id="vbox128">
	  <property name="border_width">5</property>
	  <property name="visible">True</property>
	  <property name="homogeneous">False</property>
	  <property name="spacing">4</property>

	  <child>
	    <widget class="GtkLabel" id="label254">
	      <property name="visible">True</property>
	      <property name="label" translatable="yes">&lt;b&gt;Save to file&lt;/b&gt;</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">True</property>
	      <property name="justify">GTK_JUSTIFY_LEFT</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">False</property>
	      <property name="fill">False</property>
	    </packing>
	  </child>

	  <child>
	    <widget class="GtkHBox" id="hbox119">
	      <property name="visible">True</property>
	      <property name="homogeneous">False</property>
	      <property name="spacing">0</property>

	      <child>
		<widget class="GtkLabel" id="label253">
		  <property name="visible">True</property>
		  <property name="label" translatable="yes">    </property>
		  <property name="use_underline">False</property>
		  <property name="use_markup">False</property>
		  <property name="justify">GTK_JUSTIFY_LEFT</property>
		  <property name="wrap">False</property>
		  <property name="selectable">False</property>
		  <property name="xalign">0.5</property>
		  <property name="yalign">0.5</property>
		  <property name="xpad">0</property>
		  <property name="ypad">0</property>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">False</property>
		  <property name="fill">False</property>
		</packing>
	      </child>

	      <child>
		<widget class="GtkVBox" id="vbox129">
		  <property name="visible">True</property>
		  <property name="homogeneous">False</property>
		  <property name="spacing">0</property>

		  <child>
		    <widget class="GtkHBox" id="hbox120">
		      <property name="visible">True</property>
		      <property name="homogeneous">False</property>
		      <property name="spacing">0</property>

		      <child>
			<widget class="GnomeFileEntry" id="local_fileentry">
			  <property name="border_width">2</property>
			  <property name="visible">True</property>
			  <property name="history_id">mg-xml-planner-plugin-file</property>
			  <property name="max_saved">10</property>
			  <property name="directory_entry">False</property>
			  <property name="modal">False</property>
			  <property name="use_filechooser">False</property>

			  <child internal-child="entry">
			    <widget class="GtkEntry" id="combo-entry3">
			      <property name="visible">True</property>
			      <property name="can_focus">True</property>
			      <property name="editable">True</property>
			      <property name="visibility">True</property>
			      <property name="max_length">0</property>
			      <property name="text" translatable="yes"></property>
			      <property name="has_frame">True</property>
			      <property name="invisible_char" translatable="yes">*</property>
			      <property name="activates_default">False</property>
			    </widget>
			  </child>
			</widget>
			<packing>
			  <property name="padding">0</property>
			  <property name="expand">True</property>
			  <property name="fill">True</property>
			</packing>
		      </child>
		    </widget>
		    <packing>
		      <property name="padding">0</property>
		      <property name="expand">True</property>
		      <property name="fill">True</property>
		    </packing>
		  </child>

		  <child>
		    <widget class="GtkTable" id="table9">
		      <property name="n_rows">2</property>
		      <property name="n_columns">2</property>
		      <property name="homogeneous">False</property>
		      <property name="row_spacing">6</property>
		      <property name="column_spacing">12</property>

		      <child>
			<widget class="GtkRadioButton" id="local_radiobutton">
			  <property name="visible">True</property>
			  <property name="can_focus">True</property>
			  <property name="label" translatable="yes">Local file:</property>
			  <property name="use_underline">True</property>
			  <property name="relief">GTK_RELIEF_NORMAL</property>
			  <property name="focus_on_click">True</property>
			  <property name="active">True</property>
			  <property name="inconsistent">False</property>
			  <property name="draw_indicator">True</property>
			</widget>
			<packing>
			  <property name="left_attach">0</property>
			  <property name="right_attach">1</property>
			  <property name="top_attach">0</property>
			  <property name="bottom_attach">1</property>
			  <property name="x_options">fill</property>
			  <property name="y_options"></property>
			</packing>
		      </child>

		      <child>
			<widget class="GtkRadioButton" id="server_radiobutton">
			  <property name="visible">True</property>
			  <property name="can_focus">True</property>
			  <property name="label" translatable="yes">Web location:</property>
			  <property name="use_underline">True</property>
			  <property name="relief">GTK_RELIEF_NORMAL</property>
			  <property name="focus_on_click">True</property>
			  <property name="active">False</property>
			  <property name="inconsistent">False</property>
			  <property name="draw_indicator">True</property>
			  <property name="group">local_radiobutton</property>
			</widget>
			<packing>
			  <property name="left_attach">0</property>
			  <property name="right_attach">1</property>
			  <property name="top_attach">1</property>
			  <property name="bottom_attach">2</property>
			  <property name="x_options">fill</property>
			  <property name="y_options"></property>
			</packing>
		      </child>

		      <child>
			<widget class="GnomeFileEntry" id="foo_local_fileentry">
			  <property name="visible">True</property>
			  <property name="history_id">mg-xml-planner-plugin-file</property>
			  <property name="max_saved">10</property>
			  <property name="browse_dialog_title" translatable="yes">Save to Planner XML File</property>
			  <property name="directory_entry">False</property>
			  <property name="modal">False</property>
			  <property name="use_filechooser">False</property>

			  <child internal-child="entry">
			    <widget class="GtkEntry" id="combo-entry1">
			      <property name="visible">True</property>
			      <property name="can_focus">True</property>
			      <property name="editable">True</property>
			      <property name="visibility">True</property>
			      <property name="max_length">0</property>
			      <property name="text" translatable="yes"></property>
			      <property name="has_frame">True</property>
			      <property name="invisible_char" translatable="yes">*</property>
			      <property name="activates_default">False</property>
			    </widget>
			  </child>
			</widget>
			<packing>
			  <property name="left_attach">1</property>
			  <property name="right_attach">2</property>
			  <property name="top_attach">0</property>
			  <property name="bottom_attach">1</property>
			  <property name="y_options"></property>
			</packing>
		      </child>

		      <child>
			<widget class="GnomeEntry" id="server_entry">
			  <property name="visible">True</property>
			  <property name="sensitive">False</property>
			  <property name="max_saved">10</property>

			  <child internal-child="entry">
			    <widget class="GtkEntry" id="combo-entry2">
			      <property name="visible">True</property>
			      <property name="can_focus">True</property>
			      <property name="editable">True</property>
			      <property name="visibility">True</property>
			      <property name="max_length">0</property>
			      <property name="text" translatable="yes"></property>
			      <property name="has_frame">True</property>
			      <property name="invisible_char" translatable="yes">*</property>
			      <property name="activates_default">False</property>
			    </widget>
			  </child>
			</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="y_options"></property>
			</packing>
		      </child>
		    </widget>
		    <packing>
		      <property name="padding">0</property>
		      <property name="expand">False</property>
		      <property name="fill">False</property>
		    </packing>
		  </child>
		</widget>
		<packing>
		  <property name="padding">0</property>
		  <property name="expand">True</property>
		  <property name="fill">True</property>
		</packing>
	      </child>
	    </widget>
	    <packing>
	      <property name="padding">0</property>
	      <property name="expand">True</property>
	      <property name="fill">True</property>
	    </packing>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">True</property>
	  <property name="fill">True</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>
<?xml version="1.0"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="xml" indent="yes"/>
 
<xsl:template match="@priority"/>
<xsl:template match="@short-name"/>

<xsl:template match="@*|node()">
  <xsl:copy >
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>
<Root>
  <commands>	
    <cmd name="XML Planner Export" _label="Export to Planner XML pre 0.12"/>
  </commands>
  <menu>
    <submenu name="File">
     <submenu name="Export">
      <placeholder  name="Export XML Planner placeholder">
	<menuitem name="XML Planner Export" verb="" accel=""/>
      </placeholder>
     </submenu>
    </submenu>
  </menu>
</Root>
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2004 Lincoln Phipps <lincoln phipps openmutual net>
 * Copyright (C) 2003 Imendio HB
 * Copyright (C) 2003 CodeFactory AB
 * Copyright (C) 2003 Richard Hult <richard imendio com>
 * Copyright (C) 2003 Mikael Hallendal <micke imendio com>
 *
 * 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., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <glib.h> 
#include <string.h>
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-util.h>
#include <glade/glade.h>
#include <gtk/gtkradiobutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkstock.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-file-entry.h>
#include "planner-window.h"
#include "planner-plugin.h"

struct _PlannerPluginPriv {
	PlannerWindow *main_window;
	GtkWidget     *dialog;
	GtkWidget     *local_rbutton;
	GtkWidget     *local_fileentry;
	GtkWidget     *server_rbutton;
	GtkWidget     *server_entry;
};

static void xml_planner_plugin_export                (BonoboUIComponent *component,
					       gpointer           user_data,
					       const gchar       *cname);
static void xml_planner_plugin_ok_button_clicked     (GtkButton         *button,
					       PlannerPlugin     *plugin);
static void xml_planner_plugin_cancel_button_clicked (GtkButton         *button,
					       PlannerPlugin     *plugin);
static void xml_planner_plugin_local_toggled         (GtkToggleButton   *button,
					       PlannerPlugin     *plugin);
static void xml_planner_plugin_server_toggled        (GtkToggleButton   *button,
					       PlannerPlugin     *plugin);
static void xml_planner_plugin_do_local_export       (PlannerPlugin     *plugin,
					       const gchar       *path);


void        plugin_init                       (PlannerPlugin     *plugin,
					       PlannerWindow     *main_window);
void        plugin_exit                       (PlannerPlugin     *plugin);


static BonoboUIVerb verbs[] = {
	BONOBO_UI_VERB ("XML Planner Export", xml_planner_plugin_export),
	BONOBO_UI_VERB_END
};

static void
xml_planner_plugin_export (BonoboUIComponent *component,
		    gpointer           user_data,
		    const gchar       *cname)
{
	PlannerPluginPriv *priv = PLANNER_PLUGIN (user_data)->priv;
	GladeXML          *glade;
	GtkWidget         *ok_button;
	GtkWidget         *cancel_button;

	glade = glade_xml_new (GLADEDIR"/xml-planner-output.glade",
			       NULL, NULL);

	priv->dialog = glade_xml_get_widget (glade, "xml_planner_dialog");

	gtk_window_set_transient_for (GTK_WINDOW (priv->dialog),
				      GTK_WINDOW (priv->main_window));
	priv->local_rbutton = glade_xml_get_widget (glade,
						     "local_radiobutton");
	priv->local_fileentry = glade_xml_get_widget (glade, 
						      "local_fileentry");
	priv->server_rbutton = glade_xml_get_widget (glade,
						     "server_radiobutton");
	priv->server_entry = glade_xml_get_widget (glade, "server_entry");
	ok_button = glade_xml_get_widget (glade, "ok_button");
	cancel_button = glade_xml_get_widget (glade, "cancel_button");
	
	g_signal_connect (ok_button, "clicked",
			  G_CALLBACK (xml_planner_plugin_ok_button_clicked),
			  user_data);
	
	g_signal_connect (cancel_button, "clicked",
			  G_CALLBACK (xml_planner_plugin_cancel_button_clicked),
			  user_data);
	
	g_signal_connect (priv->local_rbutton, "toggled",
			  G_CALLBACK (xml_planner_plugin_local_toggled),
			  user_data);
	g_signal_connect (priv->server_rbutton, "toggled",
			  G_CALLBACK (xml_planner_plugin_server_toggled),
			  user_data);

	gtk_widget_show (priv->dialog);
}

static void 
xml_planner_plugin_ok_button_clicked (GtkButton *button, PlannerPlugin *plugin)
{
	PlannerPluginPriv *priv = plugin->priv;
	GtkWidget         *dialog;
	gint               res;
	const gchar       *path;
	
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->local_rbutton))) {
		path = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (priv->local_fileentry), FALSE);

		if (!path || strlen (path) == 0) {
			return;
		}
		
		if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
			dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog),
							 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_MESSAGE_WARNING,
							 GTK_BUTTONS_CLOSE,
							 _("\"%s\" is a directory.\nEnter a filename and try again."),
							 path);
			res = gtk_dialog_run (GTK_DIALOG (dialog));
			gtk_widget_destroy (dialog);
		}
		else if (g_file_test (path, G_FILE_TEST_EXISTS)) {
			dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog),
							 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_MESSAGE_WARNING,
							 GTK_BUTTONS_YES_NO,
							 _("File \"%s\" exists, do you want to overwrite it?"),
							 path);
			res = gtk_dialog_run (GTK_DIALOG (dialog));
			gtk_widget_destroy (dialog);

			switch (res) {
			case GTK_RESPONSE_YES:
				xml_planner_plugin_do_local_export (plugin,
								    path);
				gtk_widget_destroy (priv->dialog);
				return;
				break;
			case GTK_RESPONSE_NO:
			case GTK_RESPONSE_DELETE_EVENT:
				break;
			default:
				g_assert_not_reached ();
			}
		} else {
			xml_planner_plugin_do_local_export (plugin, path);
			gtk_widget_destroy (priv->dialog);
		}
	} else {
		GtkEntry *entry;
		
		entry = GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (priv->server_entry)));
			
		path = gtk_entry_get_text (entry);
		if (strlen (path) > 0) {
			xml_planner_plugin_do_local_export (plugin, path);
			gtk_widget_destroy (priv->dialog);
		}
	}
}

static void
xml_planner_plugin_cancel_button_clicked (GtkButton *button, PlannerPlugin *plugin)
{
	PlannerPluginPriv *priv = plugin->priv;
	
	gtk_widget_destroy (priv->dialog);
}

static void
xml_planner_plugin_local_toggled (GtkToggleButton *button, PlannerPlugin *plugin)
{
	PlannerPluginPriv *priv   = plugin->priv;
	gboolean           active = FALSE;
	
	if (gtk_toggle_button_get_active (button)) {
		active = TRUE;
	}
	
	gtk_widget_set_sensitive (priv->local_fileentry, active);
}

static void
xml_planner_plugin_server_toggled (GtkToggleButton *button, PlannerPlugin *plugin)
{
	PlannerPluginPriv *priv   = plugin->priv;
	gboolean           active = FALSE;
	
	if (gtk_toggle_button_get_active (button)) {
		active = TRUE;
	}
	
	gtk_widget_set_sensitive (priv->server_entry, active);
}

static void
xml_planner_plugin_do_local_export (PlannerPlugin *plugin, const gchar *path)
{
	PlannerPluginPriv *priv = plugin->priv;
	MrpProject        *project;
	GError            *error = NULL;

	project = planner_window_get_project (priv->main_window);
	
	if (!mrp_project_export (project, path,
				 "Planner XML pre-0.12",
				 TRUE,
				 &error)) {
		g_warning ("Error while export to Planner XML: %s", error->message);
	}
}

G_MODULE_EXPORT void 
plugin_init (PlannerPlugin *plugin, PlannerWindow *main_window)
{
	PlannerPluginPriv *priv;
	BonoboUIContainer *ui_container;
	BonoboUIComponent *ui_component;
	
	priv = g_new0 (PlannerPluginPriv, 1);
	plugin->priv = priv;
	priv->main_window = main_window;
	
	ui_container = planner_window_get_ui_container (main_window);
	ui_component = bonobo_ui_component_new_default ();
	
	bonobo_ui_component_set_container (ui_component, 
					   BONOBO_OBJREF (ui_container),
					   NULL);
	bonobo_ui_component_freeze (ui_component, NULL);
	bonobo_ui_component_add_verb_list_with_data (ui_component, 
						     verbs,
						     plugin);
	bonobo_ui_util_set_ui (ui_component,
			       DATADIR,
			       "/planner/ui/xml-planner-plugin.ui",
			       "xmlplannerplugin",
			       NULL);
	
	bonobo_ui_component_thaw (ui_component, NULL);
}

G_MODULE_EXPORT void 
plugin_exit (PlannerPlugin *plugin) 
{
	/*g_message ("Test exit");*/
}
? data/glade/xml-planner-output.glade
? data/stylesheets/planner2plannerv011.xsl
? data/ui/xml-planner-plugin.ui
? src/planner-xml-planner-plugin.c
Index: data/glade/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/data/glade/Makefile.am,v
retrieving revision 1.1.1.1
diff -u -b -B -p -r1.1.1.1 Makefile.am
--- a/data/glade/Makefile.am	1 Dec 2003 17:36:55 -0000	1.1.1.1
+++ b/data/glade/Makefile.am	18 Jun 2004 04:09:26 -0000
@@ -12,7 +12,8 @@ glade_DATA = \
 	resource-input-dialog.glade	\
 	sql.glade			\
 	task-dialog.glade		\
-	task-input-dialog.glade
+	task-input-dialog.glade		\
+	xml-planner-output.glade
 
 EXTRA_DIST = $(glade_DATA)
 
Index: data/stylesheets/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/data/stylesheets/Makefile.am,v
retrieving revision 1.2
diff -u -b -B -p -r1.2 Makefile.am
--- a/data/stylesheets/Makefile.am	16 Apr 2004 09:37:09 -0000	1.2
+++ b/data/stylesheets/Makefile.am	18 Jun 2004 04:09:26 -0000
@@ -5,6 +5,7 @@ stylesheet_DATA = \
 	html1_css.xsl                                   \
         html1_gantt.xsl                                 \
         html1_resources.xsl                             \
-        html1_tasks.xsl
+        html1_tasks.xsl					\
+	planner2plannerv011.xsl                         
 
 EXTRA_DIST = $(stylesheet_DATA)
Index: data/ui/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/data/ui/Makefile.am,v
retrieving revision 1.5
diff -u -b -B -p -r1.5 Makefile.am
--- a/data/ui/Makefile.am	12 May 2004 17:17:08 -0000	1.5
+++ b/data/ui/Makefile.am	18 Jun 2004 04:09:26 -0000
@@ -27,6 +27,7 @@ ui_DATA = \
 	resource-view.ui	\
 	sql-plugin.ui		\
 	task-view.ui		\
+	xml-planner-plugin.ui	\
 	$(python_script_ui)	\
 	$(timetable_view_ui)
 
Index: data/ui/html-plugin.ui
===================================================================
RCS file: /cvs/gnome/planner/data/ui/html-plugin.ui,v
retrieving revision 1.1.1.1
diff -u -b -B -p -r1.1.1.1 html-plugin.ui
--- a/data/ui/html-plugin.ui	1 Dec 2003 17:36:55 -0000	1.1.1.1
+++ b/data/ui/html-plugin.ui	18 Jun 2004 04:09:26 -0000
@@ -1,12 +1,14 @@
 <Root>
   <commands>	
-    <cmd name="Html Export" _label="Export to HTML"/>
+    <cmd name="HTML Export" _label="Export to HTML"/>
   </commands>
   <menu>
     <submenu name="File">
+     <submenu name="Export">
       <placeholder  name="Export placeholder">
-	<menuitem name="Html Export" verb="" accel=""/>
+	<menuitem name="HTML Export" verb="" accel=""/>
       </placeholder>
     </submenu>
+    </submenu>
   </menu>
 </Root>
Index: data/ui/main-window.ui
===================================================================
RCS file: /cvs/gnome/planner/data/ui/main-window.ui,v
retrieving revision 1.6
diff -u -b -B -p -r1.6 main-window.ui
--- a/data/ui/main-window.ui	3 Jun 2004 19:01:15 -0000	1.6
+++ b/data/ui/main-window.ui	18 Jun 2004 04:09:26 -0000
@@ -32,7 +32,9 @@
       <separator/>
       <menuitem    name="FileSave"         verb=""  accel="*Control*s"/>
       <menuitem    name="FileSaveAs"       verb=""  accel="*Shift**Control*s"/>
+      <submenu     name="Export" _label="E_xport...">
       <placeholder name="Export placeholder" delimit="top"/>
+      </submenu>
       <separator/>
       <menuitem    name="FilePrint"        verb=""  accel="*Control*p"/>
       <menuitem    name="FilePrintPreview" verb=""  accel="*Shift**Control*p"/>
Index: libplanner/mrp-xsl.c
===================================================================
RCS file: /cvs/gnome/planner/libplanner/mrp-xsl.c,v
retrieving revision 1.3
diff -u -b -B -p -r1.3 mrp-xsl.c
--- a/libplanner/mrp-xsl.c	11 Dec 2003 13:37:13 -0000	1.3
+++ b/libplanner/mrp-xsl.c	18 Jun 2004 04:09:27 -0000
@@ -41,6 +41,12 @@ static gboolean   html_write    (MrpFile
 				 gboolean          force,
 				 GError          **error);
 
+static gboolean   xml_planner_pre012_write    (MrpFileWriter    *writer,
+				 MrpProject       *project,
+				 const gchar      *uri,
+				 gboolean          force,
+				 GError          **error);
+				 
 static gboolean
 html_write (MrpFileWriter  *writer,
 	    MrpProject     *project,
@@ -104,12 +110,80 @@ html_write (MrpFileWriter  *writer,
 	return ret;
 }
 
+				 
+static gboolean
+xml_planner_pre012_write (MrpFileWriter  *writer,
+	    MrpProject     *project,
+	    const gchar    *uri,
+	    gboolean        force,
+	    GError        **error)
+{
+        gchar          *xml_project;
+        xsltStylesheet *stylesheet;
+        xmlDoc         *doc;
+        xmlDoc         *final_doc;
+	GnomeVFSHandle *handle;
+	xmlChar        *buffer;
+	gint            len;
+	GnomeVFSResult  result;
+	gboolean        ret;
+
+	mrp_project_save_to_xml (project, &xml_project, NULL);
+
+        /* libxml housekeeping */
+        xmlSubstituteEntitiesDefault(1);
+        xmlLoadExtDtdDefaultValue = 1;
+        exsltRegisterAll ();
+
+        stylesheet = xsltParseStylesheetFile (STYLESHEETDIR "/planner2plannerv011.xsl");
+
+        doc = xmlParseMemory (xml_project, strlen (xml_project));
+                                                                                
+        final_doc = xsltApplyStylesheet (stylesheet, doc, NULL);
+                                                                                
+	ret = TRUE;
+
+	if (xsltSaveResultToString (&buffer, &len, final_doc, stylesheet) != -1) {
+		result = gnome_vfs_create (&handle, uri, GNOME_VFS_OPEN_WRITE,
+					   FALSE, 0644);
+		
+		if (result == GNOME_VFS_OK) { 
+			gnome_vfs_write (handle, buffer, (GnomeVFSFileSize) len, NULL);
+			gnome_vfs_close (handle);
+		} else {
+		  	g_set_error (error,
+				     MRP_ERROR,
+				     MRP_ERROR_EXPORT_FAILED,
+				     gnome_vfs_result_to_string (result));
+			ret = FALSE;
+		}
+		
+		xmlFree (buffer);
+	} else {
+		g_set_error (error,
+			     MRP_ERROR,
+			     MRP_ERROR_EXPORT_FAILED,
+			     _("Planner pre 0.12 export failed"));
+		ret = FALSE;
+	}
+	
+	xsltFreeStylesheet (stylesheet);
+        xmlFree (final_doc);
+        xmlFree (doc);
+
+	return ret;
+}
+
+
 G_MODULE_EXPORT void
 init (MrpFileModule *module, MrpApplication *application)
 {
         MrpFileWriter *writer;
         
         writer             = g_new0 (MrpFileWriter, 1);
+	
+	/* The HTML writer registration */
+
         writer->module     = module;
 	writer->identifier = "Planner HTML";
 	writer->mime_type  = "text/html";
@@ -118,5 +192,19 @@ init (MrpFileModule *module, MrpApplicat
         writer->write      = html_write;
 
         imrp_application_register_writer (application, writer);
+
+	/* The older Planner/Mrproject writer registration */
+
+	writer             = g_new0 (MrpFileWriter, 1);
+	
+	writer->module     = module;
+	writer->identifier = "Planner XML pre-0.12";  /* Don't change unless you change plugin to match */
+	writer->mime_type  = "text/xml";
+        writer->priv       = NULL;
+	
+        writer->write      = xml_planner_pre012_write;
+
+        imrp_application_register_writer (application, writer);
+	
 }
 
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/planner/po/POTFILES.in,v
retrieving revision 1.9
diff -u -b -B -p -r1.9 POTFILES.in
--- a/po/POTFILES.in	14 Jun 2004 15:25:18 -0000	1.9
+++ b/po/POTFILES.in	18 Jun 2004 04:09:27 -0000
@@ -13,6 +13,7 @@ data/glade/resource-input-dialog.glade
 data/glade/sql.glade
 data/glade/task-dialog.glade
 data/glade/task-input-dialog.glade
+data/glade/xml-planner-output.glade
 
 data/mime/planner.keys.in
 
@@ -26,6 +27,7 @@ data/ui/resource-view.ui
 data/ui/sql-plugin.ui
 data/ui/task-view.ui
 data/ui/time-table-view.ui
+data/ui/xml-planner-plugin.ui
 
 libegg/recent-files/egg-recent-vfs-utils.c
 
@@ -99,8 +101,6 @@ src/planner-ttable-view.c
 src/planner-view.c
 src/planner-view-loader.c
 src/planner-window.c
-
-
-
+src/planner-xml-planner-plugin.c
 
 
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/src/Makefile.am,v
retrieving revision 1.15
diff -u -b -B -p -r1.15 Makefile.am
--- a/src/Makefile.am	14 Jun 2004 15:25:18 -0000	1.15
+++ b/src/Makefile.am	18 Jun 2004 04:09:27 -0000
@@ -215,12 +215,16 @@ endif
 
 plugin_LTLIBRARIES = \
 	libhtml-plugin.la		\
+	libxmlplanner-plugin.la		\
 	$(sql_plugin)			\
 	$(python_plugin)
 
 libhtml_plugin_la_SOURCES = planner-html-plugin.c
 libhtml_plugin_la_LDFLAGS = -avoid-version -module
 
+libxmlplanner_plugin_la_SOURCES = planner-xml-planner-plugin.c
+libxmlplanner_plugin_la_LDFLAGS = -avoid-version -module
+
 planner-marshal.h: Makefile.am planner-marshal.list
 	(cd $(srcdir) && \
 	@GLIB_GENMARSHAL@ --prefix=planner_marshal planner-marshal.list --header) > xgen-gmh \
Index: src/planner-html-plugin.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-html-plugin.c,v
retrieving revision 1.5
diff -u -b -B -p -r1.5 planner-html-plugin.c
--- a/src/planner-html-plugin.c	15 Apr 2004 20:39:30 -0000	1.5
+++ b/src/planner-html-plugin.c	18 Jun 2004 04:09:28 -0000
@@ -66,7 +66,7 @@ void        plugin_exit                 
 
 
 static BonoboUIVerb verbs[] = {
-	BONOBO_UI_VERB ("Html Export", html_plugin_export),
+	BONOBO_UI_VERB ("HTML Export", html_plugin_export),
 	BONOBO_UI_VERB_END
 };
 


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