[gnumeric] Squashed commit of the following:
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Squashed commit of the following:
- Date: Sun, 19 Apr 2009 18:15:25 -0400 (EDT)
commit 4d21c5ad0e5f36a9cc500519f528d3ae27d081e9
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Apr 19 16:14:30 2009 -0600
Squashed commit of the following:
commit 7aad4484514ddd0cd43c8916f98074eff3e60e17
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Apr 19 16:11:47 2009 -0600
Making the remaining sheet object configurations undoable.
2009-04-19 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/commands.h (cmd_so_set_adjustment): new
* src/commands.c (cmd_so_set_adjustment): new
(cmd_so_set_adjustment_adj): new
(cmd_so_set_adjustment_redo): new
(cmd_so_set_adjustment_undo): new
(cmd_so_set_adjustment_finalize): new
* src/sheet-object-widget.h (sheet_widget_adjustment_get_link): new
(sheet_widget_adjustment_set_link): new
(sheet_widget_adjustment_get_adjustment): new
* src/sheet-object-widget.c (sheet_widget_adjustment_get_link): new
(sheet_widget_adjustment_set_link): new
(sheet_widget_adjustment_get_adjustment): new
(AdjustmentConfigState): new field
(cb_adjustment_config_destroy): release label memory
(cb_adjustment_config_ok_clicked): call cmd_so_set_adjustment
(sheet_widget_adjustment_user_config_impl): previously
sheet_widget_adjustment_user_config with window title and undo
string handling
(sheet_widget_adjustment_user_config): stub to call
sheet_widget_adjustment_user_config_impl with correct labels.
(sheet_widget_scrollbar_user_config) : new
(sheet_widget_scrollbar_class_init): hookup sheet_widget_scrollbar_user_config
(sheet_widget_spinbutton_user_config) : new
(sheet_widget_spinbutton_class_init): hookup sheet_widget_scrollbar_user_config
(sheet_widget_slider_user_config) : new
(sheet_widget_slider_class_init): hookup sheet_widget_scrollbar_user_config
---
ChangeLog | 29 +++++++++++++
NEWS | 2 +-
src/commands.c | 102 +++++++++++++++++++++++++++++++++++++++++++++
src/commands.h | 11 ++++-
src/sheet-object-widget.c | 96 ++++++++++++++++++++++++++++++++++-------
src/sheet-object-widget.h | 6 ++-
6 files changed, 226 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1eaf23a..fb75a82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2009-04-19 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/commands.h (cmd_so_set_adjustment): new
+ * src/commands.c (cmd_so_set_adjustment): new
+ (cmd_so_set_adjustment_adj): new
+ (cmd_so_set_adjustment_redo): new
+ (cmd_so_set_adjustment_undo): new
+ (cmd_so_set_adjustment_finalize): new
+ * src/sheet-object-widget.h (sheet_widget_adjustment_get_link): new
+ (sheet_widget_adjustment_set_link): new
+ (sheet_widget_adjustment_get_adjustment): new
+ * src/sheet-object-widget.c (sheet_widget_adjustment_get_link): new
+ (sheet_widget_adjustment_set_link): new
+ (sheet_widget_adjustment_get_adjustment): new
+ (AdjustmentConfigState): new field
+ (cb_adjustment_config_destroy): release label memory
+ (cb_adjustment_config_ok_clicked): call cmd_so_set_adjustment
+ (sheet_widget_adjustment_user_config_impl): previously
+ sheet_widget_adjustment_user_config with window title and undo
+ string handling
+ (sheet_widget_adjustment_user_config): stub to call
+ sheet_widget_adjustment_user_config_impl with correct labels.
+ (sheet_widget_scrollbar_user_config) : new
+ (sheet_widget_scrollbar_class_init): hookup sheet_widget_scrollbar_user_config
+ (sheet_widget_spinbutton_user_config) : new
+ (sheet_widget_spinbutton_class_init): hookup sheet_widget_scrollbar_user_config
+ (sheet_widget_slider_user_config) : new
+ (sheet_widget_slider_class_init): hookup sheet_widget_scrollbar_user_config
+
2009-04-18 Morten Welinder <terra gnome org>
* */*.c: Use gnm_sheet_get_last_(col|row) where appropriate.
diff --git a/NEWS b/NEWS
index eb724f7..4386e21 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Andreas:
* Show sheet sizes in manage sheet dialog
* Write metadata from the property dialog to the files
* Complete the list sheet object configuration dialog [#578557]
- * Make frame label and checkbox changes undoable
+ * Make all sheet object configurations undoable [#114098]
Jean:
* Variable sheet sizes.
diff --git a/src/commands.c b/src/commands.c
index e93696d..ec3e43c 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -7203,3 +7203,105 @@ cmd_so_set_checkbox (WorkbookControl *wbc,
/******************************************************************/
+#define CMD_SO_SET_ADJUSTMENT_TYPE (cmd_so_set_adjustment_get_type ())
+#define CMD_SO_SET_ADJUSTMENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_SET_ADJUSTMENT_TYPE, CmdSOSetAdjustment))
+
+typedef struct {
+ GnmCommand cmd;
+ SheetObject *so;
+ GnmExprTop const *new_link;
+ GnmExprTop const *old_link;
+ int old_lower;
+ int old_upper;
+ int old_step;
+ int old_page;
+} CmdSOSetAdjustment;
+
+MAKE_GNM_COMMAND (CmdSOSetAdjustment, cmd_so_set_adjustment, NULL)
+
+static void
+cmd_so_set_adjustment_adj (CmdSOSetAdjustment *me)
+{
+ GtkAdjustment *adj = sheet_widget_adjustment_get_adjustment (me->so);
+
+ int old_lower = gtk_adjustment_get_lower (adj);
+ int old_upper = gtk_adjustment_get_upper (adj);
+ int old_step = gtk_adjustment_get_step_increment (adj);
+ int old_page = gtk_adjustment_get_page_increment (adj);
+
+ gtk_adjustment_configure (adj,
+ gtk_adjustment_get_value (adj),
+ me->old_lower,
+ me->old_upper,
+ me->old_step,
+ me->old_page,
+ gtk_adjustment_get_page_size (adj));
+
+ me->old_lower = old_lower;
+ me->old_upper = old_upper;
+ me->old_step = old_step;
+ me->old_page = old_page;
+}
+
+static gboolean
+cmd_so_set_adjustment_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+ CmdSOSetAdjustment *me = CMD_SO_SET_ADJUSTMENT (cmd);
+
+ sheet_widget_adjustment_set_link (me->so, me->new_link);
+ cmd_so_set_adjustment_adj (me);
+ return FALSE;
+}
+
+static gboolean
+cmd_so_set_adjustment_undo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+ CmdSOSetAdjustment *me = CMD_SO_SET_ADJUSTMENT (cmd);
+
+ sheet_widget_adjustment_set_link (me->so, me->old_link);
+ cmd_so_set_adjustment_adj (me);
+
+ return FALSE;
+}
+
+static void
+cmd_so_set_adjustment_finalize (GObject *cmd)
+{
+ CmdSOSetAdjustment *me = CMD_SO_SET_ADJUSTMENT (cmd);
+
+ if (me->new_link)
+ gnm_expr_top_unref (me->new_link);
+ if (me->old_link)
+ gnm_expr_top_unref (me->old_link);
+ gnm_command_finalize (cmd);
+}
+
+gboolean
+cmd_so_set_adjustment (WorkbookControl *wbc,
+ SheetObject *so, GnmExprTop const *link,
+ int lower, int upper,
+ int step, int page,
+ char const *undo_label)
+{
+ CmdSOSetAdjustment *me;
+
+ g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+
+ me = g_object_new (CMD_SO_SET_ADJUSTMENT_TYPE, NULL);
+ me->cmd.sheet = sheet_object_get_sheet (so);
+ me->cmd.size = 1;
+ me->cmd.cmd_descriptor = g_strdup ((undo_label == NULL) ?
+ _("Configure Adjustment") : _(undo_label));
+ me->so = so;
+ me->new_link = link;
+ me->old_lower = lower;
+ me->old_upper = upper;
+ me->old_step = step;
+ me->old_page = page;
+
+ me->old_link = sheet_widget_adjustment_get_link (so);
+
+ return command_push_undo (wbc, G_OBJECT (me));
+}
+
+/******************************************************************/
diff --git a/src/commands.h b/src/commands.h
index b9a4785..82cf4f1 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -175,7 +175,16 @@ gboolean cmd_so_set_frame_label (WorkbookControl *wbc, SheetObject *so,
char *old_label, char *new_label);
gboolean cmd_so_set_checkbox (WorkbookControl *wbc, SheetObject *so,
- GnmExprTop const *link, char *old_label, char *new_label);
+ GnmExprTop const *link,
+ char *old_label, char *new_label);
+
+gboolean cmd_so_set_adjustment (WorkbookControl *wbc, SheetObject *so,
+ GnmExprTop const *link,
+ int lower, int upper,
+ int step, int page,
+ char const *undo_label);
+
+
/********************************************************************************/
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index d864b44..308c273 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -776,6 +776,34 @@ sheet_widget_adjustment_set_value (SheetWidgetAdjustment *swa, double new_val)
swa->being_updated = FALSE;
}
+GtkAdjustment *
+sheet_widget_adjustment_get_adjustment (SheetObject *so)
+{
+ return (SHEET_WIDGET_ADJUSTMENT (so)->adjustment);
+}
+
+void
+sheet_widget_adjustment_set_link (SheetObject *so, GnmExprTop const *texpr)
+{
+ SheetWidgetAdjustment *swa = SHEET_WIDGET_ADJUSTMENT (so);
+ dependent_set_expr (&swa->dep, texpr);
+ if (NULL != texpr)
+ dependent_link (&swa->dep);
+}
+
+GnmExprTop const *
+sheet_widget_adjustment_get_link (SheetObject *so)
+{
+ SheetWidgetAdjustment *swa = SHEET_WIDGET_ADJUSTMENT (so);
+ GnmExprTop const *texpr = swa->dep.texpr;
+
+ if (texpr)
+ gnm_expr_top_ref (texpr);
+
+ return texpr;
+}
+
+
static void
adjustment_eval (GnmDependent *dep)
{
@@ -895,7 +923,8 @@ typedef struct {
GtkWidget *max;
GtkWidget *inc;
GtkWidget *page;
-
+
+ char *undo_label;
GtkWidget *old_focus;
WBCGtk *wbcg;
@@ -934,6 +963,8 @@ cb_adjustment_config_destroy (AdjustmentConfigState *state)
g_object_unref (G_OBJECT (state->gui));
state->gui = NULL;
}
+ if (state->undo_label)
+ g_free (state->undo_label);
state->dialog = NULL;
g_free (state);
@@ -947,22 +978,18 @@ cb_adjustment_config_ok_clicked (GtkWidget *button, AdjustmentConfigState *state
GnmExprTop const *texpr = gnm_expr_entry_parse (state->expression,
parse_pos_init_sheet (&pp, so->sheet),
NULL, FALSE, GNM_EXPR_PARSE_DEFAULT);
- if (texpr != NULL) {
- dependent_set_expr (&state->swa->dep, texpr);
- dependent_link (&state->swa->dep);
- gnm_expr_top_unref (texpr);
- }
-
- state->swa->adjustment->lower = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (state->min));
- state->swa->adjustment->upper = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (state->max));
- state->swa->adjustment->step_increment = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (state->inc));
- state->swa->adjustment->page_increment = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (state->page));
- gtk_adjustment_changed (state->swa->adjustment);
+ cmd_so_set_adjustment (WORKBOOK_CONTROL (state->wbcg), so,
+ texpr,
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (state->min)),
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (state->max)),
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (state->inc)),
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (state->page)),
+ state->undo_label);
gtk_widget_destroy (state->dialog);
}
@@ -974,7 +1001,7 @@ cb_adjustment_config_cancel_clicked (GtkWidget *button, AdjustmentConfigState *s
}
static void
-sheet_widget_adjustment_user_config (SheetObject *so, SheetControl *sc)
+sheet_widget_adjustment_user_config_impl (SheetObject *so, SheetControl *sc, char const *undo_label, char const *dialog_label)
{
SheetWidgetAdjustment *swa = SHEET_WIDGET_ADJUSTMENT (so);
WBCGtk *wbcg = scg_wbcg (SHEET_CONTROL_GUI (sc));
@@ -992,10 +1019,14 @@ sheet_widget_adjustment_user_config (SheetObject *so, SheetControl *sc)
state->wbcg = wbcg;
state->sheet = sc_sheet (sc);
state->old_focus = NULL;
+ state->undo_label = (undo_label == NULL) ? NULL : g_strdup (undo_label);
state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
"so-scrollbar.glade", NULL, NULL);
state->dialog = glade_xml_get_widget (state->gui, "SO-Scrollbar");
+ if (dialog_label != NULL)
+ gtk_window_set_title (GTK_WINDOW (state->dialog), dialog_label);
+
table = glade_xml_get_widget (state->gui, "table");
state->expression = gnm_expr_entry_new (wbcg, TRUE);
@@ -1057,6 +1088,13 @@ sheet_widget_adjustment_user_config (SheetObject *so, SheetControl *sc)
gtk_widget_show (state->dialog);
}
+static void
+sheet_widget_adjustment_user_config (SheetObject *so, SheetControl *sc)
+{
+ sheet_widget_adjustment_user_config_impl (so, sc, N_("Configure Adjustment"),
+ N_("Adjustment Properties"));
+}
+
static gboolean
sheet_widget_adjustment_set_sheet (SheetObject *so, Sheet *sheet)
{
@@ -1211,9 +1249,17 @@ sheet_widget_scrollbar_create_widget (SheetObjectWidget *sow)
}
static void
+sheet_widget_scrollbar_user_config (SheetObject *so, SheetControl *sc)
+{
+ sheet_widget_adjustment_user_config_impl (so, sc, N_("Configure Scrollbar"),
+ N_("Scrollbar Properties"));
+}
+
+static void
sheet_widget_scrollbar_class_init (SheetObjectWidgetClass *sow_class)
{
sow_class->create_widget = &sheet_widget_scrollbar_create_widget;
+ SHEET_OBJECT_CLASS (sow_class)->user_config = &sheet_widget_scrollbar_user_config;
}
GSF_CLASS (SheetWidgetScrollbar, sheet_widget_scrollbar,
@@ -1246,9 +1292,17 @@ sheet_widget_spinbutton_create_widget (SheetObjectWidget *sow)
}
static void
+sheet_widget_spinbutton_user_config (SheetObject *so, SheetControl *sc)
+{
+ sheet_widget_adjustment_user_config_impl (so, sc, N_("Configure Spinbutton"),
+ N_("Spinbutton Properties"));
+}
+
+static void
sheet_widget_spinbutton_class_init (SheetObjectWidgetClass *sow_class)
{
sow_class->create_widget = &sheet_widget_spinbutton_create_widget;
+ SHEET_OBJECT_CLASS (sow_class)->user_config = &sheet_widget_spinbutton_user_config;
}
GSF_CLASS (SheetWidgetSpinbutton, sheet_widget_spinbutton,
@@ -1289,9 +1343,17 @@ sheet_widget_slider_create_widget (SheetObjectWidget *sow)
}
static void
+sheet_widget_slider_user_config (SheetObject *so, SheetControl *sc)
+{
+ sheet_widget_adjustment_user_config_impl (so, sc, N_("Configure Slider"),
+ N_("Slider Properties"));
+}
+
+static void
sheet_widget_slider_class_init (SheetObjectWidgetClass *sow_class)
{
sow_class->create_widget = &sheet_widget_slider_create_widget;
+ SHEET_OBJECT_CLASS (sow_class)->user_config = &sheet_widget_slider_user_config;
}
GSF_CLASS (SheetWidgetSlider, sheet_widget_slider,
diff --git a/src/sheet-object-widget.h b/src/sheet-object-widget.h
index ce083b4..61346fd 100644
--- a/src/sheet-object-widget.h
+++ b/src/sheet-object-widget.h
@@ -33,9 +33,13 @@ void sheet_widget_adjustment_set_details (SheetObject *so,
GnmExprTop const *result_link,
int value, int min, int max,
int inc, int page);
+GnmExprTop const *sheet_widget_adjustment_get_link (SheetObject *so);
+void sheet_widget_adjustment_set_link (SheetObject *so,
+ GnmExprTop const *result_link);
+GtkAdjustment *sheet_widget_adjustment_get_adjustment (SheetObject *so);
void sheet_widget_checkbox_set_link (SheetObject *so,
GnmExprTop const *result_link);
-GnmExprTop const *sheet_widget_checkbox_get_link (SheetObject *so);
+GnmExprTop const *sheet_widget_checkbox_get_link (SheetObject *so);
void sheet_widget_checkbox_set_label (SheetObject *so, char const *str);
void sheet_widget_button_set_label (SheetObject *so, char const *str);
void sheet_widget_radio_button_set_label (SheetObject *so, char const *str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]