[goffice] delete *_build_in and use your own hash in goffice/gtk/go-format-sel.c
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] delete *_build_in and use your own hash in goffice/gtk/go-format-sel.c
- Date: Thu, 8 Sep 2011 17:38:34 +0000 (UTC)
commit c16c4056e962aa20e04346733922c44a25de6f28
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Sep 8 11:36:09 2011 -0600
delete *_build_in and use your own hash in goffice/gtk/go-format-sel.c
2011-09-08 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.h (go_format_set_build_in): deleted again
(go_format_is_build_in): deleted again
* goffice/utils/go-format.c (go_format_set_build_in): deleted again
(go_format_is_build_in): deleted again
* goffice/gtk/go-format-sel.c (fmt_dialog_init_fmt_list): add argument
and store seen formats in hash
(fmt_dialog_load_true_custom_cb): check hash not, built_in flag
ChangeLog | 10 ++++++++++
goffice/gtk/go-format-sel.c | 23 +++++++++++++++--------
goffice/utils/go-format.c | 23 -----------------------
goffice/utils/go-format.h | 2 --
4 files changed, 25 insertions(+), 33 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 89c7e13..9ba5baa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-09-08 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * goffice/utils/go-format.h (go_format_set_build_in): deleted again
+ (go_format_is_build_in): deleted again
+ * goffice/utils/go-format.c (go_format_set_build_in): deleted again
+ (go_format_is_build_in): deleted again
+ * goffice/gtk/go-format-sel.c (fmt_dialog_init_fmt_list): add argument
+ and store seen formats in hash
+ (fmt_dialog_load_true_custom_cb): check hash not, built_in flag
+
2011-09-08 Morten Welinder <terra gnome org>
* configure.in: Switch to AM_MAINTAINER_MODE([enable])
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index bf39192..a6162f0 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -554,7 +554,7 @@ cb_fraction_automatic_toggle (GtkWidget *w, GOFormatSel *gfs)
static void
fmt_dialog_init_fmt_list (GOFormatSel *gfs, char const *const *formats,
- GtkTreeIter *select)
+ GtkTreeIter *select, GHashTable *fhash)
{
GOFormatMagic cur_magic = go_format_get_magic (gfs->format.spec);
@@ -565,12 +565,12 @@ fmt_dialog_init_fmt_list (GOFormatSel *gfs, char const *const *formats,
GOFormatMagic magic = go_format_get_magic (f);
gboolean found;
- go_format_set_build_in (f, TRUE);
-
gtk_list_store_append (gfs->format.formats.model, &iter);
gtk_list_store_set (gfs->format.formats.model, &iter,
0, fmt, -1);
g_free (fmt);
+ if (fhash)
+ g_hash_table_insert (fhash, *formats, GINT_TO_POINTER (1));
/* Magic formats are fully defined by their magic. */
found = cur_magic
@@ -617,6 +617,7 @@ find_builtin (const char *fmtstr, int page, gboolean def)
typedef struct {
GOFormatSel *gfs;
GtkTreeIter *select;
+ GHashTable *hash;
} fmt_dialog_closure_t;
static void
@@ -625,7 +626,7 @@ fmt_dialog_load_true_custom_cb (char const *key, GOFormat const *fmt,
{
GtkTreeIter iter;
char *fmt_string;
- if (go_format_is_build_in (fmt))
+ if (cl->hash != NULL && NULL != g_hash_table_lookup (cl->hash, key))
return;
fmt_string = go_format_str_localize (key);
gtk_list_store_insert_with_values (cl->gfs->format.formats.model, &iter,
@@ -817,6 +818,10 @@ stays:
case F_LIST: {
int start = 0, end = -1;
GtkTreeIter select;
+ GHashTable *fhash = NULL;
+
+ if (page == FMT_CUSTOM)
+ fhash = g_hash_table_new (g_str_hash, g_str_equal);
switch (page) {
default :
@@ -834,15 +839,17 @@ stays:
select.stamp = 0;
gtk_list_store_clear (gfs->format.formats.model);
for (; start <= end ; ++start)
- fmt_dialog_init_fmt_list (gfs,
- _go_format_builtins[start], &select);
+ fmt_dialog_init_fmt_list (gfs, _go_format_builtins[start],
+ &select, fhash);
if (page == FMT_CUSTOM) {
- fmt_dialog_closure_t cl = {gfs, &select};
-
+ fmt_dialog_closure_t cl = {gfs, &select, fhash};
go_format_foreach ((GHFunc)fmt_dialog_load_true_custom_cb, &cl);
}
+ if (fhash)
+ g_hash_table_unref (fhash);
+
/* If this is the custom page and the format has
* not been found append it */
if (page == FMT_CUSTOM && select.stamp == 0) {
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index c4bf4d7..a192ed7 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -317,8 +317,6 @@ struct _GOFormat {
unsigned int ref_count : 24;
GOColor color;
unsigned int has_fill : 7;
- /* Note: is_build_in is only set by the format selector! */
- unsigned int is_build_in : 1;
GOFormatMagic magic;
char *format;
union {
@@ -1206,8 +1204,6 @@ go_format_create (GOFormatClass cl, const char *format)
fmt->typ = cl;
fmt->ref_count = 1;
fmt->format = g_strdup (format);
- /* Note: is_build_in is only set to TRUE by the format selector! */
- fmt->is_build_in = FALSE;
return fmt;
}
@@ -5265,25 +5261,6 @@ go_format_is_var_width (GOFormat const *fmt)
#endif
#ifdef DEFINE_COMMON
-void
-go_format_set_build_in (GOFormat *fmt, gboolean build_in)
-{
- g_return_if_fail (fmt != NULL);
- fmt->is_build_in = build_in;
-}
-#endif
-
-#ifdef DEFINE_COMMON
-gboolean
-go_format_is_build_in (GOFormat const *fmt)
-{
- g_return_val_if_fail (fmt != NULL, TRUE);
- /* Note: is_build_in is only set by the format selector! */
- return fmt->is_build_in;
-}
-#endif
-
-#ifdef DEFINE_COMMON
/**
* go_format_is_date:
* @fmt: Format to query
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 4312e24..ddc517f 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -143,7 +143,6 @@ void go_render_generall (PangoLayout *layout, GString *str,
/*************************************************************************/
GOFormat *go_format_new_from_XL (char const *str);
-void go_format_set_build_in (GOFormat *fmt, gboolean build_in);
GOFormat *go_format_new_markup (PangoAttrList *markup, gboolean add_ref);
/* these do not add a reference to the result */
@@ -186,7 +185,6 @@ gboolean go_format_is_text (GOFormat const *fmt);
gboolean go_format_is_var_width (GOFormat const *fmt);
int go_format_is_date (GOFormat const *fmt);
int go_format_is_time (GOFormat const *fmt);
-gboolean go_format_is_build_in (GOFormat const *fmt);
int go_format_month_before_day (GOFormat const *fmt);
gboolean go_format_has_hour (GOFormat const *fmt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]