[gnumeric] Indicate vararg functions in function browser. [#649484]



commit ab559878353f104af82bf73ed85c6b3d12b941a6
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri May 6 02:03:42 2011 -0600

    Indicate vararg functions in function browser. [#649484]
    
    2011-05-06  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-function-select.c (describe_new_style): indicate varargs
    	by ellipsis

 NEWS                                 |    1 +
 src/dialogs/ChangeLog                |    5 +++++
 src/dialogs/dialog-function-select.c |   21 +++++++++++++++++++++
 3 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 837c9c3..6094535 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Andreas:
 	* Handle NUL characters in cvs import. [#648354]
 	* Fix some Statistics tool formatting. [#649092]
 	* Fix undo crash for column widths. [#649139]
+	* Indicate vararg functions in function browser. [#649484]
 
 Morten:
 	* Fix problems with localized function docs.
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 04affdf..fc21c6f 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-06  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-function-select.c (describe_new_style): indicate varargs
+	by ellipsis
+
 2011-04-22  Jean Brefort  <jean brefort normalesup org>
 
 	* dialog-preferences.c (enum_pref_create_widget),
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index e5b7fe5..a283027 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -54,6 +54,8 @@
 #define FUNCTION_SELECT_PASTE_KEY "function-selector-dialog-paste-mode"
 #define FUNCTION_SELECT_DIALOG_KEY "function-selector-dialog"
 
+#define UNICODE_ELLIPSIS "\xe2\x80\xa6"
+
 typedef enum {
 	GURU_MODE = 0,
 	HELP_MODE,
@@ -681,6 +683,15 @@ make_expr_example (Sheet *sheet, const char *text, gboolean localized)
 #define ADD_TEXT_WITH_ARGS(text) { const char *t = text; while (*t) { const char *at = strstr (t, "@{"); \
 			if (at == NULL) { ADD_TEXT(t); break;} ADD_LTEXT(t, at - t); t = at + 2; at = strchr (t,'}'); \
 			if (at != NULL) { ADD_BOLD_TEXT(t, at - t); t = at + 1; } else {ADD_TEXT (t); break;}}}
+#define FINISH_ARGS if (seen_args && !args_finished) {\
+	gint min, max; \
+	function_def_count_args (func, &min, &max);\
+		if (max == G_MAXINT) {	\
+			ADD_BOLD_TEXT(UNICODE_ELLIPSIS, strlen(UNICODE_ELLIPSIS)); \
+			ADD_LTEXT("\n",1);				\
+			args_finished = TRUE;				\
+		}							\
+	}
 
 static void
 describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *sheet)
@@ -693,6 +704,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 		 "weight", PANGO_WEIGHT_BOLD,
 		 NULL);
 	gboolean seen_args = FALSE;
+	gboolean args_finished = FALSE;
 	gboolean seen_examples = FALSE;
 	gboolean seen_extref = FALSE;
 
@@ -731,6 +743,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 		}
 		case GNM_FUNC_HELP_DESCRIPTION: {
 			const char *text = F2 (func, help->text);
+			FINISH_ARGS;
 			ADD_TEXT ("\n");
 			ADD_TEXT_WITH_ARGS (text);
 			ADD_TEXT ("\n");
@@ -738,6 +751,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 		}
 		case GNM_FUNC_HELP_NOTE: {
 			const char *text = F2 (func, help->text);
+			FINISH_ARGS;
 			ADD_TEXT ("\n");
 			ADD_TEXT (_("Note: "));
 			ADD_TEXT_WITH_ARGS (text);
@@ -748,6 +762,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 			const char *text = F2 (func, help->text);
 			gboolean was_translated = (text != help->text);
 
+			FINISH_ARGS;
 			if (!seen_examples) {
 				seen_examples = TRUE;
 				ADD_TEXT ("\n");
@@ -771,6 +786,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 			GtkTextTag *link =
 				make_link (description, "LINK", NULL, NULL);
 
+			FINISH_ARGS;
 			ADD_TEXT ("\n");
 
 			while (*text) {
@@ -788,12 +804,14 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 			break;
 		}
 		case GNM_FUNC_HELP_END:
+			FINISH_ARGS;
 			return;
 		case GNM_FUNC_HELP_EXTREF: {
 			GtkTextTag *link;
 			char *uri, *tagname;
 			const char *text;
 
+			FINISH_ARGS;
 			/*
 			 * We put in just one link and let the web page handle
 			 * the rest.  In particular, we do not even look at
@@ -826,6 +844,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 		}
 		case GNM_FUNC_HELP_EXCEL: {
 			const char *text = F2 (func, help->text);
+			FINISH_ARGS;
 			ADD_TEXT ("\n");
 			ADD_TEXT (_("Microsoft Excel: "));
 			ADD_TEXT_WITH_ARGS (text);
@@ -834,6 +853,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 		}
 		case GNM_FUNC_HELP_ODF: {
 			const char *text = F2 (func, help->text);
+			FINISH_ARGS;
 			ADD_TEXT ("\n");
 			ADD_TEXT (_("ODF (OpenFormula): "));
 			ADD_TEXT_WITH_ARGS (text);
@@ -851,6 +871,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
 #undef ADD_LTEXT
 #undef ADD_BOLD_TEXT
 #undef ADD_LINK_TEXT
+#undef FINISH_ARGS
 
 typedef struct {
 	GnmFunc    *fd;



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