[gnumeric] Commands: make generic command.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Commands: make generic command.
- Date: Fri, 4 Jun 2010 17:50:24 +0000 (UTC)
commit f0c9238a3f329175392f32183f2e9dcc01cd8743
Author: Morten Welinder <terra gnome org>
Date: Fri Jun 4 13:50:07 2010 -0400
Commands: make generic command.
ChangeLog | 5 +++++
src/commands.c | 37 ++++++++++++++++++++++---------------
src/commands.h | 9 ++++++---
src/dialogs/dialog-solver.c | 12 ++++++------
4 files changed, 39 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4bf5a5..a2c528e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-04 Morten Welinder <terra gnome org>
+
+ * src/commands.c (cmd_generic): Rename from cmd_solver.
+ (cmd_generic_with_size): New function.
+
2010-06-04 Andreas J. Guelzow <aguelzow pyrshep ca>
* configure.in: check for gtk_entry_set_icon_from_stock
diff --git a/src/commands.c b/src/commands.c
index e5ed0a8..162fde5 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -6357,37 +6357,36 @@ cmd_text_to_columns (WorkbookControl *wbc,
/******************************************************************/
-#define CMD_SOLVER_TYPE (cmd_solver_get_type ())
-#define CMD_SOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SOLVER_TYPE, CmdSolver))
+#define CMD_GENERIC_TYPE (cmd_generic_get_type ())
+#define CMD_GENERIC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_GENERIC_TYPE, CmdGeneric))
typedef struct {
GnmCommand cmd;
-
GOUndo *undo, *redo;
-} CmdSolver;
+} CmdGeneric;
-MAKE_GNM_COMMAND (CmdSolver, cmd_solver, NULL)
+MAKE_GNM_COMMAND (CmdGeneric, cmd_generic, NULL)
static gboolean
-cmd_solver_undo (GnmCommand *cmd, WorkbookControl *wbc)
+cmd_generic_undo (GnmCommand *cmd, WorkbookControl *wbc)
{
- CmdSolver *me = CMD_SOLVER (cmd);
+ CmdGeneric *me = CMD_GENERIC (cmd);
go_undo_undo_with_data (me->undo, GO_CMD_CONTEXT (wbc));
return FALSE;
}
static gboolean
-cmd_solver_redo (GnmCommand *cmd, WorkbookControl *wbc)
+cmd_generic_redo (GnmCommand *cmd, WorkbookControl *wbc)
{
- CmdSolver *me = CMD_SOLVER (cmd);
+ CmdGeneric *me = CMD_GENERIC (cmd);
go_undo_undo_with_data (me->redo, GO_CMD_CONTEXT (wbc));
return FALSE;
}
static void
-cmd_solver_finalize (GObject *cmd)
+cmd_generic_finalize (GObject *cmd)
{
- CmdSolver *me = CMD_SOLVER (cmd);
+ CmdGeneric *me = CMD_GENERIC (cmd);
g_object_unref (me->undo);
g_object_unref (me->redo);
@@ -6396,17 +6395,19 @@ cmd_solver_finalize (GObject *cmd)
}
gboolean
-cmd_solver (WorkbookControl *wbc, const char *txt, GOUndo *undo, GOUndo *redo)
+cmd_generic_with_size (WorkbookControl *wbc, const char *txt,
+ int size,
+ GOUndo *undo, GOUndo *redo)
{
- CmdSolver *me;
+ CmdGeneric *me;
g_return_val_if_fail (GO_IS_UNDO (undo), TRUE);
g_return_val_if_fail (GO_IS_UNDO (redo), TRUE);
- me = g_object_new (CMD_SOLVER_TYPE, NULL);
+ me = g_object_new (CMD_GENERIC_TYPE, NULL);
me->cmd.sheet = wb_control_cur_sheet (wbc);
- me->cmd.size = 1;
+ me->cmd.size = size;
me->cmd.cmd_descriptor = g_strdup (txt);
me->undo = undo;
@@ -6415,6 +6416,12 @@ cmd_solver (WorkbookControl *wbc, const char *txt, GOUndo *undo, GOUndo *redo)
return gnm_command_push_undo (wbc, G_OBJECT (me));
}
+gboolean
+cmd_generic (WorkbookControl *wbc, const char *txt, GOUndo *undo, GOUndo *redo)
+{
+ return cmd_generic_with_size (wbc, txt, 1, undo, redo);
+}
+
/******************************************************************/
#define CMD_GOAL_SEEK_TYPE (cmd_goal_seek_get_type ())
diff --git a/src/commands.h b/src/commands.h
index 0c047a3..934e2fe 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -13,6 +13,12 @@ void command_repeat (WorkbookControl *wbc);
void command_setup_combos (WorkbookControl *wbc);
void command_list_release (GSList *cmds);
+gboolean cmd_generic (WorkbookControl *wbc, const char *text,
+ GOUndo *undo, GOUndo *redo);
+gboolean cmd_generic_with_size (WorkbookControl *wbc, const char *text,
+ int size,
+ GOUndo *undo, GOUndo *redo);
+
gboolean cmd_set_text (WorkbookControl *wbc, Sheet *sheet,
GnmCellPos const *pos, char const *new_text,
PangoAttrList *markup);
@@ -128,9 +134,6 @@ gboolean cmd_text_to_columns (WorkbookControl *wbc,
GnmRange const *target, Sheet *target_sheet,
GnmCellRegion *content);
-gboolean cmd_solver (WorkbookControl *wbc, const char *text,
- GOUndo *undo, GOUndo *redo);
-
gboolean cmd_goal_seek (WorkbookControl *wbc,
GnmCell *cell, GnmValue *ov, GnmValue *nv);
diff --git a/src/dialogs/dialog-solver.c b/src/dialogs/dialog-solver.c
index a129467..8705241 100644
--- a/src/dialogs/dialog-solver.c
+++ b/src/dialogs/dialog-solver.c
@@ -440,9 +440,9 @@ check_for_changed_options (SolverState *state)
state->orig_params)) {
GOUndo *undo = set_params (sheet, state->orig_params);
GOUndo *redo = set_params (sheet, sheet->solver_parameters);
- cmd_solver (WORKBOOK_CONTROL (state->wbcg),
- _("Changing solver parameters"),
- undo, redo);
+ cmd_generic (WORKBOOK_CONTROL (state->wbcg),
+ _("Changing solver parameters"),
+ undo, redo);
g_object_unref (state->orig_params);
state->orig_params =
@@ -771,9 +771,9 @@ run_solver (SolverState *state, GnmSolverParameters *param)
gnm_solver_store_result (sol);
redo = clipboard_copy_range_undo (sr.sheet, &sr.range);
- cmd_solver (WORKBOOK_CONTROL (state->wbcg),
- _("Running solver"),
- undo, redo);
+ cmd_generic (WORKBOOK_CONTROL (state->wbcg),
+ _("Running solver"),
+ undo, redo);
res = g_object_ref (sol->result);
undo = redo = NULL;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]