[gnumeric] Help texts: kill GNM_FUNC_HELP_OLD.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Help texts: kill GNM_FUNC_HELP_OLD.
- Date: Fri, 14 Aug 2009 15:22:53 +0000 (UTC)
commit de3cea357ed06437a716cf0432c374184222da29
Author: Morten Welinder <terra gnome org>
Date: Fri Aug 14 11:22:23 2009 -0400
Help texts: kill GNM_FUNC_HELP_OLD.
plugins/perl-loader/perl-loader.c | 4 +
plugins/python-loader/python-loader.c | 17 +++--
src/dialogs/dialog-function-select.c | 109 -----------------------------
src/func.c | 123 +++++++-------------------------
src/func.h | 2 -
5 files changed, 43 insertions(+), 212 deletions(-)
---
diff --git a/plugins/perl-loader/perl-loader.c b/plugins/perl-loader/perl-loader.c
index 420215e..c989b36 100644
--- a/plugins/perl-loader/perl-loader.c
+++ b/plugins/perl-loader/perl-loader.c
@@ -50,7 +50,9 @@ static const char help_template_text[] =
"This is the perl function template. \n");
static GnmFuncHelp help_template[] = {
+#if 0
{ GNM_FUNC_HELP_OLD, help_template_text },
+#endif
{ GNM_FUNC_HELP_END }
};
@@ -161,7 +163,9 @@ gplp_func_desc_load (GOPluginService *service,
res->arg_spec = arg_spec;
res->arg_names = arg_names;
+#if 0
help_template[0].text = help_text ? help_text : help_template_text;
+#endif
res->help = g_slice_dup (GnmFuncHelp, help_template);
res->fn_args = NULL;
diff --git a/plugins/python-loader/python-loader.c b/plugins/python-loader/python-loader.c
index fb91a6d..6f90010 100644
--- a/plugins/python-loader/python-loader.c
+++ b/plugins/python-loader/python-loader.c
@@ -535,12 +535,19 @@ python_function_get_gnumeric_help (PyObject *python_fn_info_dict, PyObject *pyth
if (cobject_help_value == NULL) {
PyObject *python_fn_help = ((PyFunctionObject *) python_fn)->func_doc;
if (python_fn_help != NULL && PyString_Check (python_fn_help)) {
- GnmFuncHelp *new_help = g_new(GnmFuncHelp, 2);
+ GnmFuncHelp *new_help = g_new (GnmFuncHelp, 2);
gchar *help_str = PyString_AsString (python_fn_help);
- new_help[0].type = GNM_FUNC_HELP_OLD;
- new_help[0].text = help_str;
- new_help[1].type = GNM_FUNC_HELP_END;
- new_help[1].text = NULL;
+ int i = 0;
+
+#if 0
+ new_help[i].type = GNM_FUNC_HELP_OLD;
+ new_help[i].text = help_str;
+ i++;
+#endif
+
+ new_help[i].type = GNM_FUNC_HELP_END;
+ new_help[i].text = NULL;
+ i++;
cobject_help_value = PyCObject_FromVoidPtr (new_help, &g_free);
PyDict_SetItemString (python_fn_info_dict, help_attr_name, cobject_help_value);
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index db8f109..b0b3767 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -232,113 +232,6 @@ dialog_function_select_load_tree (FunctionSelectState *state)
}
-static void
-describe_old_style (GtkTextBuffer *description, GnmFunc const *func)
-{
- TokenizedHelp *help = tokenized_help_new (func);
- char const * f_desc = tokenized_help_find (help, "DESCRIPTION");
- char const *f_syntax = tokenized_help_find (help, "SYNTAX");
-
- char const * cursor;
- GString * buf = g_string_new (NULL);
- GtkTextIter start, end;
- GtkTextTag * tag;
- int syntax_length = g_utf8_strlen (f_syntax,-1);
-
- g_string_append (buf, f_syntax);
- g_string_append (buf, "\n\n");
- g_string_append (buf, f_desc);
- gtk_text_buffer_set_text (description, buf->str, -1);
-
- /* Set the syntax Bold */
- tag = gtk_text_buffer_create_tag (description,
- NULL,
- "weight",
- PANGO_WEIGHT_BOLD,
- NULL);
- gtk_text_buffer_get_iter_at_offset (description,
- &start, 0);
- gtk_text_buffer_get_iter_at_offset (description,
- &end, syntax_length);
- gtk_text_buffer_apply_tag (description, tag,
- &start, &end);
- syntax_length += 2;
-
- /* Set the arguments and errors Italic */
- for (cursor = f_desc; *cursor; cursor = g_utf8_next_char (cursor)) {
- int i;
- if (*cursor == '@' || *cursor == '#') {
- int j;
-
- cursor++;
- for (i = 0;
- *cursor && !g_unichar_isspace (g_utf8_get_char (cursor));
- i++)
- cursor = g_utf8_next_char (cursor);
-
- j = g_utf8_pointer_to_offset (f_desc, cursor);
-
- if (i > 0)
- cursor = g_utf8_prev_char (cursor);
-
- tag = gtk_text_buffer_create_tag
- (description,
- NULL, "style",
- PANGO_STYLE_ITALIC, NULL);
- gtk_text_buffer_get_iter_at_offset
- (description, &start,
- j - i + syntax_length);
- gtk_text_buffer_get_iter_at_offset
- (description, &end,
- j + syntax_length);
- gtk_text_buffer_apply_tag
- (description, tag,
- &start, &end);
- } else if (*cursor == '\n' &&
- cursor[1] == '*' &&
- cursor[2] == ' ') {
- int j = g_utf8_pointer_to_offset (f_desc, cursor);
- char const *p;
-
- tag = gtk_text_buffer_create_tag
- (description, NULL,
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
- gtk_text_buffer_get_iter_at_offset
- (description, &start,
- j + 1 + syntax_length);
- gtk_text_buffer_get_iter_at_offset
- (description, &end,
- j + 2 + syntax_length);
- gtk_text_buffer_apply_tag
- (description, tag,
- &start, &end);
-
- /* Make notes to look cooler. */
- p = cursor + 2;
- for (i = 0; *p && *p != '\n'; i++)
- p = g_utf8_next_char (p);
-
- tag = gtk_text_buffer_create_tag
- (description, NULL,
- "scale", 0.85, NULL);
-
- gtk_text_buffer_get_iter_at_offset
- (description,
- &start, j + 1 + syntax_length);
- gtk_text_buffer_get_iter_at_offset
- (description, &end,
- j + i + 1 + syntax_length);
- gtk_text_buffer_apply_tag
- (description, tag,
- &start, &end);
- }
- }
-
- g_string_free (buf, TRUE);
- tokenized_help_destroy (help);
-}
-
static GtkTextTag *
make_link (GtkTextBuffer *description, const char *name,
GCallback cb, gpointer user)
@@ -816,8 +709,6 @@ cb_dialog_function_select_fun_selection_changed (GtkTreeSelection *selection,
if (func->help == NULL)
gtk_text_buffer_set_text (description, "?", -1);
- else if (func->help[0].type == GNM_FUNC_HELP_OLD)
- describe_old_style (description, func);
else
describe_new_style (description, func, state->sheet);
diff --git a/src/func.c b/src/func.c
index 96a7345..c7aabfb 100644
--- a/src/func.c
+++ b/src/func.c
@@ -132,54 +132,6 @@ check_name_match (char const *name, char const *description, char const *tag)
}
static void
-cb_generate_po (gpointer key, Symbol *sym, gpointer array)
-{
- GnmFunc const *fd = sym->data;
- char const *ptr, *tmp;
-
- gnm_func_load_if_stub ((GnmFunc *) fd);
-
- if (fd->help == NULL) {
- g_warning ("'%s' : no help defined", fd->name);
- return;
- }
- if (fd->help[0].type != GNM_FUNC_HELP_OLD) {
- g_warning ("'%s' : wrong type of help '%d' != %d", fd->name,
- fd->help[0].type, GNM_FUNC_HELP_OLD);
- return;
- }
- if (fd->help[0].text == NULL) {
- g_warning ("'%s' : missing help text", fd->name);
- return;
- }
-
- ptr = dgettext ("gnumeric-functions", fd->help[0].text);
- if (NULL == (ptr = check_name_match (fd->name, ptr, "@FUNCTION=")))
- return;
- if (NULL == (ptr = check_name_match (fd->name, ptr, "@SYNTAX=")))
- return;
-
- if (NULL == (tmp = strstr (ptr, "@DESCRIPTION="))) {
- g_printerr ("'%s' : missing @DESCRIPTION section\n", fd->name);
- return;
- }
- if (NULL == (tmp = strstr (ptr, "@EXAMPLES="))) {
- return;
- }
- if (NULL == (tmp = strstr (ptr, "@SEEALSO="))) {
- g_printerr ("'%s' : missing @SEEALSO section\n", fd->name);
- return;
- }
-}
-
-static void
-generate_po (void)
-{
- g_hash_table_foreach (global_symbol_table->hash,
- (GHFunc) cb_generate_po, NULL);
-}
-
-static void
cb_dump_usage (gpointer key, Symbol *sym, FILE *out)
{
if (sym != NULL) {
@@ -293,7 +245,7 @@ function_dump_defs (char const *filename, int dump_type)
GnmFuncGroup const *group = NULL;
if (dump_type == 2) {
- generate_po ();
+ g_printerr ("generate po is obsolete.\n");
return;
}
g_return_if_fail (filename != NULL);
@@ -397,10 +349,6 @@ function_dump_defs (char const *filename, int dump_type)
fd->help[i].type != GNM_FUNC_HELP_END;
i++) {
switch (fd->help[i].type) {
- case GNM_FUNC_HELP_OLD:
- fprintf (output_file, "%s\n",
- _(fd->help[i].text));
- break;
case GNM_FUNC_HELP_NAME: {
char *short_desc;
char *name = split_at_colon (_(fd->help[i].text), &short_desc);
@@ -562,6 +510,32 @@ gnm_func_sanity_check1 (GnmFunc const *fd)
}
}
+#if 0
+ if (counts[GNM_FUNC_HELP_DESCRIPTION] != 1) {
+ g_printerr ("%s: Help has %d descriptions.\n",
+ fd->name, counts[GNM_FUNC_HELP_DESCRIPTION]);
+ res = 1;
+ }
+#endif
+
+ if (counts[GNM_FUNC_HELP_NAME] != 1) {
+ g_printerr ("%s: Help has %d NAME records.\n",
+ fd->name, counts[GNM_FUNC_HELP_NAME]);
+ res = 1;
+ }
+
+ if (counts[GNM_FUNC_HELP_EXCEL] > 1) {
+ g_printerr ("%s: Help has %d Excel notes.\n",
+ fd->name, counts[GNM_FUNC_HELP_EXCEL]);
+ res = 1;
+ }
+
+ if (counts[GNM_FUNC_HELP_ODF] > 1) {
+ g_printerr ("%s: Help has %d ODF notes.\n",
+ fd->name, counts[GNM_FUNC_HELP_ODF]);
+ res = 1;
+ }
+
return res;
}
@@ -1721,49 +1695,6 @@ tokenized_help_new (GnmFunc const *func)
tok->help_copy = NULL;
tok->sections = NULL;
- if (func->help != NULL && func->help[0].type == GNM_FUNC_HELP_OLD) {
- char *ptr, *start;
- gboolean seek_at = TRUE;
- gboolean last_newline = TRUE;
-
-#warning "fixme, use the rest of the pieces and get rid of this routine."
- tok->help_is_localized = TRUE;
- tok->help_copy = g_strdup (dgettext ("gnumeric-functions", func->help[0].text));
- tok->sections = g_ptr_array_new ();
-
- for (start = ptr = tok->help_copy; *ptr ; ptr++) {
- if (ptr[0] == '\\' && ptr[1]) {
- ptr = g_utf8_next_char (ptr + 1);
- continue;
- }
-
- /* FIXME : This is hugely ugly. we need a decent
- * format for this stuff.
- * @SECTION=content is damn ugly considering we
- * are saying things like @r = bob in side the content.
- * for now make the assumption that any args will
- * always start with lower case.
- */
- if (*ptr == '@' &&
- g_unichar_isupper (g_utf8_get_char (ptr + 1)) &&
- seek_at && last_newline) {
- /* previous newline if this is not the first */
- if (ptr != start)
- *(ptr-1) = '\0';
- else
- *ptr = '\0';
-
- g_ptr_array_add (tok->sections, (ptr+1));
- seek_at = FALSE;
- } else if (*ptr == '=' && !seek_at){
- *ptr = 0;
- g_ptr_array_add (tok->sections, (ptr+1));
- seek_at = TRUE;
- }
- last_newline = (*ptr == '\n');
- }
- }
-
return tok;
}
diff --git a/src/func.h b/src/func.h
index becc5fa..62d2f23 100644
--- a/src/func.h
+++ b/src/func.h
@@ -135,8 +135,6 @@ typedef gboolean (*GnmFuncLoadDesc) (GnmFunc const *f, GnmFuncDescriptor *fd);
typedef enum {
GNM_FUNC_HELP_END, /* Format */
/* ------ */
- GNM_FUNC_HELP_OLD, /* old token based format */
-
GNM_FUNC_HELP_NAME,
/* <NAME>:<1 SENTENCE DESCRIPTION> (translated) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]