1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 * Copyright 2000, 2001, Ximian, Inc.
7 * Chris Lahey <clahey@ximian.com>
9 * Modified for gLabels by:
10 * Jim Evins <evins@snaught.com>
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public
14 * License, version 2, as published by the Free Software Foundation.
16 * This library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30 #include <sys/types.h>
31 #include <glib-object.h>
37 #endif /* __cplusplus */
39 #include "e-marshal.h"
41 #define E_MAKE_TYPE(l,str,t,ci,i,parent) \
42 GType l##_get_type(void)\
44 static GType type = 0; \
46 static GTypeInfo const object_info = { \
49 (GBaseInitFunc) NULL, \
50 (GBaseFinalizeFunc) NULL, \
52 (GClassInitFunc) ci, \
53 (GClassFinalizeFunc) NULL, \
54 NULL, /* class_data */ \
57 0, /* n_preallocs */ \
58 (GInstanceInitFunc) i, \
60 type = g_type_register_static (parent, str, &object_info, 0); \
66 #define E_MAKE_X_TYPE(l,str,t,ci,i,parent,poa_init,offset) \
67 GtkType l##_get_type(void) \
69 static GtkType type = 0; \
74 (GBaseInitFunc) NULL, \
75 (GBaseFinalizeFunc) NULL, \
77 (GClassInitFunc) ci, \
78 (GClassFinalizeFunc) NULL, \
80 NULL, /* class_data */ \
83 0, /* n_preallocs */ \
84 (GInstanceInitFunc) i, \
86 type = bonobo_x_type_unique ( \
87 parent, poa_init, NULL, \
88 offset, &info, str); \
93 #define GET_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
99 va_start (args, (first_string)); \
102 for (s = (first_string); s; s = va_arg (args, char *)) \
106 (labels) = g_new (char *, i + 1); \
108 va_start (args, (first_string)); \
110 for (s = (first_string); s; s = va_arg (args, char *)) \
114 (labels)[i] = NULL; \
118 #define GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
121 GET_STRING_ARRAY_FROM_ELLIPSIS ((labels), (first_string)); \
122 for (i = 0; labels[i]; i++) \
123 labels[i] = g_strdup (labels[i]); \
128 # define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last) \
129 gtk_object_class_add_signals (oc, sigs, last)
130 # define E_OBJECT_CLASS_TYPE(oc) (oc)->type
132 # define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last)
133 # define E_OBJECT_CLASS_TYPE(oc) G_TYPE_FROM_CLASS (oc)
143 int g_str_compare (const void *x,
145 int g_collate_compare (const void *x,
147 int g_int_compare (const void *x,
149 char *e_strdup_strip (const char *string);
150 void e_free_object_list (GList *list);
151 void e_free_object_slist (GSList *list);
152 void e_free_string_list (GList *list);
153 void e_free_string_slist (GSList *list);
154 char *e_read_file (const char *filename);
155 int e_write_file (const char *filename,
158 int e_write_file_mkstemp (char *filename,
160 int e_mkdir_hier (const char *path,
163 gchar **e_strsplit (const gchar *string,
164 const gchar *delimiter,
166 gchar *e_strstrcase (const gchar *haystack,
167 const gchar *needle);
168 /* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */
169 void e_filename_make_safe (gchar *string);
170 gchar *e_format_number (gint number);
171 gchar *e_format_number_float (gfloat number);
172 gboolean e_create_directory (gchar *directory);
173 gchar **e_strdupv (const gchar **str_array);
176 typedef int (*ESortCompareFunc) (const void *first,
179 void e_sort (void *base,
182 ESortCompareFunc compare,
184 void e_bsearch (const void *key,
188 ESortCompareFunc compare,
192 size_t e_strftime_fix_am_pm (char *s,
195 const struct tm *tm);
197 size_t e_strftime (char *s,
200 const struct tm *tm);
202 size_t e_utf8_strftime_fix_am_pm (char *s,
205 const struct tm *tm);
207 size_t e_utf8_strftime (char *s,
210 const struct tm *tm);
212 /* String to/from double conversion functions */
213 gdouble e_flexible_strtod (const gchar *nptr,
216 /* 29 bytes should enough for all possible values that
217 * g_ascii_dtostr can produce with the %.17g format.
218 * Then add 10 for good measure */
219 #define E_ASCII_DTOSTR_BUF_SIZE (DBL_DIG + 12 + 10)
220 gchar *e_ascii_dtostr (gchar *buffer,
225 /* Alternating char * and int arguments with a NULL char * to end.
226 Less than 0 for the int means copy the whole string. */
227 gchar *e_strdup_append_strings (gchar *first_string,
232 #endif /* __cplusplus */
234 #endif /* _E_UTIL_H_ */