Commit d4b9115d authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Remove ants when we change the font. (set_selection_halign): And when we

1999-10-06  Miguel de Icaza  <miguel@gnu.org>

	* src/workbook-format-toolbar.c (change_selection_font): Remove
	ants when we change the font.
	(set_selection_halign): And when we change the alignment.

	Many more left to be removed.  Left as an excercise to Jody :-)

	* src/sheet.c (sheet_start_editing_at_cursor): remove ants when we
	start entering new text.

	* src/sheet-view.c (sheet_view_selection_unant): Destroys the
	anted cursors from the sheet view.
	(sheet_view_selection_ant): Adds cursors to the sheetview.
	(sheet_view_construct): New group that is used to hold the
	selection-ant items.

	* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Kill ants
	on escape.
	(gnumeric_sheet_key_mode_object): ditto.

	* src/selection.c (sheet_selection_unant): New function, kills the
	selection ants.
	(sheet_selection_ant): New function, adds an anted selection to
	all the selected regions.

	* src/clipboard.c (do_clipboard_paste_cell_region): Do not paste
	beyond sheet boundaries.

	* src/item-grid.c (item_grid_find_row): Do not go beyond sheet boundaries.
	(item_grid_find_col): ditto.

	* configure.in: Generate gnumeric.desktop

	* gnumeric.desktop.in: New file, used to choose the correct
	gnumeric/gnumeric-bonobo executable name.

	* src/sheet-object-item.c: Updated to fit with the new Bonobo
	changes.

1999-10-06  Jody Goldberg <jgoldberg@home.com>
parent a1f4d0f8
1999-10-06 Miguel de Icaza <miguel@gnu.org>
* src/workbook-format-toolbar.c (change_selection_font): Remove
ants when we change the font.
(set_selection_halign): And when we change the alignment.
Many more left to be removed. Left as an excercise to Jody :-)
* src/sheet.c (sheet_start_editing_at_cursor): remove ants when we
start entering new text.
* src/sheet-view.c (sheet_view_selection_unant): Destroys the
anted cursors from the sheet view.
(sheet_view_selection_ant): Adds cursors to the sheetview.
(sheet_view_construct): New group that is used to hold the
selection-ant items.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Kill ants
on escape.
(gnumeric_sheet_key_mode_object): ditto.
* src/selection.c (sheet_selection_unant): New function, kills the
selection ants.
(sheet_selection_ant): New function, adds an anted selection to
all the selected regions.
* src/clipboard.c (do_clipboard_paste_cell_region): Do not paste
beyond sheet boundaries.
* src/item-grid.c (item_grid_find_row): Do not go beyond sheet boundaries.
(item_grid_find_col): ditto.
* configure.in: Generate gnumeric.desktop
* gnumeric.desktop.in: New file, used to choose the correct
......
1999-10-06 Miguel de Icaza <miguel@gnu.org>
* src/workbook-format-toolbar.c (change_selection_font): Remove
ants when we change the font.
(set_selection_halign): And when we change the alignment.
Many more left to be removed. Left as an excercise to Jody :-)
* src/sheet.c (sheet_start_editing_at_cursor): remove ants when we
start entering new text.
* src/sheet-view.c (sheet_view_selection_unant): Destroys the
anted cursors from the sheet view.
(sheet_view_selection_ant): Adds cursors to the sheetview.
(sheet_view_construct): New group that is used to hold the
selection-ant items.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Kill ants
on escape.
(gnumeric_sheet_key_mode_object): ditto.
* src/selection.c (sheet_selection_unant): New function, kills the
selection ants.
(sheet_selection_ant): New function, adds an anted selection to
all the selected regions.
* src/clipboard.c (do_clipboard_paste_cell_region): Do not paste
beyond sheet boundaries.
* src/item-grid.c (item_grid_find_row): Do not go beyond sheet boundaries.
(item_grid_find_col): ditto.
* configure.in: Generate gnumeric.desktop
* gnumeric.desktop.in: New file, used to choose the correct
......
......@@ -46,6 +46,9 @@ paste_cell (Sheet *dest_sheet, Cell *new_cell,
int target_col, int target_row,
int paste_flags)
{
g_return_val_if_fail (target_col < SHEET_MAX_COLS, 0);
g_return_val_if_fail (target_row < SHEET_MAX_ROWS, 0);
sheet_cell_add (dest_sheet, new_cell, target_col, target_row);
if (!(paste_flags & PASTE_FORMULAS)){
......@@ -291,6 +294,11 @@ sheet_paste_selection (Sheet *sheet, CellRegion *content, SheetSelection *ss, cl
else
paste_height = content->rows;
if (pc->dest_col + paste_width > SHEET_MAX_COLS)
paste_width = SHEET_MAX_COLS - pc->dest_col;
if (pc->dest_row + paste_height > SHEET_MAX_ROWS)
paste_height = SHEET_MAX_ROWS - pc->dest_row;
if (pc->paste_flags & PASTE_TRANSPOSE){
int t;
......@@ -305,14 +313,14 @@ sheet_paste_selection (Sheet *sheet, CellRegion *content, SheetSelection *ss, cl
end_col = pc->dest_col + paste_width - 1;
end_row = pc->dest_row + paste_height - 1;
}
/* Do the actual paste operation */
do_clipboard_paste_cell_region (
content, sheet,
pc->dest_col, pc->dest_row,
paste_width, paste_height,
pc->paste_flags);
sheet_cursor_set (pc->dest_sheet,
pc->dest_col, pc->dest_row,
pc->dest_col, pc->dest_row,
......
......@@ -187,7 +187,7 @@ gnumeric_sheet_set_cursor_bounds (GnumericSheet *gsheet,
* move_cursor_horizontal:
* @Sheet: The sheet name
* @count: number of units to move the cursor horizontally
* @jump_to_boundaries : skip from the start to the end of ranges
* @jump_to_boundaries: skip from the start to the end of ranges
* of filled or unfilled cells.
*
* Moves the cursor count columns
......@@ -214,7 +214,7 @@ move_horizontal_selection (GnumericSheet *gsheet, int count, gboolean jump_to_bo
* move_cursor_vertical:
* @Sheet: The sheet name
* @count: number of units to move the cursor vertically
* @jump_to_boundaries : skip from the start to the end of ranges
* @jump_to_boundaries: skip from the start to the end of ranges
* of filled or unfilled cells.
*
* Moves the cursor count rows
......@@ -807,9 +807,11 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Escape:
sheet_cancel_pending_input (sheet);
sheet_selection_unant (sheet);
break;
case GDK_F2:
sheet_selection_unant (sheet);
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
sheet_start_editing_at_cursor (sheet, FALSE, FALSE);
/* fall down */
......@@ -840,6 +842,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
sheet_selection_unant (sheet);
break;
case GDK_BackSpace:
......
......@@ -187,7 +187,7 @@ gnumeric_sheet_set_cursor_bounds (GnumericSheet *gsheet,
* move_cursor_horizontal:
* @Sheet: The sheet name
* @count: number of units to move the cursor horizontally
* @jump_to_boundaries : skip from the start to the end of ranges
* @jump_to_boundaries: skip from the start to the end of ranges
* of filled or unfilled cells.
*
* Moves the cursor count columns
......@@ -214,7 +214,7 @@ move_horizontal_selection (GnumericSheet *gsheet, int count, gboolean jump_to_bo
* move_cursor_vertical:
* @Sheet: The sheet name
* @count: number of units to move the cursor vertically
* @jump_to_boundaries : skip from the start to the end of ranges
* @jump_to_boundaries: skip from the start to the end of ranges
* of filled or unfilled cells.
*
* Moves the cursor count rows
......@@ -807,9 +807,11 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Escape:
sheet_cancel_pending_input (sheet);
sheet_selection_unant (sheet);
break;
case GDK_F2:
sheet_selection_unant (sheet);
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
sheet_start_editing_at_cursor (sheet, FALSE, FALSE);
/* fall down */
......@@ -840,6 +842,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
sheet_selection_unant (sheet);
break;
case GDK_BackSpace:
......
......@@ -184,7 +184,7 @@ item_grid_find_col (ItemGrid *item_grid, int x, int *col_origin)
}
col++;
pixel += ci->pixels;
} while (1);
} while (col < SHEET_MAX_COLS);
}
/*
......@@ -213,7 +213,7 @@ item_grid_find_row (ItemGrid *item_grid, int y, int *row_origin)
}
row++;
pixel += ri->pixels;
} while (1);
} while (row < SHEET_MAX_ROWS);
}
/*
......
......@@ -552,6 +552,36 @@ sheet_selection_to_string (Sheet *sheet, gboolean include_sheet_name_prefix)
return result;
}
void
sheet_selection_ant (Sheet *sheet)
{
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
sheet_view_selection_ant (sheet_view);
}
}
void
sheet_selection_unant (Sheet *sheet)
{
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
sheet_view_selection_unant (sheet_view);
}
}
gboolean
sheet_selection_copy (Sheet *sheet)
{
......@@ -563,6 +593,8 @@ sheet_selection_copy (Sheet *sheet)
if (!selection_is_simple (sheet, _("copy")))
return FALSE;
sheet_selection_ant (sheet);
ss = sheet->selections->data;
if (sheet->workbook->clipboard_contents)
......@@ -598,6 +630,8 @@ sheet_selection_cut (Sheet *sheet)
if (!selection_is_simple (sheet, _("cut")))
return FALSE;
sheet_selection_ant (sheet);
ss = sheet->selections->data;
if (sheet->workbook->clipboard_contents)
......
......@@ -44,7 +44,10 @@ int sheet_selection_is_cell_selected (Sheet *sheet, int col, int row);
gboolean selection_contains_colrow (Sheet *sheet, int colrow, gboolean is_col);
/****************************************************************************/
/* User visible actions */
void sheet_selection_ant (Sheet *sheet);
void sheet_selection_unant (Sheet *sheet);
/* Utilities for operating on a selection */
typedef void (*SelectionApplyFunc) (Sheet *sheet,
int start_col, int start_row,
......
......@@ -527,6 +527,17 @@ sheet_view_construct (SheetView *sheet_view)
0, 0);
gtk_widget_show (sheet_view->sheet_view);
/*
* The selection group
*/
sheet_view->selection_group = GNOME_CANVAS_GROUP (
gnome_canvas_item_new (
root_group,
gnome_canvas_group_get_type (),
"x", 0.0,
"y", 0.0,
NULL));
/* The select-all button */
select_all = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (select_all, GTK_CAN_FOCUS);
......@@ -761,6 +772,60 @@ sheet_view_comment_relocate (SheetView *sheet_view, int col, int row, GnomeCanva
gnome_canvas_item_set (o, "points", points, NULL);
}
void
sheet_view_selection_unant (SheetView *sheet_view)
{
GList *l;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (IS_SHEET_VIEW (sheet_view));
if (sheet_view->anted_cursors == NULL)
return;
for (l = sheet_view->anted_cursors; l; l = l->next)
gtk_object_destroy (GTK_OBJECT (l->data));
g_list_free (sheet_view->anted_cursors);
sheet_view->anted_cursors = NULL;
}
void
sheet_view_selection_ant (SheetView *sheet_view)
{
GnomeCanvasGroup *group;
ItemGrid *grid;
GList *l;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (IS_SHEET_VIEW (sheet_view));
if (sheet_view->anted_cursors)
sheet_view_selection_unant (sheet_view);
group = sheet_view->selection_group;
grid = GNUMERIC_SHEET (sheet_view->sheet_view)->item_grid;
for (l = sheet_view->sheet->selections; l; l = l->next){
SheetSelection *ss = l->data;
ItemCursor *item_cursor;
item_cursor = ITEM_CURSOR (gnome_canvas_item_new (
group, item_cursor_get_type (),
"Sheet", sheet_view->sheet,
"Grid", grid,
"Style", ITEM_CURSOR_ANTED,
NULL));
item_cursor_set_bounds (
item_cursor,
ss->user.start.col, ss->user.start.row,
ss->user.end.col, ss->user.end.row);
sheet_view->anted_cursors = g_list_prepend (sheet_view->anted_cursors, item_cursor);
}
}
#if 0
#ifdef ENABLE_BONOBO
void
......
......@@ -24,6 +24,9 @@ struct _SheetView {
/* Object group */
GnomeCanvasGroup *object_group;
/* Selection group */
GnomeCanvasGroup *selection_group;
/*
* Font mappings
*/
......@@ -46,6 +49,9 @@ struct _SheetView {
/* Tip for scrolling */
GtkWidget *tip;
/* Anted cursor */
GList *anted_cursors;
};
GtkType sheet_view_get_type (void);
......@@ -75,6 +81,9 @@ void sheet_view_set_header_visibility (SheetView *sheet_view,
void sheet_view_scrollbar_config (SheetView const *sheet_view);
void sheet_view_selection_ant (SheetView *sheet_view);
void sheet_view_selection_unant (SheetView *sheet_view);
typedef struct {
GtkTableClass parent_class;
} SheetViewClass;
......
......@@ -527,6 +527,17 @@ sheet_view_construct (SheetView *sheet_view)
0, 0);
gtk_widget_show (sheet_view->sheet_view);
/*
* The selection group
*/
sheet_view->selection_group = GNOME_CANVAS_GROUP (
gnome_canvas_item_new (
root_group,
gnome_canvas_group_get_type (),
"x", 0.0,
"y", 0.0,
NULL));
/* The select-all button */
select_all = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (select_all, GTK_CAN_FOCUS);
......@@ -761,6 +772,60 @@ sheet_view_comment_relocate (SheetView *sheet_view, int col, int row, GnomeCanva
gnome_canvas_item_set (o, "points", points, NULL);
}
void
sheet_view_selection_unant (SheetView *sheet_view)
{
GList *l;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (IS_SHEET_VIEW (sheet_view));
if (sheet_view->anted_cursors == NULL)
return;
for (l = sheet_view->anted_cursors; l; l = l->next)
gtk_object_destroy (GTK_OBJECT (l->data));
g_list_free (sheet_view->anted_cursors);
sheet_view->anted_cursors = NULL;
}
void
sheet_view_selection_ant (SheetView *sheet_view)
{
GnomeCanvasGroup *group;
ItemGrid *grid;
GList *l;
g_return_if_fail (sheet_view != NULL);
g_return_if_fail (IS_SHEET_VIEW (sheet_view));
if (sheet_view->anted_cursors)
sheet_view_selection_unant (sheet_view);
group = sheet_view->selection_group;
grid = GNUMERIC_SHEET (sheet_view->sheet_view)->item_grid;
for (l = sheet_view->sheet->selections; l; l = l->next){
SheetSelection *ss = l->data;
ItemCursor *item_cursor;
item_cursor = ITEM_CURSOR (gnome_canvas_item_new (
group, item_cursor_get_type (),
"Sheet", sheet_view->sheet,
"Grid", grid,
"Style", ITEM_CURSOR_ANTED,
NULL));
item_cursor_set_bounds (
item_cursor,
ss->user.start.col, ss->user.start.row,
ss->user.end.col, ss->user.end.row);
sheet_view->anted_cursors = g_list_prepend (sheet_view->anted_cursors, item_cursor);
}
}
#if 0
#ifdef ENABLE_BONOBO
void
......
......@@ -24,6 +24,9 @@ struct _SheetView {
/* Object group */
GnomeCanvasGroup *object_group;
/* Selection group */
GnomeCanvasGroup *selection_group;
/*
* Font mappings
*/
......@@ -46,6 +49,9 @@ struct _SheetView {
/* Tip for scrolling */
GtkWidget *tip;
/* Anted cursor */
GList *anted_cursors;
};
GtkType sheet_view_get_type (void);
......@@ -75,6 +81,9 @@ void sheet_view_set_header_visibility (SheetView *sheet_view,
void sheet_view_scrollbar_config (SheetView const *sheet_view);
void sheet_view_selection_ant (SheetView *sheet_view);
void sheet_view_selection_unant (SheetView *sheet_view);
typedef struct {
GtkTableClass parent_class;
} SheetViewClass;
......
......@@ -1221,6 +1221,8 @@ sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_selection_unant (sheet);
if (blankp)
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), "");
......
......@@ -41,6 +41,9 @@ set_selection_halign (Workbook *wb, StyleHAlignFlags align)
GList *cells, *l;
sheet = workbook_get_current_sheet (wb);
sheet_selection_unant (sheet);
/*
* TODO : switch to selection_apply, but for now we don't care about
* intersection
......@@ -88,6 +91,8 @@ change_selection_font (Workbook *wb, int bold, int italic)
GList *cells, *l;
sheet = workbook_get_current_sheet (wb);
sheet_selection_unant (sheet);
/*
* TODO : switch to selection_apply, but for now we don't care about
* intersection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment