aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-11-05 22:02:54 +0100
committerThomas White <taw@bitwiz.org.uk>2011-11-05 22:02:54 +0100
commit6f29edb7b7ea789bc4bde1ee3237cca96c271202 (patch)
tree6ed2b9e0c20d1392c3c3ce0224818def5568f198 /src
parentdbff61bb3053e4fe30397b48a32ec415119bcf66 (diff)
Loading mostly works
Diffstat (limited to 'src')
-rw-r--r--src/colloquium.c2
-rw-r--r--src/loadsave.c151
-rw-r--r--src/loadsave.h13
-rw-r--r--src/mainwindow.c93
-rw-r--r--src/objects.h5
-rw-r--r--src/presentation.c76
-rw-r--r--src/presentation.h11
-rw-r--r--src/tool_image.c14
-rw-r--r--src/tool_text.c117
-rw-r--r--src/tool_text.h2
10 files changed, 371 insertions, 113 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index d9dc4d9..b389e32 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -75,6 +75,8 @@ int main(int argc, char *argv[])
}
p = new_presentation();
+ p->cur_edit_slide = add_slide(p, 0);
+ p->completely_empty = 1;
if ( open_mainwindow(p) ) {
fprintf(stderr, "Couldn't open main window.\n");
return 1;
diff --git a/src/loadsave.c b/src/loadsave.c
index 289d793..557e34a 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -34,16 +34,7 @@
#include "presentation.h"
#include "objects.h"
#include "stylesheet.h"
-
-
-struct ds_node
-{
- char *key;
- char *value;
- struct ds_node **children;
- int n_children;
- int max_children;
-};
+#include "slide_render.h"
static int alloc_children(struct ds_node *node)
@@ -313,7 +304,7 @@ static void free_ds_tree(struct ds_node *root)
}
-static int get_field_f(struct ds_node *root, const char *key, double *val)
+int get_field_f(struct ds_node *root, const char *key, double *val)
{
struct ds_node *node;
double v;
@@ -337,7 +328,7 @@ static int get_field_f(struct ds_node *root, const char *key, double *val)
}
-static int get_field_i(struct ds_node *root, const char *key, int *val)
+int get_field_i(struct ds_node *root, const char *key, int *val)
{
struct ds_node *node;
int v;
@@ -361,7 +352,7 @@ static int get_field_i(struct ds_node *root, const char *key, int *val)
}
-static int get_field_s(struct ds_node *root, const char *key, char **val)
+int get_field_s(struct ds_node *root, const char *key, char **val)
{
struct ds_node *node;
char *v;
@@ -491,10 +482,109 @@ static StyleSheet *tree_to_stylesheet(struct ds_node *root)
}
+static enum objtype text_to_type(const char *t)
+{
+ if ( strcmp(t, "text") == 0 ) return OBJ_TEXT;
+ if ( strcmp(t, "image") == 0 ) return OBJ_IMAGE;
+
+ return OBJ_UNKNOWN;
+}
+
+
+static const char *type_text(enum objtype t)
+{
+ switch ( t )
+ {
+ case OBJ_TEXT : return "text";
+ case OBJ_IMAGE : return "image";
+ default : return "unknown";
+ }
+}
+
+
+
+static struct object *tree_to_object(struct presentation *p,
+ struct ds_node *root, struct slide *s)
+{
+ struct object *o = NULL;
+ char *v;
+
+ if ( get_field_s(root, "type", &v) ) return NULL;
+
+ switch ( text_to_type(v) ) {
+
+ case OBJ_TEXT :
+ o = p->text_tool->deserialize(p, root, s, p->text_tool);
+ break;
+
+ case OBJ_IMAGE :
+ o = p->image_tool->deserialize(p, root, s, p->image_tool);
+ break;
+
+ default :
+ fprintf(stderr, "Unrecognised object type '%s'\n", v);
+ break;
+
+ }
+
+ return o;
+}
+
+
+static struct slide *tree_to_slide(struct presentation *p, struct ds_node *root)
+{
+ struct slide *s;
+ int i;
+
+ s = new_slide();
+ s->parent = p;
+
+ /* Loop over objects */
+ for ( i=0; i<root->n_children; i++ ) {
+
+ struct object *o;
+
+ o = tree_to_object(p, root->children[i], s);
+ if ( o != NULL ) {
+ add_object_to_slide(s, o);
+ }
+
+ }
+
+ redraw_slide(s);
+
+ return s;
+}
+
+
+static int tree_to_slides(struct ds_node *root, struct presentation *p)
+{
+ int i;
+
+ for ( i=0; i<root->n_children; i++ ) {
+
+ struct slide *s;
+
+ s = tree_to_slide(p, root->children[i]);
+ if ( s != NULL ) {
+ insert_slide(p, s, p->num_slides-1);
+ redraw_slide(s);
+ }
+
+ }
+
+ return 0;
+}
+
+
int tree_to_presentation(struct ds_node *root, struct presentation *p)
{
struct ds_node *node;
char *check;
+ int i;
+
+ p->cur_edit_slide = NULL;
+ p->cur_proj_slide = NULL;
node = find_node(root, "slide-properties/width");
if ( node == NULL ) return 1;
@@ -522,6 +612,24 @@ int tree_to_presentation(struct ds_node *root, struct presentation *p)
}
}
+ for ( i=0; i<p->num_slides; i++ ) {
+ free_slide(p->slides[i]);
+ p->num_slides = 0;
+ }
+
+ node = find_node(root, "slides");
+ if ( node != NULL ) {
+ tree_to_slides(node, p);
+ if ( p->num_slides == 0 ) {
+ fprintf(stderr, "Failed to load any slides\n");
+ p->cur_edit_slide = add_slide(p, 0);
+ return 1;
+ }
+ }
+
+ p->cur_edit_slide = p->slides[0];
+ redraw_slide(p->cur_edit_slide);
+
return 0;
}
@@ -550,7 +658,12 @@ int load_presentation(struct presentation *p, const char *filename)
fclose(fh);
- if ( r ) return r; /* Error */
+ if ( r ) {
+ p->cur_edit_slide = new_slide();
+ insert_slide(p, p->cur_edit_slide, 0);
+ p->completely_empty = 1;
+ return r; /* Error */
+ }
p->cur_edit_slide = p->slides[0];
@@ -558,16 +671,6 @@ int load_presentation(struct presentation *p, const char *filename)
}
-static const char *type_text(enum objtype t)
-{
- switch ( t )
- {
- case TEXT : return "text";
- default : return "unknown";
- }
-}
-
-
static void rebuild_prefix(struct serializer *ser)
{
int i;
diff --git a/src/loadsave.h b/src/loadsave.h
index 90e2f0a..e5a1015 100644
--- a/src/loadsave.h
+++ b/src/loadsave.h
@@ -30,6 +30,15 @@
/* Forward declaration */
struct presentation;
+struct ds_node
+{
+ char *key;
+ char *value;
+ struct ds_node **children;
+ int n_children;
+ int max_children;
+};
+
/* Would be opaque if I could be bothered to write the constructor */
struct serializer
{
@@ -48,6 +57,10 @@ extern void serialize_f(struct serializer *s, const char *key, double val);
extern void serialize_b(struct serializer *s, const char *key, int val);
extern void serialize_end(struct serializer *s);
+extern int get_field_f(struct ds_node *root, const char *key, double *val);
+extern int get_field_i(struct ds_node *root, const char *key, int *val);
+extern int get_field_s(struct ds_node *root, const char *key, char **val);
+
extern int load_presentation(struct presentation *p, const char *filename);
extern int save_presentation(struct presentation *p, const char *filename);
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 7b4c8e6..524c2e1 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -76,6 +76,47 @@ static void show_error(struct presentation *p, const char *message)
}
+static void update_toolbar(struct presentation *p)
+{
+ GtkWidget *d;
+ int cur_slide_number;
+
+ d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/first");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
+ d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/prev");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
+ d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/next");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
+ d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/last");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
+
+ cur_slide_number = slide_number(p, p->cur_edit_slide);
+ if ( cur_slide_number == 0 ) {
+
+ d = gtk_ui_manager_get_widget(p->ui,
+ "/ui/displaywindowtoolbar/first");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
+ d = gtk_ui_manager_get_widget(p->ui,
+ "/ui/displaywindowtoolbar/prev");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
+
+ }
+
+ if ( cur_slide_number == p->num_slides-1 ) {
+
+ d = gtk_ui_manager_get_widget(p->ui,
+ "/ui/displaywindowtoolbar/next");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
+ d = gtk_ui_manager_get_widget(p->ui,
+ "/ui/displaywindowtoolbar/last");
+ gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
+
+ }
+
+
+}
+
+
static gint open_response_sig(GtkWidget *d, gint response,
struct presentation *p)
{
@@ -88,9 +129,9 @@ static gint open_response_sig(GtkWidget *d, gint response,
if ( p->completely_empty ) {
if ( load_presentation(p, filename) ) {
show_error(p, "Failed to open presentation");
- } else {
- redraw_slide(p->cur_edit_slide);
}
+ redraw_slide(p->cur_edit_slide);
+ update_toolbar(p);
} else {
struct presentation *p;
p = new_presentation();
@@ -262,47 +303,6 @@ static gint about_sig(GtkWidget *widget, struct presentation *p)
}
-static void update_toolbar(struct presentation *p)
-{
- GtkWidget *d;
- int cur_slide_number;
-
- d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/first");
- gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
- d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/prev");
- gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
- d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/next");
- gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
- d = gtk_ui_manager_get_widget(p->ui, "/ui/displaywindowtoolbar/last");
- gtk_widget_set_sensitive(GTK_WIDGET(d), TRUE);
-
- cur_slide_number = slide_number(p, p->cur_edit_slide);
- if ( cur_slide_number == 0 ) {
-
- d = gtk_ui_manager_get_widget(p->ui,
- "/ui/displaywindowtoolbar/first");
- gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
- d = gtk_ui_manager_get_widget(p->ui,
- "/ui/displaywindowtoolbar/prev");
- gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
-
- }
-
- if ( cur_slide_number == p->num_slides-1 ) {
-
- d = gtk_ui_manager_get_widget(p->ui,
- "/ui/displaywindowtoolbar/next");
- gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
- d = gtk_ui_manager_get_widget(p->ui,
- "/ui/displaywindowtoolbar/last");
- gtk_widget_set_sensitive(GTK_WIDGET(d), FALSE);
-
- }
-
-
-}
-
-
static gint start_slideshow_sig(GtkWidget *widget, struct presentation *p)
{
try_start_slideshow(p);
@@ -608,7 +608,7 @@ static gboolean im_commit_sig(GtkIMContext *im, gchar *str,
struct presentation *p)
{
if ( p->editing_object == NULL ) return FALSE;
- if ( p->editing_object->type != TEXT ) return FALSE;
+ if ( p->editing_object->type != OBJ_TEXT ) return FALSE;
p->cur_tool->im_commit(p->editing_object, str, p->cur_tool);
@@ -1114,10 +1114,7 @@ int open_mainwindow(struct presentation *p)
p->slide_width + 20,
p->slide_height + 20);
- p->select_tool = initialise_select_tool();
- p->text_tool = initialise_text_tool(p->drawingarea);
- p->image_tool = initialise_image_tool();
- p->cur_tool = p->select_tool;
+ p->text_tool->realise(p->text_tool, p->drawingarea);
gtk_widget_set_can_focus(GTK_WIDGET(p->drawingarea), TRUE);
gtk_widget_add_events(GTK_WIDGET(p->drawingarea),
diff --git a/src/objects.h b/src/objects.h
index adaf8fc..5b3a8b1 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -33,8 +33,9 @@
enum objtype
{
- TEXT,
- IMAGE,
+ OBJ_UNKNOWN,
+ OBJ_TEXT,
+ OBJ_IMAGE,
};
diff --git a/src/presentation.c b/src/presentation.c
index 2dacde2..75b76d0 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -33,38 +33,28 @@
#include "slide_render.h"
#include "objects.h"
#include "stylesheet.h"
+#include "tool_select.h"
+#include "tool_text.h"
+#include "tool_image.h"
-struct slide *add_slide(struct presentation *p, int pos)
+int insert_slide(struct presentation *p, struct slide *new, int pos)
{
struct slide **try;
- struct slide *new;
- int i;
-
- new = calloc(1, sizeof(struct slide));
- if ( new == NULL ) return NULL;
-
- /* No objects to start with */
- new->num_objects = 0;
- new->objects = NULL;
-
- p->completely_empty = 0;
- new->parent = p;
-
- new->rendered_edit = NULL;
- new->rendered_proj = NULL;
- new->rendered_thumb = NULL;
try = realloc(p->slides, (1+p->num_slides)*sizeof(struct slide *));
if ( try == NULL ) {
free(new);
- return NULL;
+ return 1;
}
p->slides = try;
+ p->completely_empty = 0;
/* Insert into list. Yuk yuk yuk etc. */
if ( (p->num_slides>1) && (pos<p->num_slides-1) ) {
+ int i;
+
for ( i=p->num_slides; i>pos+1; i-- ) {
p->slides[i] = p->slides[i-1];
}
@@ -79,12 +69,55 @@ struct slide *add_slide(struct presentation *p, int pos)
p->slides[pos] = new;
}
+ new->parent = p;
p->num_slides++;
+ return 0;
+}
+
+
+struct slide *new_slide()
+{
+ struct slide *new;
+
+ new = calloc(1, sizeof(struct slide));
+ if ( new == NULL ) return NULL;
+
+ /* No objects to start with */
+ new->num_objects = 0;
+ new->objects = NULL;
+
+ new->rendered_edit = NULL;
+ new->rendered_proj = NULL;
+ new->rendered_thumb = NULL;
+
return new;
}
+void free_slide(struct slide *s)
+{
+ int i;
+
+ for ( i=0; i<s->num_objects; i++ ) {
+ delete_object(s->objects[i]);
+ }
+
+ free(s);
+}
+
+
+struct slide *add_slide(struct presentation *p, int pos)
+{
+ struct slide *s = new_slide();
+ if ( insert_slide(p, s, pos) ) {
+ free_slide(s);
+ return NULL;
+ }
+ return s;
+}
+
+
int add_object_to_slide(struct slide *s, struct object *o)
{
struct object **try;
@@ -229,7 +262,7 @@ struct presentation *new_presentation()
/* Add one blank slide and view it */
new->num_slides = 0;
new->slides = NULL;
- new->cur_edit_slide = add_slide(new, 0);
+ new->cur_edit_slide = NULL;
new->cur_proj_slide = NULL;
new->editing_object = NULL;
@@ -240,5 +273,10 @@ struct presentation *new_presentation()
default_stylesheet(new->ss);
new->image_store = image_store_new();
+ new->select_tool = initialise_select_tool();
+ new->text_tool = initialise_text_tool();
+ new->image_tool = initialise_image_tool();
+ new->cur_tool = new->select_tool;
+
return new;
}
diff --git a/src/presentation.h b/src/presentation.h
index 804cc4b..b659ac7 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -91,6 +91,12 @@ struct toolinfo
void (*im_commit)(struct object *o, gchar *str, struct toolinfo *tip);
int (*valid_object)(struct object *o);
+
+ void (*realise)(struct toolinfo *tip, GtkWidget *w);
+
+ struct object *(*deserialize)(struct presentation *p,
+ struct ds_node *root, struct slide *s,
+ struct toolinfo *tip);
};
@@ -175,7 +181,12 @@ struct presentation
extern struct presentation *new_presentation(void);
+
+extern struct slide *new_slide(void);
extern struct slide *add_slide(struct presentation *p, int pos);
+extern int insert_slide(struct presentation *p, struct slide *s, int pos);
+extern void free_slide(struct slide *s);
+
extern int add_object_to_slide(struct slide *s, struct object *o);
extern void remove_object_from_slide(struct slide *s, struct object *o);
extern struct object *find_object_at_position(struct slide *s,
diff --git a/src/tool_image.c b/src/tool_image.c
index 2baf7c3..8e09c27 100644
--- a/src/tool_image.c
+++ b/src/tool_image.c
@@ -133,7 +133,7 @@ struct object *add_image_object(struct slide *s, double x, double y,
new->base.x = x; new->base.y = y;
new->base.bb_width = bb_width;
new->base.bb_height = bb_height;
- new->base.type = IMAGE;
+ new->base.type = OBJ_IMAGE;
new->base.empty = 0;
new->base.parent = NULL;
new->base.style = sty;
@@ -171,7 +171,7 @@ static void click_select(struct presentation *p, struct toolinfo *tip,
struct image_toolinfo *ti = (struct image_toolinfo *)tip;
struct image_object *o = (struct image_object *)p->editing_object;
- assert(o->base.type == IMAGE);
+ assert(o->base.type == OBJ_IMAGE);
xo = x - o->base.x; yo = y - o->base.y;
@@ -308,11 +308,18 @@ static void im_commit(struct object *o, gchar *str, struct toolinfo *tip)
static int valid_object(struct object *o)
{
- if ( o->type == IMAGE ) return 1;
+ if ( o->type == OBJ_IMAGE ) return 1;
return 0;
}
+static struct object *deserialize(struct presentation *p, struct ds_node *root,
+ struct toolinfo *tip)
+{
+ return NULL;
+}
+
+
struct toolinfo *initialise_image_tool()
{
struct image_toolinfo *ti;
@@ -330,6 +337,7 @@ struct toolinfo *initialise_image_tool()
ti->base.key_pressed = key_pressed;
ti->base.im_commit = im_commit;
ti->base.valid_object = valid_object;
+ ti->base.deserialize = deserialize;
return (struct toolinfo *)ti;
}
diff --git a/src/tool_text.c b/src/tool_text.c
index cdf96b5..320ffbf 100644
--- a/src/tool_text.c
+++ b/src/tool_text.c
@@ -190,9 +190,8 @@ static void update_text(struct text_object *o)
double ebottom = 0.0;
double mw = 0.0;
double mh = 0.0;
- int furniture = 0;
- furniture = o->base.style != o->base.parent->parent->ss->styles[0];
+ o->furniture = o->base.style != o->base.parent->parent->ss->styles[0];
pango_layout_set_text(o->layout, o->text, -1);
o->fontdesc = pango_font_description_from_string(o->base.style->font);
@@ -235,7 +234,7 @@ void insert_text(struct object *op, char *t)
size_t tlen, olen, offs;
int i;
- assert(o->base.type == TEXT);
+ assert(o->base.type == OBJ_TEXT);
tlen = strlen(t);
olen = strlen(o->text);
@@ -310,7 +309,7 @@ void handle_text_backspace(struct object *op)
int old_idx, new_idx;
struct text_object *o = (struct text_object *)op;
- assert(o->base.type == TEXT);
+ assert(o->base.type == OBJ_TEXT);
if ( o->insertion_point == 0 ) return; /* Nothing to delete */
@@ -347,7 +346,7 @@ static void draw_caret(cairo_t *cr, struct text_object *o)
PangoRectangle pos;
const double t = 1.8;
- assert(o->base.type == TEXT);
+ assert(o->base.type == OBJ_TEXT);
pango_layout_get_cursor_pos(o->layout,
o->insertion_point+o->insertion_trail,
@@ -410,8 +409,7 @@ static void serialize(struct object *op, struct serializer *ser)
}
-static struct object *add_text_object(struct slide *s, double x, double y,
- struct style *sty,
+static struct object *new_text_object(double x, double y, struct style *sty,
struct text_toolinfo *ti)
{
struct text_object *new;
@@ -423,7 +421,7 @@ static struct object *add_text_object(struct slide *s, double x, double y,
new->base.x = x; new->base.y = y;
new->base.bb_width = 10.0;
new->base.bb_height = 40.0;
- new->base.type = TEXT;
+ new->base.type = OBJ_TEXT;
new->base.empty = 1;
new->base.parent = NULL;
new->base.style = sty;
@@ -443,14 +441,26 @@ static struct object *add_text_object(struct slide *s, double x, double y,
new->base.update_object = update_text_object;
new->base.serialize = serialize;
- if ( add_object_to_slide(s, (struct object *)new) ) {
- delete_object((struct object *)new);
+ return (struct object *)new;
+}
+
+
+static struct object *add_text_object(struct slide *s, double x, double y,
+ struct style *sty,
+ struct text_toolinfo *ti)
+{
+ struct object *o;
+
+ o = new_text_object(x, y, sty, ti);
+
+ if ( add_object_to_slide(s, o) ) {
+ delete_object(o);
return NULL;
}
- redraw_slide(((struct object *)new)->parent);
+ redraw_slide(o->parent);
- return (struct object *)new;
+ return o;
}
@@ -466,7 +476,7 @@ static void click_select(struct presentation *p, struct toolinfo *tip,
struct text_object *o = (struct text_object *)p->editing_object;
int idx, trail;
- assert(o->base.type == TEXT);
+ assert(o->base.type == OBJ_TEXT);
xo = x - o->base.x; yo = y - o->base.y;
@@ -659,19 +669,92 @@ static void im_commit(struct object *o, gchar *str, struct toolinfo *tip)
static int valid_object(struct object *o)
{
- if ( o->type == TEXT ) return 1;
+ if ( o->type == OBJ_TEXT ) return 1;
return 0;
}
+static void realise(struct toolinfo *tip, GtkWidget *w)
+{
+ struct text_toolinfo *ti = (struct text_toolinfo *)tip;
+ ti->pc = gtk_widget_get_pango_context(w);
+}
+
+
+static struct object *deserialize(struct presentation *p, struct ds_node *root,
+ struct slide *s, struct toolinfo *tip)
+{
+ struct object *o;
+ struct text_object *to;
+ char *style;
+ char *text;
+ struct style *sty;
+ double x, y;
+ struct text_toolinfo *ti = (struct text_toolinfo *)tip;
+
+ if ( get_field_s(root, "style", &style) ) {
+ fprintf(stderr, "Couldn't find style for object '%s'\n",
+ root->key);
+ return NULL;
+ }
+
+ sty = find_style(p->ss, style);
+ if ( sty == NULL ) {
+ fprintf(stderr, "Style '%s' not found in style sheet.\n",
+ style);
+ free(style);
+ return NULL;
+ }
+ free(style);
+
+ if ( sty == p->ss->styles[0] ) {
+
+ if ( get_field_f(root, "x", &x) ) {
+ fprintf(stderr,
+ "Couldn't find x position for object '%s'\n",
+ root->key);
+ return NULL;
+ }
+ if ( get_field_f(root, "y", &y) ) {
+ fprintf(stderr,
+ "Couldn't find y position for object '%s'\n",
+ root->key);
+ return NULL;
+ }
+
+ } else {
+
+ /* Furniture */
+ x = 0.0;
+ y = 0.0;
+
+ }
+
+ o = new_text_object(x, y, sty, ti);
+
+ /* Apply the correct text */
+ if ( get_field_s(root, "text", &text) ) {
+ fprintf(stderr, "Couldn't find text for object '%s'\n",
+ root->key);
+ return NULL;
+ }
+ to = (struct text_object *)o;
+ free(to->text);
+ to->text = text;
+ o->parent = s;
+ o->empty = 0;
+ update_text(to);
+
+ return o;
+}
+
+
struct toolinfo *initialise_text_tool(GtkWidget *w)
{
struct text_toolinfo *ti;
ti = malloc(sizeof(*ti));
- ti->pc = gtk_widget_get_pango_context(w);
-
ti->base.click_select = click_select;
ti->base.create_default = create_default;
ti->base.select = select_object;
@@ -683,6 +766,8 @@ struct toolinfo *initialise_text_tool(GtkWidget *w)
ti->base.key_pressed = key_pressed;
ti->base.im_commit = im_commit;
ti->base.valid_object = valid_object;
+ ti->base.realise = realise;
+ ti->base.deserialize = deserialize;
return (struct toolinfo *)ti;
}
diff --git a/src/tool_text.h b/src/tool_text.h
index 2e865d7..aaca10a 100644
--- a/src/tool_text.h
+++ b/src/tool_text.h
@@ -30,7 +30,7 @@
#include <gtk/gtk.h>
-extern struct toolinfo *initialise_text_tool(GtkWidget *w);
+extern struct toolinfo *initialise_text_tool();
#endif /* TOOL_TEXT_H */