Commit 7a32affa authored by Aleksey Lim's avatar Aleksey Lim Committed by Bruno Coudoin

Initial support of Sugar look&feel

parent eb987fc9
......@@ -45,6 +45,8 @@ AM_GLIB_GNU_GETTEXT
#*******************************************************************************
GTK_REQUIRED=2.4.0
LIBRSVG_REQUIRED=2.26.0
LIBXML_REQUIRED=2.7.3
dnl
dnl Start of pkg-config checks
......@@ -53,8 +55,8 @@ dnl
PKG_CHECK_MODULES(GCOMPRIS, \
gtk+-2.0 >= $GTK_REQUIRED \
gstreamer-0.10 \
librsvg-2.0 \
libxml-2.0)
librsvg-2.0 >= $LIBRSVG_REQUIRED \
libxml-2.0 >= $LIBXML_REQUIRED)
AC_SUBST(GCOMPRIS_CFLAGS)
AC_SUBST(GCOMPRIS_LIBS)
......@@ -409,6 +411,23 @@ if test x$with_dbus = xyes; then
AC_DEFINE([USE_DBUS], 1,[DBUS support is enabled])
fi
dnl Sugar DE support
AC_MSG_CHECKING([wether we build with Sugar DE support])
AC_ARG_ENABLE(sugar,
AC_HELP_STRING(
[--enable-sugar],
[Turn on sugar support (will let GCompris integrate well on Sugar DE)]),
with_sugar="$enableval", with_sugar="no")
AC_MSG_RESULT($with_sugar)
if test x$with_sugar = xyes; then
if test x$with_dbus = xno; then
AC_MSG_ERROR([You need to add DBUS support as well.])
fi
PKG_CHECK_MODULES(SUGAR, [sugar-toolkit])
AC_DEFINE([USE_SUGAR], 1, [Sugar DE support is enabled])
fi
AM_CONDITIONAL([SUGAR], [test x$with_sugar = xyes])
dnl check for python
AC_ARG_WITH(python,AC_HELP_STRING(
[--with-python=path],
......@@ -422,7 +441,7 @@ if test x$python_path != xnot ; then
PYTHON=$python_path
fi
AM_PATH_PYTHON(2.6)
AM_PATH_PYTHON
AM_CHECK_PYTHON_HEADERS( [build_python_plugin="yes"], [build_python_plugin="no"] )
fi
......@@ -442,7 +461,10 @@ if test x$build_python_plugin = xno; then
AC_MSG_NOTICE([Python plugin is disabled.])
else
dnl Python interpreter is available so check for pygtk
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 pycairo >= 1.8)
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 pycairo)
PYCAIRO_VERSION=$(pkg-config pycairo --modversion | awk -F. '{print ($1 * 1000) + $2 }')
AC_DEFINE_UNQUOTED([PYCAIRO_VERSION], $PYCAIRO_VERSION, [pycairo version])
AC_MSG_CHECKING([for pygtk defs])
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
......@@ -834,6 +856,7 @@ echo "Python plugin = $build_python_plugin"
echo "SQLITE database (--enable-sqlite) = $with_sqlite (profiles depend on this)"
echo "DBUS Support (OLPC XO Sugar) = $with_dbus"
echo "Sugar DE Support = $with_sugar"
echo "GNET Networking (--enable-gnet) = $with_gnet (networking depends on this)"
echo "BINRELOC (--enable-binreloc) = $br_cv_binreloc"
echo "NSBundle (--enable-nsbundle) = $nsbundle"
......
......@@ -35,8 +35,7 @@ _cairo_matrix_to_gvalue(GValue *value, PyObject *obj)
static PyObject *
_cairo_pattern_from_gvalue(const GValue *value)
{
#if defined WIN32
// On windows we have the old cairo API for now
#if PYCAIRO_VERSION < 1008
return PycairoPattern_FromPattern(cairo_pattern_reference((cairo_pattern_t *) g_value_get_boxed(value)));
#else
return PycairoPattern_FromPattern(cairo_pattern_reference((cairo_pattern_t *) g_value_get_boxed(value)), NULL);
......
......@@ -113,16 +113,19 @@ py_gc_board_end(PyObject* self, PyObject* args)
static PyObject*
py_gc_bar_start(PyObject* self, PyObject* args)
{
PyObject* pyWorkspace;
PyObject* pyCanvas;
GtkContainer* workspace;
GooCanvas* canvas;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "O:gc_bar_start", &pyCanvas))
if(!PyArg_ParseTuple(args, "OO:gc_bar_start", &pyWorkspace, &pyCanvas))
return NULL;
workspace = (GtkContainer*) pygobject_get(pyWorkspace);
canvas = (GooCanvas*) pygobject_get(pyCanvas);
/* Call the corresponding C function */
gc_bar_start(canvas);
gc_bar_start(workspace, canvas);
/* Create and return the result */
Py_INCREF(Py_None);
......
......@@ -147,3 +147,9 @@ EXTRA_DIST = \
DONT_DIST_SOURCE = $(marshal_sources)
gcompris_nsbundle_CPPFLAGS = -fconstant-string-class=NSConstantString
if SUGAR
INCLUDES += $(SUGAR_CFLAGS)
gcompris_SOURCES += sugar.c
gcompris_LDADD += $(SUGAR_LIBS)
endif
......@@ -27,6 +27,7 @@
#include "gc_core.h"
#include "gcompris_config.h"
#include "about.h"
#include "bar.h"
#define SOUNDLISTFILE PACKAGE
......@@ -47,7 +48,7 @@ static gboolean item_event_bar (GooCanvasItem *item,
GComprisBarFlags flag);
static void bar_reset_sound_id (void);
static gint bar_play_sound (GooCanvasItem *item);
static void play_level_voice(int level);
static void bar_set (const GComprisBarFlags flags);
static gint current_level = -1;
static gint current_flags = 0;
......@@ -146,7 +147,8 @@ new_button(GooCanvasItem *rootitem,
/*
* Do all the bar display and register the events
*/
void gc_bar_start (GooCanvas *theCanvas)
static void
bar_start (GooCanvas *theCanvas)
{
GcomprisProperties *properties = gc_prop_get();
gint16 height;
......@@ -275,13 +277,14 @@ void gc_bar_start (GooCanvas *theCanvas)
update_exit_button();
gc_bar_set(0);
bar_set(0);
_hidden = FALSE;
}
void gc_bar_set_level(GcomprisBoard *gcomprisBoard)
static void
bar_set_level(GcomprisBoard *gcomprisBoard)
{
goo_canvas_item_raise(rootitem, NULL);
......@@ -315,8 +318,8 @@ void gc_bar_set_level(GcomprisBoard *gcomprisBoard)
* This must be called before calling gc_bar_set with GC_BAR_REPEAT_ICON
* the given svg_handle is not freed.
*/
void
gc_bar_set_repeat_icon (RsvgHandle *svg_handle)
static void
bar_set_repeat_icon (RsvgHandle *svg_handle)
{
GooCanvasItem *item;
goo_canvas_item_raise(rootitem, NULL);
......@@ -338,8 +341,8 @@ gc_bar_set_repeat_icon (RsvgHandle *svg_handle)
* @param[in] y the bar y coordinate, -1 to set the default
* @param[in] zoom the bar zoom factor, -1 to set the default
*/
void
gc_bar_location (int x, int y, double zoom)
static void
bar_location (int x, int y, double zoom)
{
// Make the y coord be assigned at its bottom
int ny = (y == -1 ? _default_y : y);
......@@ -358,8 +361,8 @@ gc_bar_location (int x, int y, double zoom)
}
/* Setting list of available icons in the control bar */
void
gc_bar_set (const GComprisBarFlags flags)
static void
bar_set (const GComprisBarFlags flags)
{
// Always reset the zoom factor or the calculation
// will be wrong
......@@ -431,14 +434,14 @@ gc_bar_set (const GComprisBarFlags flags)
// Always center the bar with its new bounds
//SET_ITEM_LOCATION(rootitem, 0, _default_y);
gc_bar_location (-1, -1, -1);
bar_location (-1, -1, -1);
}
/* Hide all icons in the control bar
* or restore the icons to the previous value
*/
void
gc_bar_hide (gboolean hide)
static void
bar_hide (gboolean hide)
{
/* Non yet initialized : Something Wrong */
g_assert(rootitem);
......@@ -542,8 +545,8 @@ on_leave_notify (GooCanvasItem *item,
/** Play the audio number given in @level
*/
static void
play_level_voice(int level)
void
gc_bar_play_level_voice(int level)
{
/* Play the audio level number */
gchar *number_str = g_strdup_printf("%d", level);
......@@ -591,7 +594,7 @@ item_event_bar (GooCanvasItem *item,
if(gcomprisBoard && gcomprisBoard->plugin->set_level != NULL)
gcomprisBoard->plugin->set_level(current_level);
play_level_voice(current_level);
gc_bar_play_level_voice(current_level);
}
break;
case GC_BAR_LEVEL_DOWN:
......@@ -605,12 +608,12 @@ item_event_bar (GooCanvasItem *item,
if(gcomprisBoard && gcomprisBoard->plugin->set_level != NULL)
gcomprisBoard->plugin->set_level(current_level);
play_level_voice(current_level);
gc_bar_play_level_voice(current_level);
}
break;
case GC_BAR_HOME:
{
gc_bar_hide (TRUE);
bar_hide (TRUE);
gc_board_stop();
}
break;
......@@ -668,3 +671,67 @@ confirm_quit(gboolean answer)
if (answer)
gc_exit();
}
/* bar registration */
static Bar *custom_bar = NULL;
void
gc_bar_register (Bar *bar)
{
custom_bar = bar;
}
void
gc_bar_start (GtkContainer *workspace, GooCanvas *theCanvas)
{
if (custom_bar == NULL)
bar_start (theCanvas);
else if (custom_bar->start != NULL)
custom_bar->start (workspace, theCanvas);
}
void
gc_bar_set_level (GcomprisBoard *gcomprisBoard)
{
if (custom_bar == NULL)
bar_set_level (gcomprisBoard);
else if (custom_bar->set_level != NULL)
custom_bar->set_level (gcomprisBoard);
}
void
gc_bar_set_repeat_icon (RsvgHandle *svg_handle)
{
if (custom_bar == NULL)
bar_set_repeat_icon (svg_handle);
else if (custom_bar->set_repeat_icon != NULL)
custom_bar->set_repeat_icon (svg_handle);
}
void
gc_bar_location (int x, int y, double zoom)
{
if (custom_bar == NULL)
bar_location (x, y, zoom);
else if (custom_bar->set_location != NULL)
custom_bar->set_location (x, y, zoom);
}
void
gc_bar_set (const GComprisBarFlags flags)
{
if (custom_bar == NULL)
bar_set (flags);
else if (custom_bar->set_flags != NULL)
custom_bar->set_flags (flags);
}
void
gc_bar_hide (gboolean hide)
{
if (custom_bar == NULL)
bar_hide (hide);
else if (custom_bar->set_hide != NULL)
custom_bar->set_hide (hide);
}
/* gcompris - bar.h
*
* Copyright (C) 2010, Aleksey Lim
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BAR_H
#define BAR_H
#include "gcompris.h"
typedef struct
{
void (*start) (GtkContainer *workspace, GooCanvas *theCanvas);
void (*set_level) (GcomprisBoard *gcomprisBoard);
void (*set_repeat_icon) (RsvgHandle *svg_handle);
void (*set_location) (int x, int y, double zoom);
void (*set_flags) (const GComprisBarFlags flags);
void (*set_hide) (gboolean hide);
} Bar;
void gc_bar_register (Bar *bar);
#endif
......@@ -316,6 +316,31 @@ gc_config_start ()
"fill-color-rgba", gc_skin_color_content,
NULL);
// Zoom
y_start += Y_GAP;
item = goo_canvas_svg_new (rootitem,
gc_skin_rsvg_get(),
"svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked),
"autocrop", TRUE,
NULL);
SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);
g_signal_connect(item, "button_press_event",
(GtkSignalFunc) item_event_ok,
"zoom");
gc_item_focus_init(item, NULL);
goo_canvas_text_new (rootitem,
_("Zoom"),
(gdouble) x_text_start,
(gdouble) y_start,
-1,
GTK_ANCHOR_WEST,
"font", gc_skin_font_subtitle,
"fill-color-rgba", gc_skin_color_content,
NULL);
// Timer
y_start += Y_GAP;
......@@ -729,6 +754,15 @@ item_event_ok(GooCanvasItem *item,
NULL);
gc_item_focus_init(item, NULL);
}
else if(!strcmp((char *)data, "zoom"))
{
properties->zoom = (properties->zoom ? 0 : 1);
gc_update_canvas_zoom();
g_object_set (item,
"svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked),
NULL);
gc_item_focus_init(item, NULL);
}
else if(!strcmp((char *)data, "locale_previous"))
{
current_locale = get_previous_locale(current_locale);
......
......@@ -37,6 +37,7 @@
#include "gc_core.h"
#include "gcompris_config.h"
#include "about.h"
#include "bar.h"
#include <locale.h>
#include "binreloc.h"
......@@ -56,20 +57,14 @@ static double zoom_factor = 1.0;
#define GC_LOCK_LIMIT 30 /* seconds */
static GtkWidget *window;
static GtkWidget *workspace;
static GtkWidget *alignment;
static GtkWidget *canvas;
static GtkWidget *fixed;
static GtkWidget *drawing_area;
gchar * exec_prefix = NULL;
//static gint pause_board_cb (GtkWidget *widget, gpointer data);
static void quit_cb (GtkWidget *widget, gpointer data);
static void map_cb (GtkWidget *widget, gpointer data);
static gint _gc_configure_event_callback (GtkWidget *widget,
GdkEventConfigure *event,
gpointer client_data);
static gboolean _expose_background_callback (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
#ifndef WIN32
static gboolean _realize_callback (GtkWidget *widget, GdkEventExpose *event,
gpointer data);
......@@ -146,6 +141,10 @@ static gchar *popt_cache_dir = NULL;
static gchar *popt_drag_mode = NULL;
static gchar *sugarBundleId = NULL;
static gchar *sugarActivityId = NULL;
static gint popt_sugar_look = FALSE;
static gint popt_no_zoom = FALSE;
static gdouble popt_timing_base = 1.0;
static gdouble popt_timing_mult = 1.0;
static GOptionEntry options[] = {
{"fullscreen", 'f', 0, G_OPTION_ARG_NONE, &popt_fullscreen,
......@@ -250,6 +249,18 @@ static GOptionEntry options[] = {
{"sugarActivityId", '\0', 0, G_OPTION_ARG_STRING, &sugarActivityId,
"Sugar Activity Id", NULL},
{"sugar",'\0', 0, G_OPTION_ARG_NONE, &popt_sugar_look,
("Use Sugar DE look&feel"), NULL},
{"no-zoom",'\0', 0, G_OPTION_ARG_NONE, &popt_no_zoom,
("Disable maximization zoom"), NULL},
{"timing-base",'\0', 0, G_OPTION_ARG_DOUBLE, &popt_timing_base,
("Increase activiites' timeout delays; useful values > 1.0; 1.0 to not change hardcoded value"), NULL},
{"timing-mult",'\0', 0, G_OPTION_ARG_DOUBLE, &popt_timing_mult,
("How activiites' timeout delays are growing for several actors; useful values < 1.0; 1.0 to not change hardcoded value"), NULL},
{ NULL }
};
......@@ -272,30 +283,27 @@ double gc_zoom_factor_get()
}
static gint
_gc_configure_event_callback (GtkWidget *widget,
GdkEventConfigure *event,
_gc_size_allocate_event_callback (GtkWidget *widget,
GtkAllocation *allocation,
gpointer client_data)
{
double xratio, yratio;
gint screen_height, screen_width;
gdk_drawable_get_size(GDK_DRAWABLE (window->window),
&screen_width,
&screen_height);
double canvas_width, canvas_height;
yratio=screen_height/(float)(BOARDHEIGHT);
xratio=screen_width/(float)BOARDWIDTH;
yratio=allocation->height/(float)(BOARDHEIGHT);
xratio=allocation->width/(float)BOARDWIDTH;
zoom_factor = MIN(xratio, yratio);
g_message("The screen_width=%f screen_height=%f ratio=%f\n",
(double)screen_width, (double)screen_height, zoom_factor);
(double)allocation->width, (double)allocation->height, zoom_factor);
gtk_widget_set_usize (canvas, BOARDWIDTH*zoom_factor, BOARDHEIGHT*zoom_factor);
goo_canvas_set_scale (GOO_CANVAS(canvas), zoom_factor);
gtk_fixed_move(GTK_FIXED(fixed), canvas,
(screen_width-BOARDWIDTH*zoom_factor)/2,
(screen_height-BOARDHEIGHT*zoom_factor)/2);
if (!properties->zoom && zoom_factor > 1.)
zoom_factor = 1.;
canvas_width = BOARDWIDTH * zoom_factor;
canvas_height = BOARDHEIGHT * zoom_factor;
_expose_background_callback (drawing_area, NULL, NULL);
gtk_widget_set_size_request(canvas, canvas_width, canvas_height);
goo_canvas_set_scale (GOO_CANVAS(canvas), zoom_factor);
return FALSE;
}
......@@ -618,27 +626,6 @@ gc_set_default_background(GooCanvasItem *parent)
"#BACKGROUND");
}
/* Redraw the black background
*/
static gboolean
_expose_background_callback (GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
gint screen_height, screen_width;
gdk_drawable_get_size(GDK_DRAWABLE (window->window),
&screen_width,
&screen_height);
gtk_widget_set_size_request (widget, screen_width, screen_height);
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
TRUE,
0, 0, widget->allocation.width, widget->allocation.height);
return FALSE;
}
/*
* Sugar requires properties to be set before the windows is realized
*/
......@@ -669,28 +656,28 @@ _realize_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
#endif
static void
init_background()
init_workspace()
{
drawing_area = gtk_drawing_area_new ();
gtk_widget_set_size_request (drawing_area, BOARDWIDTH, BOARDHEIGHT);
g_signal_connect (G_OBJECT (drawing_area), "expose_event",
G_CALLBACK (_expose_background_callback), NULL);
/* Create a vertical box in which I put first the play board area, then the button bar */
fixed = gtk_fixed_new ();
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(fixed));
workspace = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), workspace);
gtk_fixed_put (GTK_FIXED(fixed), GTK_WIDGET(drawing_area), 0, 0);
gtk_fixed_put (GTK_FIXED(fixed), GTK_WIDGET(canvas), 0, 0);
GtkWidget *background = gtk_event_box_new();
GdkColor black = {0, 0, 0, 0};
gtk_widget_modify_bg(background, GTK_STATE_NORMAL, &black);
gtk_box_pack_end(GTK_BOX(workspace), background, TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET(fixed));
gtk_widget_show (GTK_WIDGET(canvas));
alignment = gtk_alignment_new(.5, .5, 0., 0.);
g_signal_connect (GTK_OBJECT (alignment), "size-allocate",
G_CALLBACK (_gc_size_allocate_event_callback), NULL);
gtk_container_add(GTK_CONTAINER(background), alignment);
gtk_widget_set_usize (GTK_WIDGET(canvas), BOARDWIDTH, BOARDHEIGHT);
gtk_container_add(GTK_CONTAINER(alignment), canvas);
gtk_widget_set_size_request (GTK_WIDGET(canvas), BOARDWIDTH, BOARDHEIGHT);
goo_canvas_set_bounds (GOO_CANVAS(canvas),
0, 0,
BOARDWIDTH,
BOARDHEIGHT);
g_object_set (G_OBJECT(canvas), "background-color", "#000", NULL);
}
static GcomprisBoard *get_board_to_start()
......@@ -782,13 +769,12 @@ static void setup_window ()
hints.height_inc = 1;
hints.min_aspect = (float)BOARDWIDTH/BOARDHEIGHT;
hints.max_aspect = (float)BOARDWIDTH/BOARDHEIGHT;
gtk_window_set_geometry_hints (GTK_WINDOW (window),
NULL,
&hints,
GDK_HINT_RESIZE_INC |
GDK_HINT_MIN_SIZE |
GDK_HINT_BASE_SIZE |
GDK_HINT_ASPECT);
gint geom_mask = GDK_HINT_RESIZE_INC |
GDK_HINT_MIN_SIZE |
GDK_HINT_BASE_SIZE;
if (!popt_sugar_look)
geom_mask |= GDK_HINT_ASPECT;
gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, &hints, geom_mask);
/*
* Set the main window
......@@ -809,9 +795,6 @@ static void setup_window ()
gtk_signal_connect (GTK_OBJECT (window), "map_event",
GTK_SIGNAL_FUNC (map_cb), NULL);
gtk_signal_connect (GTK_OBJECT (window), "configure_event",
GTK_SIGNAL_FUNC (_gc_configure_event_callback), NULL);
// Set the cursor
gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);
......@@ -828,9 +811,6 @@ static void setup_window ()
"key_press_event",
GTK_SIGNAL_FUNC (board_widget_key_press_callback), 0);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
gtk_widget_grab_focus (canvas);
gc_im_init(window);
gc_board_init();
......@@ -841,10 +821,13 @@ static void setup_window ()
/* Save the root_menu */
properties->menu_board = gc_menu_section_get(properties->root_menu);
/* Run the bar */
gc_bar_start(GOO_CANVAS(canvas));
init_workspace();
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
gtk_widget_grab_focus (canvas);
init_background();
/* Run the bar */
gc_bar_start(GTK_CONTAINER(workspace), GOO_CANVAS(canvas));
board_to_start = get_board_to_start();
......@@ -1056,7 +1039,10 @@ void gc_fullscreen_set(gboolean state)
if(state)
{
gdk_window_set_decorations (window->window, 0);
gtk_window_fullscreen (GTK_WINDOW(window));
if (popt_sugar_look)
gtk_window_maximize (GTK_WINDOW(window));
else
gtk_window_fullscreen (GTK_WINDOW(window));
gtk_widget_set_uposition (window, 0, 0);
}
else
......@@ -1313,6 +1299,13 @@ void gc_log_handler (const gchar *log_domain,
g_printerr ("%s: %s\n\n", "gcompris", message);
}
/* Refresh canvas zoom e.g. after setting zoom setting */
void
gc_update_canvas_zoom()
{
_gc_size_allocate_event_callback(NULL, &alignment->allocation, NULL);
}
static void
start_bg_music (gchar *file)
{
......@@ -1785,6 +1778,23 @@ main (int argc, char *argv[])
exit(0);
}
if (popt_sugar_look){
#ifdef USE_SUGAR
extern Bar sugar_bar;
gc_bar_register(&sugar_bar);
extern Score sugar_score;
gc_score_register(&sugar_score);
#else
printf("GCompris was not built with Sugar DE support.\n");
popt_sugar_look = FALSE;
#endif
}
if (popt_no_zoom){
g_message("Zoom disabled");
properties->zoom = FALSE;
}
/*------------------------------------------------------------*/
single_instance_check();
......@@ -1832,3 +1842,13 @@ main (int argc, char *argv[])
return(0);
}
gint
gc_timing (gint timeout, gint actors_number)
{
if (popt_timing_base > 1.0)
timeout = (int) (timeout * popt_timing_base);
if (popt_timing_mult < 1.0 && actors_number > 1)
timeout += (int) (timeout * actors_number * popt_timing_mult);
return timeout;
}
......@@ -83,7 +83,7 @@
void gc_board_end(void);
/* Control Bar methods */
void gc_bar_start (GooCanvas *theCanvas);
void gc_bar_start (GtkContainer *workspace, GooCanvas *theCanvas);
/** Set the default background of your activity.
* Always set the background in your activity startup.
......@@ -156,6 +156,10 @@ void gc_bar_hide (gboolean hide);
* @param[in] zoom is the zoom factor. Set to -1 to keep the default.
*/
void gc_bar_location (int x, int y, double zoom);
/** Pronounce level changing notification
* @param[in] level to pronounce, should be < 10
*/
void gc_bar_play_level_voice (int level);
/* General */
GooCanvas *gc_get_canvas(void);
......@@ -220,11 +224,17 @@ void gc_log_set_comment (GcomprisBoard *gcomprisBoard, gchar *expected, gchar*
/* Do not use it if you use the bonus API in your board */
void gc_log_end (GcomprisBoard *gcomprisBoard, GCBonusStatusList status);
/* Refresh canvas zoom e.g. after setting zoom setting */
void gc_update_canvas_zoom();
/* For menu type activity */
GList *gc_menu_getlist(gchar *section);
GcomprisBoard *gc_menu_section_get(gchar *section);
GList *gc_menu_get_boards();
/* Correct timeout delay for activity timings */
gint gc_timing (gint timeout, gint actors_number);
/*=========================================================*/
/* Some global definition to keep a constant look and feel */
/* Boards coders are invited to use them */
......
......@@ -176,6 +176,8 @@ gc_prop_new ()
tmp->server = NULL;
tmp->drag_mode = GC_DRAG_MODE_GRAB;
tmp->zoom = 1;
tmp->config_dir = gc_prop_default_config_directory_get();
tmp->user_dir = gc_prop_default_user_directory_get();
tmp->database = NULL;
......@@ -424,7 +426,10 @@ gc_prop_load (GcomprisProperties *props, GCPropSourceConf source_conf)
props->key = scan_get_string(scanner);
if(!props->key)
g_warning("Config file parsing error on token %s", token);
}
} else if(!strcmp(value.v_identifier, "zoom")) {
if(!scan_get_int(scanner, &props->zoom))
g_warning("Config file parsing error on token %s", token);
}
g_free(token);
break;
}
......@@ -556,6 +561,8 @@ gc_prop_save (GcomprisProperties *props)
fprintf(filefd, "%s=\"%s\"\n", "locale", props->locale);
fprintf(filefd, "%s=\"%s\"\n", "key", props->key);
fprintf(filefd, "%s=%d\n", "zoom", props->zoom);
fclose(filefd);
g_free(config_file);
......