Commit 2f042ff1 authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Implement zoom undo/redo (cmd_zoom_destroy) : Idem. (cmd_zoom_redo): Idem.

2001-04-29  Almer S. Tigelaar  <almer@gnome.org>

	* src/commands.c (cmd_zoom) : Implement zoom undo/redo
	(cmd_zoom_destroy) : Idem.
	(cmd_zoom_redo): Idem.
	(cmd_zoom_undo): Idem.

	* src/workbook-control-gui.c (cb_change_zoom):
	Use cmd_zoom here.
parent 5655e1bd
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_zoom) : Implement zoom undo/redo
(cmd_zoom_destroy) : Idem.
(cmd_zoom_redo): Idem.
(cmd_zoom_undo): Idem.
* src/workbook-control-gui.c (cb_change_zoom):
Use cmd_zoom here.
2001-04-28 Jody Goldberg <jgoldberg@home.com>
* src/style-border.c (print_hline) : handle offset of screen coords vs
......
Gnumeric 0.65
Almer:
* Fix a variety of bugs
* Improve parser error messages
* Fix a variety of bugs.
* Improve parser error messages.
* Implement Undo/Redo for Zoom.
Chema:
* GNUMERIC_ENABLE_XL_OVERWRITE
......
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_zoom) : Implement zoom undo/redo
(cmd_zoom_destroy) : Idem.
(cmd_zoom_redo): Idem.
(cmd_zoom_undo): Idem.
* src/workbook-control-gui.c (cb_change_zoom):
Use cmd_zoom here.
2001-04-28 Jody Goldberg <jgoldberg@home.com>
* src/style-border.c (print_hline) : handle offset of screen coords vs
......
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_zoom) : Implement zoom undo/redo
(cmd_zoom_destroy) : Idem.
(cmd_zoom_redo): Idem.
(cmd_zoom_undo): Idem.
* src/workbook-control-gui.c (cb_change_zoom):
Use cmd_zoom here.
2001-04-28 Jody Goldberg <jgoldberg@home.com>
* src/style-border.c (print_hline) : handle offset of screen coords vs
......
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_zoom) : Implement zoom undo/redo
(cmd_zoom_destroy) : Idem.
(cmd_zoom_redo): Idem.
(cmd_zoom_undo): Idem.
* src/workbook-control-gui.c (cb_change_zoom):
Use cmd_zoom here.
2001-04-28 Jody Goldberg <jgoldberg@home.com>
* src/style-border.c (print_hline) : handle offset of screen coords vs
......
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* src/commands.c (cmd_zoom) : Implement zoom undo/redo
(cmd_zoom_destroy) : Idem.
(cmd_zoom_redo): Idem.
(cmd_zoom_undo): Idem.
* src/workbook-control-gui.c (cb_change_zoom):
Use cmd_zoom here.
2001-04-28 Jody Goldberg <jgoldberg@home.com>
* src/style-border.c (print_hline) : handle offset of screen coords vs
......
......@@ -3443,7 +3443,122 @@ cmd_colrow_std_size (WorkbookControl *wbc, Sheet *sheet,
/******************************************************************/
#define CMD_ZOOM_TYPE (cmd_zoom_get_type ())
#define CMD_ZOOM(o) (GTK_CHECK_CAST ((o), CMD_ZOOM_TYPE, CmdZoom))
typedef struct
{
GnumericCommand parent;
GSList *sheets;
double new_factor;
double *old_factors;
} CmdZoom;
GNUMERIC_MAKE_COMMAND (CmdZoom, cmd_zoom);
static gboolean
cmd_zoom_undo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdZoom *me = CMD_ZOOM (cmd);
GSList *l;
int i;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->sheets != NULL, TRUE);
g_return_val_if_fail (me->old_factors != NULL, TRUE);
for (i = 0, l = me->sheets; l != NULL; l = l->next, i++) {
Sheet *sheet = l->data;
sheet_set_zoom_factor (sheet, me->old_factors[i], FALSE, TRUE);
}
return FALSE;
}
static gboolean
cmd_zoom_redo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdZoom *me = CMD_ZOOM (cmd);
GSList *l;
g_return_val_if_fail (me != NULL, TRUE);
g_return_val_if_fail (me->sheets != NULL, TRUE);
for (l = me->sheets; l != NULL; l = l->next) {
Sheet *sheet = l->data;
sheet_set_zoom_factor (sheet, me->new_factor, FALSE, TRUE);
}
return FALSE;
}
static void
cmd_zoom_destroy (GtkObject *cmd)
{
CmdZoom *me = CMD_ZOOM (cmd);
if (me->sheets)
g_slist_free (me->sheets);
if (me->old_factors)
g_free (me->old_factors);
gnumeric_command_destroy (cmd);
}
gboolean
cmd_zoom (WorkbookControl *wbc, GSList *sheets, double factor)
{
GtkObject *obj;
CmdZoom *me;
GString *namelist;
GSList *l;
int i;
g_return_val_if_fail (wbc != NULL, TRUE);
g_return_val_if_fail (sheets != NULL, TRUE);
obj = gtk_type_new (CMD_ZOOM_TYPE);
me = CMD_ZOOM (obj);
/* Store the specs for the object */
me->sheets = sheets;
me->old_factors = g_new0 (double, g_slist_length (sheets));
me->new_factor = factor;
/* Make a list of all sheets to zoom and save zoom factor for each */
namelist = g_string_new ("");
for (i = 0, l = me->sheets; l != NULL; l = l->next, i++) {
Sheet *sheet = l->data;
namelist = g_string_append (namelist, sheet->name_unquoted);
me->old_factors[i] = sheet->last_zoom_factor_used;
if (l->next)
namelist = g_string_append (namelist, ", ");
}
/* Make sure the string doesn't get overly wide */
if (strlen (namelist->str) > MAX_DESCRIPTOR_WIDTH) {
g_string_truncate (namelist, MAX_DESCRIPTOR_WIDTH - 3);
g_string_append (namelist, "...");
}
me->parent.sheet = NULL;
me->parent.size = 1;
me->parent.cmd_descriptor =
g_strdup_printf (_("Zoom %s to %.0f%%"), namelist->str, factor * 100);
g_string_free (namelist, TRUE);
/* Register the command object */
return command_push_undo (wbc, obj);
}
/******************************************************************/
/* TODO :
* - SheetObject creation & manipulation.
* - Zoom
*/
......@@ -71,5 +71,7 @@ gboolean cmd_search_replace (WorkbookControl *wbc, Sheet *sheet, SearchRepla
gboolean cmd_colrow_std_size (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, double new_default);
gboolean cmd_zoom (WorkbookControl *wbc, GSList *sheets, double factor);
#endif /* GNUMERIC_COMMANDS_H */
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* dialog-zoom.c (dialog_zoom_impl): Use cmd_zoom.
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* dialog-goal-seek.c (goal_seek_eval) : Merge in some of boc's
......
......@@ -10,6 +10,7 @@
#include <glade/glade.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "commands.h"
#include "dialogs.h"
#include "workbook-control.h"
#include "workbook.h"
......@@ -143,10 +144,17 @@ dialog_zoom_impl (WorkbookControlGUI *wbcg, Sheet *cur_sheet, GladeXML *gui)
res = gnumeric_dialog_run (wbcg, GNOME_DIALOG (dialog));
if (res == 0) {
float const new_zoom = gtk_spin_button_get_value_as_int(zoom) / 100.;
GSList *sheets = NULL;
for (l = list->selection; l != NULL ; l = l->next) {
Sheet * s = gtk_clist_get_row_data (list, GPOINTER_TO_INT(l->data));
sheet_set_zoom_factor (s, new_zoom, FALSE, TRUE);
sheets = g_slist_prepend (sheets, s);
}
sheets = g_slist_reverse (sheets);
/* The GSList of sheet passed will be freed by cmd_zoom */
cmd_zoom (WORKBOOK_CONTROL (wbcg), sheets, new_zoom);
}
/* If the user closed the dialog with prejudice, its already destroyed */
......
......@@ -647,8 +647,9 @@ cb_change_zoom (GtkWidget *caller, WorkbookControlGUI *wbcg)
if (sheet == NULL || wbcg->updating_ui)
return;
/* The GSList of sheet passed to cmd_zoom will be freed by cmd_zoom */
factor = atoi (gtk_entry_get_text (GTK_ENTRY (caller)));
sheet_set_zoom_factor (sheet, (double) factor / 100, FALSE, TRUE);
cmd_zoom (WORKBOOK_CONTROL (wbcg), g_slist_append (NULL, sheet), (double) factor / 100);
/* Restore the focus to the sheet */
wb_control_gui_focus_cur_sheet (wbcg);
......
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