AbiWord SDK

From AbiWiki

(Difference between revisions)
Jump to: navigation, search
m (Reverted edits by Ikexadyma (Talk) to last revision by Peb)
 
(23 intermediate revisions not shown)
Line 1: Line 1:
-
<H2>[[AbiWordSDK|AbiWordSDK]]</H2>
+
[[AbiWord]] can be compiled to create a stand alone library, headers and package configuration file. This page shows you how to do this.
-
[[AbiWord|AbiWord]] can be compiled to create a stand alone library, headers and package configuration file. These are built if you place the following into the [[AbiWord|AbiWord]] ./configure script.
+
===Version 2.6===
 +
For AbiWord version 2.6 first configure and build the main [[AbiWord]] tree like this:
-
./configure --prefix=/Path/To/Install --enable-libabiword
+
  ./configure --prefix=/Path/To/Install --enable-libabiword
 +
 
 +
  make install
-
This will create the following files
+
Then in the abiword-plugins directory do:
 +
  ./configure --prefix=/Path/To/Install --enable-libabiword --with-abiword=/Path/To/AbiWordSource --disable-all
 +
  --enable-plugin1 --enable-plugin2
 +
 
 +
  make install
 +
 
 +
Where --enable-plugin1, --enable-plugin2 etc should specify the names of the plugins you want to build. It is very important that you put --enable-libabiword in the configure line when you build the plugins otherwise they won't load with [[AbiWidget]]. Of course you build as many or as few of the plugins as you want.
 +
 
 +
My (Martin Sevior) favourite set of plugins is built with the configure line:
 +
 
 +
  ./configure --with-abiword=../abiword-2.6 --prefix=/home/msevior/abidir  --enable-libabiword --disable-all
 +
  --enable-abicollab --with-abicollab-service-backend  --enable-abimathview --enable-abicommand --enable-loadbindings
 +
  --enable-presentation --enable-OpenDocument
 +
 
 +
  make install
 +
 
 +
This will build
 +
 
 +
* /Path/To/Install/bin/abiword-2.6
 +
* /Path/To/Install/include/abiword-2.6/libabiword.h
 +
* /Path/To/Install/lib/pkgconfig/abiword-2.6.pc
 +
* /Path/To/Install/lib/libabiword-2.6.so
 +
 
 +
===SVN TRUNK===
 +
 
 +
For svn TRUNK, the plugins have been merged into the main [[AbiWord]] tree and only one configure and compile statement is needed to build libabiword and the plugins you want. To build libabiword on SVN do:
 +
 
 +
  ./configure --prefix=/Path/To/Install --enable-dynamic --enable-plugins="plugin1 plugin2"
 +
  make install
 +
 
 +
Of course you can add as many plugins as you want on the configure line. My favourite set of plugins is built with:
 +
 
 +
  ./configure  --enable-dynamic --prefix=/home/msevior/abidir --enable-plugins="collab mathview command loadbindings presentation latex"
 +
  make install
 +
 
 +
The odt filters are built by default for SVN trunk so do not need to be specified.
 +
 
 +
This will create the following files:
* /Path/To/Install/bin/abiword-2.7  
* /Path/To/Install/bin/abiword-2.7  
Line 12: Line 52:
* /Path/To/Install/lib/libabiword-2.7.so
* /Path/To/Install/lib/libabiword-2.7.so
-
The most easily accessible way to use this library is to use the [[GtkWidget|GtkWidget]], [[AbiWidget|AbiWidget]].
+
The most easily accessible way to use this library is to use the [[GtkWidget]], [[AbiWidget]].
-
In addition tere are a large variety of [[[AbiWordSignals|AbiWordSignals]] Gtk signals] emitted by the widget that reflect the current document and th elocation of the insersion caret within the document. You can hook up callback''s to these signals to implement useful features (like buttons that reflect the current state of the document at the caret).
+
In addition there are a large variety of [[AbiWord signals|Gtk signals]] emitted by the widget that reflect the current document and the location of the insertion caret within the document. You can hook up callback's to these signals to implement useful features (like buttons that reflect the current state of the document at the caret).
-
<H3> Simple Example program </H3>
+
= Simple Example program =
-
The following example assumes that you set your PKG_CONFIG_PATH evironment variable to discover abiword-2.7.pc.
+
The following example assumes that you set your PKG_CONFIG_PATH environment variable to discover abiword-2.7.pc. The code below also shows some of the signals emitted by the widget as the user navigates through the document. You can use these signals to determine the state of the document at the current insertion point.
-
By default, [[PyAbiWord|PyAbiWord]] starts using the "Normal View".
+
A complete listing of all the methods and signals currently implemented will be made eventually. In the meantime look at the abiwidget.h header file available [[AbiWidget Header|here]].
-
The code below also shows some of the signals emitted by the widget as the user navigates through the document. You can use these signals to determine the state of the document at the current insertion point.
+
== The Makefile ==
-
 
+
-
A complete listing of all the methods and signals currently implemented will be made eventually. In the meantime look at the abiwidget.h header file available [[[AbiWidgetHeader|AbiWidgetHeader]] here].
+
-
 
+
-
<H4> The Makefile </H4>
+
<pre>
<pre>
test-widget: test-widget.c
test-widget: test-widget.c
Line 35: Line 71:
</pre>
</pre>
-
<H4> The Example code, test-widget.c</H4> 
+
== The Example code, test-widget.c ==
<pre>
<pre>
#include <stdio.h>
#include <stdio.h>
Line 46: Line 82:
gpointer user_data)
gpointer user_data)
{
{
-
     g_print ("Boolean signal ''d\n", (char *)user_data, value);
+
     g_print ("Boolean signal %s: %d\n", (char *)user_data, value);
}
}
Line 53: Line 89:
gpointer user_data)
gpointer user_data)
{
{
-
     g_print ("String signal ''s\n", (char *)user_data, value);
+
     g_print ("String signal %s: %s\n", (char *)user_data, value);
}
}
Line 60: Line 96:
gpointer user_data)
gpointer user_data)
{
{
-
     g_print ("Double signal ''f\n", (char *)user_data, value);
+
     g_print ("Double signal %s: %f\n", (char *)user_data, value);
}
}
Line 74: Line 110:
     /* Initialize libabiword */
     /* Initialize libabiword */
-
     libabiword_init(argc, (const char **)argv);
+
     libabiword_init(argc, (char **)argv);
     /* Construct our widget! */
     /* Construct our widget! */
Line 81: Line 117:
     gtk_widget_show_all (window);
     gtk_widget_show_all (window);
-
     g_signal_connect (G_OBJECT (abi), "bold", G_CALLBACK (boolean_signal), "bold");
+
     g_signal_connect (G_OBJECT (abi), "bold", G_CALLBACK (boolean_signal), (void*)"bold");
-
     g_signal_connect (G_OBJECT (abi), "italic", G_CALLBACK (boolean_signal), "italic");
+
     g_signal_connect (G_OBJECT (abi), "italic", G_CALLBACK (boolean_signal), (void*)"italic");
-
     g_signal_connect (G_OBJECT (abi), "underline", G_CALLBACK (boolean_signal), "underline");
+
     g_signal_connect (G_OBJECT (abi), "underline", G_CALLBACK (boolean_signal), (void*)"underline");
-
     g_signal_connect (G_OBJECT (abi), "can-undo", G_CALLBACK (boolean_signal), "can-undo");
+
     g_signal_connect (G_OBJECT (abi), "can-undo", G_CALLBACK (boolean_signal), (void*)"can-undo");
-
     g_signal_connect (G_OBJECT (abi), "can-redo", G_CALLBACK (boolean_signal), "can-redo");
+
     g_signal_connect (G_OBJECT (abi), "can-redo", G_CALLBACK (boolean_signal), (void*)"can-redo");
-
     g_signal_connect (G_OBJECT (abi), "font-size", G_CALLBACK (double_signal), "font-size");
+
     g_signal_connect (G_OBJECT (abi), "font-size", G_CALLBACK (double_signal), (void*)"font-size");
-
     g_signal_connect (G_OBJECT (abi), "font-family", G_CALLBACK (string_signal), "font-family");
+
     g_signal_connect (G_OBJECT (abi), "font-family", G_CALLBACK (string_signal), (void*)"font-family");
     g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
     g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
Line 93: Line 129:
     if (argv[1])
     if (argv[1])
-
         abi_widget_load_file (ABI_WIDGET (abi), argv[1]);
+
         abi_widget_load_file (ABI_WIDGET (abi), argv[1], "");
     gtk_main ();
     gtk_main ();
Line 103: Line 139:
</pre>
</pre>
-
[[Category:To Convert]]
+
== Python Bindings ==
 +
 
 +
There are also an extensive and well maintained set of python bindings to [[AbiWidget]]. These are used to by the One Laptop Per Child (OLPC) Write program. You can find information about our Python bindings in our [[PyAbiWord]] section.
 +
 
 +
[[Category:Developer]]
 +
[[Category:SDK]]

Current revision as of 13:13, 27 November 2010

AbiWord can be compiled to create a stand alone library, headers and package configuration file. This page shows you how to do this.

Contents

Version 2.6

For AbiWord version 2.6 first configure and build the main AbiWord tree like this:

 ./configure --prefix=/Path/To/Install --enable-libabiword
 
 make install

Then in the abiword-plugins directory do:

 ./configure --prefix=/Path/To/Install --enable-libabiword --with-abiword=/Path/To/AbiWordSource --disable-all 
 --enable-plugin1 --enable-plugin2
 
 make install

Where --enable-plugin1, --enable-plugin2 etc should specify the names of the plugins you want to build. It is very important that you put --enable-libabiword in the configure line when you build the plugins otherwise they won't load with AbiWidget. Of course you build as many or as few of the plugins as you want.

My (Martin Sevior) favourite set of plugins is built with the configure line:

 ./configure --with-abiword=../abiword-2.6 --prefix=/home/msevior/abidir  --enable-libabiword --disable-all 
 --enable-abicollab --with-abicollab-service-backend  --enable-abimathview --enable-abicommand --enable-loadbindings 
 --enable-presentation --enable-OpenDocument
 
 make install

This will build

  • /Path/To/Install/bin/abiword-2.6
  • /Path/To/Install/include/abiword-2.6/libabiword.h
  • /Path/To/Install/lib/pkgconfig/abiword-2.6.pc
  • /Path/To/Install/lib/libabiword-2.6.so

SVN TRUNK

For svn TRUNK, the plugins have been merged into the main AbiWord tree and only one configure and compile statement is needed to build libabiword and the plugins you want. To build libabiword on SVN do:

 ./configure --prefix=/Path/To/Install --enable-dynamic --enable-plugins="plugin1 plugin2"
 make install

Of course you can add as many plugins as you want on the configure line. My favourite set of plugins is built with:

 ./configure  --enable-dynamic --prefix=/home/msevior/abidir --enable-plugins="collab mathview command loadbindings presentation latex" 
 make install

The odt filters are built by default for SVN trunk so do not need to be specified.

This will create the following files:

  • /Path/To/Install/bin/abiword-2.7
  • /Path/To/Install/include/abiword-2.7/libabiword.h
  • /Path/To/Install/lib/pkgconfig/abiword-2.7.pc
  • /Path/To/Install/lib/libabiword-2.7.so

The most easily accessible way to use this library is to use the GtkWidget, AbiWidget.

In addition there are a large variety of Gtk signals emitted by the widget that reflect the current document and the location of the insertion caret within the document. You can hook up callback's to these signals to implement useful features (like buttons that reflect the current state of the document at the caret).

Simple Example program

The following example assumes that you set your PKG_CONFIG_PATH environment variable to discover abiword-2.7.pc. The code below also shows some of the signals emitted by the widget as the user navigates through the document. You can use these signals to determine the state of the document at the current insertion point.

A complete listing of all the methods and signals currently implemented will be made eventually. In the meantime look at the abiwidget.h header file available here.

The Makefile

test-widget: test-widget.c
		  gcc -o test-widget `pkg-config --cflags --libs abiword-2.7` test-widget.c

clean:
		  rm -f test-widget *~

The Example code, test-widget.c

#include <stdio.h>
#include <stdlib.h>
#include <libabiword.h>
#include <abiwidget.h>

static void boolean_signal (AbiWidget * widget,
									 gboolean value,
									 gpointer user_data)
{
    g_print ("Boolean signal %s: %d\n", (char *)user_data, value);
}

static void string_signal (AbiWidget * widget,
									const char * value,
									gpointer user_data)
{
    g_print ("String signal %s: %s\n", (char *)user_data, value);
}

static void double_signal (AbiWidget * widget,
									double value,
									gpointer user_data)
{
    g_print ("Double signal %s: %f\n", (char *)user_data, value);
}

int main(int argc, char ** argv)
{
    GtkWidget * window;
    GtkWidget * abi;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_usize(GTK_WIDGET(window),640,480);

    /* Initialize libabiword */
    libabiword_init(argc, (char **)argv);

    /* Construct our widget! */
    abi = abi_widget_new ();
    gtk_container_add (GTK_CONTAINER (window), abi);
    gtk_widget_show_all (window);

    g_signal_connect (G_OBJECT (abi), "bold", G_CALLBACK (boolean_signal), (void*)"bold");
    g_signal_connect (G_OBJECT (abi), "italic", G_CALLBACK (boolean_signal), (void*)"italic");
    g_signal_connect (G_OBJECT (abi), "underline", G_CALLBACK (boolean_signal), (void*)"underline");
    g_signal_connect (G_OBJECT (abi), "can-undo", G_CALLBACK (boolean_signal), (void*)"can-undo");
    g_signal_connect (G_OBJECT (abi), "can-redo", G_CALLBACK (boolean_signal), (void*)"can-redo");
    g_signal_connect (G_OBJECT (abi), "font-size", G_CALLBACK (double_signal), (void*)"font-size");
    g_signal_connect (G_OBJECT (abi), "font-family", G_CALLBACK (string_signal), (void*)"font-family");

    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);

    if (argv[1])
        abi_widget_load_file (ABI_WIDGET (abi), argv[1], "");

    gtk_main ();

    /* Close libabiword */
    libabiword_shutdown ();
    return 0;
}

Python Bindings

There are also an extensive and well maintained set of python bindings to AbiWidget. These are used to by the One Laptop Per Child (OLPC) Write program. You can find information about our Python bindings in our PyAbiWord section.

Personal tools