-->
Home » » MlView is a tree-oriented XML editor written in C++ and is heavily based on gtkmm and the GNOME libraries
Friday
27 November 2009

MlView is a tree-oriented XML editor written in C++ and is heavily based on gtkmm and the GNOME libraries

mlview MlView is a tree-oriented XML editor for GNOME. It is written in C++ and is heavily based on gtkmm and the GNOME libraries. Its aim is to ease XML editing, with or without validation.

Chapter 1. Why this document ?

The purpose of this document is to help people willing to understand the internals of MlView. We tried to write down the general design principles of the project because we think that grasping the big picture helps to understand the code. Another important thing to notice is that this document has been authored in docbook using MlView itself. It is therefore a nice playground to find and address bugs and usability issues of the editor.

Chapter 2. Overview

MlView is a generic XML editor that can edit all types of xml documents. MlView's design is organized around the Model/View/Controller paradigm. The model a.k.a "document model" is an in memory representation of the XML document. The views are the things (namely widgets) that allow the user to edit the document Model. In other words, views are what allows the user to perform editing actions on the document model. Controllers are somehow what does the glue between the document model and the editing views.

Each type of view "exports" the editing actions that it allows. Some view may allow the user to work on the structure of the document, other views may allow her to work in a more textual form, for example. These two hypothetical types of views would obviously "export" to different sets of edition actions.

The MlView editor can then be seen as a container of views and documents. Each view being "connected" to one document model. When a view issues an editing action on a document model, this model emits signals to reflect its new state. View that are connected to that document can then receive these signals and update themselves to reflect the new state of the document they are connected to.

mlview-0.7

Chapter 3. MlView's main classes



The code of MlVIew, though in C, is heavily object oriented. One of the key classes is the MlViewEditor class. It's basically the abstraction of the views and documents container. This class can instanciate and destroy of views (instances of MlViewIView) and documents (instances of MlViewXMLDocument).

  • MlViewEditor.�This is what abstracts the editor. it's basically a container of views and documents. It provides methods to manage documents and views, namely: open documents, save documents close views etc ...

  • MlViewIView.This is the abstract interface implemented by all the editing views. It defines methods to connect/disconnect the view to/from a document model, set the name of the view, get the document the view is related to, execute an editing action. One should keep in mind that an editing view is generally not a single widget. In our terminology, and editing view is a set of widgets that lets the user edit a document.

  • MlViewAppContext.I hate global variables. Especially variables which scope si wider than a class. In MlView, a class takes one source file. Again, I hate variables which scopes are wider than a file. That being said, all the classes of MlView need to share some data and behaviour. MlViewAppContext is there for that purpose: share data and behaviour across the different classes of MlView. This class contains methods to display error/warning messages (in an unified way), access application wide settings, set/query key/value pairs etc ... Generally, all the classes of MlView have methods to set/get an instance of MlViewAppContext so that they can have access to all the needed application wide data and behaviour. A single instance of MlViewAppContext is created at the MlView launch time and is "passed" to all the classes that are further created.

  • MlViewApp.This is an abstraction of the MlView application. Its duty is to build the main window, the main toolbar, the application wide instance of MlViewAppContext and the instance of MlViewEditor.

  • MlViewViewAdapter.This is a minimal implementation of MlViewIView. It aimes at providing a class that editing views can derive from. It implements all the interfaces of MlViewIView and does basically nothing. All the editing views can then inherit from MlViewViewAdapter

  • MlViewTreeView.This is the editing view available in MlView today. It's made of 3 main widgets: A tree editing widget:

    • A tree editing widget: MlViewTreeEditor

    • A node editing widget: MlViewNodeEditor

    • A node/attribute name completion widget: MlViewCompletionTable

    mlview-4

Chapter 4. Keybindings management

A keybinding is the association between a sequence of keyboard events (what happens when the user hits a keyboard key) and an editing action. Basically, a defined keybinding triggers an editing actin when the user types a given predefined sequence of keys.

MlView tries to ease the definition of keybindings for the programmer. Therefore, a keybinding engine has been written. It's abstracted by the MlViewKBEng class.

The MlViewKBEng class provides apis to register, and lookup a binding.

Chapter 5.Undo/Redo management

introduction.MlView has an infinite undo/redo feature designed around the concept of "document mutation". A document mutation is basically the abstraction of a modification of the document model. From now on, we will refer to changes on the document model as "document mutations".

Design of the Undo infrastructure.The Undo feature lives at the MlViewXMLDocument level. This class is the document object model used by MlView. It has methods like MlViewXMLDocument::add_child_node() that actually perform mutations on the document. Each time a mutation is performed on an instance of MlViewXMLDocument, a mutation is "stored" in an undo stack. Each MlViewXMLDocument has a private instance of undo stack. The undo stack is an instance of MlViewDocMutationStack. It is a stack of instances of MlViewDocMutation. At instanciation time MlViewDocMutation object must be registered callbacks that will be called to do or undo the mutation. Later on, the client code can invoke MlViewDocMutation::do_mutation() or MlViewDocMutation::undo_mutation() to do/undo a given mutation. As I said earlier, each time a mutation occurs, an instance of MlViewDocMutation that matches that mutation is pushed on the undo stack. Later on, the MlViewXMLDocument::undo_mutation() method (that execute the undo feature) pops the topmost instance of MlViewDocMutation from the undo stack and invokes its MlViewDocMutation::undo_mutation() method. That MlViewDocMutation::undo_mutation() method calls the undo code registered by the client code to actually perform the undo. Simple isn't it ? ;)

Then comes the Redo ...To be continued ...

Chapter 6. Study of the "open document" workflow

In this chapter, we are going to see what happens when the user opens an xml document. This "open document" workflow can be triggered by doing file -> open or by hitting the "open" button in the application toolbar. The actual entry point of this workflow is the MlViewEditor::open_local_xml_document_interactive() method. This method basically pops up a file chooser to let the user choose the path of the document she wants to use. If the document is already loaded in the editor, the user is asked if she wants to reload it. Eventually, the MlViewEditor::load_xml_file() method is called to load the actual document in the editor.

The MlViewEditor::load_xml_file() method first parses the xml document into an in memory tree (using the excellent xml capabilities offered by the Libxml2 library). That in memory xml tree is an instance of the MlViewXMLDocument class. Afterwards, an instance of MlViewTreeView (the default editing view) is built and added to the current instance of MlViewEditor. The user can now edit the document using the editing capabilities offered by that editing view.

As you have noticed, the default view used when loading documents into the editor is the "tree-view" (MlViewTreeView). However, the user can at any time create a new view on the document being edited and then choose to instanciate another type view. Of course, the editor must have been compiled with the support of other views but the "tree-view".

xmp_megatracker-0.96

If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:

Related Post






Linux Links

0 commenti:

Post a Comment

Random Posts

  • Creating a Fancy Watch in Blender, Chapter VIII.
    21.05.2013 - 0 Comments
    Blender is a free and open-source 3D computer graphics software product used for creating animated films, visual effects, interactive 3D applications or video games. Blender's features include 3D modeling, UV unwrapping, texturing, rigging and…
  • Hattrick Organizer is a popular, free, java-based helper application and is a CHPP-approved program.
    22.04.2009 - 0 Comments
    Hattrick Organizer is a popular, free, java-based helper application and is a CHPP-approved program. It's OpenSource licensed LGPL and written in Java, therefore it's OS independent. Installers for Windows and MacOS are supplied, as well as a ZIP…
  • Follow our step by step guides for installing StatCounter on your favourite platforms: Blogger / Blogspot Install Guide.
    03.02.2018 - 0 Comments
    StatCounter provides free customisable hit counters, visitor tracking, web analytics and website statsfor Blogger / Blogspot.Please watch this short video guide for an over view of the installation.Copy the StatCounter code. Login to your blogger…
  • Geeklog 1.5.0 released, web content management system suitable for running full-featured community sites
    08.07.2008 - 0 Comments
    It allows you within minutes to set up a fully functioning dynamic website, and has many features to get you started: user-system, allowing members of the public to register for your site and submit stories; comment system, allowing users to…
  • Time to Shine: Why Desktop Linux is Taking Over.
    20.10.2012 - 0 Comments
    Microsoft Windows has long been the operating system of choice for corporate level desktop PCs, but times change. There are a number of drivers that are pushing Linux into the domain of the end user device from the enterprise server space; such as…
  • Vine Linux is a supreme Linux distribution with integrated Japanese environment for desktop PCs and notebooks.
    28.02.2010 - 0 Comments
    Vine Linux is a compact and lightweight Japanese Linux distribution for desktop PCs and notebooks.The whole Vine Linux distribution consists of two categories: one CD install media (Vine Linux main) which can also be installed from 1GB USB…
  • Software Packages in Ubuntu 8.10
    08.03.2009 - 0 Comments
    qcad (2.0.5.0-1-2.1ubuntu1)A professional CAD Systemqcad-doc (2.0.5.0-1-2.1ubuntu1)Qcad Documentationqcam (0.91-12) [universe]QuickCam image grabberqcomicbook (0.4.0-0ubuntu1) [multiverse]A viewer for comic book archives containing jpeg/png…
  • Installing KXStudio: Linux Audio Overview.
    23.02.2014 - 0 Comments
    digg_url = "http://linuxlandit.blogspot.com/2014/02/installing-kxstudio-linux-audio-overview_23.html";digg_title = "Installing KXStudio: Linux Audio Overview.";digg_bgcolor = "#FFFFFF";digg_skin = "normal";digg_url = undefined;digg_title =…
  • OpenJDK is a free and open source implementation of the Java programming language.
    20.03.2011 - 0 Comments
    OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language.It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GPL)…
  • The LDAP is an application protocol for accessing and maintaining distributed directory information services over an IP network.
    17.07.2011 - 0 Comments
    The Lightweight Directory Access Protocol (LDAP) is an application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network. Directory services may provide any organized set of…

Recent Posts

Recent Posts Widget

Popular Posts

Labels

Archive

page counter follow us in feedly
 
Copyright © 2014 Linuxlandit & The Conqueror Penguin
-->