[gnumeric] replace cmd_so_rename with cmd_generic



commit ae9f89a63b0cba6c2e9100504032aba927b132eb
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jun 22 11:13:13 2010 -0600

    replace cmd_so_rename with cmd_generic
    
    2010-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/commands.h (cmd_so_rename): deleted
    	* src/commands.c (cmd_so_rename*): deleted
    
    2010-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-sheetobject-size.c (set_params): new
    	(cb_dialog_so_size_apply_clicked): use cmd_generic instead of
    	  cmd_so_rename

 ChangeLog                             |    5 ++
 src/commands.c                        |   68 ---------------------------------
 src/commands.h                        |    2 -
 src/dialogs/ChangeLog                 |    6 +++
 src/dialogs/dialog-sheetobject-size.c |   26 +++++++++++--
 5 files changed, 33 insertions(+), 74 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a432c69..2b152cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/commands.h (cmd_so_rename): deleted
+	* src/commands.c (cmd_so_rename*): deleted
+
 2010-06-17  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/gui-util.c (gnumeric_create_tooltip): windows should have names
diff --git a/src/commands.c b/src/commands.c
index d3701b3..789606b 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -7779,73 +7779,5 @@ cmd_autofilter_add_remove (WorkbookControl *wbc)
 	return gnm_command_push_undo (wbc, G_OBJECT (me));
 }
 
-/******************************************************************/
-
-
-#define CMD_SO_RENAME_TYPE (cmd_so_rename_get_type ())
-#define CMD_SO_RENAME(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_RENAME_TYPE, CmdSORename))
-
-typedef struct {
-	GnmCommand cmd;
-	SheetObject *so;
-	char *old_name;
-	char *new_name;
-} CmdSORename;
-
-MAKE_GNM_COMMAND (CmdSORename, cmd_so_rename, NULL)
-
-static gboolean
-cmd_so_rename_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
-{
-	CmdSORename *me = CMD_SO_RENAME (cmd);
-
-	sheet_object_set_name (me->so, me->new_name);
-
-	return FALSE;
-}
-
-static gboolean
-cmd_so_rename_undo (GnmCommand *cmd, G_GNUC_UNUSED  WorkbookControl *wbc)
-{
-	CmdSORename *me = CMD_SO_RENAME (cmd);
-
-	sheet_object_set_name (me->so, me->old_name);
-
-	return FALSE;
-}
-
-static void
-cmd_so_rename_finalize (GObject *cmd)
-{
-	CmdSORename *me = CMD_SO_RENAME (cmd);
-
-	g_free (me->old_name);
-	me->old_name = NULL;
-
-	g_free (me->new_name);
-	me->new_name = NULL;
-
-	gnm_command_finalize (cmd);
-}
-
-gboolean
-cmd_so_rename (WorkbookControl *wbc,
-	       SheetObject *so,
-	       char const *new_name)
-{
-	CmdSORename *me;
-
-	g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
-
-	me = g_object_new (CMD_SO_RENAME_TYPE, NULL);
-	me->cmd.sheet = sheet_object_get_sheet (so);
-	me->cmd.size = 1;
-	me->cmd.cmd_descriptor = g_strdup (_("Set Object Name"));
-	me->so = so;
-	g_object_get (G_OBJECT (so), "name", &(me->old_name), NULL);
-	me->new_name = g_strdup (new_name);
-
-	return gnm_command_push_undo (wbc, G_OBJECT (me));
-}
 
 /******************************************************************/
diff --git a/src/commands.h b/src/commands.h
index 934e2fe..9a6f144 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -153,8 +153,6 @@ gboolean cmd_objects_move	(WorkbookControl *wbc,
 gboolean cmd_object_format	(WorkbookControl *wbc, SheetObject *so,
 				 gpointer orig_style, char *orig_text,
 				 PangoAttrList *orig_attr);
-gboolean cmd_so_rename	        (WorkbookControl *wbc, SheetObject *so,
-				 char const *new_name);
 
 gboolean cmd_so_graph_config (WorkbookControl *wbc, SheetObject *sog,
                               GObject *n_graph, GObject *o_graph);
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index fa9df69..cf810ba 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-sheetobject-size.c (set_params): new
+	(cb_dialog_so_size_apply_clicked): use cmd_generic instead of
+	  cmd_so_rename
+	
 2010-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* dialog-solver.c (dialog_init): setup first entry
diff --git a/src/dialogs/dialog-sheetobject-size.c b/src/dialogs/dialog-sheetobject-size.c
index 0fab58f..005c179 100644
--- a/src/dialogs/dialog-sheetobject-size.c
+++ b/src/dialogs/dialog-sheetobject-size.c
@@ -183,6 +183,14 @@ dialog_so_size_load (SOSizeState *state)
 	state->so_pos_needs_restore = FALSE;
 }
 
+static GOUndo *
+set_params (SheetObject *so, char *name)
+{
+	return go_undo_binary_new
+		(g_object_ref (G_OBJECT (so)), name,
+		 (GOUndoBinaryFunc)sheet_object_set_name,
+		 g_object_unref, g_free);
+}
 
 static void
 cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
@@ -206,11 +214,21 @@ cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
 	name = gtk_entry_get_text (state->nameentry);
 	if (name == NULL)
 		name = "";
-	if (strcmp (name, state->old_name) != 0)
+	if (strcmp (name, state->old_name) != 0) {
+		GOUndo *undo, *redo;
+		char *old_name, *new_name;
+
+		g_object_get (G_OBJECT (state->so), "name", &old_name, NULL);
+		undo = set_params (state->so, old_name);
+
+		new_name = (*name == '\0') ? NULL : g_strdup (name);
+		redo = set_params (state->so, new_name);
+
 		state->so_name_changed 
-			= cmd_so_rename (WORKBOOK_CONTROL (state->wbcg),
-					 state->so, 
-					 (*name == '\0') ? NULL : name);
+			= cmd_generic (WORKBOOK_CONTROL (state->wbcg),
+				       _("Set Object Name"),
+				       undo, redo);
+	}
 
 	dialog_so_size_button_sensitivity (state);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]