gnumeric r17315 - in trunk: . src src/dialogs



Author: guelzow
Date: Tue Apr 14 03:28:51 2009
New Revision: 17315
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17315&view=rev

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

	* dialog-so-list.c (cb_so_list_response): handle ok response
	* dialog-function-select.c (dialog_function_select_init): connect sheet destroy
	  handler

2009-04-13  Andreas J. Guelzow <aguelzow pyrshep ca>

	* src/commands.c (gboolean cmd_so_set_links): new
	(CmdSOSetLink): new
	(cmd_so_set_links_redo): new
	(cmd_so_set_links_undo): new
	(cmd_so_set_links_finalize): new
	* src/commands.h (gboolean cmd_so_set_links): new
	* src/sheet-object-widget.c (list_content_eval): permit dep->texpr to
	  be NULL.
	(sheet_widget_list_base_set_links): empty the list as necessary




Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/commands.c
   trunk/src/commands.h
   trunk/src/dialogs/ChangeLog
   trunk/src/dialogs/dialog-function-select.c
   trunk/src/dialogs/dialog-so-list.c
   trunk/src/sheet-object-widget.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Tue Apr 14 03:28:51 2009
@@ -3,6 +3,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]
 
 Jean:
 	* Variable sheet sizes.

Modified: trunk/src/commands.c
==============================================================================
--- trunk/src/commands.c	(original)
+++ trunk/src/commands.c	Tue Apr 14 03:28:51 2009
@@ -6977,3 +6977,81 @@
 }
 
 /******************************************************************/
+
+
+#define CMD_SO_SET_LINKS_TYPE (cmd_so_set_links_get_type ())
+#define CMD_SO_SET_LINKS(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_SO_SET_LINKS_TYPE, CmdSOSetLink))
+
+typedef struct {
+	GnmCommand cmd;
+	SheetObject *so;
+	GnmExprTop const *output;
+	GnmExprTop const *content;
+} CmdSOSetLink;
+
+MAKE_GNM_COMMAND (CmdSOSetLink, cmd_so_set_links, NULL)
+
+static gboolean
+cmd_so_set_links_redo (GnmCommand *cmd, G_GNUC_UNUSED WorkbookControl *wbc)
+{
+	CmdSOSetLink *me = CMD_SO_SET_LINKS (cmd);
+	GnmExprTop const *old_output;
+	GnmExprTop const *old_content;
+
+	old_content = sheet_widget_list_base_get_content_dep (me->so)->texpr;
+	if (old_content)
+		gnm_expr_top_ref (old_content);
+	old_output = sheet_widget_list_base_get_result_dep (me->so)->texpr;
+	if (old_output)
+		gnm_expr_top_ref (old_output);
+
+	sheet_widget_list_base_set_links
+		(me->so, me->output, me->content);
+	if (me->output)
+		gnm_expr_top_unref (me->output);
+	if (me->content)
+		gnm_expr_top_unref (me->content);
+	me->output = old_output;
+	me->content = old_content;
+
+	return FALSE;
+}
+
+static gboolean
+cmd_so_set_links_undo (GnmCommand *cmd, G_GNUC_UNUSED  WorkbookControl *wbc)
+{
+	return cmd_so_set_links_redo (cmd, wbc);
+}
+
+static void
+cmd_so_set_links_finalize (GObject *cmd)
+{
+	CmdSOSetLink *me = CMD_SO_SET_LINKS (cmd);
+	
+	if (me->output)
+		gnm_expr_top_unref (me->output);
+	if (me->content)
+		gnm_expr_top_unref (me->content);
+	gnm_command_finalize (cmd);
+}
+
+gboolean
+cmd_so_set_links (WorkbookControl *wbc,
+		  SheetObject *so, 
+		  GnmExprTop const *output, 
+		  GnmExprTop const *content)
+{
+	CmdSOSetLink *me;
+
+	g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+
+	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->so = so;
+	me->output = output;
+	me->content = content;
+
+	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 03:28:51 2009
@@ -157,6 +157,7 @@
 
 gboolean cmd_so_graph_config (WorkbookControl *wbc, SheetObject *sog,
                               GObject *n_graph, GObject *o_graph);
+
 gboolean cmd_toggle_rtl (WorkbookControl *wbc, Sheet *sheet);
 
 gboolean cmd_so_set_value (WorkbookControl *wbc,
@@ -165,6 +166,9 @@
 			   GnmValue *new_val,
 			   Sheet *sheet);
 
+gboolean cmd_so_set_links (WorkbookControl *wbc, SheetObject *so, 
+			   GnmExprTop const *output, GnmExprTop const *content);
+
 G_END_DECLS
 
 #endif /* _GNM_COMMANDS_H_ */

Modified: trunk/src/dialogs/dialog-function-select.c
==============================================================================
--- trunk/src/dialogs/dialog-function-select.c	(original)
+++ trunk/src/dialogs/dialog-function-select.c	Tue Apr 14 03:28:51 2009
@@ -804,6 +804,10 @@
 		"clicked",
 		G_CALLBACK (cb_dialog_function_select_cancel_clicked), state);
 
+	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), 
+					   state->wbcg,
+					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);
+	
 	gnumeric_init_help_button (
 		glade_xml_get_widget (state->gui, "help_button"),
 		GNUMERIC_HELP_LINK_FUNCTION_SELECT);

Modified: trunk/src/dialogs/dialog-so-list.c
==============================================================================
--- trunk/src/dialogs/dialog-so-list.c	(original)
+++ trunk/src/dialogs/dialog-so-list.c	Tue Apr 14 03:28:51 2009
@@ -72,9 +72,9 @@
 		"scg", wbcg_cur_scg (state->wbcg),
 		"with-icon", TRUE,
 		NULL);
-	gnm_expr_entry_set_flags (gee,
-		GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL | GNM_EE_SINGLE_RANGE,
-		GNM_EE_MASK);
+	gnm_expr_entry_set_flags (gee, GNM_EE_FORCE_ABS_REF | 
+				  GNM_EE_SHEET_OPTIONAL | 
+				  GNM_EE_SINGLE_RANGE, GNM_EE_MASK);
 	gnm_expr_entry_load_from_dep (gee, dep);
 	return gee;
 }
@@ -85,6 +85,17 @@
 	if (response_id == GTK_RESPONSE_HELP)
 		return;
 	if (response_id == GTK_RESPONSE_OK) {
+		GnmParsePos pp;
+		Sheet *sheet = sheet_object_get_sheet (state->so);
+		GnmExprTop const *output;
+		GnmExprTop const *content;
+
+		parse_pos_init (&pp, sheet->workbook, sheet, 0, 0);
+		output = gnm_expr_entry_parse (state->link_entry, 
+					       &pp, NULL, FALSE, GNM_EE_FORCE_ABS_REF);
+		content = gnm_expr_entry_parse (state->content_entry, 
+						&pp, NULL, FALSE, GNM_EE_FORCE_ABS_REF);
+		cmd_so_set_links (WORKBOOK_CONTROL (state->wbcg), state->so, output, content);
 	}
 
 	gtk_object_destroy (GTK_OBJECT (dialog));
@@ -106,9 +117,9 @@
 	table = GTK_TABLE (glade_xml_get_widget (state->gui, "table"));
 
 	state->content_entry = init_entry (state, "content-entry",
-		sheet_widget_list_base_get_content_dep (so));
+					   sheet_widget_list_base_get_content_dep (so));
 	state->link_entry = init_entry (state, "link-entry",
-		sheet_widget_list_base_get_result_dep (so));
+					sheet_widget_list_base_get_result_dep (so));
 
 	g_signal_connect (G_OBJECT (state->dialog), "response",
 		G_CALLBACK (cb_so_list_response), state);

Modified: trunk/src/sheet-object-widget.c
==============================================================================
--- trunk/src/sheet-object-widget.c	(original)
+++ trunk/src/sheet-object-widget.c	Tue Apr 14 03:28:51 2009
@@ -2096,17 +2096,21 @@
 {
 	SheetWidgetListBase *swl = DEP_TO_LIST_BASE_CONTENT (dep);
 	GnmEvalPos ep;
-	GnmValue *v = gnm_expr_top_eval (dep->texpr,
-		eval_pos_init_dep (&ep, dep),
-		GNM_EXPR_EVAL_PERMIT_NON_SCALAR | GNM_EXPR_EVAL_PERMIT_EMPTY);
+	GnmValue *v = NULL;
 	GtkListStore *model;
 
-	if (NULL == v)
-		return;
+	if (dep->texpr != NULL) {
+		v = gnm_expr_top_eval (dep->texpr,
+				       eval_pos_init_dep (&ep, dep),
+				       GNM_EXPR_EVAL_PERMIT_NON_SCALAR | 
+				       GNM_EXPR_EVAL_PERMIT_EMPTY);
+	}
 	model = gtk_list_store_new (1, G_TYPE_STRING);
-	value_area_foreach (v, &ep, CELL_ITER_ALL,
-		 (GnmValueIterFunc) cb_collect, model);
-	value_release (v);
+	if ((dep != NULL) && (v != NULL)) {
+		value_area_foreach (v, &ep, CELL_ITER_ALL,
+				    (GnmValueIterFunc) cb_collect, model);
+		value_release (v);
+	}
 
 	if (NULL != swl->model)
 		g_object_unref (G_OBJECT (swl->model));
@@ -2260,11 +2264,11 @@
 	if (NULL != output)
 		dependent_link (&swl->output_dep);
 	dependent_set_expr (&swl->content_dep, content);
-	if (NULL != content) {
+	if (NULL != content)
 		dependent_link (&swl->content_dep);
-		list_content_eval (&swl->content_dep); /* populate the list */
-	}
+	list_content_eval (&swl->content_dep); /* populate the list */
 }
+
 GnmDependent const *
 sheet_widget_list_base_get_result_dep  (SheetObject const *so)
 {



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