gnumeric r17316 - in trunk: . src



Author: guelzow
Date: Tue Apr 14 05:58:42 2009
New Revision: 17316
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17316&view=rev

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

	* src/commands.c (cmd_so_set_frame_label_redo): new
	(cmd_so_set_frame_label_undo): new
	(cmd_so_set_frame_label_finalize): new
	(cmd_so_set_frame_label): new
	* src/commands.h (cmd_so_set_frame_label): new
	* src/sheet-object-widget.c (sheet_widget_frame_set_label): new
	(cb_frame_config_ok_clicked): call cmd_so_set_frame_label
	(cb_frame_config_cancel_clicked): use sheet_widget_frame_set_label
	(cb_frame_label_changed): ditto
	* src/sheet-object-widget.h (sheet_widget_frame_set_label): new




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	Tue Apr 14 05:58:42 2009
@@ -4,6 +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
 
 Jean:
 	* Variable sheet sizes.

Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c	(original)
+++ trunk/src/commands.c	Tue Apr 14 05:58:42 2009
@@ -7055,3 +7055,77 @@
 
 	return command_push_undo (wbc, G_OBJECT (me));
 }
+
+/******************************************************************/
+
+
+
+#define CMD_SO_SET_FRAME_LABEL_TYPE (cmd_so_set_frame_label_get_type ())
+#define CMD_SO_SET_FRAME_LABEL(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_SET_FRAME_LABEL_TYPE, CmdSOSetFrameLabel))
+
+typedef struct {
+	GnmCommand cmd;
+	SheetObject *so;
+	char *old_label;
+	char *new_label;
+} CmdSOSetFrameLabel;
+
+MAKE_GNM_COMMAND (CmdSOSetFrameLabel, cmd_so_set_frame_label, NULL)
+
+static gboolean
+cmd_so_set_frame_label_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+	CmdSOSetFrameLabel *me = CMD_SO_SET_FRAME_LABEL (cmd);
+
+	sheet_widget_frame_set_label (me->so, me->new_label);	
+
+	return FALSE;
+}
+
+static gboolean
+cmd_so_set_frame_label_undo (GnmCommand *cmd, G_GNUC_UNUSED  WorkbookControl *wbc)
+{
+	CmdSOSetFrameLabel *me = CMD_SO_SET_FRAME_LABEL (cmd);
+
+	sheet_widget_frame_set_label (me->so, me->old_label);
+
+	return FALSE;
+}
+
+static void
+cmd_so_set_frame_label_finalize (GObject *cmd)
+{
+	CmdSOSetFrameLabel *me = CMD_SO_SET_FRAME_LABEL (cmd);
+	
+	if (me->old_label) {
+		g_free (me->old_label);
+		me->old_label = NULL;
+	}
+	if (me->new_label) {
+		g_free (me->new_label);
+		me->new_label = NULL;
+	}
+	gnm_command_finalize (cmd);
+}
+
+gboolean
+cmd_so_set_frame_label (WorkbookControl *wbc,
+			SheetObject *so, 
+			char *old_label, char *new_label )
+{
+	CmdSOSetFrameLabel *me;
+
+	g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+
+	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->so = so;
+	me->old_label = old_label;
+	me->new_label = new_label;
+
+	return command_push_undo (wbc, G_OBJECT (me));
+}
+
+/******************************************************************/

Modified: trunk/src/commands.h
==============================================================================
--- trunk/src/commands.h	(original)
+++ trunk/src/commands.h	Tue Apr 14 05:58:42 2009
@@ -90,18 +90,6 @@
 
 gboolean cmd_zoom               (WorkbookControl *wbc, GSList *sheets, double factor);
 
-gboolean cmd_objects_delete	(WorkbookControl *wbc, GSList *objects,
-				 char const *name);
-gboolean cmd_objects_move	(WorkbookControl *wbc,
-				 GSList *objects, GSList *anchors,
-				 gboolean objects_created, char const *name);
-gboolean cmd_object_format	(WorkbookControl *wbc, SheetObject *so,
-				 gpointer orig_style);
-
-gboolean cmd_reorganize_sheets  (WorkbookControl *wbc,
-				 WorkbookSheetState *old_state,
-				 Sheet *undo_sheet);
-
 gboolean cmd_rename_sheet	(WorkbookControl *wbc, Sheet *sheet,
 				 char const *new_name);
 
@@ -123,14 +111,6 @@
 				 char const *descriptor);
 gboolean cmd_remove_name        (WorkbookControl *wbc, GnmNamedExpr *nexpr);
 
-typedef enum  {
-	cmd_object_pull_to_front,
-	cmd_object_pull_forward ,
-	cmd_object_push_backward,
-	cmd_object_push_to_back
-} CmdObjectRaiseSelector;
-gboolean cmd_object_raise (WorkbookControl *wbc, SheetObject *so, CmdObjectRaiseSelector dir);
-
 /* FIXME: figure out how to resolve these better.  */
 struct _scenario_t;
 struct _scenario_cmd_t;
@@ -155,10 +135,32 @@
 
 gboolean cmd_tabulate (WorkbookControl *wbc, gpointer data);
 
+gboolean cmd_toggle_rtl (WorkbookControl *wbc, Sheet *sheet);
+
+/**************************  Sheet Objects **************************************/
+
+gboolean cmd_objects_delete	(WorkbookControl *wbc, GSList *objects,
+				 char const *name);
+gboolean cmd_objects_move	(WorkbookControl *wbc,
+				 GSList *objects, GSList *anchors,
+				 gboolean objects_created, char const *name);
+gboolean cmd_object_format	(WorkbookControl *wbc, SheetObject *so,
+				 gpointer orig_style);
+
+gboolean cmd_reorganize_sheets  (WorkbookControl *wbc,
+				 WorkbookSheetState *old_state,
+				 Sheet *undo_sheet);
+
 gboolean cmd_so_graph_config (WorkbookControl *wbc, SheetObject *sog,
                               GObject *n_graph, GObject *o_graph);
 
-gboolean cmd_toggle_rtl (WorkbookControl *wbc, Sheet *sheet);
+typedef enum  {
+	cmd_object_pull_to_front,
+	cmd_object_pull_forward ,
+	cmd_object_push_backward,
+	cmd_object_push_to_back
+} CmdObjectRaiseSelector;
+gboolean cmd_object_raise (WorkbookControl *wbc, SheetObject *so, CmdObjectRaiseSelector dir);
 
 gboolean cmd_so_set_value (WorkbookControl *wbc,
 			   const char *text,
@@ -169,6 +171,11 @@
 gboolean cmd_so_set_links (WorkbookControl *wbc, SheetObject *so, 
 			   GnmExprTop const *output, GnmExprTop const *content);
 
+gboolean cmd_so_set_frame_label (WorkbookControl *wbc, SheetObject *so, 
+				 char *old_label, char *new_label);
+
+/********************************************************************************/
+
 G_END_DECLS
 
 #endif /* _GNM_COMMANDS_H_ */

Modified: trunk/src/sheet-object-widget.c
==============================================================================
--- trunk/src/sheet-object-widget.c	(original)
+++ trunk/src/sheet-object-widget.c	Tue Apr 14 05:58:42 2009
@@ -425,44 +425,48 @@
 static void
 cb_frame_config_ok_clicked (GtkWidget *button, FrameConfigState *state)
 {
+	gchar const *text = gtk_entry_get_text(GTK_ENTRY(state->label));
+
+	cmd_so_set_frame_label (WORKBOOK_CONTROL (state->wbcg), SHEET_OBJECT (state->swf), 
+				g_strdup (state->old_label), g_strdup (text));
 	gtk_widget_destroy (state->dialog);
 }
 
-static void
-cb_frame_config_cancel_clicked (GtkWidget *button, FrameConfigState *state)
+void
+sheet_widget_frame_set_label (SheetObject *so, char const* str)
 {
+	SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
 	GList *ptr;
-	SheetWidgetFrame *swf = state->swf;
 
-	g_free (swf->label);
+	str = str ? str : "";
+	
+	if (swf->label)
+		g_free (swf->label);
+	swf->label = g_strdup (str);
 
-	swf->label = g_strdup (state->old_label);
-	for (ptr = swf->sow.realized_list; ptr != NULL ; ptr = ptr->next)
+	for (ptr = swf->sow.realized_list; ptr != NULL; ptr = ptr->next) {
 		gtk_frame_set_label
 			(GTK_FRAME (FOO_CANVAS_WIDGET (ptr->data)->widget),
-			 state->old_label);
+			 str);
+	}	
+}
+
+static void
+cb_frame_config_cancel_clicked (GtkWidget *button, FrameConfigState *state)
+{
+	sheet_widget_frame_set_label (SHEET_OBJECT (state->swf), state->old_label);
 
 	gtk_widget_destroy (state->dialog);
 }
 
+
 static void
 cb_frame_label_changed (GtkWidget *entry, FrameConfigState *state)
 {
-	GList *ptr;
-	SheetWidgetFrame *swf;
 	gchar const *text;
 
 	text = gtk_entry_get_text(GTK_ENTRY(entry));
-	swf = state->swf;
-
-	g_free (swf->label);
-	swf->label = g_strdup (text);
-
-	for (ptr = swf->sow.realized_list; ptr != NULL; ptr = ptr->next) {
-		gtk_frame_set_label
-			(GTK_FRAME (FOO_CANVAS_WIDGET (ptr->data)->widget),
-			 text);
-	}
+	sheet_widget_frame_set_label (SHEET_OBJECT (state->swf), text);
 }
 
 static void

Modified: trunk/src/sheet-object-widget.h
==============================================================================
--- trunk/src/sheet-object-widget.h	(original)
+++ trunk/src/sheet-object-widget.h	Tue Apr 14 05:58:42 2009
@@ -40,6 +40,7 @@
 void sheet_widget_radio_button_set_label (SheetObject *so, char const *str);
 
 void sheet_widget_button_set_markup      (SheetObject *so, PangoAttrList *markup);
+void sheet_widget_frame_set_label        (SheetObject *so, char const *str);
 
 G_END_DECLS
 



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