Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

mlview-node-editor.c

Go to the documentation of this file.
00001 /*
00002  *This file is part of GNU MlView
00003  *
00004  *GNU MlView is free software; you can redistribute it and/or modify it under the terms of 
00005  *the GNU General Public License as published by the Free Software Foundation; either version 2, 
00006  *or (at your option) any later version.
00007  *
00008  *GNU MlView is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
00009  *without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  *See the GNU General Public License for more details.
00011  *
00012  *You should have received a copy of the GNU General Public License along with MlView; 
00013  *see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00014  *
00015  *
00016  *Copyright 2001-2002 Dodji Seketeli
00017  */
00018 
00019 
00034 #include "mlview-node-editor.h"
00035 #include "mlview-xml-document.h"
00036 #include "mlview-attributes-list.h"
00037 #include "mlview-namespace-editor.h"
00038 #include "utils.h"
00039 
00040 #include <libxml/tree.h>
00041 #include <ctype.h>
00042 
00043 typedef struct _XMLElementNodeView XMLElementNodeView ;
00044 typedef struct _XMLCommentNodeView XMLCommentNodeView ;
00045 typedef struct _XMLCDataSectionNodeView XMLCDataSectionNodeView ;
00046 typedef struct _XMLTextNodeView  XMLTextNodeView ;
00047 typedef struct _XMLPINodeView XMLPINodeView ;
00048 typedef struct _XMLDocNodeView XMLDocNodeView ;
00049 
00050 /*===========================================================
00051  *Some structure used in the private data part of MlViewElementEditor.
00052  *===========================================================*/
00053 
00058 struct _XMLElementNodeView{
00059         GtkVBox *vbox ;
00060         GtkEntry *name ;  /*a GtkEntry: contains the current element name*/
00061         MlViewAttributesList *attributes ; /*a GtkCList: contains the attibutes list*/  
00062         MlViewNamespaceEditor *namespaces ; /*a GtkClist: contains the list of namespaces visible on this node*/
00063         guint name_changed_handler_id ; 
00064 };
00065 
00070 struct _XMLTextNodeView{
00071         GtkVBox *vbox ;
00072         GtkText *content ;
00073 };
00074 
00079 struct _XMLCommentNodeView{
00080         GtkVBox *vbox ;
00081         GtkText *content ;
00082 };
00083 
00088 struct _XMLCDataSectionNodeView{
00089         GtkVBox *vbox ;
00090         GtkText *content ;
00091 } ;
00092 
00097 struct _XMLPINodeView{
00098         GtkVBox *vbox ;
00099         GtkEntry *name ;
00100         GtkText *content ;
00101         guint name_changed_handler_id ;
00102 };
00103 
00104 struct _XMLDocNodeView {
00105         GtkVBox *vbox ;
00106         GtkEntry *name ; /*the name of this document ... not mandatory*/
00107         guint name_changed_handler_id ;
00108 
00109         GtkEntry *standalone ; /*wether this document is mandatory or not*/
00110         GtkEntry *xml_version ; /*the xml version*/
00111         GtkEntry *external_encoding ; /*the encoding of the on disk file*/
00112         GtkEntry *ext_subset_external_id ; /*the external id of the external subset*/
00113         GtkEntry *ext_subset_system_id ; /*the system id of the external subset*/
00114 } ;
00115 
00116 /*===========================================================
00117  *The private part of the MlViewNodeEditor structure.
00118  *===========================================================*/
00119 struct _MlViewNodeEditorPrivate
00120 {
00121         /*the left part of the MlViewNodeEditor widget*/
00122         GtkVBox *left_margin ;
00123 
00124         /*the combo that defines the type of element being edited*/
00125         GtkEntry *xml_node_type ;
00126 
00127         /*right part of element editor. This widget shows a view appropriated to the type of xml element
00128          *being edited. Let's say the xml node being edited is a text node, the view (widget) used to edit it
00129          *will be a GtkText. If the xml node being edited is an element node, the view used to edit it
00130          *will be more complex: it will be a widget that enable the user to edit the xml element name and the
00131          *it attributes ...
00132          */
00133         GtkNotebook *node_view ;
00134 
00135         /*the current xml node being edited*/
00136         xmlNode *curr_xml_node ;
00137         MlViewXMLDocument *curr_xml_document ;
00138         gboolean iseditable;
00139 
00140         /*the view used to edit an xml element node*/
00141         XMLElementNodeView * element_node_view ;
00142 
00143         /*the view used to edit an xml text node*/
00144         XMLTextNodeView * text_node_view ;
00145 
00146         /*the view used to edit an xml comment node*/
00147         XMLCommentNodeView * comment_node_view ; 
00148 
00149         /*the view used to edit an xml cdata section node*/
00150         XMLCDataSectionNodeView * cdata_section_node_view ; 
00151 
00152         /*the view used to edit an xml pi node*/
00153         XMLPINodeView * pi_node_view ; 
00154 
00155         /*the view used to edit an xml doc node*/
00156         XMLDocNodeView * doc_node_view ;
00157  
00158         MlViewAppContext * app_context ;
00159         guint xml_node_type_changed_handler_id ;
00160         guint left_right_percentage ;
00161 } ;
00162 
00163 /*
00164  *This enum defines the signals emited by MlViewNodeEditor.
00165  *It is used as the offset of the signal in the private p_table mlview_node_editor_signals.
00166  */
00167 enum
00168 {
00169         ELEMENT_CHANGED,
00170         EDIT_STATE_CHANGED,
00171         ELEMENT_NAME_CHANGED,
00172         ELEMENT_ATTRIBUTE_CHANGED,
00173         ELEMENT_CONTENT_CHANGED,
00174         NUMBER_OF_SIGNALS
00175 };
00176 
00177 /*
00178  *This enum defines the notebook pages that hold
00179  *the possibles views of an xml node. It is used
00180  *as the offset of matching notebook pages.
00181  *Make sure that the order of the construction of the views (of the notebook pages)
00182  *(at the end of mlview_node_editor_init()) matches the order defined by this enum.
00183  */
00184 enum
00185 {
00186         ELEMENT_NODE_VIEW_PAGE,
00187         TEXT_NODE_VIEW_PAGE,
00188         COMMENT_NODE_VIEW_PAGE,
00189         CDATA_SECTION_VIEW_PAGE,
00190         PI_NODE_VIEW_PAGE,
00191         DOC_NODE_VIEW_PAGE
00192 } ;
00193 
00194 #define PRIVATE(node_editor) (node_editor->private) /*the macro used to access the private part of the MlViewNodeEditor*/
00195 #define ELEMENT_NODE_VIEW(node_editor) (PRIVATE(node_editor)->element_node_view) /*acess the element node view ...*/
00196 #define TEXT_NODE_VIEW(node_editor)  (PRIVATE(node_editor)->text_node_view)
00197 #define COMMENT_NODE_VIEW(node_editor) (PRIVATE(node_editor)->comment_node_view)
00198 #define CDATA_SECTION_NODE_VIEW(node_editor) (PRIVATE(node_editor)->cdata_section_node_view)
00199 #define PI_NODE_VIEW(node_editor) (PRIVATE(node_editor)->pi_node_view)
00200 #define DOC_NODE_VIEW(node_editor) (PRIVATE(node_editor)->doc_node_view)
00201 #define CURRENT_XML_NODE(node_editor) (PRIVATE(node_editor)->curr_xml_node)
00202 #define IS_EDITABLE(node_editor) (PRIVATE(node_editor)->iseditable)
00203 #define DEFAULT_LEFT_RIGHT_PERCENTAGE 20
00204 
00205 /*private functions declarations*/
00206 static void 
00207 mlview_node_editor_xml_text_node_view_set_editable (MlViewNodeEditor *a_node_editor) ;
00208 
00209 static void 
00210 mlview_node_editor_xml_cdata_section_node_view_set_editable (MlViewNodeEditor *a_node_editor) ;
00211 
00212 static void 
00213 mlview_node_editor_xml_comment_node_view_set_editable (MlViewNodeEditor *a_node_editor) ;
00214 
00215 static void 
00216 mlview_node_editor_xml_pi_node_view_set_editable (MlViewNodeEditor *a_node_editor) ;
00217 
00218 static void 
00219 mlview_node_editor_build_xml_element_node_view (MlViewNodeEditor *a_node_editor) ;
00220 
00221 static void 
00222 mlview_node_editor_build_xml_text_node_view (MlViewNodeEditor *a_node_editor) ;
00223 
00224 static void 
00225 mlview_node_editor_build_xml_comment_node_view (MlViewNodeEditor *a_node_editor) ;
00226 
00227 static void 
00228 mlview_node_editor_build_xml_cdata_section_node_view (MlViewNodeEditor *a_node_editor) ;
00229 
00230 static void 
00231 mlview_node_editor_build_xml_pi_node_view (MlViewNodeEditor *a_node_editor) ;
00232 
00233 static void 
00234 mlview_node_editor_build_xml_doc_node_view (MlViewNodeEditor *a_node_editor) ;
00235 
00236 static void 
00237 mlview_node_editor_clear_xml_element_node_view (MlViewNodeEditor *a_node_editor) ;
00238 
00239 static void 
00240 mlview_node_editor_clear_xml_text_node_view (MlViewNodeEditor *a_node_editor) ;
00241 
00242 static void 
00243 mlview_node_editor_clear_xml_comment_node_view (MlViewNodeEditor *a_node_editor) ;
00244 
00245 static void 
00246 mlview_node_editor_clear_xml_cdata_section_node_view (MlViewNodeEditor *a_node_editor) ;
00247 
00248 static void 
00249 mlview_node_editor_clear_xml_pi_node_view (MlViewNodeEditor *a_node_editor) ;
00250 
00251 static void 
00252 mlview_node_editor_xml_element_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00253                                                         MlViewXMLDocument * a_xml_doc,
00254                                                         xmlNode * a_node) ;
00255 
00256 static void 
00257 mlview_node_editor_xml_text_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00258                                                      MlViewXMLDocument * a_xml_doc,
00259                                                      xmlNode * a_node) ;
00260 
00261 static void 
00262 mlview_node_editor_xml_comment_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00263                                                         MlViewXMLDocument * a_xml_doc,
00264                                                         xmlNode * a_node) ;
00265 
00266 static void 
00267 mlview_node_editor_xml_cdata_section_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00268                                                               MlViewXMLDocument * a_xml_doc,
00269                                                               xmlNode * a_node) ;
00270 
00271 static void 
00272 mlview_node_editor_xml_pi_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00273                                                    MlViewXMLDocument * a_xml_doc,
00274                                                    xmlNode * a_node) ;
00275 
00276 static void 
00277 mlview_node_editor_xml_doc_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00278                                                     MlViewXMLDocument * a_xml_doc,
00279                                                     xmlNode * a_node) ;
00280 
00281 static void 
00282 mlview_node_editor_class_init (MlViewNodeEditorClass *a_klass) ;
00283 
00284 static void 
00285 mlview_node_editor_init (MlViewNodeEditor *a_node_editor) ;
00286 
00287 static void 
00288 mlview_node_editor_destroy (GtkObject *a_object);
00289 
00290 static void 
00291 mlview_node_editor_construct (MlViewNodeEditor * a_node_editor,
00292                               MlViewAppContext *a_app_context) ;
00293 
00294 static void 
00295 mlview_node_editor_editable_state_changed_cb (GtkWidget *a_widget ,
00296                                               MlViewNodeEditor* a_editor) ;
00297 
00298 static void 
00299 mlview_node_editor_name_changed_cb (GtkWidget *a_entry, 
00300                                     MlViewNodeEditor *a_editor) ;
00301 
00302 static void 
00303 mlview_node_editor_attribute_changed_cb (MlViewAttributesList* a_attributes,
00304                                          gpointer a_editor) ;
00305 
00306 static void 
00307 mlview_node_editor_content_changed_cb (GtkText * a_content,
00308                                        MlViewNodeEditor *a_editor) ;
00309 
00310 static void 
00311 mlview_node_editor_configure_event_cb (GtkWidget *a_node_editor, 
00312                                        GdkEventConfigure * a_event, 
00313                                        gpointer a_data) ;
00314 
00315 /*private static data*/
00316 static GtkHPanedClass *parent_class ;
00317 static guint mlview_node_editor_signals[NUMBER_OF_SIGNALS]={0} ;
00318 
00319 /*================================================================
00320  *private helper functions
00321  *===============================================================*/
00322 
00323 
00327 static void
00328 mlview_node_editor_build_xml_element_node_view (MlViewNodeEditor *a_node_editor)
00329 {
00330         XMLElementNodeView * view ;
00331         MlViewNodeEditorPrivate *private_data ;
00332         GtkWidget *table, *label = NULL ;
00333         GtkWidget *frame=NULL, *vbox = NULL ;
00334 
00335         gchar * attributes_names_title = N_("Attribute names");
00336         gchar * attributes_values_title = N_("Attribute values") ;
00337 
00338         g_return_if_fail (a_node_editor != NULL) ;
00339 
00340 
00341         if (PRIVATE (a_node_editor) == NULL)
00342                 PRIVATE (a_node_editor) = g_malloc0 (sizeof (MlViewNodeEditorPrivate)) ;
00343 
00344         if (ELEMENT_NODE_VIEW (a_node_editor) == NULL)
00345                 ELEMENT_NODE_VIEW (a_node_editor) = g_malloc0 (sizeof (XMLElementNodeView))  ;
00346         else
00347                 if (ELEMENT_NODE_VIEW (a_node_editor)->vbox != NULL)
00348                         gtk_widget_destroy (GTK_WIDGET (TEXT_NODE_VIEW (a_node_editor)->vbox)) ;
00349 
00350         view = ELEMENT_NODE_VIEW (a_node_editor) ;
00351         
00352         private_data = PRIVATE (a_node_editor) ;
00353         view->vbox = GTK_VBOX (gtk_vbox_new (FALSE,0)) ;
00354         frame = gtk_frame_new (_("Element node")) ;
00355         gtk_box_pack_start (GTK_BOX (view->vbox),frame,
00356                            TRUE,TRUE,0) ;
00357         vbox = gtk_vbox_new (FALSE,0) ;
00358         gtk_container_add (GTK_CONTAINER (frame),vbox) ;
00359         
00360         label = gtk_label_new (_("Element name")) ;
00361         view->name = GTK_ENTRY (gtk_entry_new ()) ;     
00362         gtk_entry_set_text (GTK_ENTRY (view->name), "") ;
00363         gtk_entry_set_editable (GTK_ENTRY (view->name), private_data->iseditable) ;
00364         
00365         table = gtk_table_new (1,2,TRUE) ;
00366         gtk_box_pack_start (GTK_BOX (vbox),
00367                            table, FALSE, FALSE, 0) ;
00368         gtk_table_attach_defaults (GTK_TABLE (table),
00369                                  label,0,1,0,1) ;
00370         gtk_table_attach_defaults (GTK_TABLE (table),
00371                                   GTK_WIDGET (view->name),
00372                                   1,2,0,1) ;
00373         view->name_changed_handler_id = gtk_signal_connect (GTK_OBJECT (view->name),
00374                                                             "changed",
00375                                                             GTK_SIGNAL_FUNC (mlview_node_editor_name_changed_cb),
00376                                                             a_node_editor) ;
00377         
00378         /*init the attributes and the namespace edition areas*/
00379         table = gtk_table_new (1,2,TRUE) ;
00380         frame = gtk_frame_new (_("attributes edition")) ;
00381         view->attributes = 
00382                 MLVIEW_ATTRIBUTES_LIST (mlview_attributes_list_new (attributes_names_title,
00383                                                                     attributes_values_title,
00384                                                                     PRIVATE (a_node_editor)->app_context)) ;
00385         gtk_signal_connect (GTK_OBJECT (view->attributes),
00386                            "attribute-changed",
00387                             GTK_SIGNAL_FUNC (mlview_node_editor_attribute_changed_cb),
00388                             a_node_editor) ;
00389 
00390         gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view->attributes)) ;
00391         gtk_table_attach_defaults (GTK_TABLE (table), frame,
00392                                    0,1,0,1) ;
00393 
00394         view->namespaces = MLVIEW_NAMESPACE_EDITOR (mlview_namespace_editor_new (PRIVATE (a_node_editor)->app_context)) ;
00395         frame = gtk_frame_new (_("namespaces edition")) ;    
00396 
00397         gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(view->namespaces)) ;
00398         gtk_table_attach_defaults(GTK_TABLE(table),frame,
00399                                   1,2,0,1) ;
00400         /*FIXME: add signals on the namespaces editor*/
00401         gtk_box_pack_start(GTK_BOX(vbox),
00402                           table,TRUE,TRUE,0) ;
00403 
00404         gtk_widget_show_all(GTK_WIDGET(view->vbox));
00405         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00406 }
00407 
00412 static void
00413 mlview_node_editor_build_xml_text_node_view(MlViewNodeEditor *a_node_editor)
00414 {
00415         XMLTextNodeView *view ;
00416         MlViewNodeEditorPrivate * private_data ;
00417         GtkWidget * frame, *scrolled_window;
00418         g_return_if_fail(a_node_editor != NULL) ;
00419                 
00420 
00421         
00422         if(PRIVATE(a_node_editor) == NULL)
00423                 PRIVATE(a_node_editor) = g_malloc0(sizeof(MlViewNodeEditorPrivate));
00424         
00425         private_data = PRIVATE(a_node_editor);
00426 
00427         
00428         if(TEXT_NODE_VIEW(a_node_editor) == NULL)
00429                 TEXT_NODE_VIEW(a_node_editor) = g_malloc0(sizeof(XMLElementNodeView)) ;
00430         else
00431                 if(TEXT_NODE_VIEW(a_node_editor)->vbox != NULL)
00432                         gtk_widget_destroy(GTK_WIDGET(TEXT_NODE_VIEW(a_node_editor)->vbox)) ;
00433 
00434         view = TEXT_NODE_VIEW(a_node_editor) ;
00435         frame = gtk_frame_new(_("Text Node")) ;
00436         view->vbox=GTK_VBOX(gtk_vbox_new(FALSE,0)) ;
00437         gtk_box_pack_start(GTK_BOX(view->vbox),frame,TRUE,TRUE,0) ;             
00438         gtk_widget_show(frame) ;
00439         
00440         view->content = GTK_TEXT(gtk_text_new(NULL,NULL)) ;
00441         scrolled_window = gtk_scrolled_window_new(NULL, NULL) ;
00442         gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view->content)) ;
00443         gtk_container_add(GTK_CONTAINER(frame),
00444                           scrolled_window) ;
00445         gtk_signal_connect(GTK_OBJECT(view->content),
00446                            "changed",
00447                            GTK_SIGNAL_FUNC(mlview_node_editor_content_changed_cb),
00448                            a_node_editor) ;
00449         gtk_widget_show(GTK_WIDGET(view->content)) ;
00450         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00451 }
00452 
00458 static void
00459 mlview_node_editor_build_xml_comment_node_view(MlViewNodeEditor *a_node_editor)
00460 {
00461         MlViewNodeEditorPrivate *private_data ;
00462         XMLCommentNodeView * view ;
00463         GtkWidget * frame, *scrolled_window ;
00464         
00465         g_return_if_fail(a_node_editor != NULL) ;
00466         
00467         
00468         if(PRIVATE(a_node_editor) == NULL)
00469                 PRIVATE(a_node_editor) = g_malloc0(sizeof(MlViewNodeEditorPrivate)) ;
00470         
00471         private_data = PRIVATE(a_node_editor) ;
00472         
00473         if(COMMENT_NODE_VIEW(a_node_editor) == NULL)
00474                 COMMENT_NODE_VIEW(a_node_editor) = g_malloc0(sizeof(XMLCommentNodeView)) ;
00475         else{
00476                 if(COMMENT_NODE_VIEW(a_node_editor)->vbox != NULL)
00477                         gtk_widget_destroy(GTK_WIDGET(COMMENT_NODE_VIEW(a_node_editor)->vbox)) ;
00478         }
00479         view = COMMENT_NODE_VIEW(a_node_editor) ;
00480         view->vbox = GTK_VBOX(gtk_vbox_new(TRUE,0)) ;
00481         view->content = GTK_TEXT(gtk_text_new(NULL,NULL)) ;
00482         frame = gtk_frame_new(_("Comment node")) ;      
00483         gtk_box_pack_start(GTK_BOX(view->vbox),
00484                            GTK_WIDGET(frame),TRUE,TRUE,0) ;
00485 
00486         scrolled_window = gtk_scrolled_window_new(NULL, NULL) ;
00487         gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view->content)) ;
00488 
00489         gtk_container_add(GTK_CONTAINER(frame),scrolled_window) ;
00490         gtk_signal_connect(GTK_OBJECT(view->content),
00491                            "changed",
00492                            GTK_SIGNAL_FUNC(mlview_node_editor_content_changed_cb),
00493                            a_node_editor) ;
00494         gtk_widget_show_all(GTK_WIDGET(view->vbox)) ;
00495         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00496 }
00497 
00502 static void
00503 mlview_node_editor_build_xml_cdata_section_node_view(MlViewNodeEditor *a_node_editor)
00504 {
00505         MlViewNodeEditorPrivate * private_data ;
00506         XMLCDataSectionNodeView * view ;
00507         GtkWidget *frame, *scrolled_window ;
00508         
00509         g_return_if_fail(a_node_editor != NULL) ;
00510                 
00511         if(PRIVATE(a_node_editor) == NULL)
00512                 PRIVATE(a_node_editor) = g_malloc0(sizeof(MlViewNodeEditorPrivate)) ;
00513                 
00514         private_data = PRIVATE(a_node_editor) ;
00515         if(CDATA_SECTION_NODE_VIEW(a_node_editor) == NULL)
00516                 CDATA_SECTION_NODE_VIEW(a_node_editor) = g_malloc0(sizeof(XMLCDataSectionNodeView)) ;
00517         else{
00518                 if(CDATA_SECTION_NODE_VIEW(a_node_editor)->vbox != NULL)
00519                         gtk_widget_destroy(GTK_WIDGET(CDATA_SECTION_NODE_VIEW(a_node_editor)->vbox)) ;
00520         }
00521         view = CDATA_SECTION_NODE_VIEW(a_node_editor) ;
00522         view->vbox = GTK_VBOX(gtk_vbox_new(TRUE,0)) ;
00523         view->content = GTK_TEXT(gtk_text_new(NULL,NULL)) ;
00524         frame = gtk_frame_new(_("CDATA Section node")) ;
00525         
00526         gtk_box_pack_start(GTK_BOX(view->vbox),frame,TRUE,TRUE,0) ;
00527         scrolled_window = gtk_scrolled_window_new(NULL, NULL) ;
00528         gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view->content)) ;
00529         gtk_container_add(GTK_CONTAINER(frame), scrolled_window) ;
00530 
00531         gtk_signal_connect(GTK_OBJECT(view->content),
00532                            "changed",
00533                            GTK_SIGNAL_FUNC(mlview_node_editor_content_changed_cb),
00534                            a_node_editor) ;
00535         gtk_widget_show_all(GTK_WIDGET(view->vbox)) ;
00536         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00537 }
00538 
00543 static void
00544 mlview_node_editor_build_xml_pi_node_view(MlViewNodeEditor *a_node_editor)
00545 {
00546         XMLPINodeView *view ;
00547         MlViewNodeEditorPrivate * private_data ;
00548         GtkWidget *frame, *scrolled_window, *table, *label ;
00549 
00550         g_return_if_fail(a_node_editor != NULL) ;
00551         
00552         if(PRIVATE(a_node_editor) == NULL)
00553                 PRIVATE(a_node_editor) = g_malloc(sizeof(MlViewNodeEditorPrivate)) ;
00554         private_data = PRIVATE(a_node_editor) ;
00555         
00556         if(PI_NODE_VIEW(a_node_editor) == NULL)
00557                 PI_NODE_VIEW(a_node_editor) = g_malloc0(sizeof(XMLPINodeView)) ;
00558         else
00559                 if(PI_NODE_VIEW(a_node_editor)->vbox != NULL)
00560                         gtk_widget_destroy(GTK_WIDGET(PI_NODE_VIEW(a_node_editor)->vbox)) ;
00561         
00562         view = PI_NODE_VIEW(a_node_editor) ;
00563         frame = gtk_frame_new(_("PI Node")) ;
00564         view->vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0)) ;
00565         
00566         label = gtk_label_new(_("PI node name")) ;
00567         view->name = GTK_ENTRY(gtk_entry_new()) ;
00568         gtk_entry_set_editable(view->name, private_data->iseditable) ;
00569         table = gtk_table_new(1,2,TRUE) ;
00570         gtk_table_attach_defaults(GTK_TABLE(table),label,
00571                          0,1,0,1);
00572         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->name),
00573                          1,2,0,1);
00574         gtk_box_pack_start(GTK_BOX(view->vbox),table,TRUE,TRUE,0) ;
00575         gtk_box_pack_start(GTK_BOX(view->vbox),frame,TRUE,TRUE,0) ;
00576         view->name_changed_handler_id = gtk_signal_connect(GTK_OBJECT(view->name),
00577                                                            "changed",
00578                                                            GTK_SIGNAL_FUNC(mlview_node_editor_name_changed_cb),
00579                                                            a_node_editor) ;
00580         view->content = GTK_TEXT(gtk_text_new(NULL,NULL)) ;
00581         gtk_text_set_editable(view->content, private_data->iseditable) ;
00582         scrolled_window = gtk_scrolled_window_new(NULL, NULL) ;
00583         gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view->content)) ;
00584 
00585         gtk_container_add(GTK_CONTAINER(frame),
00586                           scrolled_window) ;
00587         gtk_signal_connect(GTK_OBJECT(view->content),
00588                            "changed",
00589                            GTK_SIGNAL_FUNC(mlview_node_editor_content_changed_cb),
00590                            a_node_editor) ;
00591         gtk_widget_show_all(GTK_WIDGET(view->vbox)) ;
00592         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00593 }
00594 
00595 
00600 static 
00601 void mlview_node_editor_build_xml_doc_node_view(MlViewNodeEditor *a_node_editor)
00602 {
00603         XMLDocNodeView *view ;
00604         MlViewNodeEditorPrivate * private_data ;
00605         GtkWidget *frame, *table, *label, *vbox ;
00606 
00607         g_return_if_fail(a_node_editor != NULL) ;
00608 
00609         if(PRIVATE(a_node_editor) == NULL)
00610                 PRIVATE(a_node_editor) = g_malloc(sizeof(MlViewNodeEditorPrivate)) ;
00611         private_data = PRIVATE(a_node_editor) ;
00612 
00613         if(DOC_NODE_VIEW(a_node_editor) == NULL)
00614                 DOC_NODE_VIEW(a_node_editor) = g_malloc0(sizeof(XMLDocNodeView)) ;
00615         else
00616                 if(DOC_NODE_VIEW(a_node_editor)->vbox != NULL)
00617                         gtk_widget_destroy(GTK_WIDGET(DOC_NODE_VIEW(a_node_editor)->vbox)) ;
00618 
00619         view = DOC_NODE_VIEW(a_node_editor) ;
00620         /*Set the decoration ...*/
00621         frame = gtk_frame_new(_("document node")) ;
00622         view->vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0)) ;
00623         gtk_box_pack_start(GTK_BOX(view->vbox), frame,
00624                            TRUE,TRUE,0) ;
00625         vbox = gtk_vbox_new(FALSE, 0) ;
00626         gtk_container_add(GTK_CONTAINER(frame),vbox) ;
00627         
00628         /*The "name of the document" entry*/
00629         view->name = GTK_ENTRY(gtk_entry_new()) ;
00630         gtk_entry_set_editable(view->name, private_data->iseditable) ;
00631         view->name_changed_handler_id = gtk_signal_connect(GTK_OBJECT(view->name),
00632                                                            "changed",
00633                                                            GTK_SIGNAL_FUNC(mlview_node_editor_name_changed_cb),
00634                                                            a_node_editor) ;
00635         label = gtk_label_new(_("document name or uri:")) ;
00636         table = gtk_table_new(1,2,TRUE) ;
00637         gtk_table_attach_defaults(GTK_TABLE(table),label,
00638                                   0,1,0,1) ;
00639         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->name),
00640                                   1,2,0,1) ;
00641         gtk_box_pack_start(GTK_BOX(vbox),table,TRUE,TRUE,0) ;
00642 
00643         /*the "standalone" combo ...*/
00644         label = gtk_label_new(_("is document standalone:")) ;
00645         view->standalone = GTK_ENTRY(gtk_entry_new()) ;
00646         gtk_entry_set_editable(view->standalone, FALSE) ;
00647         table = gtk_table_new(1,2,TRUE) ;
00648         gtk_table_attach_defaults(GTK_TABLE(table),label,
00649                                  0,1,0,1) ;
00650         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->standalone),
00651                                   1,2,0,1) ;
00652         gtk_box_pack_start(GTK_BOX(vbox),table,
00653                            TRUE,TRUE,0) ;
00654 
00655         /*The "xml version" entry ...*/
00656         label = gtk_label_new(_("xml version:")) ;
00657         view->xml_version = GTK_ENTRY(gtk_entry_new()) ;
00658         gtk_entry_set_editable(view->xml_version, FALSE) ;
00659         table = gtk_table_new(1,2,TRUE) ;
00660         gtk_table_attach_defaults(GTK_TABLE(table),label,
00661                                   0,1,0,1);
00662         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->xml_version),
00663                                   1,2,0,1);
00664         gtk_box_pack_start(GTK_BOX(vbox),table,
00665                            TRUE,TRUE,0) ;
00666 
00667         /*The "xml encoding" entry ...*/
00668         label = gtk_label_new(_("xml file encoding:")) ;
00669         view->external_encoding = GTK_ENTRY(gtk_entry_new()) ;
00670         gtk_entry_set_editable(view->external_encoding, FALSE) ;
00671         table = gtk_table_new(1,2,TRUE) ;
00672         gtk_table_attach_defaults(GTK_TABLE(table),label,
00673                                   0,1,0,1) ;
00674         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->external_encoding),
00675                                   1,2,0,1) ;
00676         gtk_box_pack_start(GTK_BOX(vbox),
00677                            table,TRUE,TRUE,0) ;
00678 
00679         /*The external subset external is*/
00680         label = gtk_label_new(_("external id of the external subset:")) ;
00681         view->ext_subset_external_id = GTK_ENTRY(gtk_entry_new()) ;
00682         gtk_entry_set_editable(view->ext_subset_external_id, FALSE) ;
00683         table = gtk_table_new(1,2,TRUE) ;
00684         gtk_table_attach_defaults(GTK_TABLE(table),label,
00685                                   0,1,0,1) ;
00686         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->ext_subset_external_id),
00687                                   1,2,0,1) ;
00688         gtk_box_pack_start(GTK_BOX(vbox),
00689                            table,TRUE,TRUE,0) ;
00690 
00691         /*The external subset external id entry ...*/
00692         label = gtk_label_new(_("system id of the external subset:")) ;
00693         view->ext_subset_system_id = GTK_ENTRY(gtk_entry_new()) ;
00694         gtk_entry_set_editable(view->ext_subset_system_id, FALSE) ;
00695         table = gtk_table_new(1,2,TRUE) ;
00696         gtk_table_attach_defaults(GTK_TABLE(table),label,
00697                                   0,1,0,1) ;
00698         gtk_table_attach_defaults(GTK_TABLE(table),GTK_WIDGET(view->ext_subset_system_id),
00699                                   1,2,0,1) ;
00700         gtk_box_pack_start(GTK_BOX(vbox),
00701                            table,TRUE,TRUE,0) ;
00702 
00703         /*Show everything and attach it to the views*/
00704         gtk_widget_show_all(GTK_WIDGET(view->vbox)) ;
00705         gtk_notebook_append_page(private_data->node_view,GTK_WIDGET(view->vbox),NULL) ;
00706 }
00707 
00708 
00713 static void
00714 mlview_node_editor_clear_xml_element_node_view(MlViewNodeEditor *a_node_editor)
00715 {
00716         XMLElementNodeView *view ;
00717         g_return_if_fail(a_node_editor != NULL) ;
00718         view = ELEMENT_NODE_VIEW(a_node_editor) ;
00719         g_return_if_fail(view != NULL) ;
00720         
00721         if(view->name_changed_handler_id != 0)
00722                 gtk_signal_handler_block(GTK_OBJECT(view->name),
00723                                          view->name_changed_handler_id) ;
00724         
00725         gtk_entry_set_text(view->name,"") ;
00726         mlview_attributes_list_clear(view->attributes);
00727         
00728         if(view->name_changed_handler_id != 0)
00729                 gtk_signal_handler_unblock(GTK_OBJECT(view->name),
00730                                            view->name_changed_handler_id) ;
00731 }
00732 
00737 static void
00738 mlview_node_editor_clear_xml_text_node_view(MlViewNodeEditor *a_node_editor)
00739 {
00740         XMLTextNodeView *view ;
00741         g_return_if_fail(a_node_editor != NULL) ;
00742         
00743         view = TEXT_NODE_VIEW(a_node_editor) ;
00744         g_return_if_fail(view != NULL) ;
00745 /*
00746  *FIXME: remember to block the "text-changed" signal (if used) before clearing the text node view.
00747  */
00748         gtk_text_set_point(view->content,0) ;
00749         gtk_text_forward_delete(view->content,gtk_text_get_length(view->content));
00750         
00751 }
00752 
00753 
00758 static void
00759 mlview_node_editor_clear_xml_comment_node_view(MlViewNodeEditor *a_node_editor)
00760 {
00761         XMLCommentNodeView * view ;
00762         
00763         g_return_if_fail( a_node_editor != NULL) ;
00764         view = COMMENT_NODE_VIEW(a_node_editor) ;
00765         g_return_if_fail(view != NULL) ;
00766         
00767         gtk_text_set_point(view->content,0) ;
00768         gtk_text_forward_delete(view->content,gtk_text_get_length(view->content));
00769         
00770 }
00771 
00775 static void
00776 mlview_node_editor_clear_xml_cdata_section_node_view(MlViewNodeEditor *a_node_editor)
00777 {
00778         XMLCDataSectionNodeView * view ;
00779         
00780         g_return_if_fail( a_node_editor != NULL) ;
00781         g_return_if_fail(PRIVATE(a_node_editor) != NULL) ;
00782 
00783         view = CDATA_SECTION_NODE_VIEW(a_node_editor) ;
00784         g_return_if_fail(view != NULL) ;
00785         
00786         gtk_text_set_point(view->content,0) ;
00787         gtk_text_forward_delete(view->content,gtk_text_get_length(view->content));
00788 }
00789 
00794 static void 
00795 mlview_node_editor_clear_xml_pi_node_view(MlViewNodeEditor *a_node_editor)
00796 {
00797         XMLPINodeView * view ;
00798 
00799         g_return_if_fail(a_node_editor != NULL) ;
00800         g_return_if_fail(PRIVATE(a_node_editor) != NULL) ;
00801 
00802         view = PI_NODE_VIEW(a_node_editor) ;
00803         g_return_if_fail(view != NULL) ;
00804         
00805         /*clear the pi node content editor*/
00806         gtk_text_set_point(view->content, 0) ;
00807         gtk_text_forward_delete(view->content, gtk_text_get_length(view->content)) ;
00808 
00809         /*clear the name*/
00810         gtk_editable_delete_text(GTK_EDITABLE(view->name),0,-1) ;
00811 }
00812 
00813 
00817 static void
00818 mlview_node_editor_xml_element_node_view_set_editable(MlViewNodeEditor *a_node_editor)
00819 {
00820         XMLElementNodeView *view ;
00821         
00822         g_return_if_fail(a_node_editor != NULL) ;
00823         view = ELEMENT_NODE_VIEW(a_node_editor) ;
00824         g_return_if_fail(view != NULL) ;
00825         
00826         gtk_entry_set_editable(view->name, PRIVATE(a_node_editor)->iseditable) ;
00827         mlview_attributes_list_set_editable(view->attributes, PRIVATE(a_node_editor)->iseditable) ;
00828 }
00829 
00833 static void
00834 mlview_node_editor_xml_text_node_view_set_editable(MlViewNodeEditor *a_node_editor)
00835 {
00836         XMLTextNodeView * view ;
00837 
00838         g_return_if_fail(a_node_editor != NULL) ;
00839         view = TEXT_NODE_VIEW(a_node_editor) ;
00840         g_return_if_fail(view != NULL) ;
00841         
00842         gtk_text_set_editable(view->content, PRIVATE(a_node_editor)->iseditable) ;      
00843 }
00844 
00848 static void
00849 mlview_node_editor_xml_cdata_section_node_view_set_editable(MlViewNodeEditor *a_node_editor)
00850 {
00851         XMLCDataSectionNodeView *view ;
00852         
00853         g_return_if_fail(a_node_editor != NULL) ;
00854         view = CDATA_SECTION_NODE_VIEW(a_node_editor) ;
00855         g_return_if_fail(view != NULL) ;
00856         
00857         gtk_text_set_editable(view->content, PRIVATE(a_node_editor)->iseditable) ;      
00858 }
00859 
00863 static void
00864 mlview_node_editor_xml_comment_node_view_set_editable(MlViewNodeEditor *a_node_editor)
00865 {
00866         XMLCommentNodeView *view ;
00867         
00868         g_return_if_fail(a_node_editor != NULL) ;
00869         view = COMMENT_NODE_VIEW(a_node_editor) ;
00870         g_return_if_fail(view != NULL) ;
00871         
00872         gtk_text_set_editable(view->content, PRIVATE(a_node_editor)->iseditable) ;      
00873 }
00874 
00878 static void
00879 mlview_node_editor_xml_pi_node_view_set_editable(MlViewNodeEditor *a_node_editor)
00880 {
00881         XMLPINodeView *view ;
00882         
00883         g_return_if_fail(a_node_editor != NULL) ;
00884         view = PI_NODE_VIEW(a_node_editor) ;
00885         g_return_if_fail(view != NULL) ;
00886         
00887         gtk_text_set_editable(view->content, PRIVATE(a_node_editor)->iseditable) ;
00888 }
00889 
00890 
00896 static void
00897 mlview_node_editor_xml_element_node_view_edit_xml_node (MlViewNodeEditor *a_editor,
00898                                                         MlViewXMLDocument * a_xml_doc,
00899                                                         xmlNode * a_node)
00900 {
00901         MlViewNodeEditorPrivate *editor_private = NULL ;
00902         XMLElementNodeView * editor_view = NULL ;
00903         gchar *full_name = NULL ;
00904 
00905         g_return_if_fail (a_editor != NULL) ;
00906         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
00907         g_return_if_fail (a_xml_doc != NULL) ;
00908         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
00909         g_return_if_fail (a_node != NULL) ;
00910         g_return_if_fail (PRIVATE(a_editor) != NULL) ;
00911 
00912         editor_private = PRIVATE(a_editor) ;
00913         editor_private->curr_xml_node = a_node ;
00914 
00915         editor_private->curr_xml_document = a_xml_doc ;
00916 
00917         if(a_node->type != XML_ELEMENT_NODE)
00918                 return ;
00919         editor_view = ELEMENT_NODE_VIEW(a_editor) ;
00920         g_return_if_fail(editor_view != NULL) ;
00921         
00922         if(a_node->ns != NULL  
00923            && a_node->ns->prefix
00924            && utils_is_white_string(a_node->ns->prefix) == FALSE){
00925                 full_name = g_strconcat(a_node->ns->prefix, ":", a_node->name, NULL) ;
00926         }else{
00927                 full_name = g_strdup(a_node->name) ;
00928         }
00929 
00930         /*set the name of the element*/
00931         gtk_signal_handler_block(GTK_OBJECT(editor_view->name),editor_view->name_changed_handler_id) ;
00932         gtk_entry_set_text(editor_view->name,"") ;
00933         gtk_entry_set_text(GTK_ENTRY(editor_view->name),full_name);
00934         if(full_name != NULL){
00935                 g_free(full_name) ;
00936                 full_name= NULL ;
00937         }
00938         gtk_signal_handler_unblock(GTK_OBJECT(editor_view->name),editor_view->name_changed_handler_id) ;
00939         /*edit the attributes*/
00940         mlview_attributes_list_clear(editor_view->attributes) ;
00941         mlview_attributes_list_edit_xml_attributes(editor_view->attributes, a_node) ;
00942         /*edit the namespaces*/
00943         mlview_namespace_editor_clear(editor_view->namespaces) ;
00944         mlview_namespace_editor_edit_node_visible_namespaces(editor_view->namespaces, a_node) ;
00945         gtk_notebook_set_page(editor_private->node_view,ELEMENT_NODE_VIEW_PAGE) ;               
00946         gtk_entry_set_text(editor_private->xml_node_type, _("Element node")) ;  
00947 }
00948 
00949 
00953 static void 
00954 mlview_node_editor_xml_text_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00955                                                      MlViewXMLDocument *a_xml_doc,
00956                                                      xmlNode * a_node)
00957 {
00958         MlViewNodeEditorPrivate *editor_private ;
00959         XMLTextNodeView * editor_view  ;
00960         gchar * content ;
00961 
00962         g_return_if_fail (a_editor != NULL) ;
00963         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
00964         g_return_if_fail (a_xml_doc != NULL) ;
00965         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
00966         g_return_if_fail (a_node != NULL) ;
00967         g_return_if_fail (PRIVATE (a_editor) != NULL) ;
00968 
00969         if(a_node->type != XML_TEXT_NODE)
00970                 return ;
00971 
00972         editor_view = TEXT_NODE_VIEW (a_editor) ;
00973         g_return_if_fail (editor_view != NULL) ;
00974 
00975         editor_private = PRIVATE (a_editor) ;
00976         editor_private->curr_xml_node = a_node ;
00977         editor_private->curr_xml_document = a_xml_doc ;
00978 
00979         content = xmlNodeGetContent (a_node) ;
00980         gtk_text_set_point (editor_view->content,0) ;
00981         gtk_text_forward_delete (editor_view->content,
00982                                  gtk_text_get_length (editor_view->content));
00983         gtk_text_insert (editor_view->content, NULL, NULL, NULL,
00984                         content, strlen (content));
00985         g_free (content); 
00986         gtk_notebook_set_page (editor_private->node_view, TEXT_NODE_VIEW_PAGE) ;
00987         gtk_entry_set_text (editor_private->xml_node_type, _("Text node")) ;    
00988 }
00989 
00996 static void 
00997 mlview_node_editor_xml_comment_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
00998                                                         MlViewXMLDocument * a_xml_doc,
00999                                                         xmlNode * a_node)
01000 {
01001         MlViewNodeEditorPrivate *editor_private = NULL ;
01002         XMLCommentNodeView * editor_view = NULL ;
01003         gchar * content = NULL ;
01004 
01005         g_return_if_fail (a_editor != NULL) ;
01006         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01007         g_return_if_fail (a_xml_doc != NULL) ;
01008         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
01009         g_return_if_fail (a_node != NULL) ;
01010         g_return_if_fail (PRIVATE(a_editor) !=NULL ) ;
01011 
01012         if(a_node->type != XML_COMMENT_NODE)
01013                 return ;
01014         
01015 
01016         editor_view = COMMENT_NODE_VIEW (a_editor) ;
01017         g_return_if_fail (editor_view != NULL) ;
01018         editor_private = PRIVATE (a_editor) ;
01019         editor_private->curr_xml_node = a_node ;
01020         editor_private->curr_xml_document = a_xml_doc ;
01021 
01022         content = xmlNodeGetContent (a_node) ;
01023         gtk_text_set_point (editor_view->content,0) ;
01024         gtk_text_forward_delete (editor_view->content,
01025                                  gtk_text_get_length (editor_view->content));
01026         gtk_text_insert (editor_view->content, NULL, NULL, NULL,
01027                          content, strlen (content));
01028         g_free (content);
01029         gtk_notebook_set_page (editor_private->node_view, COMMENT_NODE_VIEW_PAGE) ;
01030         gtk_entry_set_text (editor_private->xml_node_type, _("Comment node")) ;
01031 }
01032 
01038 static void 
01039 mlview_node_editor_xml_cdata_section_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
01040                                                               MlViewXMLDocument *a_xml_doc,
01041                                                               xmlNode * a_node)
01042 {
01043         MlViewNodeEditorPrivate *editor_private = NULL ;
01044         XMLCDataSectionNodeView * editor_view = NULL ;
01045         gchar * content = NULL ;
01046 
01047         g_return_if_fail (a_editor) ;
01048         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01049         g_return_if_fail (a_xml_doc != NULL) ;
01050         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
01051         g_return_if_fail (a_node) ;
01052         g_return_if_fail (PRIVATE(a_editor) != NULL) ;
01053 
01054         editor_view = CDATA_SECTION_NODE_VIEW (a_editor) ;
01055         g_return_if_fail (editor_view) ;
01056 
01057         editor_private = PRIVATE (a_editor) ;
01058         editor_private->curr_xml_node = a_node ;
01059         editor_private->curr_xml_document = a_xml_doc ;
01060 
01061         content = xmlNodeGetContent (a_node) ;
01062 
01063         gtk_text_set_point (editor_view->content, 0) ;
01064 
01065         gtk_text_forward_delete (editor_view->content,
01066                                  gtk_text_get_length (editor_view->content));
01067 
01068         gtk_text_insert (editor_view->content,NULL,NULL,NULL,
01069                         content, strlen (content));
01070 
01071         g_free (content);
01072         gtk_notebook_set_page (editor_private->node_view, CDATA_SECTION_VIEW_PAGE) ;
01073         gtk_entry_set_text(editor_private->xml_node_type, _("CDATA Section node")) ;
01074         
01075 }
01076 
01082 static void 
01083 mlview_node_editor_xml_pi_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
01084                                                    MlViewXMLDocument *a_xml_doc,
01085                                                    xmlNode * a_node)
01086 {
01087         MlViewNodeEditorPrivate *editor_private = NULL ;
01088         XMLPINodeView * editor_view = NULL;
01089         gchar * content = NULL, *full_name=NULL ;
01090 
01091         g_return_if_fail (a_editor != NULL) ;
01092         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01093         g_return_if_fail (a_xml_doc != NULL) ;
01094         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
01095         g_return_if_fail (a_node != NULL) ;
01096         g_return_if_fail (PRIVATE(a_editor) != NULL) ;
01097 
01098         editor_view = PI_NODE_VIEW (a_editor) ;
01099         g_return_if_fail (editor_view != NULL) ;
01100         editor_private = PRIVATE (a_editor) ;
01101         editor_private->curr_xml_node = a_node ;
01102         editor_private->curr_xml_document = a_xml_doc ;
01103 
01104         if (a_node->ns && !utils_is_white_string((const gchar*)a_node->ns->prefix)) {
01105                 full_name = g_strconcat (a_node->ns->prefix, ":", a_node->name, NULL) ;
01106         } else {
01107                 full_name = g_strdup (a_node->name) ;
01108         }
01109         /*get the name of the element.*/
01110         gtk_signal_handler_block (GTK_OBJECT (editor_view->name),
01111                                   editor_view->name_changed_handler_id) ;
01112         gtk_entry_set_text (editor_view->name,"") ;
01113         gtk_entry_set_text (GTK_ENTRY (editor_view->name), 
01114                             full_name);
01115         if (full_name)
01116                 g_free (full_name) ;
01117         gtk_signal_handler_unblock (GTK_OBJECT (editor_view->name), 
01118                                     editor_view->name_changed_handler_id) ;
01119 
01120         /*edit the content*/
01121         content = xmlNodeGetContent (a_node);
01122         gtk_text_set_point (editor_view->content, 0) ;
01123         gtk_text_forward_delete (editor_view->content,
01124                                  gtk_text_get_length (editor_view->content));
01125 
01126         gtk_text_insert (editor_view->content, NULL, NULL, NULL,
01127                         content, strlen (content));
01128         g_free (content);
01129         gtk_notebook_set_page (editor_private->node_view, 
01130                                PI_NODE_VIEW_PAGE) ;
01131         gtk_entry_set_text (editor_private->xml_node_type, 
01132                             _("PI node")) ;     
01133 }
01134 
01135 
01141 static void 
01142 mlview_node_editor_xml_doc_node_view_edit_xml_node (MlViewNodeEditor *a_editor, 
01143                                                     MlViewXMLDocument *a_xml_doc,
01144                                                     xmlNode * a_node)
01145 {
01146         MlViewNodeEditorPrivate *editor_private = NULL ;
01147         XMLDocNodeView * editor_view = NULL ;
01148 
01149         g_return_if_fail (a_editor != NULL) ;
01150         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01151         g_return_if_fail (a_xml_doc != NULL) ;
01152         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
01153         g_return_if_fail (a_node != NULL) ;
01154         g_return_if_fail (PRIVATE(a_editor) != NULL) ;
01155         
01156         if(a_node->type != XML_DOCUMENT_NODE)
01157                 return ;
01158         editor_view = DOC_NODE_VIEW(a_editor) ;
01159         g_return_if_fail (editor_view != NULL) ;
01160         editor_private = PRIVATE (a_editor) ;
01161         editor_private->curr_xml_node = a_node ;
01162         editor_private->curr_xml_document = a_xml_doc ;
01163 
01164         /*get the name of the element.*/
01165         gtk_signal_handler_block (GTK_OBJECT (editor_view->name),
01166                                   editor_view->name_changed_handler_id) ;
01167         gtk_entry_set_text (editor_view->name, "") ;
01168 
01169         if (a_node->name != NULL)
01170                 gtk_entry_set_text (GTK_ENTRY (editor_view->name),
01171                                     a_node->name);
01172         else
01173                 gtk_entry_set_text (GTK_ENTRY (editor_view->name),
01174                                     "");
01175         gtk_signal_handler_unblock (GTK_OBJECT (editor_view->name),
01176                                     editor_view->name_changed_handler_id) ;
01177 
01178         /*get the standalone*/
01179         if( ((xmlDocPtr)a_node)->extSubset ) {
01180 
01181                 gtk_entry_set_text (editor_view->standalone, 
01182                                    _("NO")) ;
01183                 ((xmlDocPtr)a_node)->standalone = TRUE ;
01184 
01185         } else {
01186 
01187                 gtk_entry_set_text(editor_view->standalone, 
01188                                    _("YES")) ;
01189                 ((xmlDocPtr)a_node)->standalone = FALSE ;
01190 
01191         }
01192 
01193         /*get the xml version*/
01194         if (((xmlDocPtr)a_node)->version)
01195                 gtk_entry_set_text (editor_view->xml_version, 
01196                                     ((xmlDocPtr)a_node)->version) ;
01197         else
01198                 gtk_entry_set_text (editor_view->xml_version,
01199                                     "1.0") ;
01200 
01201         /*get the external encoding*/
01202         if (((xmlDocPtr)a_node)->encoding)
01203                 gtk_entry_set_text (editor_view->external_encoding, 
01204                                     ((xmlDocPtr)a_node)->encoding) ;
01205         else
01206                 gtk_entry_set_text (editor_view->external_encoding, 
01207                                     "auto") ;
01208         
01209         /*get stuffs about the external subset*/
01210         if (((xmlDocPtr)a_node)->extSubset && ((xmlDocPtr)a_node)->extSubset->ExternalID) {
01211                 gtk_entry_set_text (editor_view->ext_subset_external_id, 
01212                                    ((xmlDocPtr)a_node)->extSubset->ExternalID) ;
01213         }
01214 
01215         if (((xmlDocPtr)a_node)->extSubset && ((xmlDocPtr)a_node)->extSubset->SystemID) {
01216                 gtk_entry_set_text (editor_view->ext_subset_system_id, 
01217                                     ((xmlDocPtr)a_node)->extSubset->SystemID) ;
01218         }
01219 
01220         gtk_notebook_set_page (editor_private->node_view,
01221                                DOC_NODE_VIEW_PAGE) ;
01222 
01223         gtk_entry_set_text (editor_private->xml_node_type,
01224                             _("xml document node")) ;
01225 }
01226 
01227         
01228 /*
01229  *===================================================================
01230  *private signal handlers
01231  *FIXME: recode everything below to support the private field in MlViewNodeEditor and the different views ...
01232  *===================================================================
01233  */
01234 
01239 static void
01240 mlview_node_editor_editable_state_changed_cb(GtkWidget *a_widget,MlViewNodeEditor* a_editor)
01241 {
01242         g_return_if_fail(a_widget != NULL) ;
01243         g_return_if_fail(a_editor != NULL) ;
01244         
01245         mlview_node_editor_set_editable(a_editor, ! (PRIVATE(a_editor)->iseditable)) ;
01246         
01247 }
01248 
01249 
01258 static void
01259 mlview_node_editor_name_changed_cb (GtkWidget *a_entry, 
01260                                     MlViewNodeEditor *a_editor)
01261 {
01262         gchar *full_name = NULL, *local_name = NULL ;
01263         xmlNs * ns = NULL ;
01264 
01265         g_return_if_fail(a_entry != NULL) ;
01266         g_return_if_fail(a_editor != NULL) ;
01267         g_return_if_fail(PRIVATE(a_editor) != NULL) ;
01268         g_return_if_fail(PRIVATE(a_editor)->curr_xml_node != NULL) ;
01269 
01270         if (PRIVATE (a_editor)->curr_xml_node->type == XML_ELEMENT_NODE 
01271             || PRIVATE (a_editor)->curr_xml_node->type == XML_PI_NODE) {
01272 
01273                 full_name = gtk_entry_get_text (GTK_ENTRY (a_entry)) ;
01274                 utils_parse_full_name (PRIVATE (a_editor)->curr_xml_node, 
01275                                        full_name, &ns, &local_name) ;
01276                 if (ns != NULL) {
01277                         xmlSetNs (PRIVATE (a_editor)->curr_xml_node, ns) ;
01278                 } else {
01279                         PRIVATE (a_editor)->curr_xml_node->ns = NULL ;
01280                 }
01281                 //xmlNodeSetName(PRIVATE(a_editor)->curr_xml_node, local_name) ;
01282                 mlview_xml_document_set_node_name (PRIVATE (a_editor)->curr_xml_document,
01283                                                    PRIVATE (a_editor)->curr_xml_node,
01284                                                    local_name) ;
01285                 if (local_name)
01286                         g_free (local_name) ;
01287 
01288                 gtk_signal_emit (GTK_OBJECT (a_editor),
01289                                  mlview_node_editor_signals[ELEMENT_CHANGED]) ;
01290         }
01291 }
01292 
01296 static void
01297 mlview_node_editor_attribute_changed_cb (MlViewAttributesList* a_attributes, gpointer a_node_editor)
01298 {
01299         MlViewNodeEditor *node_editor ;
01300         g_return_if_fail(a_attributes) ;
01301         g_return_if_fail(a_node_editor) ;
01302         
01303         node_editor = MLVIEW_NODE_EDITOR(a_node_editor) ;
01304         gtk_signal_emit(GTK_OBJECT(node_editor), mlview_node_editor_signals[ELEMENT_CHANGED]) ;
01305 }
01306 
01312 static void
01313 mlview_node_editor_content_changed_cb (GtkText * a_content,
01314                                        MlViewNodeEditor *a_editor)
01315 {
01316         gchar *content ;
01317         g_return_if_fail (a_content != NULL) ;
01318         g_return_if_fail (GTK_IS_TEXT (a_content)) ;
01319         g_return_if_fail (a_editor != NULL) ;
01320         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01321         g_return_if_fail (PRIVATE (a_editor) != NULL) ;
01322         g_return_if_fail (PRIVATE (a_editor)->curr_xml_node != NULL) ;
01323         g_return_if_fail (PRIVATE (a_editor)->curr_xml_document != NULL) ;
01324 
01325         content = gtk_editable_get_chars(GTK_EDITABLE(a_content),0,-1) ;
01326         //xmlNodeSetContent(PRIVATE(a_editor)->curr_xml_node, content) ;
01327         mlview_xml_document_set_node_content (PRIVATE (a_editor)->curr_xml_document, 
01328                                               PRIVATE(a_editor)->curr_xml_node,
01329                                               content) ;
01330 
01331         gtk_signal_emit(GTK_OBJECT(a_editor),mlview_node_editor_signals[ELEMENT_CONTENT_CHANGED],content) ;
01332         gtk_signal_emit(GTK_OBJECT(a_editor),mlview_node_editor_signals[ELEMENT_CHANGED]) ;
01333         g_free(content) ;
01334 }
01335 
01336 
01337 static void 
01338 mlview_node_editor_configure_event_cb (GtkWidget * a_node_editor, 
01339                                        GdkEventConfigure * a_event, 
01340                                        gpointer a_data)
01341 {
01342         MlViewNodeEditor *node_editor ;
01343 
01344         g_return_if_fail (a_node_editor != NULL) ;
01345         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_node_editor) != TRUE) ;
01346         g_return_if_fail (a_event->type != GDK_CONFIGURE) ;
01347 
01348         node_editor = 
01349                 MLVIEW_NODE_EDITOR (a_node_editor) ;
01350         mlview_node_editor_set_left_right_percentage (node_editor, 
01351                                                       PRIVATE(node_editor)->left_right_percentage) ;
01352 }
01353 
01354 /*=========================================
01355  *private gtk object framework methods
01356  *=========================================*/
01357 
01362 guint
01363 mlview_node_editor_get_type(void)
01364 {
01365 
01366         static guint mlview_node_editor_type=0 ;
01367         if(!mlview_node_editor_type){
01368                 const static GtkTypeInfo mlview_node_editor_type_info =
01369                 {
01370                         "MlViewNodeEditor",
01371                         sizeof(MlViewNodeEditor),
01372                         sizeof(MlViewNodeEditorClass),
01373                         (GtkClassInitFunc)mlview_node_editor_class_init ,
01374                         (GtkObjectInitFunc)mlview_node_editor_init,
01375                         NULL,
01376                         NULL,
01377                         (GtkClassInitFunc)NULL
01378                 };
01379                 mlview_node_editor_type = gtk_type_unique(gtk_hpaned_get_type(), &mlview_node_editor_type_info);
01380         }
01381         return mlview_node_editor_type ;
01382 }
01383 
01390 static void
01391 mlview_node_editor_class_init(MlViewNodeEditorClass *a_klass)
01392 {
01393         GtkObjectClass * object_class = GTK_OBJECT_CLASS(a_klass) ;
01394         parent_class = gtk_type_class(gtk_hpaned_get_type()) ;
01395   
01396         object_class->destroy=mlview_node_editor_destroy ; /*overload the destroy method of object*/
01397   
01398         /*signal definitions*/
01399         mlview_node_editor_signals[ELEMENT_CHANGED]=gtk_signal_new("element-changed",
01400                                                                       GTK_RUN_FIRST,
01401                                                                       object_class->type,
01402                                                                       GTK_SIGNAL_OFFSET(MlViewNodeEditorClass,element_changed),
01403                                                                       gtk_marshal_NONE__NONE,
01404                                                                       GTK_TYPE_NONE,0);
01405         mlview_node_editor_signals[ELEMENT_NAME_CHANGED]=gtk_signal_new("element-name-changed",
01406                                                                            GTK_RUN_FIRST,
01407                                                                            object_class->type,
01408                                                                            GTK_SIGNAL_OFFSET(MlViewNodeEditorClass,element_name_changed),
01409                                                                            gtk_marshal_NONE__NONE,
01410                                                                            GTK_TYPE_NONE,0);
01411         mlview_node_editor_signals[ELEMENT_ATTRIBUTE_CHANGED]=gtk_signal_new("element-attribute-changed",
01412                                                                                 GTK_RUN_FIRST,
01413                                                                                 object_class->type,
01414                                                                                 GTK_SIGNAL_OFFSET(MlViewNodeEditorClass,element_attribute_changed),
01415                                                                                 gtk_marshal_NONE__NONE,
01416                                                                                 GTK_TYPE_NONE,0) ;
01417         mlview_node_editor_signals[ELEMENT_CONTENT_CHANGED]=gtk_signal_new("element-content-changed",
01418                                                                               GTK_RUN_FIRST,
01419                                                                               object_class->type,
01420                                                                               GTK_SIGNAL_OFFSET(MlViewNodeEditorClass,element_content_changed),
01421                                                                               gtk_marshal_NONE__NONE,
01422                                                                               GTK_TYPE_NONE,0);
01423         mlview_node_editor_signals[EDIT_STATE_CHANGED]=gtk_signal_new("edit-state-changed",
01424                                                                          GTK_RUN_FIRST,
01425                                                                          object_class->type,
01426                                                                          GTK_SIGNAL_OFFSET(MlViewNodeEditorClass,edit_state_changed),
01427                                                                          gtk_marshal_NONE__NONE,
01428                                                                          GTK_TYPE_NONE,0) ;
01429         gtk_object_class_add_signals(object_class, mlview_node_editor_signals, NUMBER_OF_SIGNALS) ;
01430         a_klass->element_changed=NULL ; /*no default signal handler for signal "document-changed"*/
01431         a_klass->element_name_changed=NULL ;
01432         a_klass->element_attribute_changed=NULL ;
01433         a_klass->element_content_changed=NULL ;
01434         a_klass->edit_state_changed=NULL;
01435 }
01436 
01437 static void 
01438 mlview_node_editor_construct (MlViewNodeEditor * a_node_editor,
01439                               MlViewAppContext *a_app_context)
01440 {
01441         MlViewNodeEditorPrivate *private_data ; 
01442         GtkWidget *label = NULL, *table = NULL ;
01443         GtkWidget *combo = NULL ;
01444         GList *list2 = NULL ;
01445 
01446         g_return_if_fail (a_node_editor != NULL) ;
01447         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_node_editor)) ;
01448         g_return_if_fail (PRIVATE (a_node_editor) != NULL) ;
01449 
01450         
01451         private_data = PRIVATE (a_node_editor) ;
01452         private_data->curr_xml_node = NULL ;
01453         private_data->iseditable = TRUE;
01454         private_data->app_context = a_app_context ;
01455         
01456         private_data->left_margin = GTK_VBOX (gtk_vbox_new (FALSE, 0)) ;
01457         private_data->node_view = GTK_NOTEBOOK (gtk_notebook_new ());
01458         gtk_notebook_set_show_tabs (private_data->node_view, FALSE) ;
01459         gtk_notebook_popup_disable (private_data->node_view) ;
01460         gtk_paned_add1 (GTK_PANED (a_node_editor), GTK_WIDGET (private_data->left_margin)) ;
01461         gtk_paned_add2 (GTK_PANED (a_node_editor), GTK_WIDGET (private_data->node_view)) ;
01462         
01463         /*build left margin ...*/
01464         label = gtk_label_new (_("Node type")) ;
01465         private_data->xml_node_type = GTK_ENTRY (gtk_entry_new ()) ;
01466         
01467         gtk_entry_set_editable (GTK_ENTRY (private_data->xml_node_type),
01468                                 FALSE) ;
01469         table = gtk_table_new (1,2,TRUE) ;
01470         gtk_box_pack_start (GTK_BOX (private_data->left_margin),
01471                             table,FALSE,FALSE,0) ;
01472         gtk_table_attach_defaults (GTK_TABLE (table),
01473                                    label,
01474                                    0,1,0,1) ;
01475         gtk_table_attach_defaults (GTK_TABLE (table),
01476                                    GTK_WIDGET (private_data->xml_node_type),
01477                                    1,2,0,1) ;
01478         gtk_widget_show_all (table) ;
01479                         
01480         label = gtk_label_new (_("Edit State: ")) ;
01481         list2 = g_list_append (list2, _("Editable")) ;
01482         list2 = g_list_append (list2, _("Read Only")) ; 
01483         combo = gtk_combo_new () ;
01484         gtk_combo_set_popdown_strings (GTK_COMBO (combo),
01485                                        list2) ;
01486         gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combo)->entry),
01487                             "changed",
01488                             GTK_SIGNAL_FUNC (mlview_node_editor_editable_state_changed_cb),
01489                             (gpointer) a_node_editor) ;
01490         table = gtk_table_new (1,2,TRUE) ;
01491         gtk_box_pack_start (GTK_BOX (private_data->left_margin),
01492                             table,FALSE,FALSE,0) ;
01493         gtk_table_attach_defaults (GTK_TABLE (table),
01494                                    label,
01495                                    0,1,0,1) ;
01496         gtk_table_attach_defaults (GTK_TABLE (table),
01497                                    combo,
01498                                    1,2,0,1) ;
01499         gtk_widget_show_all (table) ;
01500         
01501         /*handle size modif of the window*/
01502         gtk_signal_connect (GTK_OBJECT (a_node_editor),
01503                             "configure_event",
01504                             GTK_SIGNAL_FUNC (mlview_node_editor_configure_event_cb),
01505                             NULL) ;
01506         
01507         /*now that the mlview app context context has been passed to this object, can build
01508          *sub components that need that context.
01509          */
01510         mlview_node_editor_build_xml_element_node_view (a_node_editor) ;
01511         mlview_node_editor_build_xml_text_node_view (a_node_editor) ;
01512         mlview_node_editor_build_xml_comment_node_view (a_node_editor) ;
01513         mlview_node_editor_build_xml_cdata_section_node_view (a_node_editor) ;
01514         mlview_node_editor_build_xml_pi_node_view (a_node_editor) ;
01515         mlview_node_editor_build_xml_doc_node_view (a_node_editor) ;
01516         mlview_node_editor_set_editable (a_node_editor, TRUE) ;
01517 }
01518 
01519 
01524 static void 
01525 mlview_node_editor_init (MlViewNodeEditor *a_node_editor)
01526 {                       
01527         if (PRIVATE (a_node_editor) == NULL)
01528                 PRIVATE (a_node_editor) = g_malloc0 (sizeof (MlViewNodeEditorPrivate)) ;
01529         
01530 }
01531 
01532 /*============================================
01533  *public exported methods
01534  *===========================================
01535  */
01536 
01541 GtkWidget *
01542 mlview_node_editor_new(MlViewAppContext *a_app_context)
01543 {
01544         MlViewNodeEditor *editor ;
01545 
01546         editor = gtk_type_new(MLVIEW_TYPE_NODE_EDITOR) ;
01547         mlview_node_editor_construct (editor, a_app_context) ;
01548         
01549         return GTK_WIDGET(editor);
01550 }
01551 
01552 
01557 void
01558 mlview_node_editor_set_application_context (MlViewNodeEditor *a_node_editor,
01559                                             MlViewAppContext *a_app_context)
01560 {
01561         g_return_if_fail (a_node_editor != NULL) ;
01562         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_node_editor)) ;
01563         g_return_if_fail (PRIVATE (a_node_editor) != NULL) ;
01564 
01565         PRIVATE (a_node_editor)->app_context = a_app_context ;
01566 }
01567 
01568 
01569 MlViewAppContext * 
01570 mlview_node_editor_get_application_context (MlViewNodeEditor *a_node_editor)
01571 {
01572         g_return_val_if_fail (a_node_editor != NULL, NULL) ;
01573         g_return_val_if_fail (MLVIEW_IS_NODE_EDITOR (a_node_editor), NULL) ;
01574         g_return_val_if_fail (PRIVATE (a_node_editor) != NULL, NULL) ;
01575 
01576         return PRIVATE (a_node_editor)->app_context ;
01577 }
01578 
01584 xmlNodePtr 
01585 mlview_node_editor_get_current_xml_node (MlViewNodeEditor *a_editor)
01586 {
01587         g_return_val_if_fail(a_editor != NULL , NULL) ;
01588         return PRIVATE(a_editor)->curr_xml_node ;
01589 }
01590 
01591 
01596 void
01597 mlview_node_editor_edit_xml_node (MlViewNodeEditor *a_editor, 
01598                                  MlViewXMLDocument *a_xml_doc, 
01599                                  xmlNode *a_node)
01600 {               
01601         /*some sanity checks */
01602         g_return_if_fail (a_editor != NULL) ;
01603         g_return_if_fail (MLVIEW_IS_NODE_EDITOR (a_editor)) ;
01604         g_return_if_fail(PRIVATE (a_editor) != NULL) ;
01605         g_return_if_fail (a_xml_doc != NULL) ;
01606         g_return_if_fail (MLVIEW_IS_XML_DOCUMENT (a_xml_doc)) ;
01607 
01608         PRIVATE (a_editor)->curr_xml_node = a_node ;
01609         g_return_if_fail(PRIVATE (a_editor)->curr_xml_node != NULL) ;
01610 
01611         switch (a_node->type) {
01612         case XML_ELEMENT_NODE:
01613                 /*edit the element node using th XMLElementNodeView of the element editor*/
01614                 mlview_node_editor_xml_element_node_view_edit_xml_node (a_editor, 
01615                                                                         a_xml_doc, 
01616                                                                         a_node) ;
01617                 break ;
01618         case XML_TEXT_NODE:
01619                 /*show the text content using the XMLTextNodeView of the element editor*/
01620                 mlview_node_editor_xml_text_node_view_edit_xml_node (a_editor, 
01621                                                                     a_xml_doc, 
01622                                                                     a_node) ;
01623                 break ;
01624                 
01625         case XML_CDATA_SECTION_NODE:
01626                 /*show the cdata using th XMLCDataSectionNodeView of the element editor*/
01627                 mlview_node_editor_xml_cdata_section_node_view_edit_xml_node (a_editor, 
01628                                                                               a_xml_doc,
01629                                                                               a_node) ;
01630                 break ;
01631 
01632         case XML_COMMENT_NODE:
01633                 mlview_node_editor_xml_comment_node_view_edit_xml_node(a_editor,
01634                                                                        a_xml_doc,
01635                                                                        a_node) ;
01636                 break ;
01637 
01638         case XML_DOCUMENT_NODE:
01639                 mlview_node_editor_xml_doc_node_view_edit_xml_node(a_editor, 
01640                                                                    a_xml_doc,
01641                                                                    a_node) ;
01642                 break ;
01643 
01644         case XML_PI_NODE:
01645                 mlview_node_editor_xml_pi_node_view_edit_xml_node(a_editor, 
01646                                                                   a_xml_doc,
01647                                                                   a_node) ;
01648                 break ;
01649 
01650         default:
01651                 break ;
01652         }
01653         /*FIXME: remove the provious children of right side of a_editor*/
01654         gtk_widget_show_all(GTK_WIDGET (PRIVATE (a_editor)->node_view)) ;
01655 }/*end mlview_node_editor_edit_xml_node*/
01656 
01661 void
01662 mlview_node_editor_clear (MlViewNodeEditor *a_editor)
01663 {
01664         g_return_if_fail(a_editor!=NULL) ;
01665         /*clear all the views*/
01666         mlview_node_editor_clear_xml_element_node_view(a_editor) ;
01667         mlview_node_editor_clear_xml_text_node_view(a_editor) ;
01668         mlview_node_editor_clear_xml_comment_node_view(a_editor) ;
01669         mlview_node_editor_clear_xml_cdata_section_node_view(a_editor) ;
01670 }
01671 
01678 void
01679 mlview_node_editor_set_editable(MlViewNodeEditor *a_editor, gboolean a_editable)
01680 {
01681         MlViewNodeEditorPrivate *private_data ;
01682         g_return_if_fail(a_editor!=NULL) ;
01683         private_data = PRIVATE(a_editor) ;
01684         g_return_if_fail(private_data) ;
01685         
01686         private_data->iseditable = a_editable ;
01687         
01688         mlview_node_editor_xml_element_node_view_set_editable(a_editor) ;
01689         mlview_node_editor_xml_text_node_view_set_editable(a_editor) ;
01690         mlview_node_editor_xml_cdata_section_node_view_set_editable(a_editor) ;
01691         mlview_node_editor_xml_comment_node_view_set_editable(a_editor) ;
01692         mlview_node_editor_xml_pi_node_view_set_editable(a_editor) ;
01693 
01694         gtk_signal_emit(GTK_OBJECT(a_editor),mlview_node_editor_signals[EDIT_STATE_CHANGED]) ;
01695 }
01696 
01700 void 
01701 mlview_node_editor_set_left_right_percentage(MlViewNodeEditor * a_node_editor, const guint a_percentage)
01702 {
01703         guint separator_position ;
01704         GtkWidget * top_level_widget ;
01705 
01706         g_return_if_fail(a_node_editor != NULL) ;
01707         g_return_if_fail(PRIVATE(a_node_editor) != NULL) ;
01708         top_level_widget = gtk_widget_get_toplevel(GTK_WIDGET(a_node_editor)) ;
01709         g_return_if_fail(top_level_widget != NULL) ;
01710 
01711         PRIVATE(a_node_editor)->left_right_percentage = a_percentage ;  
01712         separator_position = top_level_widget->allocation.width * a_percentage / 100 ;
01713         gtk_paned_set_position(GTK_PANED(a_node_editor),separator_position) ;
01714         gtk_widget_show_all(GTK_WIDGET(a_node_editor)) ;
01715 }
01716 
01717 
01721 void
01722 mlview_node_editor_destroy(GtkObject *a_object)
01723 {
01724         MlViewNodeEditor *editor ;
01725         MlViewNodeEditorPrivate *private_data ;
01726         
01727         g_return_if_fail(a_object !=NULL) ;
01728         g_return_if_fail(MLVIEW_IS_NODE_EDITOR(a_object)) ;
01729         g_return_if_fail(PRIVATE(MLVIEW_NODE_EDITOR(a_object)) != NULL) ;
01730         
01731         editor=MLVIEW_NODE_EDITOR(a_object) ;
01732         private_data = PRIVATE(editor) ;
01733 
01734         if(private_data->element_node_view != NULL){
01735                 XMLElementNodeView *view = private_data->element_node_view ;
01736                 if(view->vbox){
01737                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01738                         view->vbox=NULL ;
01739                 }
01740                 g_free(view) ;
01741                 view = NULL ;
01742         }
01743         if(private_data->text_node_view != NULL){
01744                 XMLTextNodeView *view = private_data->text_node_view ;
01745                 if(view->vbox){
01746                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01747                         view->vbox = NULL ;
01748                 }
01749                 g_free(view) ;
01750                 view = NULL ;
01751         }
01752         if(private_data->comment_node_view != NULL){
01753                 XMLCommentNodeView *view = private_data->comment_node_view ;
01754                 if(view->vbox){
01755                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01756                         view->vbox = NULL ;
01757                 }
01758                 g_free(view) ;
01759                 view = NULL ;
01760         }
01761         if(private_data->cdata_section_node_view != NULL){
01762                 XMLCDataSectionNodeView *view = private_data->cdata_section_node_view ;
01763                 if(view->vbox){
01764                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01765                         view->vbox = NULL ;
01766                 }
01767                 g_free(view) ;
01768                 view = NULL ;
01769         }
01770         if(private_data->pi_node_view != NULL){
01771                 XMLPINodeView *view = private_data->pi_node_view ;
01772                 if(view->vbox){
01773                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01774                         view->vbox = NULL ;
01775                 }
01776                 g_free(view) ;
01777                 view = NULL ;
01778         }
01779         if(private_data->doc_node_view != NULL){
01780                 XMLDocNodeView *view = private_data->doc_node_view ;
01781                 if(view->vbox){
01782                         gtk_widget_destroy(GTK_WIDGET(view->vbox)) ;
01783                         view->vbox = NULL ;
01784                 }
01785                 g_free(view) ;
01786                 view = NULL ;
01787         }
01788         if(private_data->left_margin){
01789                 gtk_widget_destroy(GTK_WIDGET(private_data->left_margin)) ;
01790                 private_data->left_margin = NULL ;
01791         }
01792         if(PRIVATE(editor) != NULL){/*this if clause should be the last one before the one that follows*/
01793                 g_free(PRIVATE(editor)) ;
01794                 PRIVATE(editor) = NULL ;
01795         }
01796         
01797         /*do not delete curr_xml_node cause it is to be freed by the MlViewTreeEditor*/
01798         if(*GTK_OBJECT_CLASS(parent_class)->destroy)
01799                 (*GTK_OBJECT_CLASS(parent_class)->destroy)(a_object);
01800 }

Generated on Sat Jul 6 09:57:34 2002 for Gnome-MlView by doxygen1.2.16