gnumeric r17318 - in trunk: . src



Author: guelzow
Date: Wed Apr 15 06:17:01 2009
New Revision: 17318
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17318&view=rev

Log:
2009-04-15  Andreas J. Guelzow <aguelzow pyrshep ca>

	* src/commands.h (cmd_so_set_checkbox): new
	* src/commands.c (cmd_so_set_checkbox): new
	(cmd_so_set_checkbox_redo): new
	(cmd_so_set_checkbox_undo): new
	(cmd_so_set_checkbox_finalize): new
	* src/sheet-object-widget.h (sheet_widget_checkbox_get_link): new
	* src/sheet-object-widget.c (sheet_widget_checkbox_get_link): new
	(cb_checkbox_config_ok_clicked): call cmd_so_set_checkbox




Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/commands.c
   trunk/src/commands.h
   trunk/src/sheet-object-widget.c
   trunk/src/sheet-object-widget.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Wed Apr 15 06:17:01 2009
@@ -4,7 +4,7 @@
 	* 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 changes undoable
+	* Make frame label and checkbox changes undoable
 
 Jean:
 	* Variable sheet sizes.

Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c	(original)
+++ trunk/src/commands.c	Wed Apr 15 06:17:01 2009
@@ -7048,7 +7048,7 @@
 	me = g_object_new (CMD_SO_SET_LINKS_TYPE, NULL);
 	me->cmd.sheet = sheet_object_get_sheet (so);
 	me->cmd.size = 1;
-	me->cmd.cmd_descriptor = g_strdup (_("Set cell references."));
+	me->cmd.cmd_descriptor = g_strdup (_("Configure List"));
 	me->so = so;
 	me->output = output;
 	me->content = content;
@@ -7120,7 +7120,7 @@
 	me = g_object_new (CMD_SO_SET_FRAME_LABEL_TYPE, NULL);
 	me->cmd.sheet = sheet_object_get_sheet (so);
 	me->cmd.size = 1;
-	me->cmd.cmd_descriptor = g_strdup (_("Set frame label."));
+	me->cmd.cmd_descriptor = g_strdup (_("Set Frame Label"));
 	me->so = so;
 	me->old_label = old_label;
 	me->new_label = new_label;
@@ -7129,3 +7129,80 @@
 }
 
 /******************************************************************/
+#define CMD_SO_SET_CHECKBOX_TYPE (cmd_so_set_checkbox_get_type ())
+#define CMD_SO_SET_CHECKBOX(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_SET_CHECKBOX_TYPE, CmdSOSetCheckbox))
+
+typedef struct {
+	GnmCommand cmd;
+	SheetObject *so;
+	GnmExprTop const *new_link;
+	GnmExprTop const *old_link;
+	char *old_label;
+	char *new_label;
+} CmdSOSetCheckbox;
+
+MAKE_GNM_COMMAND (CmdSOSetCheckbox, cmd_so_set_checkbox, NULL)
+
+static gboolean
+cmd_so_set_checkbox_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+	CmdSOSetCheckbox *me = CMD_SO_SET_CHECKBOX (cmd);
+
+	sheet_widget_checkbox_set_link (me->so, me->new_link);
+	sheet_widget_checkbox_set_label (me->so, me->new_label);
+
+	return FALSE;
+}
+
+static gboolean
+cmd_so_set_checkbox_undo (GnmCommand *cmd, G_GNUC_UNUSED  WorkbookControl *wbc)
+{
+	CmdSOSetCheckbox *me = CMD_SO_SET_CHECKBOX (cmd);
+
+	sheet_widget_checkbox_set_link (me->so, me->old_link);
+	sheet_widget_checkbox_set_label (me->so, me->old_label);
+
+	return FALSE;
+}
+
+static void
+cmd_so_set_checkbox_finalize (GObject *cmd)
+{
+	CmdSOSetCheckbox *me = CMD_SO_SET_CHECKBOX (cmd);
+	
+	if (me->new_link)
+		gnm_expr_top_unref (me->new_link);
+	if (me->old_link)
+		gnm_expr_top_unref (me->old_link);
+	if (me->old_label)
+		g_free (me->old_label);
+	if (me->new_label)
+		g_free (me->new_label);
+	gnm_command_finalize (cmd);
+}
+
+gboolean
+cmd_so_set_checkbox (WorkbookControl *wbc,
+		     SheetObject *so, GnmExprTop const *link, 
+		     char *old_label, char *new_label)
+{
+	CmdSOSetCheckbox *me;
+
+	g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+
+	me = g_object_new (CMD_SO_SET_CHECKBOX_TYPE, NULL);
+	me->cmd.sheet = sheet_object_get_sheet (so);
+	me->cmd.size = 1;
+	me->cmd.cmd_descriptor = g_strdup (_("Configure Checkbox"));
+	me->so = so;
+	me->new_link = link;
+	me->old_label = old_label;
+	me->new_label = new_label;
+
+	me->old_link = sheet_widget_checkbox_get_link (so);
+
+	return command_push_undo (wbc, G_OBJECT (me));
+}
+
+/******************************************************************/
+

Modified: trunk/src/commands.h
==============================================================================
--- trunk/src/commands.h	(original)
+++ trunk/src/commands.h	Wed Apr 15 06:17:01 2009
@@ -174,6 +174,10 @@
 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);
+
+
 /********************************************************************************/
 
 G_END_DECLS

Modified: trunk/src/sheet-object-widget.c
==============================================================================
--- trunk/src/sheet-object-widget.c	(original)
+++ trunk/src/sheet-object-widget.c	Wed Apr 15 06:17:01 2009
@@ -1552,11 +1552,10 @@
 	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->swc->dep, texpr);
-		dependent_link (&state->swc->dep);
-		gnm_expr_top_unref (texpr);
-	}
+	gchar const *text = gtk_entry_get_text(GTK_ENTRY(state->label));
+
+	cmd_so_set_checkbox (WORKBOOK_CONTROL (state->wbcg), so, 
+			     texpr, g_strdup (state->old_label), g_strdup (text));
 
 	gtk_widget_destroy (state->dialog);
 }
@@ -1729,6 +1728,19 @@
 		dependent_link (&swc->dep);
 }
 
+GnmExprTop const *
+sheet_widget_checkbox_get_link	 (SheetObject *so)
+{
+	SheetWidgetCheckbox *swc = SHEET_WIDGET_CHECKBOX (so);
+	GnmExprTop const *texpr = swc->dep.texpr;
+	
+	if (texpr)
+		gnm_expr_top_ref (texpr);
+
+	return texpr;
+}
+
+
 void
 sheet_widget_checkbox_set_label	(SheetObject *so, char const *str)
 {

Modified: trunk/src/sheet-object-widget.h
==============================================================================
--- trunk/src/sheet-object-widget.h	(original)
+++ trunk/src/sheet-object-widget.h	Wed Apr 15 06:17:01 2009
@@ -35,6 +35,7 @@
 					  int inc, int page);
 void sheet_widget_checkbox_set_link	 (SheetObject *so,
 					  GnmExprTop const *result_link);
+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]