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

patch some warnings and make some comments.


2006-05-13  Jody Goldberg <jody@gnome.org>

	* component/gnumeric.c : patch some warnings and make some comments.

	* src/gnumeric-pane.c (display_object_menu) : Use the new
	  sheet_object_populate_menu and clarify that so and event can be
	  NULL.
	(cb_pane_popup_menu) : if objects are selected use
	  display_object_menu.

	* src/sheet-object.c (sheet_object_populate_menu) : new and public.
	(sheet_object_populate_menu_real) : renamed from sheet_object_populate_menu
	  and make smarter to be able to handle so == NULL.

	* src/gnumeric-canvas.c (gnm_canvas_class_init) : delete some unused
	  variables.

	* src/clipboard.c (clipboard_copy_obj) : tidy up a bit, and prepare to
	  clean out the odd GObject data usage.

	* src/sheet-control-gui.c (scg_object_coords_to_anchor) : set the
	  direction.

	* src/wbcg-actions.c (permanent_actions) : Make Save and Save-As
	  permanent so that the user can always save.

	* src/xml-sax-write.c (gnm_xml_file_save) : accept saving to unnamed
	  files.
parent 7602e336
2006-05-13 Jody Goldberg <jody@gnome.org>
* component/gnumeric.c : patch some warnings and make some comments.
* src/gnumeric-pane.c (display_object_menu) : Use the new
sheet_object_populate_menu and clarify that so and event can be
NULL.
(cb_pane_popup_menu) : if objects are selected use
display_object_menu.
* src/sheet-object.c (sheet_object_populate_menu) : new and public.
(sheet_object_populate_menu_real) : renamed from sheet_object_populate_menu
and make smarter to be able to handle so == NULL.
* src/gnumeric-canvas.c (gnm_canvas_class_init) : delete some unused
variables.
* src/clipboard.c (clipboard_copy_obj) : tidy up a bit, and prepare to
clean out the odd GObject data usage.
* src/sheet-control-gui.c (scg_object_coords_to_anchor) : set the
direction.
* src/wbcg-actions.c (permanent_actions) : Make Save and Save-As
permanent so that the user can always save.
* src/xml-sax-write.c (gnm_xml_file_save) : accept saving to unnamed
files.
2006-05-12 Jean Brefort <jean.brefort@normalesup.org>
* component/gnumeric.c: (go_gnm_component_print): implemented.
......
......@@ -2,6 +2,8 @@ Gnumeric 1.7.1
Jody:
* Fix ODF sheet name import ('aa''a' == aa'a).
* Don't lose the orientation of line objects when copying.
* Add context menu binding for selected objects. [#338616]
Morten:
* Moved font metrics to goffice.
......
......@@ -49,6 +49,7 @@
#include <workbook-control-gui-priv.h>
#include <workbook.h>
#include <sheet.h>
#include <print-cell.h>
#include <sheet-object.h>
#include <command-context.h>
#include <command-context-stderr.h>
......@@ -207,7 +208,6 @@ cell_render (cairo_t *cairo, GnmCell *cell)
cairo_set_source_rgb (cairo, UINT_RGBA_B(fore_color), UINT_RGBA_G(fore_color), UINT_RGBA_R(fore_color));
if (rv->rotation) {
RenderedRotatedValue *rrv = (RenderedRotatedValue *)rv;
PangoContext *context = pango_layout_get_context (rv->layout);
struct RenderedRotatedValueInfo const *li = rrv->lines;
GSList *lines;
cairo_matrix_t m;
......@@ -381,7 +381,7 @@ static void
go_gnm_component_set_property (GObject *obj, guint param_id,
GValue const *value, GParamSpec *pspec)
{
GOGnmComponent *gognm = GO_GNM_COMPONENT (obj);
/* GOGnmComponent *gognm = GO_GNM_COMPONENT (obj);*/
switch (param_id) {
case COMPONENT_PROP_START_ROW:
......@@ -403,7 +403,7 @@ static void
go_gnm_component_get_property (GObject *obj, guint param_id,
GValue *value, GParamSpec *pspec)
{
GOGnmComponent *gognm = GO_GNM_COMPONENT (obj);
/* GOGnmComponent *gognm = GO_GNM_COMPONENT (obj);*/
switch (param_id) {
case COMPONENT_PROP_START_ROW:
......@@ -464,6 +464,7 @@ go_gnm_component_class_init (GOComponentClass *klass)
klass->print = go_gnm_component_print;
klass->edit = go_gnm_component_edit;
/* Better to do this as a GnmRange */
g_object_class_install_property (obj_klass, COMPONENT_PROP_START_ROW,
g_param_spec_int ("gnm-start-row", _("Start row"),
_("First displayed row"),
......@@ -484,6 +485,8 @@ go_gnm_component_class_init (GOComponentClass *klass)
_("Last displayed column"),
0, SHEET_MAX_COLS - 1, 4,
G_PARAM_READWRITE | GOC_PARAM_PERSISTENT));
/* or even a GnmSheetRange */
g_object_class_install_property (obj_klass, COMPONENT_PROP_END_COL,
g_param_spec_int ("gnm-sheet", _("Sheet"),
_("Index of dislpayed sheet"),
......@@ -523,6 +526,7 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
if (env_var != NULL)
GO_SLIST_CONCAT (dir_list, go_strsplit_to_slist (env_var, G_SEARCHPATH_SEPARATOR));
/* WHERE IS THIS DEFINED */
go_plugins_add (go_component_get_command_context (),
gnm_app_prefs->plugin_file_states,
gnm_app_prefs->active_plugins,
......
......@@ -3265,7 +3265,7 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
static GnmRange const fixed_size = { { 1, 1 }, { 12, 32 } };
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor,
&fixed_size, NULL, NULL, SO_DIR_DOWN_RIGHT);
&fixed_size, NULL, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (sog, &anchor);
sheet_object_set_sheet (sog, full_page);
g_object_unref (sog);
......
......@@ -385,7 +385,7 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
GnmRange range;
ExcelReadSheet *esheet;
MSObjAttr *attr, *flip_h, *flip_v;
SheetObjectDirection direction;
GODrawingAnchorDir direction;
SheetObjectAnchor anchor;
SheetObject *so;
GogStyle *style;
......@@ -412,8 +412,8 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
flip_h = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_H);
flip_v = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_V);
direction =
((flip_h == NULL) ? SO_DIR_RIGHT : 0) |
((flip_v == NULL) ? SO_DIR_DOWN : 0);
((flip_h == NULL) ? GOD_ANCHOR_DIR_RIGHT : 0) |
((flip_v == NULL) ? GOD_ANCHOR_DIR_DOWN : 0);
sheet_object_anchor_init (&anchor, &range,
offsets, anchor_types, direction);
......
......@@ -3691,7 +3691,7 @@ excel_write_autofilter_objs (ExcelWriteSheet *esheet)
r.end.col = 1 + (r.start.col = filter->r.start.col + i);
sheet_object_anchor_init (&anchor, &r, offsets, anchor_types,
SO_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
if (bp->version >= MS_BIFF_V8) {
guint32 id = excel_write_start_drawing (esheet);
memcpy (buf, obj_v8, sizeof obj_v8);
......
......@@ -1571,7 +1571,7 @@ od_draw_frame (GsfXMLIn *xin, xmlChar const **attrs)
frame_offset[2] = (width/col->size_pts);
frame_offset[3] = (height/row->size_pts);
sheet_object_anchor_init (&state->cur_frame.anchor, &cell_base, frame_offset, NULL, SO_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&state->cur_frame.anchor, &cell_base, frame_offset, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
}
static void
......
......@@ -546,6 +546,8 @@ clipboard_copy_range (Sheet *sheet, GnmRange const *r)
GnmCellRegion *
clipboard_copy_obj (Sheet *sheet, GSList *objects)
{
SheetObjectAnchor tmp_anchor;
SheetObjectAnchor const *anchor;
GnmCellRegion *cr;
GnmRange *r;
GSList *ptr;
......@@ -557,24 +559,28 @@ clipboard_copy_obj (Sheet *sheet, GSList *objects)
g_return_val_if_fail (objects != NULL, NULL);
cr = cellregion_new (sheet);
for (ptr = objects ; ptr != NULL ; ptr = ptr->next) {
sheet_object_position_pts_get (SHEET_OBJECT (ptr->data),
coords);
w = fabs (coords[2] - coords[0]) + 1;
h = fabs (coords[3] - coords[1]) + 1.;
so = sheet_object_dup (ptr->data);
if (so != NULL) {
r = (GnmRange *) sheet_object_get_range (so);
range_translate (r,
-MIN (r->start.col, r->end.col),
-MIN (r->start.row, r->end.row));
for (ptr = objects ; ptr != NULL ; ptr = ptr->next)
if (NULL != (so = sheet_object_dup (ptr->data))) {
anchor = sheet_object_get_anchor (so);
/* FIXME : This is only used in gnm_sog_write_image What is it for ?? */
sheet_object_anchor_to_pts (anchor, sheet, coords);
w = fabs (coords[2] - coords[0]) + 1.5;
h = fabs (coords[3] - coords[1]) + 1.5;
g_object_set_data (G_OBJECT (so), "pt-width-at-copy",
GUINT_TO_POINTER (w));
GUINT_TO_POINTER (w));
g_object_set_data (G_OBJECT (so), "pt-height-at-copy",
GUINT_TO_POINTER (h));
GUINT_TO_POINTER (h));
sheet_object_anchor_cpy (&tmp_anchor, anchor);
r = &tmp_anchor.cell_bound;
range_translate (r,
-MIN (r->start.col, r->end.col),
-MIN (r->start.row, r->end.row));
sheet_object_set_anchor (so, &tmp_anchor);
cr->objects = g_slist_prepend (cr->objects, so);
}
}
return cr;
}
......
......@@ -287,7 +287,7 @@ sv_select_cur_inputs (SheetView *sv)
* When pasting a copy the destination can be a singleton, or an integer
* multiple of the size of the source. This is not tested here.
* Full undo support.
*/
**/
void
cmd_paste (WorkbookControl *wbc, GnmPasteTarget const *pt)
{
......
......@@ -586,7 +586,7 @@ gnm_so_filled_init (GObject *obj)
sof->markup = NULL;
sof->margin_pts.top = sof->margin_pts.bottom = 3;
sof->margin_pts.left = sof->margin_pts.right = 5;
SHEET_OBJECT (obj)->anchor.direction = SO_DIR_NONE_MASK;
SHEET_OBJECT (obj)->anchor.base.direction = GOD_ANCHOR_DIR_NONE_MASK;
}
GSF_CLASS (GnmSOFilled, gnm_so_filled,
......
......@@ -206,14 +206,14 @@ gnm_so_line_print (SheetObject const *so, GnomePrintContext *ctx,
if (style->color == 0 || style->width < 0 || style->pattern == 0)
return;
switch (so->anchor.direction) {
case SO_DIR_UP_RIGHT:
case SO_DIR_DOWN_RIGHT:
switch (so->anchor.base.direction) {
case GOD_ANCHOR_DIR_UP_RIGHT:
case GOD_ANCHOR_DIR_DOWN_RIGHT:
x1 = 0.;
x2 = width;
break;
case SO_DIR_UP_LEFT:
case SO_DIR_DOWN_LEFT:
case GOD_ANCHOR_DIR_UP_LEFT:
case GOD_ANCHOR_DIR_DOWN_LEFT:
x1 = width;
x2 = 0.;
break;
......@@ -222,14 +222,14 @@ gnm_so_line_print (SheetObject const *so, GnomePrintContext *ctx,
return;
}
switch (so->anchor.direction) {
case SO_DIR_UP_LEFT:
case SO_DIR_UP_RIGHT:
switch (so->anchor.base.direction) {
case GOD_ANCHOR_DIR_UP_LEFT:
case GOD_ANCHOR_DIR_UP_RIGHT:
y1 = -height;
y2 = 0.;
break;
case SO_DIR_DOWN_LEFT:
case SO_DIR_DOWN_RIGHT:
case GOD_ANCHOR_DIR_DOWN_LEFT:
case GOD_ANCHOR_DIR_DOWN_RIGHT:
y1 = 0.;
y2 = -height;
break;
......@@ -439,7 +439,7 @@ gnm_so_line_init (GObject *obj)
go_arrow_init (&sol->start_arrow, 0., 0., 0.);
go_arrow_init (&sol->end_arrow, 0., 0., 0.);
SHEET_OBJECT (obj)->anchor.direction = SO_DIR_NONE_MASK;
SHEET_OBJECT (obj)->anchor.base.direction = GOD_ANCHOR_DIR_NONE_MASK;
}
GSF_CLASS (GnmSOLine, gnm_so_line,
......
......@@ -611,14 +611,8 @@ gnm_canvas_finalize (GObject *object)
static void
gnm_canvas_class_init (GnmCanvasClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
FooCanvasClass *canvas_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
canvas_class = (FooCanvasClass *) klass;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
parent_klass = g_type_class_peek_parent (klass);
......
......@@ -43,6 +43,8 @@
#undef DEBUG_DND
static void cb_pane_popup_menu (GnmPane *pane);
/**
* For now, application/x-gnumeric is disabled. It handles neither
* images nor graphs correctly.
......@@ -147,33 +149,6 @@ gnm_pane_display_obj_size_tip (GnmPane *pane, SheetObject const *so)
g_free (msg);
}
static void
cb_pane_popup_menu (GnmPane *pane)
{
/* the popup-menu signal is a binding. the grid almost always has focus
* we need to cheat to find out if the user realllllly wants a col/row
* header menu */
gboolean is_col = FALSE;
gboolean is_row = FALSE;
GdkWindow *gdk_win = gdk_display_get_window_at_pointer (
gtk_widget_get_display (GTK_WIDGET (pane->gcanvas)),
NULL, NULL);
if (gdk_win != NULL) {
gpointer gtk_win_void = NULL;
GtkWindow *gtk_win = NULL;
gdk_window_get_user_data (gdk_win, &gtk_win_void);
gtk_win = gtk_win_void;
if (gtk_win != NULL) {
if (gtk_win == (GtkWindow *)pane->col.canvas)
is_col = TRUE;
else if (gtk_win == (GtkWindow *)pane->row.canvas)
is_row = TRUE;
}
}
scg_context_menu (pane->gcanvas->simple.scg, NULL, is_col, is_row);
}
static void
cb_ctrl_pts_free (GtkObject **ctrl_pts)
{
......@@ -852,6 +827,7 @@ cb_ptr_array_free (GPtrArray *actions)
g_ptr_array_free (actions, TRUE);
}
/* event and so can be NULL */
static void
display_object_menu (GnmPane *pane, SheetObject *so, GdkEvent *event)
{
......@@ -860,9 +836,11 @@ display_object_menu (GnmPane *pane, SheetObject *so, GdkEvent *event)
GtkWidget *menu;
unsigned i = 0;
if (NULL == g_hash_table_lookup (scg->selected_objects, so))
if (NULL != so &&
NULL == g_hash_table_lookup (scg->selected_objects, so))
scg_object_select (scg, so);
SHEET_OBJECT_CLASS (G_OBJECT_GET_CLASS(so))->populate_menu (so, actions);
sheet_object_populate_menu (so, actions);
if (actions->len == 0) {
g_ptr_array_free (actions, TRUE);
......@@ -878,6 +856,53 @@ display_object_menu (GnmPane *pane, SheetObject *so, GdkEvent *event)
gnumeric_popup_menu (GTK_MENU (menu), &event->button);
}
static void
cb_collect_selected_objs (SheetObject *so, double *coords, GSList **accum)
{
*accum = g_slist_prepend (*accum, so);
}
static void
cb_pane_popup_menu (GnmPane *pane)
{
SheetControlGUI *scg = pane->gcanvas->simple.scg;
/* ignore new_object, it is not visible, and should not create a
* context menu */
if (NULL != scg->selected_objects) {
GSList *accum = NULL;
g_hash_table_foreach (scg->selected_objects,
(GHFunc) cb_collect_selected_objs, &accum);
if (NULL != accum && NULL == accum->next)
display_object_menu (pane, accum->data, NULL);
g_slist_free (accum);
} else {
/* the popup-menu signal is a binding. the grid almost always
* has focus we need to cheat to find out if the user
* realllllly wants a col/row header menu */
gboolean is_col = FALSE;
gboolean is_row = FALSE;
GdkWindow *gdk_win = gdk_display_get_window_at_pointer (
gtk_widget_get_display (GTK_WIDGET (pane->gcanvas)),
NULL, NULL);
if (gdk_win != NULL) {
gpointer gtk_win_void = NULL;
GtkWindow *gtk_win = NULL;
gdk_window_get_user_data (gdk_win, &gtk_win_void);
gtk_win = gtk_win_void;
if (gtk_win != NULL) {
if (gtk_win == (GtkWindow *)pane->col.canvas)
is_col = TRUE;
else if (gtk_win == (GtkWindow *)pane->row.canvas)
is_row = TRUE;
}
}
scg_context_menu (scg, NULL, is_col, is_row);
}
}
static void
control_point_set_cursor (SheetControlGUI const *scg, FooCanvasItem *ctrl_pt)
{
......
......@@ -329,6 +329,14 @@ kill_popup_menu (GtkWidget *widget, GtkMenu *menu)
g_object_unref (G_OBJECT (menu));
}
/**
* gnumeric_popup_menu :
* @menu : #GtkMenu
* @event : #GdkEventButton optionally NULL
*
* Bring up a popup and if @event is non-NULL ensure that the popup is on the
* right screen.
**/
void
gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
{
......
......@@ -775,7 +775,7 @@ ig_obj_create_begin (ItemGrid *ig, GdkEventButton *event)
coords[0] = coords[2] = event->x;
coords[1] = coords[3] = event->y;
sheet_object_anchor_init (&anchor, NULL, NULL, NULL, SO_DIR_DOWN_RIGHT);
sheet_object_anchor_init (&anchor, NULL, NULL, NULL, GOD_ANCHOR_DIR_DOWN_RIGHT);
scg_object_coords_to_anchor (ig->scg, coords, &anchor);
sheet_object_set_anchor (so, &anchor);
sheet_object_set_sheet (so, sc_sheet (SHEET_CONTROL (ig->scg)));
......
......@@ -2307,12 +2307,14 @@ scg_object_coords_to_anchor (SheetControlGUI const *scg,
g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
g_return_if_fail (coords != NULL);
in_out->base.direction = GOD_ANCHOR_DIR_NONE_MASK;
if ((coords [0] > coords [2]) == (!scg->sheet_control.sheet->text_is_rtl)) {
tmp [0] = coords [2];
tmp [2] = coords [0];
} else {
tmp [0] = coords [0];
tmp [2] = coords [2];
in_out->base.direction = GOD_ANCHOR_DIR_RIGHT;
}
if (coords [1] > coords [3]) {
tmp [1] = coords [3];
......@@ -2320,6 +2322,7 @@ scg_object_coords_to_anchor (SheetControlGUI const *scg,
} else {
tmp [1] = coords [1];
tmp [3] = coords [3];
in_out->base.direction |= GOD_ANCHOR_DIR_DOWN;
}
foo_canvas_w2c (FOO_CANVAS (gcanvas), tmp [0], tmp [1],
......@@ -2355,7 +2358,7 @@ scg_object_anchor_to_coords (SheetControlGUI const *scg,
/* pane 0 always exists and the others are always use the same basis */
GnmCanvas *gcanvas = scg_pane ((SheetControlGUI *)scg, 0);
Sheet *sheet = ((SheetControl const *) scg)->sheet;
SheetObjectDirection direction;
GODrawingAnchorDir direction;
double pixels [4], scale;
GnmRange const *r;
......@@ -2379,15 +2382,15 @@ scg_object_anchor_to_coords (SheetControlGUI const *scg,
pixels [3] += cell_offset_calc_pixel (sheet, r->end.row,
FALSE, anchor->type [3], anchor->offset [3]);
direction = anchor->direction;
if (direction == SO_DIR_UNKNOWN)
direction = SO_DIR_DOWN_RIGHT;
direction = anchor->base.direction;
if (direction == GOD_ANCHOR_DIR_UNKNOWN)
direction = GOD_ANCHOR_DIR_DOWN_RIGHT;
scale = 1. / FOO_CANVAS (gcanvas)->pixels_per_unit;
coords [0] = pixels [direction & SO_DIR_H_MASK ? 0 : 2] * scale;
coords [1] = pixels [direction & SO_DIR_V_MASK ? 1 : 3] * scale;
coords [2] = pixels [direction & SO_DIR_H_MASK ? 2 : 0] * scale;
coords [3] = pixels [direction & SO_DIR_V_MASK ? 3 : 1] * scale;
coords [0] = pixels [direction & GOD_ANCHOR_DIR_H_MASK ? 0 : 2] * scale;
coords [1] = pixels [direction & GOD_ANCHOR_DIR_V_MASK ? 1 : 3] * scale;
coords [2] = pixels [direction & GOD_ANCHOR_DIR_H_MASK ? 2 : 0] * scale;
coords [3] = pixels [direction & GOD_ANCHOR_DIR_V_MASK ? 3 : 1] * scale;
if (sheet->text_is_rtl) {
double tmp = -coords [0];
coords [0] = -coords [2];
......@@ -3135,7 +3138,7 @@ scg_paste_image (SheetControlGUI *scg, GnmRange *where,
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor, where, NULL, NULL,
SO_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
scg_image_create (scg, &anchor, data, len);
}
......@@ -3147,7 +3150,7 @@ scg_drag_receive_img_data (SheetControlGUI *scg, double x, double y,
double coords[4];
sheet_object_anchor_init (&anchor, NULL, NULL, NULL,
SO_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
coords[0] = coords[2] = x;
coords[1] = coords[3] = y;
scg_object_coords_to_anchor (scg, coords, &anchor);
......@@ -3216,7 +3219,7 @@ scg_paste_cellregion (SheetControlGUI *scg, double x, double y,
double coords[4];
sheet_object_anchor_init (&anchor, NULL, NULL, NULL,
SO_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
coords[0] = coords[2] = x;
coords[1] = coords[3] = y;
scg_object_coords_to_anchor (scg, coords, &anchor);
......
......@@ -1002,7 +1002,7 @@ gnm_filter_add_field (GnmFilter *filter, int i)
tmp.start.row = tmp.end.row = filter->r.start.row;
tmp.start.col = tmp.end.col = filter->r.start.col + i;
sheet_object_anchor_init (&anchor, &tmp, offsets, anchor_types,
SO_DIR_DOWN_RIGHT);
GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (&field->parent, &anchor);
sheet_object_set_sheet (&field->parent, filter->sheet);
......
......@@ -397,7 +397,7 @@ cell_comment_set_cell (GnmComment *cc, GnmCellPos const *pos)
r.start = r.end = *pos;
sheet_object_anchor_init (&anchor, &r, NULL,
anchor_types, SO_DIR_DOWN_RIGHT);
anchor_types, GOD_ANCHOR_DIR_DOWN_RIGHT);
sheet_object_set_anchor (SHEET_OBJECT (cc), &anchor);
}
......
......@@ -527,7 +527,7 @@ static void
gnm_sog_init (GObject *obj)
{
SheetObject *so = SHEET_OBJECT (obj);
so->anchor.direction = SO_DIR_DOWN_RIGHT;
so->anchor.base.direction = GOD_ANCHOR_DIR_DOWN_RIGHT;
}
static void
......
......@@ -682,7 +682,7 @@ gnm_soi_init (GObject *obj)
= 0.0;
so = SHEET_OBJECT (obj);
so->anchor.direction = SO_DIR_DOWN_RIGHT;
so->anchor.base.direction = GOD_ANCHOR_DIR_DOWN_RIGHT;
}
static void
......
......@@ -104,7 +104,7 @@ cb_so_copy (SheetObject *so, SheetControl *sc)
}
static void
sheet_object_populate_menu (SheetObject *so, GPtrArray *actions)
sheet_object_populate_menu_real (SheetObject *so, GPtrArray *actions)
{
static SheetObjectAction const so_actions [] = {
{ "gtk-properties", NULL, NULL, 0, sheet_object_get_editor },
......@@ -126,6 +126,23 @@ sheet_object_populate_menu (SheetObject *so, GPtrArray *actions)
g_ptr_array_add (actions, (gpointer) (so_actions + i));
}
/**
* sheet_object_populate_menu :
* @so : #SheetObject optionally NULL
* @actions : #GPtrArray
*
* Get a list of the actions that can be performed on @so, if @so is NULL use
* the default set.
**/
void
sheet_object_populate_menu (SheetObject *so, GPtrArray *actions)
{
if (NULL != so)
SHEET_OBJECT_CLASS (G_OBJECT_GET_CLASS(so))->populate_menu (so, actions);
else
sheet_object_populate_menu (NULL, actions);
}
/**
* sheet_objects_max_extent :
* @sheet :
......@@ -176,7 +193,7 @@ sheet_object_init (GObject *object)
/* Store the logical position as A1 */
so->anchor.cell_bound.start.col = so->anchor.cell_bound.start.row = 0;
so->anchor.cell_bound.end.col = so->anchor.cell_bound.end.row = 1;
so->anchor.direction = SO_DIR_UNKNOWN;
so->anchor.base.direction = GOD_ANCHOR_DIR_UNKNOWN;
for (i = 4; i-- > 0 ;) {
so->anchor.offset [i] = 0.;
......@@ -199,7 +216,7 @@ sheet_object_class_init (GObjectClass *klass)
parent_klass = g_type_class_peek_parent (klass);
klass->finalize = sheet_object_finalize;
sheet_object_class->populate_menu = sheet_object_populate_menu;
sheet_object_class->populate_menu = sheet_object_populate_menu_real;
sheet_object_class->print = NULL;
sheet_object_class->user_config = NULL;
sheet_object_class->rubber_band_directly = FALSE;
......@@ -886,16 +903,15 @@ sheet_object_clone_sheet (Sheet const *src, Sheet *dst, GnmRange *range)
void
sheet_object_direction_set (SheetObject *so, gdouble const *coords)
{
if (so->anchor.direction == SO_DIR_UNKNOWN)
if (so->anchor.base.direction == GOD_ANCHOR_DIR_UNKNOWN)
return;
so->anchor.direction = SO_DIR_NONE_MASK;
so->anchor.base.direction = GOD_ANCHOR_DIR_NONE_MASK;
if (coords [1] < coords [3])
so->anchor.direction |= SO_DIR_DOWN;
so->anchor.base.direction |= GOD_ANCHOR_DIR_DOWN;
if (coords [0] < coords [2])
so->anchor.direction |= SO_DIR_RIGHT;
so->anchor.base.direction |= GOD_ANCHOR_DIR_RIGHT;
}
/**
......@@ -923,7 +939,7 @@ void
sheet_object_anchor_init (SheetObjectAnchor *anchor,
GnmRange const *r, float const *offsets,
SheetObjectAnchorType const *types,
SheetObjectDirection direction)
GODrawingAnchorDir direction)
{
int i;
......@@ -952,7 +968,7 @@ sheet_object_anchor_init (SheetObjectAnchor *anchor,
for (i = 4; i-- > 0 ; )
anchor->type [i] = types [i];
anchor->direction = direction;
anchor->base.direction = direction;
/* TODO : add sanity checking to handle offsets past edges of col/row */
}
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef GNUMERIC_SHEET_OBJECT_H
#define GNUMERIC_SHEET_OBJECT_H
......@@ -7,6 +7,28 @@
#include <libgnomeprint/gnome-print.h>
#include <gsf/gsf-output.h>
/***********************************************************
* Move to goffice during 1.7 */
typedef enum {
GOD_ANCHOR_DIR_UNKNOWN = 0xFF,
GOD_ANCHOR_DIR_UP_LEFT = 0x00,
GOD_ANCHOR_DIR_UP_RIGHT = 0x01,
GOD_ANCHOR_DIR_DOWN_LEFT = 0x10,
GOD_ANCHOR_DIR_DOWN_RIGHT = 0x11,
GOD_ANCHOR_DIR_NONE_MASK = 0x00,
GOD_ANCHOR_DIR_H_MASK = 0x01,
GOD_ANCHOR_DIR_RIGHT = 0x01,
GOD_ANCHOR_DIR_V_MASK = 0x10,
GOD_ANCHOR_DIR_DOWN = 0x10
} GODrawingAnchorDir;
typedef struct _GODrawingAnchor {
int pos_pts [4]; /* position in points */
GODrawingAnchorDir direction;
} GODrawingAnchor;
/***********************************************************/
typedef enum {
SO_ANCHOR_UNKNOWN = 0x00,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START = 0x10,
......@@ -19,26 +41,12 @@ typedef enum {
/* only allowed for Anchors 2-3 to support fixed size */
SO_ANCHOR_PTS_ABSOLUTE = 0x30
} SheetObjectAnchorType;
typedef enum {
SO_DIR_UNKNOWN = 0xFF,
SO_DIR_UP_LEFT = 0x00,
SO_DIR_UP_RIGHT = 0x01,
SO_DIR_DOWN_LEFT = 0x10,
SO_DIR_DOWN_RIGHT = 0x11,
SO_DIR_NONE_MASK = 0x00,
SO_DIR_H_MASK = 0x01,
SO_DIR_RIGHT = 0x01,
SO_DIR_V_MASK = 0x10,
SO_DIR_DOWN = 0x10
} SheetObjectDirection;
struct _SheetObjectAnchor {
GnmRange cell_bound; /* cellpos containg corners */
float offset [4];
SheetObjectAnchorType type [4];
SheetObjectDirection direction;
GODrawingAnchor base;
GnmRange cell_bound; /* cellpos containg corners */
float offset [4];
SheetObjectAnchorType type [4];
};
#define SHEET_OBJECT_TYPE (sheet_object_get_type ())
......@@ -68,6 +76,8 @@ void sheet_object_print (SheetObject const *so,
GnomePrintContext *ctx,
double width, double height);
void sheet_object_get_editor (SheetObject *so, SheetControl *sc);
void sheet_object_populate_menu (SheetObject *so, GPtrArray *actions);
void sheet_object_update_bounds (SheetObject *so, GnmCellPos const *p);
void sheet_object_default_size (SheetObject *so, double *w, double *h);
gint sheet_object_adjust_stacking(SheetObject *so, gint positions);
......@@ -100,7 +110,7 @@ void sheet_object_anchor_init (SheetObjectAnchor *anchor,
GnmRange const *cell_bound,
float const offset [4],
SheetObjectAnchorType const type [4],
SheetObjectDirection direction);
GODrawingAnchorDir direction);
void sheet_object_anchor_cpy (SheetObjectAnchor *dst,
SheetObjectAnchor const *src);
......
......@@ -1517,6 +1517,12 @@ static GtkActionEntry const permanent_actions[] = {
{ "MenuExternalData", NULL, N_("Get _External Data") },
{ "MenuHelp", NULL, N_("_Help") },
{ "FileSave", GTK_STOCK_SAVE, NULL,
NULL, N_("Save the current workbook"),
G_CALLBACK (cb_file_save) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, NULL,