Commit bf2de288 authored by Bruno Coudoin's avatar Bruno Coudoin

- fixed missing config.h.mingw.in (that replaces config.h.mingw)

	- added support for python plugin compilation under mingw
	- improved wordprocessor activity. it no more crashes and allow
	  two styles, on for the layout, one for the color (on an idea
	  of my daughter Clara)
	- This activity could be moved out of --experimental now but
	  we are in string freeze.
	- Added a double switch in electricity. It is now possible to make
	  a 2 switches corridor like circuit (va et vient in french).
	- config.c : fixed a double memory free on locale that crashed GC at exit time.
	- file_selector.c: fixed mime type loading and display. now uses gettext instead of
	  inline xml translation.
	- menu.c: fixed a misplaced free that makes all board description in the database to be junk
parent bb62b10e
2006-09-25 Bruno coudoin <bruno.coudoin@free.fr>
- fixed missing config.h.mingw.in (that replaces config.h.mingw)
- added support for python plugin compilation under mingw
- improved wordprocessor activity. it no more crashes and allow
two styles, on for the layout, one for the color (on an idea
of my daughter Clara)
- This activity could be moved out of --experimental now but
we are in string freeze.
- Added a double switch in electricity. It is now possible to make
a 2 switches corridor like circuit (va et vient in french).
- config.c : fixed a double memory free on locale that crashed GC at exit time.
- file_selector.c: fixed mime type loading and display. now uses gettext instead of
inline xml translation.
- menu.c: fixed a misplaced free that makes all board description in the database to be junk.
* Makefile.mingw:
* boards/gcompris/mimetypes/Makefile.am:
* config.h.mingw.in:
* src/boards/python/electric.py:
* src/boards/wordprocessor.c: (wordprocessor_create),
(display_style_buttons), (item_event), (create_tags),
(set_default_style), (display_style_selector),
(display_color_style_selector), (tag_style_set),
(item_event_style_selection), (item_event_color_style_selection),
(key_press_event):
* src/gcompris/config.c: (gc_config_start), (gc_config_stop),
(display_previous_next), (get_next_locale), (get_previous_locale),
(item_event_ok):
* src/gcompris/file_selector.c: (gc_selector_file_stop),
(display_file_selector), (display_files), (item_event_directory),
(item_event_scroll), (item_event_file_selector), (parseMime),
(parse_doc), (load_mime_type_from_file), (gc_mime_type_load):
* src/gcompris/gameutil.c: (gc_pixmap_load), (gc_item_focus_set),
(reactivate_newline), (gc_item_rotate_relative),
(gc_difficulty_display), (g_utf8_strndup), (gc_file_find_absolute):
* src/gcompris/gcompris.c: (board_widget_key_press_callback):
* src/gcompris/gcompris_db.c: (gc_db_init), (gc_db_set_date),
(gc_db_set_version), (gc_db_check_boards), (gc_db_board_update),
(gc_menu_load_db), (gc_db_get_board_id), (gc_db_remove_board),
(gc_db_get_profile_from_id), (gc_db_profile_from_name_get),
(gc_db_get_profile), (gc_db_users_from_group_get),
(gc_db_get_user_from_id), (gc_db_get_class_from_id),
(gc_db_set_board_conf), (gc_db_conf_with_table_get),
(gc_db_get_board_conf), (gc_db_profiles_list_get),
(gc_db_get_group_from_id), (gc_db_get_groups_list),
(gc_db_get_board_from_id), (gc_db_get_users_list),
(gc_db_get_classes_list), (gc_db_is_activity_in_profile):
* src/gcompris/menu.c: (_add_xml_to_data), (gc_menu_load):
* src/gcompris/properties.c: (gc_prop_destroy):
2006-09-23 Bruno coudoin <bruno.coudoin@free.fr> 2006-09-23 Bruno coudoin <bruno.coudoin@free.fr>
- Start of support of python plugin on window. - Start of support of python plugin on window.
......
...@@ -18,7 +18,6 @@ LIBXML2_TOP := /libxml2 ...@@ -18,7 +18,6 @@ LIBXML2_TOP := /libxml2
SDL_TOP := /sdl SDL_TOP := /sdl
CANVAS_TOP := /gnomecanvas CANVAS_TOP := /gnomecanvas
GNUCHESS_TOP := /gnuchess GNUCHESS_TOP := /gnuchess
PYTHON_TOP := /c/Python24
MAKENSIS := "/c/Program Files/NSIS/makensis.exe" MAKENSIS := "/c/Program Files/NSIS/makensis.exe"
...@@ -55,11 +54,9 @@ NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \ ...@@ -55,11 +54,9 @@ NEEDED_DLLS = $(GNUCHESS_TOP)/bin/pthreadGC.dll \
$(GTK_TOP)/expat/bin/xmlparse.dll \ $(GTK_TOP)/expat/bin/xmlparse.dll \
$(GTK_TOP)/expat/bin/xmltok.dll \ $(GTK_TOP)/expat/bin/xmltok.dll \
$(GTK_TOP)/bin/iconv.dll \ $(GTK_TOP)/bin/iconv.dll \
$(GTK_TOP)/bin/libpng13.dll \ $(GTK_TOP)/bin/intl.dll \
$(GTK_TOP)/bin/jpeg62.dll \ $(GTK_TOP)/bin/libpng12.dll \
$(GTK_TOP)/bin/libcairo-2.dll \ $(GTK_TOP)/bin/jpeg62.dll
$(GTK_TOP)/bin/libpangocairo-1.0-0.dll \
/c/WINDOWS/system32/python24.dll
NEEDED_FILES = README \ NEEDED_FILES = README \
COPYING \ COPYING \
......
...@@ -14,5 +14,4 @@ $(xml_DATA): %.xml: %.xml.in ...@@ -14,5 +14,4 @@ $(xml_DATA): %.xml: %.xml.in
sed -e "s/\(\<\)\/*_//g" $< > $@ sed -e "s/\(\<\)\/*_//g" $< > $@
CLEANFILES = $(xml_DATA)
/* config.h. Generated by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
/* Version number of package */
#define VERSION "@VERSION@"
/* Supported languages */
#define ALL_LINGUAS "am ar az bg ca cs da de el en_CA en_GB es et fi fr ga gu he hi hr hu it lt mk ml ms nl nb nn pa pl pt pt_BR ro ru sk sl sq sr sr@Latn sv tr wa zh_CN"
/* Global assetml directory */
#define ASSETML_DIR "share/assetml"
/* "Enable debug messages." */
/* #undef DEBUG */
/* always defined to indicate that i18n is enabled */
/* #undef ENABLE_NLS */
/* Gettext package name */
#define GETTEXT_PACKAGE "gcompris"
/* Defines where GNU Chess resides on the system */
#define GNUCHESS "gnuchess.exe"
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */
/* Define to 1 if you have the `dcgettext' function. */
/* #undef HAVE_DCGETTEXT */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define if the GNU gettext() function is already present or preinstalled. */
/* #undef HAVE_GETTEXT */
/* Define if you have the iconv() function. */
/* #undef HAVE_ICONV */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define if your <locale.h> file defines LC_MESSAGES. */
/* #undef HAVE_LC_MESSAGES */
/* Define to 1 if you have the `popt' library (-lpopt). */
#define HAVE_LIBPOPT 1
/* Define to 1 if you have the `SDL_mixer' library (-lSDL_mixer). */
#define HAVE_LIBSDL_MIXER 1
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define as const if the declaration of iconv() needs const. */
/* #undef ICONV_CONST */
/* Name of package */
#define PACKAGE "gcompris"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Gcompris data directory */
#define PACKAGE_DATA_DIR "share"
/* Gcompris plugins directory (not needed, static compile on windows) */
#define PACKAGE_CLIB_DIR ""
/* Gcompris help directory */
#define PACKAGE_HELP_DIR "share/gnome/help/gcompris"
/* Gcompris locale directory */
#define PACKAGE_LOCALE_DIR "share/locale"
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
...@@ -32,7 +32,7 @@ import os ...@@ -32,7 +32,7 @@ import os
import tempfile import tempfile
# Set to True to debug # Set to True to debug
debug = False debug = True
from gcompris import gcompris_gettext as _ from gcompris import gcompris_gettext as _
...@@ -280,6 +280,7 @@ class Gcompris_electric: ...@@ -280,6 +280,7 @@ class Gcompris_electric:
(Bulb, 0.11), (Bulb, 0.11),
(Rheostat, 1000), (Rheostat, 1000),
(Switch, None), (Switch, None),
(Switch2, None),
(Connection, None), (Connection, None),
) )
elif(level == 3): elif(level == 3):
...@@ -730,11 +731,13 @@ class Component(object): ...@@ -730,11 +731,13 @@ class Component(object):
self.center_x = pixmap.get_width()/2 self.center_x = pixmap.get_width()/2
self.center_y = pixmap.get_height()/2 self.center_y = pixmap.get_height()/2
self.component_item_offset_x = 0
self.component_item_offset_y = 0
self.component_item = self.comp_rootitem.add( self.component_item = self.comp_rootitem.add(
gnome.canvas.CanvasPixbuf, gnome.canvas.CanvasPixbuf,
pixbuf = pixmap, pixbuf = pixmap,
x = self.x, x = self.x + self.component_item_offset_x,
y = self.y, y = self.y + self.component_item_offset_y,
) )
self.component_item.connect("event", self.component_move, self) self.component_item.connect("event", self.component_move, self)
...@@ -780,8 +783,8 @@ class Component(object): ...@@ -780,8 +783,8 @@ class Component(object):
self.item_values.set(x = self.item_values_x + self.x, self.item_values.set(x = self.item_values_x + self.x,
y = self.item_values_y + self.y) y = self.item_values_y + self.y)
self.component_item.set(x = self.x, self.component_item.set(x = self.x + self.component_item_offset_x,
y = self.y) y = self.y + self.component_item_offset_y )
for node in self.nodes: for node in self.nodes:
node.move( self.x, self.y) node.move( self.x, self.y)
...@@ -1057,6 +1060,156 @@ class Switch(Component): ...@@ -1057,6 +1060,156 @@ class Switch(Component):
self.item_values.hide() self.item_values.hide()
return True return True
# ----------------------------------------
# SWITCH2
#
#
class Switch2(Component):
image = "electric/switch2_on.png"
icon = "electric/switch2_icon.png"
def __init__(self, electric,
x, y, dummy):
self.click_ofset_x = 22
self.click_ofset_y = -28
self.gnucap_current_resistor = 1
self.gnucap_nb_resistor = 0
self.value_on = "0"
self.value_off = "10000k"
self.value_top = self.value_on
self.value_bottom = self.value_off
super(Switch2, self).__init__(electric,
"R",
self.value_off,
self.image,
[Node("electric/connect.png", "C", -15, 0),
Node("electric/connect.png", "A", 80, -25),
Node("electric/connect.png", "B", 80, 25)])
# Overide some values
self.item_values.hide()
self.move(x, y)
pixmap = gcompris.utils.load_pixmap("electric/switch_click.png")
self.click_item = self.comp_rootitem.add(
gnome.canvas.CanvasPixbuf,
pixbuf = pixmap,
x = self.x + self.click_ofset_x,
y = self.y + self.click_ofset_y,
)
self.click_item.connect("event", self.component_click)
self.show()
# Callback event on the switch
def component_click(self, widget, event):
if event.state & gtk.gdk.BUTTON1_MASK:
if(self.value_top == self.value_off):
self.value_top = self.value_on
self.value_bottom = self.value_off
self.component_item_offset_y = - 6
pixmap = gcompris.utils.load_pixmap("electric/switch2_on.png")
else:
self.value_top = self.value_off
self.value_bottom = self.value_on
self.component_item_offset_y = 10
pixmap = gcompris.utils.load_pixmap("electric/switch2_off.png")
self.component_item.set(y = self.y + self.component_item_offset_y)
self.component_item.set(pixbuf = pixmap)
self.electric.run_simulation()
return False
# Callback event to move the component
def component_move(self, widget, event, component):
super(Switch2, self).component_move(widget, event, component)
if(self.electric.get_current_tools()=="DEL"):
return True
self.click_item.set(
x = self.x + self.click_ofset_x,
y = self.y + self.click_ofset_y)
return True
# Return True if this component is connected and can provides a gnucap
# description
#
# The switch2 needs at least 2 connected nodes
#
def is_connected(self):
count = 0
for node in self.nodes:
if node.get_wires():
count += 1
if count >= 2:
return True
return False
# Return the gnucap definition for a single resitor of the switch2
# node_id1 and node_id2 are the index in the list of nodes
def to_gnucap_res(self, gnucap_name, node_id1, node_id2, gnucap_value):
gnucap = gnucap_name
gnucap += " "
for i in (node_id1, node_id2):
node = self.nodes[i]
if node.get_wires():
gnucap += str(node.get_wires()[0].get_wire_id())
gnucap += " "
gnucap += " "
gnucap += str(gnucap_value)
gnucap += "\n"
gnucap += ".print dc + v(%s) i(%s)\n" %(gnucap_name, gnucap_name)
return gnucap
# Return the gnucap definition for this component
# depending of the connected nodes, it create one or two resistor
def to_gnucap(self, model):
gnucap = ""
# reset set_voltage_intensity counter
self.gnucap_current_resistor = 0
self.gnucap_nb_resistor = 0
# top resistor
if self.nodes[0].get_wires() and \
self.nodes[1].get_wires():
gnucap += self.to_gnucap_res(self.gnucap_name + "_top", 0, 1,
self.value_top)
self.gnucap_nb_resistor += 1
# bottom resistor
if self.nodes[0].get_wires() and \
self.nodes[2].get_wires():
gnucap += self.to_gnucap_res(self.gnucap_name + "_bot", 0, 2,
self.value_bottom)
self.gnucap_nb_resistor += 1
return gnucap
# Return False if we need more value to complete our component
# This is usefull in case where one Component is made of several gnucap component
def set_voltage_intensity(self, valid_value, voltage, intensity):
# Never show values
self.item_values.hide()
self.gnucap_current_resistor += 1
if(self.gnucap_nb_resistor == self.gnucap_current_resistor):
return True
else:
return False
# ---------------------------------------- # ----------------------------------------
# RHEOSTAT # RHEOSTAT
# #
......
...@@ -36,32 +36,90 @@ typedef struct { ...@@ -36,32 +36,90 @@ typedef struct {
gint indent; gint indent;
gint pixels_above_lines; gint pixels_above_lines;
gint pixels_below_lines; gint pixels_below_lines;
gchar *foreground;
} style_t; } style_t;
static style_t doctype_default[] = #define NUMBER_OF_STYLE 4
static GtkTextTag *tag_list[NUMBER_OF_STYLE];
/*
* The document styles
*/
typedef struct {
gchar *name;
style_t style[NUMBER_OF_STYLE];
} doctype_t;
doctype_t type_normal =
{
.name = N_("Default"),
.style = {
{ "H0", "Serif 30", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20 },
{ "H1", "Serif 26", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15 },
{ "H2", "Serif 20", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12 },
{ "P", "Serif 16", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3 }
}
};
doctype_t type_letter =
{ {
{ "H0", "Serif 30", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20, "black"}, .name = N_("Letter"),
{ "H1", "Serif 26", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15, "black" }, .style = {
{ "H2", "Serif 20", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12, "black" }, { "H0", "Serif 26", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20 },
{ "P", "Serif 16", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3, "black" } { "H1", "Serif 20", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15 },
{ "H2", "Serif 16", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12 },
{ "P", "Serif 14", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3 }
},
}; };
#define NUMBER_OF_STYLE G_N_ELEMENTS(doctype_default)
static style_t doctype_love_letter[] = doctype_t type_small =
{ {
{ "Hx0", "Serif 30", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20, "DeepPink" }, .name = N_("Small"),
{ "Hx1", "Serif 26", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15, "HotPink" }, .style = {
{ "Hx2", "Serif 20", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12, "MediumOrchid" }, { "H0", "Serif 18", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20 },
{ "Px", "Serif 16", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3, "black" } { "H1", "Serif 16", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15 },
{ "H2", "Serif 14", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12 },
{ "P", "Serif 12", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3 }
},
}; };
static style_t *doctype_list[] = doctype_t type_text =
{ {
doctype_default, .name = N_("Text"),
doctype_love_letter .style = {
{ "H0", "Serif 12", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20 },
{ "H1", "Serif 12", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15 },
{ "H2", "Serif 12", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12 },
{ "P", "Serif 12", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3 }
},
}; };
doctype_t type_big =
{
.name = N_("Big"),
.style = {
{ "H0", "Serif 34", PANGO_WEIGHT_ULTRABOLD, GTK_JUSTIFY_CENTER, 0, 40, 20 },
{ "H1", "Serif 30", PANGO_WEIGHT_BOLD, GTK_JUSTIFY_LEFT, 0, 30, 15 },
{ "H2", "Serif 26", PANGO_WEIGHT_SEMIBOLD, GTK_JUSTIFY_LEFT, 0, 20, 12 },
{ "P", "Serif 18", PANGO_WEIGHT_NORMAL, GTK_JUSTIFY_LEFT, 30, 3, 3 }
},
};
#define NUMBER_OF_DOCTYPE 5
static doctype_t *doctype_list[NUMBER_OF_DOCTYPE];
/*
* The color styles
*/
#define NUMBER_OF_COLOR_STYLE 4
static gchar *color_style_list[NUMBER_OF_COLOR_STYLE][NUMBER_OF_STYLE+1] =
{
{N_("Black"), "black", "black", "black", "black"},
{N_("Red"), "red", "blue", "light blue", "black"},
{N_("Blue"), "blue", "red", "light blue", "black"},
{N_("Pink"), "DeepPink", "HotPink", "MediumOrchid", "black"},
};
static GcomprisBoard *gcomprisBoard = NULL; static GcomprisBoard *gcomprisBoard = NULL;
static gboolean board_paused = TRUE; static gboolean board_paused = TRUE;
static GtkWidget *gtk_combo_filetypes = NULL; static GtkWidget *gtk_combo_filetypes = NULL;
...@@ -79,27 +137,33 @@ static GnomeCanvasGroup *boardRootItem = NULL; ...@@ -79,27 +137,33 @@ static GnomeCanvasGroup *boardRootItem = NULL;
static GnomeCanvasItem *wordprocessor_create(void); static GnomeCanvasItem *wordprocessor_create(void);
static void wordprocessor_destroy_all_items(void); static void wordprocessor_destroy_all_items(void);
static gint item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data); static gint item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data);
static void display_style_buttons(GnomeCanvasGroup *boardRootItem, static void display_style_buttons(GnomeCanvasGroup *boardRootItem,
int x, int x,
int y); int y);
static void create_tags (GtkTextBuffer *buffer, style_t style[]); static void create_tags (GtkTextBuffer *buffer, doctype_t *doctype);
static void set_default_style (GtkTextBuffer *buffer, style_t *style); static void set_default_style (GtkTextBuffer *buffer, style_t *style);
static void display_style_selector(GnomeCanvasGroup *boardRootItem); static void display_style_selector(GnomeCanvasGroup *boardRootItem);
static void item_event_style_selection (GtkComboBox *widget, void *styles_tab[]); static void display_color_style_selector(GnomeCanvasGroup *boardRootItem);
static void item_event_style_selection (GtkComboBox *widget, void *data);
static void item_event_color_style_selection (GtkComboBox *widget, void *data);
#define word_area_x1 120 #define word_area_x1 120
#define word_area_y1 80 #define word_area_y1 80
#define word_area_width 580 #define word_area_width 580
#define word_area_height 420 #define word_area_height 420
#define combo_style_x1 500 #define combo_style_x1 300
#define combo_style_y1 20 #define combo_style_y1 20
#define combo_style_width 200
#define combo_color_style_x1 500
#define combo_color_style_y1 20
#define combo_color_style_width 200
static style_t *current_style_default; static style_t *current_style_default;
static style_t **current_doctype_default; static doctype_t *current_doctype_default;
static GtkTextBuffer *buffer; static GtkTextBuffer *buffer;
static GtkWidget *view; static GtkWidget *view;
static GHashTable* styles_hash = NULL;
/* Description of this plugin */ /* Description of this plugin */
static BoardPlugin menu_bp = static BoardPlugin menu_bp =
...@@ -230,11 +294,11 @@ static GnomeCanvasItem *wordprocessor_create() ...@@ -230,11 +294,11 @@ static GnomeCanvasItem *wordprocessor_create()
view = gtk_text_view_new (); view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
g_signal_connect (view, "key-release-event", g_signal_connect (view, "key-release-event",
G_CALLBACK (key_press_event), NULL); G_CALLBACK (key_press_event), NULL);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
sw = gtk_scrolled_window_new (NULL, NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
...@@ -258,8 +322,14 @@ static GnomeCanvasItem *wordprocessor_create() ...@@ -258,8 +322,14 @@ static GnomeCanvasItem *wordprocessor_create()
/* /*
* Create the default style tags * Create the default style tags
*/ */
current_doctype_default = &doctype_list[0]; doctype_list[0] = &type_normal;
create_tags(buffer, *current_doctype_default); doctype_list[1] = &type_letter;
doctype_list[2] = &type_small;
doctype_list[3] = &type_text;
doctype_list[4] = &type_big;
current_doctype_default = doctype_list[0];
create_tags(buffer, current_doctype_default);
/* /*
* Display the style buttons * Display the style buttons
...@@ -269,6 +339,7 @@ static GnomeCanvasItem *wordprocessor_create() ...@@ -269,6 +339,7 @@ static GnomeCanvasItem *wordprocessor_create()
word_area_y1); word_area_y1);
display_style_selector(boardRootItem); display_style_selector(boardRootItem);
display_color_style_selector(boardRootItem);
return NULL; return NULL;
} }
...@@ -276,7 +347,7 @@ static GnomeCanvasItem *wordprocessor_create() ...@@ -276,7 +347,7 @@ static GnomeCanvasItem *wordprocessor_create()
/* /*
* Display the style buttons * Display the style buttons
*/ */
static void display_style_buttons(GnomeCanvasGroup *boardRootItem, static void display_style_buttons(GnomeCanvasGroup *boardRootItem,
int x, int x,
int y) int y)
{ {
...@@ -350,10 +421,10 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) ...@@ -350,10 +421,10 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
if(board_paused) if(board_paused)
return FALSE; return FALSE;
switch (event->type) switch (event->type)
{ {
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
switch(event->button.button) switch(event->button.button)
{ {
case 1: case 1:
case 2: case 2:
...@@ -412,7 +483,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data) ...@@ -412,7 +483,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
*/ */
static void static void
create_tags (GtkTextBuffer *buffer, style_t style[]) create_tags (GtkTextBuffer *buffer, doctype_t *doctype)
{ {
gint i; gint i;
...@@ -420,22 +491,22 @@ create_tags (GtkTextBuffer *buffer, style_t style[]) ...@@ -420,22 +491,22 @@ create_tags (GtkTextBuffer *buffer, style_t style[])
{ {
GtkTextTag *tag; GtkTextTag *tag;
tag = gtk_text_buffer_create_tag (buffer, style[i].name, tag = gtk_text_buffer_create_tag (buffer, doctype->style[i].name,
"weight", style[i].weight, "weight", doctype->style[i].weight,
"font", style[i].font, "font", doctype->style[i].font,
"justification", style[i].justification, "justification", doctype->style[i].justification,
"indent", style[i].indent, "indent", doctype->style[i].indent,
"pixels-above-lines", style[i].pixels_above_lines, "pixels-above-lines", doctype->style[i].pixels_above_lines,