Commit b0b2e5ba authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Improve function tooltips and remove some unneccessary tests from configure

 2010-07-19 Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* dao.c: delete HAVE_G_DATE_SET_TIME_T throughout

2010-07-19  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* configure.in: checks for g_date_set_time_t and g_slice_alloc have
	  been superceded by the glib 2.12 requirement; check for
	  g_hash_table_get_keys
	* src/dependent.c: remove HAVE_G_SLICE_ALLOC throughout
	* src/func.c (gnm_func_lookup_prefix): new
	* src/func.h (gnm_func_lookup_prefix): new
	* src/rendered-value.c: remove HAVE_G_SLICE_ALLOC throughout
	* src/symbol.c (symbol_names): new
	* src/symbol.h (symbol_names): new
	* src/value.c: remove HAVE_G_SLICE_ALLOC throughout

2010-07-19  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* gnumeric-expr-entry.c (gee_set_tooltip): We can have a tooltip without
	  function descriptor
	(gee_set_tooltip_completion): new
	(gee_check_tooltip): if we are typing what might be a function name
	  provide suggestions
parent 320f5fef
2010-07-19 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* configure.in: checks for g_date_set_time_t and g_slice_alloc have
been superceded by the glib 2.12 requirement; check for
g_hash_table_get_keys
* src/dependent.c: remove HAVE_G_SLICE_ALLOC throughout
* src/func.c (gnm_func_lookup_prefix): new
* src/func.h (gnm_func_lookup_prefix): new
* src/rendered-value.c: remove HAVE_G_SLICE_ALLOC throughout
* src/symbol.c (symbol_names): new
* src/symbol.h (symbol_names): new
* src/value.c: remove HAVE_G_SLICE_ALLOC throughout
2010-07-18 Morten Welinder <terra@gnome.org>
* src/wbc-gtk-edit.c (attrs_at_byte): Fix signedness problem.
......
......@@ -687,7 +687,7 @@ SAVE_LIBS=$LIBS
CFLAGS="$CFLAGS $GNUMERIC_CFLAGS"
LIBS="$GNUMERIC_LIBS $LIBS"
AC_CHECK_FUNCS(g_date_set_time_t g_slice_alloc g_option_context_set_delocalize)
AC_CHECK_FUNCS(g_option_context_set_delocalize g_hash_table_get_keys)
AC_CHECK_FUNCS(pango_font_map_create_context)
AC_CHECK_FUNCS(gtk_orientable_set_orientation gtk_adjustment_configure gtk_widget_set_visible gtk_widget_get_state gtk_widget_is_toplevel gtk_widget_get_window gsf_open_pkg_foreach_rel gtk_dialog_get_content_area gtk_entry_get_buffer gtk_widget_get_can_focus gtk_entry_get_text_length gtk_entry_set_icon_from_stock gtk_layout_get_bin_window gtk_widget_get_allocation)
AC_CHECK_FUNCS(gsf_infile_msvba_steal_modules)
......
......@@ -37,14 +37,9 @@
#include <stdio.h>
#include <string.h>
#ifdef HAVE_G_SLICE_ALLOC
#define g_slice_new_array0(T,c) ((T*) g_slice_alloc0 ((sizeof (T))*(c)))
#define ALLOC_ARRAY(T,c) (g_slice_new_array0 (T,c))
#define FREE_ARRAY(p,c) (g_slice_free1 (sizeof(*p)*(c),(p)))
#else
#define ALLOC_ARRAY(T,c) (g_new0 (T,c))
#define FREE_ARRAY(p,c) (g_free ((p)))
#endif
static char * pascal_string_from_c_string(const char *s){
char *o=NULL;
......
......@@ -50,14 +50,9 @@
#include <sys/mman.h>
#endif
#if defined( HAVE_G_SLICE_ALLOC )
#define g_slice_new_array0(T,c) ((T*) g_slice_alloc0 ((sizeof (T))*(c)))
#define ALLOC_ARRAY(T,c) ( g_slice_new_array0 (T,c) )
#define FREE_ARRAY(p,c) ( g_slice_free1 (sizeof(*p)*(c),(p)) )
#else
#define ALLOC_ARRAY(T,c) ( g_new0 (T,c) )
#define FREE_ARRAY(p,c) ( g_free ((p)) )
#endif
GNM_PLUGIN_MODULE_HEADER;
......
......@@ -52,11 +52,7 @@ static void dependent_changed (GnmDependent *dep);
*/
#ifndef USE_STRING_POOLS
#ifdef HAVE_G_SLICE_ALLOC
#define USE_POOLS 0
#else
#define USE_POOLS 1
#endif
#endif
#if USE_POOLS
......@@ -68,19 +64,11 @@ static GOMemChunk *cset_pool;
#define NEW_FEW CHUNK_ALLOC (gpointer, micro_few_pool)
#define FREE_FEW(p) CHUNK_FREE (micro_few_pool, p)
#else
#ifdef HAVE_G_SLICE_ALLOC
#define CHUNK_ALLOC(T,c) g_slice_new (T)
#define CHUNK_FREE(p,v) g_slice_free1 (sizeof(*v),(v))
#define MICRO_HASH_FEW 4 /* Even and small. */
#define NEW_FEW (gpointer *)g_slice_alloc (MICRO_HASH_FEW * sizeof (gpointer))
#define FREE_FEW(p) g_slice_free1 (MICRO_HASH_FEW * sizeof (gpointer), p)
#else
#define CHUNK_ALLOC(T,c) g_new (T,1)
#define CHUNK_FREE(p,v) g_free ((v))
#define MICRO_HASH_FEW 3 /* Who cares? */
#define NEW_FEW g_new (gpointer, MICRO_HASH_FEW)
#define FREE_FEW(p) CHUNK_FREE (micro_few_pool, p)
#endif
#endif
/* ------------------------------------------------------------------------- */
......
......@@ -963,6 +963,14 @@ gnm_func_lookup (char const *name, Workbook *scope)
return g_hash_table_lookup (scope->sheet_local_functions, (gpointer)name);
}
GSList *
gnm_func_lookup_prefix (char const *prefix, Workbook *scope)
{
GSList *list = symbol_names (global_symbol_table, NULL, prefix);
return list;
}
GnmFunc *
gnm_func_add (GnmFuncGroup *fn_group,
GnmFuncDescriptor const *desc,
......
......@@ -230,6 +230,7 @@ char const *gnm_func_get_name (GnmFunc const *fn_def);
gpointer gnm_func_get_user_data (GnmFunc const *func);
void gnm_func_set_user_data (GnmFunc *func, gpointer user_data);
GnmFunc *gnm_func_lookup (char const *name, Workbook *scope); /* change scope one day */
GSList *gnm_func_lookup_prefix (char const *prefix, Workbook *scope);
GnmFunc *gnm_func_add (GnmFuncGroup *group,
GnmFuncDescriptor const *descriptor,
const char *textdomain);
......
......@@ -46,11 +46,7 @@
#undef DEBUG_BOUNDING_BOX
#ifndef USE_RV_POOLS
#ifdef HAVE_G_SLICE_ALLOC
#define USE_RV_POOLS 0
#else
#define USE_RV_POOLS 1
#endif
#endif
#if USE_RV_POOLS
......@@ -61,13 +57,8 @@ static GOMemChunk *rendered_rotated_value_pool;
#define CHUNK_FREE(p,v) go_mem_chunk_free ((p), (v))
#else
static int rv_allocations;
#ifdef HAVE_G_SLICE_ALLOC
#define CHUNK_ALLOC(T,c) (rv_allocations++, g_slice_new (T))
#define CHUNK_FREE(p,v) (rv_allocations--, g_slice_free1 (sizeof(*v),(v)))
#else
#define CHUNK_ALLOC(T,c) (rv_allocations++, g_new (T,1))
#define CHUNK_FREE(p,v) (rv_allocations--, g_free ((v)))
#endif
#endif
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Symbol management for the Gnumeric spreadsheet
*
......@@ -30,6 +31,22 @@ symbol_lookup (SymbolTable *st, char const *str)
return sym;
}
GSList *
symbol_names (SymbolTable *st, GSList *list, char const *prefix)
{
#ifdef HAVE_G_HASH_TABLE_GET_KEYS
GList *l = g_hash_table_get_keys (st->hash), *lc;
for (lc = l; lc != NULL; lc = lc->next) {
if (g_str_has_prefix (lc->data, prefix))
list = g_slist_prepend (list, lc->data);
}
g_list_free (l);
#endif
return list;
}
/**
* symbol_install:
*
......
......@@ -26,6 +26,7 @@ void symbol_table_destroy (SymbolTable *st);
Symbol *symbol_lookup (SymbolTable *st, char const *str);
Symbol *symbol_install (SymbolTable *st, char const *str,
SymbolType type, void *data);
GSList *symbol_names (SymbolTable *st, GSList *list, char const *prefix);
void symbol_ref (Symbol *sym);
void symbol_unref (Symbol *sym);
......
2010-07-19 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* dao.c: delete HAVE_G_DATE_SET_TIME_T throughout
2010-07-12 Jean Brefort <jean.brefort@normalesup.org>
* Makefile.am: install a self-consistent headers list.
......
......@@ -974,15 +974,8 @@ dao_append_date (GString *buf)
gchar *tmp;
time_t now;
#ifdef HAVE_G_DATE_SET_TIME_T
now = time (NULL);
g_date_set_time_t (&date, now);
#else
GTimeVal t;
g_get_current_time (&t);
now = t.tv_sec;
g_date_set_time (&date, t.tv_sec);
#endif
g_date_to_struct_tm (&date, &tm_s);
tm_s.tm_sec = now % 60;
tm_s.tm_min = (now / 60) % 60;
......
......@@ -34,11 +34,7 @@
#include <string.h>
#ifndef USE_VALUE_POOLS
#ifdef HAVE_G_SLICE_ALLOC
#define USE_VALUE_POOLS 0
#else
#define USE_VALUE_POOLS 1
#endif
#endif
#if USE_VALUE_POOLS
......@@ -51,13 +47,8 @@ static GOMemChunk *value_array_pool;
#define CHUNK_FREE(p,v) go_mem_chunk_free ((p), (v))
#else
static int value_allocations = 0;
#ifdef HAVE_G_SLICE_ALLOC
#define CHUNK_ALLOC(T,c) (value_allocations++, g_slice_new (T))
#define CHUNK_FREE(p,v) (value_allocations--, g_slice_free1 (sizeof(*v),(v)))
#else
#define CHUNK_ALLOC(T,c) (value_allocations++, g_new (T,1))
#define CHUNK_FREE(p,v) (value_allocations--, g_free ((v)))
#endif
#endif
......
2010-07-19 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* gnumeric-expr-entry.c (gee_set_tooltip): We can have a tooltip without
function descriptor
(gee_set_tooltip_completion): new
(gee_check_tooltip): if we are typing what might be a function name
provide suggestions
2010-07-19 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* gnumeric-expr-entry.c (gee_check_tooltip): fix the check for unclosed
......
......@@ -45,6 +45,7 @@
#define UNICODE_RIGHT_TRIANGLE "\xe2\x96\xb6"
#define UNICODE_CROSS_AND_SKULLBONES "\xe2\x98\xa0"
#define UNICODE_ELLIPSIS "\xe2\x80\xa6"
#define UNICODE_ELLIPSIS_VERT "\xe2\x8b\xae"
#warning We should replace these token names with the correct values
enum yytokentype {
......@@ -687,12 +688,11 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd, gint args, gboolean had_stuff)
gnm_func_load_if_stub (fd);
function_def_count_args (fd, &min, &max);
if (gee->tooltip.fd) {
if (gee->tooltip.fd == fd && gee->tooltip.args == args
&& gee->tooltip.had_stuff == (max == 0 && args == 0 && had_stuff))
if ((gee->tooltip.fd)
&& (gee->tooltip.fd == fd && gee->tooltip.args == args
&& gee->tooltip.had_stuff == (max == 0 && args == 0 && had_stuff)))
return;
gee_delete_tooltip (gee);
}
gee_delete_tooltip (gee);
gee->tooltip.fd = fd;
gnm_func_ref (gee->tooltip.fd);
......@@ -752,6 +752,32 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd, gint args, gboolean had_stuff)
g_string_free (str, TRUE);
}
static void
gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list)
{
GString *str;
guint i = 0;
guint max = 10;
gee_delete_tooltip (gee);
str = g_string_new (NULL);
while (list != NULL) {
g_string_append (str, list->data);
i++;
list = list->next;
if (list != NULL) {
g_string_append_c (str, '\n');
if (i == max) {
g_string_append (str, UNICODE_ELLIPSIS_VERT);
break;
}
}
}
gee->tooltip.tooltip = gee_create_tooltip (gee, str->str);
g_string_free (str, TRUE);
}
static void
gee_dump_lexer (GnmLexerItem *gli) {
g_print ("************\n");
......@@ -807,6 +833,29 @@ gee_check_tooltip (GnmExprEntry *gee)
}
gli--;
/* This creates the completion tooltip */
if (gli->start > 0 && gli->token == STRING) {
gint start_t = gli->start;
gint end_t = gli->end;
if (end_t - start_t > 1) {
char *prefix = g_strndup (str + start_t,
end_t - start_t);
GSList *list = gnm_func_lookup_prefix
(prefix, gee->sheet->workbook);
g_free (prefix);
if (list != NULL) {
list = g_slist_sort
(list,
(GCompareFunc)g_utf8_collate);
gee_set_tooltip_completion (gee, list);
g_slist_free (list);
g_free (str);
g_free (gli_c);
return;
}
}
}
while (gli->start > 1) {
switch (gli->token) {
case TOKEN_PARENTHESIS_OPEN:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment