Commit a9f2efca authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

apply theme style for graphs to do a full init.

2004-07-06  Jody Goldberg <jody@gnome.org>

	* graph/gog-graph.c (gog_graph_init) : apply theme style for graphs
	  to do a full init.

2004-07-04  Jody Goldberg <jody@gnome.org>

	* graph/gog-styled-object.c (gog_styled_object_parent_changed) :
	    initialize the style completely using the theme when we have a
	    theme.

2004-07-05  Jody Goldberg <jody@gnome.org>

	* ms-excel-read.c (excel_read_IMDATA) : Add an optional mechanism for
	  doing something with the data.  Still not entirely sure what format
	  it is.  I'd hoped BMP but that does not appear to work.

	* biff-types.h : Add a few more records

2004-07-05  Jody Goldberg <jody@gnome.org>

	* src/workbook-cmd-format.c (workbook_cmd_mutate_borders) :  move into
	  wbcg-actions.c

	* src/sheet-autofill.c (fill_item_new) : fix an old leak

	* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) :  no need to
	  check for accelerators here any more.
	(gnm_canvas_commit_cb) :  nor here.
	(gnm_check_ctrl_mask) :  delete and make these real accelerators the
	  way they belong.

	* src/wbcg-actions.c
	(cb_format_as_number) : a real accelerator
	(cb_format_as_currency) : ditto
	(cb_format_as_accounting) : ditto
	(cb_format_as_percentage) : ditto
	(cb_format_as_scientific) : ditto
	(cb_format_as_time) : ditto
	(cb_format_as_date) : ditto
	(cb_format_add_borders) : ditto
	(cb_format_clear_borders) : ditto

	* src/GNOME_Gnumeric-gtk.xml :  Add the new accelerators
	* src/application.c (gnumeric_application_setup_icons) : Rename the
	  icons to match the verbs (Percentage, Accounting)
parent 42930f8d
......@@ -89,7 +89,7 @@ Pending Patches
5.8.13) Cleanup (DONE)
5.8.14) why is first custom colour not displayed (DONE)
5.8.15) Better cursor
5.9) Move the hard coded accelerators out of
5.9) Move the hard coded accelerators out of (DONE)
canvas into actions
5.10) Add indent/unindent icons to gtk (DONE)
5.10.1) Patch written (DONE)
......
2004-07-05 Jody Goldberg <jody@gnome.org>
* src/workbook-cmd-format.c (workbook_cmd_mutate_borders) : move into
wbcg-actions.c
* src/sheet-autofill.c (fill_item_new) : fix an old leak
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : no need to
check for accelerators here any more.
(gnm_canvas_commit_cb) : nor here.
(gnm_check_ctrl_mask) : delete and make these real accelerators the
way they belong.
* src/wbcg-actions.c
(cb_format_as_number) : a real accelerator
(cb_format_as_currency) : ditto
(cb_format_as_accounting) : ditto
(cb_format_as_percentage) : ditto
(cb_format_as_scientific) : ditto
(cb_format_as_time) : ditto
(cb_format_as_date) : ditto
(cb_format_add_borders) : ditto
(cb_format_clear_borders) : ditto
* src/GNOME_Gnumeric-gtk.xml : Add the new accelerators
* src/application.c (gnumeric_application_setup_icons) : Rename the
icons to match the verbs (Percentage, Accounting)
2004-07-02 Jody Goldberg <jody@gnome.org>
* configure.in : Make gconf conditional and test for uname
......
2004-07-05 Jody Goldberg <jody@gnome.org>
* src/workbook-cmd-format.c (workbook_cmd_mutate_borders) : move into
wbcg-actions.c
* src/sheet-autofill.c (fill_item_new) : fix an old leak
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : no need to
check for accelerators here any more.
(gnm_canvas_commit_cb) : nor here.
(gnm_check_ctrl_mask) : delete and make these real accelerators the
way they belong.
* src/wbcg-actions.c
(cb_format_as_number) : a real accelerator
(cb_format_as_currency) : ditto
(cb_format_as_accounting) : ditto
(cb_format_as_percentage) : ditto
(cb_format_as_scientific) : ditto
(cb_format_as_time) : ditto
(cb_format_as_date) : ditto
(cb_format_add_borders) : ditto
(cb_format_clear_borders) : ditto
* src/GNOME_Gnumeric-gtk.xml : Add the new accelerators
* src/application.c (gnumeric_application_setup_icons) : Rename the
icons to match the verbs (Percentage, Accounting)
2004-07-02 Jody Goldberg <jody@gnome.org>
* configure.in : Make gconf conditional and test for uname
......
2004-07-05 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (excel_read_IMDATA) : Add an optional mechanism for
doing something with the data. Still not entirely sure what format
it is. I'd hoped BMP but that does not appear to work.
* biff-types.h : Add a few more records
2004-06-29 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (excel_read_REFMODE) : new.
......
......@@ -5,10 +5,10 @@
* biff-types.h: A long and dull list of BIFF types.
*
* Author:
* Michael Meeks (michael@ximian.com)
* Jody Goldberg (jody@gnome.org)
* Michael Meeks (michael@ximian.com)
*
* (C) 1998-2002 Michael Meeks, Jody Goldberg
* (C) 1998-2004 Michael Meeks, Jody Goldberg
**/
/**
* See S59D52.HTM for the spec.
......@@ -213,10 +213,17 @@
#define BIFF_SXVDEX 0x100 /* ONLY 1 */
#define BIFF_SXFORMULA 0x103 /* ONLY 1 */
#define BIFF_SXDBEX 0x122 /* ONLY 1 */
#define BIFF_CHTRINSERT 0x137 /* ONLY 1 */
#define BIFF_CHTRINFO 0x138 /* ONLY 1 */
#define BIFF_CHTRCELLCONTENT 0x13B /* ONLY 1 */
#define BIFF_TABID 0x13d /* ONLY 1 */
#define BIFF_CHTRMOVERANGE 0x140 /* ONLY 1 */
#define BIFF_CHTRINSERTTAB 0x14D /* ONLY 1 */
#define BIFF_LABELRANGES 0x15F /* ONLY 1 */
#define BIFF_USESELFS 0x160 /* ONLY 1 */
#define BIFF_DSF 0x161 /* ONLY 1 */
#define BIFF_XL5MODIFY 0x162 /* ONLY 1 */
#define BIFF_CHTRHEADER 0x196 /* ONLY 1 */
#define BIFF_FILESHARING2 0x1a5
#define BIFF_USERDBVIEW 0x1a9 /* ONLY 1 */
#define BIFF_USERSVIEWBEGIN 0x1aa
......
......@@ -3579,12 +3579,21 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet)
firstcol, lastcol);
}
void
excel_read_IMDATA (BiffQuery *q)
GdkPixbuf *
excel_read_IMDATA (BiffQuery *q, gboolean keep_image)
{
static int count = 0;
FILE *f;
guint16 op;
guint32 image_len = GSF_LE_GET_GUINT32 (q->data + 4);
GError *err = NULL;
GdkPixbufLoader *loader = NULL;
GdkPixbuf *pixbuf = NULL;
gboolean ret;
d (1,{
char *file_name;
char const *from_name;
char const *format_name;
guint16 const format = GSF_LE_GET_GUINT16 (q->data);
......@@ -3607,16 +3616,42 @@ excel_read_IMDATA (BiffQuery *q)
fprintf (stderr,"Picture from %s in %s format\n",
from_name, format_name);
file_name = g_strdup_printf ("imdata%d", count++);
f = fopen (file_name, "w");
fwrite (q->data+8, 1, q->length-8, f);
g_free (file_name);
});
loader = gdk_pixbuf_loader_new_with_type ("bmp", &err);
if (loader != NULL)
ret = gdk_pixbuf_loader_write (loader, q->data+8, q->length-8, &err);
image_len += 8;
while (image_len > q->length &&
ms_biff_query_peek_next (q, &op) && op == BIFF_CONTINUE) {
image_len -= q->length;
ms_biff_query_next (q);
d(1, fwrite (q->data, 1, q->length, f););
if (ret)
ret = gdk_pixbuf_loader_write (loader, q->data, q->length, &err);
}
d(1, fclose (f););
gdk_pixbuf_loader_close (loader, ret ? &err : NULL);
if (ret)
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
g_object_unref (G_OBJECT (loader));
g_return_val_if_fail (image_len == q->length, pixbuf);
if (err != NULL) {
g_warning (err-> message);
g_error_free (err);
err = NULL;
}
g_return_if_fail (image_len == q->length);
return pixbuf;
}
/* S59DE2.HTM */
......@@ -4675,7 +4710,9 @@ excel_read_BG_PIC (BiffQuery *q,
ExcelReadSheet *esheet)
{
/* undocumented, looks similar to IMDATA */
excel_read_IMDATA (q);
GdkPixbuf *background = excel_read_IMDATA (q, TRUE);
if (background != NULL)
g_object_unref (background);
}
static GnmValue *
......@@ -5292,7 +5329,7 @@ excel_read_sheet (BiffQuery *q, ExcelWorkbook *ewb,
biff_get_rk (q->data + 6));
break;
case BIFF_IMDATA: excel_read_IMDATA (q); break;
case BIFF_IMDATA: excel_read_IMDATA (q, FALSE); break;
case BIFF_GUTS: excel_read_GUTS (q, esheet); break;
case BIFF_WSBOOL: excel_read_WSBOOL (q, esheet); break;
case BIFF_GRIDSET: break;
......
......@@ -16,6 +16,7 @@
#include "ms-container.h"
#include <expr.h>
#include <pango/pango-attributes.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
typedef struct {
Workbook *wb;
......@@ -143,7 +144,7 @@ char *ms_biff_get_chars (char const *ptr, guint length,
GnmColor *excel_palette_get (ExcelPalette const *pal, gint idx);
void excel_read_IMDATA (BiffQuery *q);
GdkPixbuf *excel_read_IMDATA (BiffQuery *q, gboolean keep_image);
/* A utility routine to handle unexpected BIFF records */
void excel_unexpected_biff (BiffQuery *q, char const *state, int debug_level);
......
......@@ -726,7 +726,7 @@ ms_obj_read_pre_biff8_obj (BiffQuery *q, MSContainer *c, MSObj *obj)
guint16 op;
if (ms_biff_query_peek_next (q, &op) && op == BIFF_IMDATA) {
ms_biff_query_next (q);
excel_read_IMDATA (q);
excel_read_IMDATA (q, FALSE);
}
}
return FALSE;
......@@ -991,7 +991,7 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, MSObj *obj)
if (ms_biff_query_peek_next (q, &op) && op == BIFF_IMDATA) {
printf ("Reading trailing IMDATA;\n");
ms_biff_query_next (q);
excel_read_IMDATA (q);
excel_read_IMDATA (q, FALSE);
}
}
......
......@@ -251,8 +251,8 @@
<toolitem action="FormatMergeCells"/>
<toolitem action="FormatUnmergeCells"/>
<separator name="fmt-sep2"/>
<toolitem action="FormatAsMoney"/>
<toolitem action="FormatAsPercent"/>
<toolitem action="FormatAsAccounting"/>
<toolitem action="FormatAsPercentage"/>
<toolitem action="FormatWithThousands"/>
<toolitem action="FormatIncreasePrecision"/>
<toolitem action="FormatDecreasePrecision"/>
......@@ -283,9 +283,18 @@
<toolitem action="CreateEllipse"/>
</toolbar>
<accelerator name="CopyRight" action="CopyRight"/>
<accelerator name="CopyDown" action="CopyDown"/>
<accelerator name="FontBold" action="FontBold"/>
<accelerator name="FontItalic" action="FontItalic"/>
<accelerator name="FontUnderline" action="FontUnderline"/>
<accelerator name="CopyRight" action="CopyRight"/>
<accelerator name="CopyDown" action="CopyDown"/>
<accelerator name="FontBold" action="FontBold"/>
<accelerator name="FontItalic" action="FontItalic"/>
<accelerator name="FontUnderline" action="FontUnderline"/>
<accelerator name="FormatAsNumber" action="FormatAsNumber"/>
<accelerator name="FormatAsCurrency" action="FormatAsCurrency"/>
<accelerator name="FormatAsAccounting" action="FormatAsAccounting"/>
<accelerator name="FormatAsPercentage" action="FormatAsPercentage"/>
<accelerator name="FormatAsScientific" action="FormatAsScientific"/>
<accelerator name="FormatAsDate" action="FormatAsDate"/>
<accelerator name="FormatAsTime" action="FormatAsTime"/>
<accelerator name="FormatAddBorders" action="FormatAddBorders"/>
<accelerator name="FormatClearBorders" action="FormatClearBorders"/>
</ui>
......@@ -628,8 +628,8 @@ gnumeric_application_setup_icons (void)
{ gnm_add_decimals, NULL, "Gnumeric_FormatAddPrecision" },
{ gnm_remove_decimals, NULL, "Gnumeric_FormatRemovePrecision" },
{ gnm_money, NULL, "Gnumeric_FormatAsMoney" },
{ gnm_percent, NULL, "Gnumeric_FormatAsPercent" },
{ gnm_money, NULL, "Gnumeric_FormatAsAccounting" },
{ gnm_percent, NULL, "Gnumeric_FormatAsPercentage" },
{ gnm_thousand, NULL, "Gnumeric_FormatThousandSeparator" },
{ gnm_auto, NULL, "Gnumeric_AutoSum" },
......
2004-07-06 Jody Goldberg <jody@gnome.org>
* graph/gog-graph.c (gog_graph_init) : apply theme style for graphs
to do a full init.
2004-07-04 Jody Goldberg <jody@gnome.org>
* graph/gog-styled-object.c (gog_styled_object_parent_changed) :
initialize the style completely using the theme when we have a
theme.
2004-07-04 Christopher James Lahey <clahey@ximian.com>
* drawing/god-drawing-renderer-gdk.c (draw_text): Handle
......
......@@ -898,7 +898,7 @@ ms_obj_read_biff8_obj (BiffQuery *q, MSContainer *container, GODrawingPropertyTa
if (ms_biff_query_peek_next (q, &op) && op == BIFF_IMDATA) {
printf ("Reading trailing IMDATA;\n");
ms_biff_query_next (q);
excel_read_IMDATA (q);
excel_read_IMDATA (q, FALSE);
}
}
......
......@@ -922,8 +922,8 @@ static void
gog_axis_init_style (GogStyledObject *gso, GogStyle *style)
{
style->interesting_fields = GOG_STYLE_LINE | GOG_STYLE_FONT;
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0, FALSE);
}
static void
......
......@@ -210,6 +210,8 @@ gog_graph_init (GogGraph *graph)
/* Cheat and assign a name here, graphs will not have parents until we
* support graphs in graphs */
GOG_OBJECT (graph)->user_name = g_strdup (_("Graph"));
gog_theme_fillin_style (graph->theme,
gso->style, GOG_OBJECT (graph), 0, TRUE);
gog_styled_object_apply_theme (gso, gso->style);
}
......
......@@ -45,8 +45,8 @@ static void
gog_grid_init_style (GogStyledObject *gso, GogStyle *style)
{
style->interesting_fields = GOG_STYLE_FILL | GOG_STYLE_LINE;
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0, FALSE);
}
static void
......
......@@ -119,8 +119,8 @@ static void
gog_label_init_style (GogStyledObject *gso, GogStyle *style)
{
style->interesting_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL | GOG_STYLE_FONT;
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0, FALSE);
}
static void
......
......@@ -168,8 +168,8 @@ static void
gog_legend_init_style (GogStyledObject *gso, GogStyle *style)
{
style->interesting_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL | GOG_STYLE_FONT;
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0, FALSE);
}
static void
......
......@@ -368,8 +368,8 @@ gog_plot_foreach_elem (GogPlot *plot, gboolean only_visible,
style = gog_style_dup (series->base.style);
n = only_visible ? plot->visible_cardinality : plot->full_cardinality;
for (i = 0; i < n ; i++) {
gog_theme_init_style (theme, style, GOG_OBJECT (series),
plot->index_num + i);
gog_theme_fillin_style (theme, style, GOG_OBJECT (series),
plot->index_num + i, FALSE);
if (labels != NULL)
label = (i < num_labels)
? go_data_vector_get_str (labels, i) : g_strdup ("");
......
......@@ -398,8 +398,8 @@ gog_series_init_style (GogStyledObject *gso, GogStyle *style)
{
GogSeries const *series = (GogSeries const *)gso;
style->interesting_fields = series->plot->desc.series.style_fields;
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), series->index);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), series->index, FALSE);
}
static void
......
......@@ -1017,13 +1017,12 @@ gog_style_assign (GogStyle *dst, GogStyle const *src)
* gog_style_apply_theme :
* @dst : #GogStyle
* @src : #GogStyle
* @override : apply even if the setting is not auto
*
* Merge the attributes from @src onto the elements of @dst that were not user
* assigned (is_auto)
**/
void
gog_style_apply_theme (GogStyle *dst, GogStyle const *src, gboolean override)
gog_style_apply_theme (GogStyle *dst, GogStyle const *src)
{
if (src == dst)
return;
......@@ -1096,6 +1095,7 @@ gog_style_init (GogStyle *style)
style->interesting_fields = GOG_STYLE_ALL;
style->disable_theming = 0;
gog_style_force_auto (style);
style->outline.width = 0;
style->fill.type = GOG_FILL_STYLE_PATTERN;
style->fill.gradient.brightness = -1.;
go_pattern_set_solid (&style->fill.pattern, RGBA_BLACK);
......
......@@ -109,8 +109,7 @@ struct _GogStyle {
GogStyle *gog_style_new (void);
GogStyle *gog_style_dup (GogStyle const *style);
void gog_style_assign (GogStyle *dst, GogStyle const *src);
void gog_style_apply_theme (GogStyle *dst, GogStyle const *src,
gboolean override);
void gog_style_apply_theme (GogStyle *dst, GogStyle const *src);
void gog_style_set_marker (GogStyle *style, GOMarker *marker);
void gog_style_set_font (GogStyle *style,
PangoFontDescription *desc);
......
......@@ -109,6 +109,8 @@ gog_styled_object_parent_changed (GogObject *obj, gboolean was_set)
GogObjectClass *gog_object_klass = GOG_OBJECT_CLASS (parent_klass);
if (was_set) {
GogStyledObject *gso = GOG_STYLED_OBJECT (obj);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
gso->style, GOG_OBJECT (gso), 0, TRUE);
gog_styled_object_apply_theme (gso, gso->style);
}
gog_object_klass->parent_changed (obj, was_set);
......@@ -118,8 +120,8 @@ static void
gog_styled_object_init_style (GogStyledObject *gso, GogStyle *style)
{
style->interesting_fields = GOG_STYLE_OUTLINE | GOG_STYLE_FILL; /* default */
gog_theme_init_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0);
gog_theme_fillin_style (gog_object_get_theme (GOG_OBJECT (gso)),
style, GOG_OBJECT (gso), 0, FALSE);
}
static void
......
......@@ -129,9 +129,8 @@ GSF_CLASS (GogTheme, gog_theme,
gog_theme_class_init, gog_theme_init,
G_TYPE_OBJECT)
void
gog_theme_init_style (GogTheme *theme, GogStyle *style,
GogObject *obj, int ind)
static GogThemeElement *
gog_theme_find_element (GogTheme *theme, GogObject *obj)
{
GogThemeElement *elem = NULL;
GObjectClass *klass;
......@@ -139,7 +138,7 @@ gog_theme_init_style (GogTheme *theme, GogStyle *style,
if (theme == NULL)
theme = default_theme;
g_return_if_fail (theme != NULL);
g_return_val_if_fail (theme != NULL, NULL);
if (theme->load_from_file != NULL) {
#warning TODO parse some xml
......@@ -185,12 +184,35 @@ gog_theme_init_style (GogTheme *theme, GogStyle *style,
if (elem != NULL) /* if found lets cache the result */
g_hash_table_insert (theme->elem_hash_by_class, klass, elem);
}
return elem;
}
/**
* gog_theme_fillin_style :
* @theme : #GogTheme
* @style : #GogStyle to initialize
* @obj : #GogObject The object associated with @style
* @ind : an optional index
* @complete_overwrite : boolean
*
* Fill in the auto aspects of @style based on @theme 's element for objects of
* type/role similar to @obj with index @ind. If @complete_overwrite is used,
* fillin the entire style, not just the auto portions.
**/
void
gog_theme_fillin_style (GogTheme *theme, GogStyle *style,
GogObject *obj, int ind, gboolean complete_overwrite)
{
GogThemeElement *elem = gog_theme_find_element (theme, obj);
/* no theme entry for this type */
g_return_if_fail (elem != NULL);
#warning we should handle the applicability here not in the themes
gog_style_apply_theme (style, elem->style, FALSE);
if (complete_overwrite)
gog_style_assign (style, elem->style);
else
gog_style_apply_theme (style, elem->style);
#warning we should handle the applicability here not in the map
if (ind >= 0 && elem->map)
(elem->map) (style, ind);
}
......
......@@ -32,9 +32,8 @@ G_BEGIN_DECLS
GType gog_theme_get_type (void);
void gog_theme_init_style (GogTheme *theme, GogStyle *style,
GogObject *obj, int i);
void gog_theme_fillin_style (GogTheme *theme, GogStyle *style,
GogObject *obj, int i, gboolean complete_overwrite);
void gog_theme_register (GogTheme *theme, gboolean is_default);
void gog_theme_register_file (char const *name, char const *file);
GogTheme *gog_theme_lookup (char const *name);
......
......@@ -461,8 +461,8 @@ gog_pie_view_render (GogView *view, GogViewAllocation const *bbox)
gog_styled_object_get_style (
GOG_STYLED_OBJECT (gpse)));
} else if (model->base.vary_style_by_element)
gog_theme_init_style (theme, style, GOG_OBJECT (series),
model->base.index_num + k);
gog_theme_fillin_style (theme, style, GOG_OBJECT (series),
model->base.index_num + k, FALSE);
/* only separate the outer ring */
separated_cx = cx;
......
......@@ -692,8 +692,8 @@ gog_xy_view_render (GogView *view, GogViewAllocation const *bbox)
} else continue;
} else {
if (model->base.vary_style_by_element)
gog_theme_init_style (theme, style, GOG_OBJECT (series),
model->base.index_num + i - 1);
gog_theme_fillin_style (theme, style, GOG_OBJECT (series),
model->base.index_num + i - 1, FALSE);
bubble_draw_circle (view, x, y, ((size_as_area)? sqrt (z / zmax): z / zmax) * rmax);
}
} else if (prev_valid && show_lines) {
......
2004-07-05 Jody Goldberg <jody@gnome.org>
* dialog-about.c (dialog_about) : Throw in some gradients and a cheesy
text fade in out.
2004-06-29 Jody Goldberg <jody@gnome.org>
* dialog-preferences.c (pref_tree_initializer) : fix crash on startup
......
......@@ -173,13 +173,15 @@ typedef struct {
GtkWidget *canvas;
FooCanvasItem *ctrl;
GogObject *graph;
GogStyle *contributor_style;
GOData *contribs_data, *individual_data, *contributor_name;
guint timer;
double contribs [GNM_ABOUT_NUM_TYPES];
double individual [GNM_ABOUT_NUM_TYPES];
unsigned indx;
unsigned item_index;
int fade_state;
gboolean dec;
} GnmAboutState;
......@@ -194,24 +196,39 @@ gnm_about_state_free (GnmAboutState *state)
g_free (state);
}
#define FADE_STATES 15
#define MAX_FADE_STATE (FADE_STATES*2)
static gboolean
cb_about_animate (GnmAboutState *state)
{
int i;
float alpha;
if (state->indx >= G_N_ELEMENTS (contributors)) {
state->indx = 0;
state->dec = !state->dec;
}
if (state->fade_state == MAX_FADE_STATE) {
state->fade_state = 0;
state->item_index++;
if (state->item_index >= G_N_ELEMENTS (contributors)) {
state->item_index = 0;
state->dec = !state->dec;
}
for (i = 0 ; i < GNM_ABOUT_NUM_TYPES ; i++)
if (contributors [state->item_index].contributions & (1 << i)) {
state->contribs [i] += state->dec ? -1 : 1;
state->individual [i] = 1;
} else
state->individual [i] = 0;
} else
state->fade_state++;
for (i = 0 ; i < GNM_ABOUT_NUM_TYPES ; i++)
if (contributors [state->indx].contributions & (1 << i)) {
state->contribs [i] += state->dec ? -1 : 1;
state->individual [i] = 1;
} else
state->individual [i] = 0;
/* 1-((x-25)/25)**4 */
alpha = (state->fade_state - FADE_STATES) / (double)FADE_STATES;
alpha *= alpha;
state->contributor_style->font.color = UINT_RGBA_CHANGE_A (
state->contributor_style->font.color, (unsigned)(255 * (1. - alpha)));
go_data_scalar_str_set_str (GO_DATA_SCALAR_STR (state->contributor_name),
contributors [state->indx++].name, FALSE);
contributors [state->item_index].name, FALSE);
go_data_emit_changed (GO_DATA (state->contribs_data));
go_data_emit_changed (GO_DATA (state->individual_data));
return TRUE;
......@@ -236,7 +253,8 @@ dialog_about (WorkbookControlGUI *wbcg)
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
state->indx = 0;
state->fade_state = MAX_FADE_STATE; /* prime things to start at item 0 */
state->item_index = -1;
state->dec = FALSE;
for (i = GNM_ABOUT_NUM_TYPES ; i-- > 0 ; )
state->contribs[i] = state->individual[i] = 0.;
......@@ -245,7 +263,7 @@ dialog_about (WorkbookControlGUI *wbcg)
state->graph = g_object_new (GOG_GRAPH_TYPE, NULL);
GOG_STYLED_OBJECT (state->graph)->style->fill.type = GOG_FILL_STYLE_GRADIENT;
GOG_STYLED_OBJECT (state->graph)->style->fill.pattern.fore = 0xFFFF99FF;
GOG_STYLED_OBJECT (state->graph)->style->fill.pattern.back = 0xFFFF99FF;
GOG_STYLED_OBJECT (state->graph)->style->fill.gradient.dir = GO_GRADIENT_W_TO_E_MIRRORED;
GOG_STYLED_OBJECT (state->graph)->style->outline.width = 0; /* hairline */
GOG_STYLED_OBJECT (state->graph)->style->outline.color = RGBA_BLACK;
......@@ -279,6 +297,11 @@ dialog_about (WorkbookControlGUI *wbcg)
state->individual_data = go_data_vector_val_new (
state->individual, G_N_ELEMENTS (state->individual));
gog_series_set_dim (series, 1, state->individual_data, NULL);
GOG_STYLED_OBJECT (series)->style->outline.width = -1;
GOG_STYLED_OBJECT (series)->style->fill.type = GOG_FILL_STYLE_GRADIENT;
GOG_STYLED_OBJECT (series)->style->fill.gradient.dir = GO_GRADIENT_N_TO_S_MIRRORED;
gog_style_set_fill_brightness (
GOG_STYLED_OBJECT (series)->style, 70.);
/* remove the default grid, its ugly here */
tmp = gog_object_get_child_by_role (chart,
......@@ -300,9 +323,10 @@ dialog_about (WorkbookControlGUI *wbcg)
pango_font_description_from_string ("Sans 10"));
tmp = gog_object_add_by_name (chart, "Title", NULL);
gog_object_set_pos (tmp, GOG_POSITION_N | GOG_POSITION_ALIGN_CENTER);
gog_object_set_pos (tmp, GOG_POSITION_N | GOG_POSITION_ALIGN_START);
state->contributor_name = go_data_scalar_str_new ("", FALSE);
gog_dataset_set_dim (GOG_DATASET (tmp), 0, state->contributor_name, NULL);
state->contributor_style = GOG_STYLED_OBJECT (tmp)->style;
gog_style_set_font (GOG_STYLED_OBJECT (tmp)->style,
pango_font_description_from_string ("Sans Bold 10"));
......@@ -323,6 +347,11 @@ dialog_about (WorkbookControlGUI *wbcg)
state->contribs_data = go_data_vector_val_new (
state->contribs, G_N_ELEMENTS (state->contribs));
gog_series_set_dim (series, 1, state->contribs_data, NULL);
GOG_STYLED_OBJECT (series)->style->outline.width = -1;
GOG_STYLED_OBJECT (series)->style->fill.type = GOG_FILL_STYLE_GRADIENT;
GOG_STYLED_OBJECT (series)->style->fill.gradient.dir = GO_GRADIENT_NW_TO_SE;
gog_style_set_fill_brightness (
GOG_STYLED_OBJECT (series)->style, 70.);
tmp = gog_object_add_by_name (state->graph, "Title", NULL);
gog_object_set_pos (tmp, GOG_POSITION_S | GOG_POSITION_ALIGN_END);
......@@ -353,6 +382,6 @@ dialog_about (WorkbookControlGUI *wbcg)
g_signal_connect (state->about, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
state->timer = g_timeout_add (1000,
state->timer = g_timeout_add (100,
(GSourceFunc) cb_about_animate, state);
}
......@@ -51,67 +51,6 @@ gnm_canvas_guru_key (WorkbookControlGUI const *wbcg, GdkEventKey *event)
return TRUE;
}
static gboolean
gnm_check_ctrl_mask (GnmCanvas *gcanvas,guint keyval)
{
SheetControl *sc = (SheetControl *) gcanvas->simple.scg;
Sheet *sheet = sc->sheet;
WorkbookControlGUI *wbcg = gcanvas->simple.scg->wbcg;
char const *fmt = NULL;
char const *desc = NULL;
switch (keyval) {
case GDK_asciitilde :
fmt = cell_formats [FMT_NUMBER][0];
desc = _("Format as Number");
break;
case GDK_dollar :
fmt = cell_formats [FMT_CURRENCY][0];
desc = _("Format as Currency");
break;
case GDK_percent :
fmt = cell_formats [FMT_PERCENT][0];
desc = _("Format as Percentage");
break;
case GDK_asciicircum :
fmt