Bug 776391 - Disable WebKit developer mode by default
[evolution.git] / src / e-util / e-misc-utils.h
blob4a0835192246affd13c4639260d5b8480033c1b9
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published by
4 * the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful, but
7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 * Authors:
16 * Chris Lahey <clahey@ximian.com>
18 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
22 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
23 #error "Only <e-util/e-util.h> should be included directly."
24 #endif
26 #ifndef E_MISC_UTILS_H
27 #define E_MISC_UTILS_H
29 #include <sys/types.h>
30 #include <gtk/gtk.h>
31 #include <limits.h>
33 #include <libedataserver/libedataserver.h>
35 #include <e-util/e-marshal.h>
36 #include <e-util/e-util-enums.h>
38 G_BEGIN_DECLS
40 typedef enum {
41 E_FOCUS_NONE,
42 E_FOCUS_CURRENT,
43 E_FOCUS_START,
44 E_FOCUS_END
45 } EFocus;
47 typedef enum {
48 E_RESTORE_WINDOW_SIZE = 1 << 0,
49 E_RESTORE_WINDOW_POSITION = 1 << 1
50 } ERestoreWindowFlags;
52 typedef void (*EForeachFunc) (gint model_row,
53 gpointer closure);
55 const gchar * e_get_accels_filename (void);
56 void e_show_uri (GtkWindow *parent,
57 const gchar *uri);
58 void e_display_help (GtkWindow *parent,
59 const gchar *link_id);
60 void e_restore_window (GtkWindow *window,
61 const gchar *settings_path,
62 ERestoreWindowFlags flags);
63 GtkAction * e_lookup_action (GtkUIManager *ui_manager,
64 const gchar *action_name);
65 GtkActionGroup *e_lookup_action_group (GtkUIManager *ui_manager,
66 const gchar *group_name);
67 gint e_action_compare_by_label (GtkAction *action1,
68 GtkAction *action2);
69 void e_action_group_remove_all_actions
70 (GtkActionGroup *action_group);
71 GtkRadioAction *e_radio_action_get_current_action
72 (GtkRadioAction *radio_action);
73 void e_action_group_add_actions_localized
74 (GtkActionGroup *action_group,
75 const gchar *translation_domain,
76 const GtkActionEntry *entries,
77 guint n_entries,
78 gpointer user_data);
79 GtkWidget * e_builder_get_widget (GtkBuilder *builder,
80 const gchar *widget_name);
81 void e_load_ui_builder_definition (GtkBuilder *builder,
82 const gchar *basename);
83 guint e_load_ui_manager_definition (GtkUIManager *ui_manager,
84 const gchar *basename);
85 void e_categories_add_change_hook (GHookFunc func,
86 gpointer object);
88 /* String to/from double conversion functions */
89 gdouble e_flexible_strtod (const gchar *nptr,
90 gchar **endptr);
92 /* 29 bytes should enough for all possible values that
93 * g_ascii_dtostr can produce with the %.17g format.
94 * Then add 10 for good measure */
95 #define E_ASCII_DTOSTR_BUF_SIZE (DBL_DIG + 12 + 10)
96 gchar * e_ascii_dtostr (gchar *buffer,
97 gint buf_len,
98 const gchar *format,
99 gdouble d);
101 gchar * e_str_without_underscores (const gchar *string);
102 GString * e_str_replace_string (const gchar *text,
103 const gchar *find,
104 const gchar *replace);
105 gint e_str_compare (gconstpointer x,
106 gconstpointer y);
107 gint e_str_case_compare (gconstpointer x,
108 gconstpointer y);
109 gint e_collate_compare (gconstpointer x,
110 gconstpointer y);
111 gint e_int_compare (gconstpointer x,
112 gconstpointer y);
113 guint32 e_color_to_value (const GdkColor *color);
115 guint32 e_rgba_to_value (const GdkRGBA *rgba);
117 void e_rgba_to_color (const GdkRGBA *rgba,
118 GdkColor *color);
120 void e_utils_get_theme_color (GtkWidget *widget,
121 const gchar *color_names,
122 const gchar *fallback_color_ident,
123 GdkRGBA *rgba);
125 void e_utils_get_theme_color_color (GtkWidget *widget,
126 const gchar *color_names,
127 const gchar *fallback_color_ident,
128 GdkColor *color);
130 #define E_UTILS_LIGHTNESS_MULT 1.3
131 #define E_UTILS_DARKNESS_MULT 0.7
132 #define E_UTILS_DEFAULT_THEME_BG_COLOR "#AAAAAA"
133 #define E_UTILS_DEFAULT_THEME_BASE_COLOR "#FFFFFF"
134 #define E_UTILS_DEFAULT_THEME_FG_COLOR "#000000"
135 #define E_UTILS_DEFAULT_THEME_TEXT_COLOR "#000000"
136 #define E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR "#729fcf"
137 #define E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR "#000000"
138 #define E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_BG_COLOR "#808080"
139 #define E_UTILS_DEFAULT_THEME_UNFOCUSED_SELECTED_FG_COLOR "#000000"
141 void e_utils_shade_color (const GdkRGBA *a,
142 GdkRGBA *b,
143 gdouble mult);
145 /* This only makes a filename safe for usage as a filename.
146 * It still may have shell meta-characters in it. */
147 gchar * e_format_number (gint number);
149 typedef gint (*ESortCompareFunc) (gconstpointer first,
150 gconstpointer second,
151 gpointer closure);
153 void e_bsearch (gconstpointer key,
154 gconstpointer base,
155 gsize nmemb,
156 gsize size,
157 ESortCompareFunc compare,
158 gpointer closure,
159 gsize *start,
160 gsize *end);
162 gsize e_strftime_fix_am_pm (gchar *str,
163 gsize max,
164 const gchar *fmt,
165 const struct tm *tm);
166 gsize e_utf8_strftime_fix_am_pm (gchar *str,
167 gsize max,
168 const gchar *fmt,
169 const struct tm *tm);
170 gsize e_utf8_strftime_match_lc_messages
171 (gchar *string,
172 gsize max,
173 const gchar *fmt,
174 const struct tm *tm);
175 const gchar * e_get_month_name (GDateMonth month,
176 gboolean abbreviated);
177 const gchar * e_get_weekday_name (GDateWeekday weekday,
178 gboolean abbreviated);
179 GDateWeekday e_weekday_get_next (GDateWeekday weekday);
180 GDateWeekday e_weekday_get_prev (GDateWeekday weekday);
181 GDateWeekday e_weekday_add_days (GDateWeekday weekday,
182 guint n_days);
183 GDateWeekday e_weekday_subtract_days (GDateWeekday weekday,
184 guint n_days);
185 guint e_weekday_get_days_between (GDateWeekday weekday1,
186 GDateWeekday weekday2);
187 gint e_weekday_to_tm_wday (GDateWeekday weekday);
188 GDateWeekday e_weekday_from_tm_wday (gint tm_wday);
190 gboolean e_file_lock_create (void);
191 void e_file_lock_destroy (void);
192 gboolean e_file_lock_exists (void);
193 GPid e_file_lock_get_pid (void);
195 gchar * e_util_guess_mime_type (const gchar *filename,
196 gboolean localfile);
198 GSList * e_util_get_category_filter_options
199 (void);
200 GList * e_util_dup_searchable_categories (void);
202 gboolean e_util_get_open_source_job_info (const gchar *extension_name,
203 const gchar *source_display_name,
204 gchar **description,
205 gchar **alert_ident,
206 gchar **alert_arg_0);
207 struct _EAlertSinkThreadJobData;
208 void e_util_propagate_open_source_job_error
209 (struct _EAlertSinkThreadJobData *job_data,
210 const gchar *extension_name,
211 GError *local_error,
212 GError **error);
213 struct _EClientCache;
214 EClient * e_util_open_client_sync (struct _EAlertSinkThreadJobData *job_data,
215 struct _EClientCache *client_cache,
216 const gchar *extension_name,
217 ESource *source,
218 guint32 wait_for_connected_seconds,
219 GCancellable *cancellable,
220 GError **error);
222 /* Useful GBinding transform functions */
223 gboolean e_binding_transform_color_to_string
224 (GBinding *binding,
225 const GValue *source_value,
226 GValue *target_value,
227 gpointer not_used);
228 gboolean e_binding_transform_string_to_color
229 (GBinding *binding,
230 const GValue *source_value,
231 GValue *target_value,
232 gpointer not_used);
233 gboolean e_binding_transform_source_to_uid
234 (GBinding *binding,
235 const GValue *source_value,
236 GValue *target_value,
237 ESourceRegistry *registry);
238 gboolean e_binding_transform_uid_to_source
239 (GBinding *binding,
240 const GValue *source_value,
241 GValue *target_value,
242 ESourceRegistry *registry);
244 gboolean e_binding_transform_text_non_null
245 (GBinding *binding,
246 const GValue *source_value,
247 GValue *target_value,
248 gpointer user_data);
250 GBinding * e_binding_bind_object_text_property
251 (gpointer source,
252 const gchar *source_property,
253 gpointer target,
254 const gchar *target_property,
255 GBindingFlags flags);
257 gulong e_signal_connect_notify (gpointer instance,
258 const gchar *notify_name,
259 GCallback c_handler,
260 gpointer user_data);
261 gulong e_signal_connect_notify_after (gpointer instance,
262 const gchar *notify_name,
263 GCallback c_handler,
264 gpointer user_data);
265 gulong e_signal_connect_notify_swapped (gpointer instance,
266 const gchar *notify_name,
267 GCallback c_handler,
268 gpointer user_data);
269 gulong e_signal_connect_notify_object (gpointer instance,
270 const gchar *notify_name,
271 GCallback c_handler,
272 gpointer gobject,
273 GConnectFlags connect_flags);
274 void e_signal_disconnect_notify_handler
275 (gpointer instance,
276 gulong *handler_id);
278 GSettings * e_util_ref_settings (const gchar *schema_id);
279 void e_util_cleanup_settings (void);
280 gboolean e_util_prompt_user (GtkWindow *parent,
281 const gchar *settings_schema,
282 const gchar *promptkey,
283 const gchar *tag,
284 ...);
285 void e_util_run_simple_async_result_in_thread
286 (GSimpleAsyncResult *simple,
287 GSimpleAsyncThreadFunc func,
288 GCancellable *cancellable);
289 gboolean e_util_is_running_gnome (void);
290 void e_util_set_entry_issue_hint (GtkWidget *entry,
291 const gchar *hint);
293 guint e_util_normalize_font_size (GtkWidget *widget,
294 gdouble font_size);
295 void e_util_init_main_thread (GThread *thread);
296 gboolean e_util_is_main_thread (GThread *thread);
297 gchar * e_util_save_image_from_clipboard
298 (GtkClipboard *clipboard);
299 gboolean e_util_check_gtk_bindings_in_key_press_event_cb
300 (GtkWidget *widget,
301 GdkEvent *event);
302 void e_util_claim_dbus_proxy_call_error
303 (GDBusProxy *dbus_proxy,
304 const gchar *method_name,
305 const GError *in_error);
306 void e_util_invoke_g_dbus_proxy_call_with_error_check
307 (GDBusProxy *dbus_proxy,
308 const gchar *method_name,
309 GVariant *parameters,
310 GCancellable *cancellable);
311 void e_util_invoke_g_dbus_proxy_call_with_error_check_full
312 (GDBusProxy *dbus_proxy,
313 const gchar *method_name,
314 GVariant *parameters,
315 GDBusCallFlags flags,
316 gint timeout_msec,
317 GCancellable *cancellable);
318 GVariant * e_util_invoke_g_dbus_proxy_call_sync_wrapper_with_error_check
319 (GDBusProxy *dbus_proxy,
320 const gchar *method_name,
321 GVariant *parameters,
322 GCancellable *cancellable);
323 GVariant * e_util_invoke_g_dbus_proxy_call_sync_wrapper_full
324 (GDBusProxy *dbus_proxy,
325 const gchar *method_name,
326 GVariant *parameters,
327 GDBusCallFlags flags,
328 gint timeout_msec,
329 GCancellable *cancellable,
330 GError **error);
331 void e_util_save_file_chooser_folder (GtkFileChooser *file_chooser);
332 void e_util_load_file_chooser_folder (GtkFileChooser *file_chooser);
333 gboolean e_util_get_webkit_developer_mode_enabled
334 (void);
336 G_END_DECLS
338 #endif /* E_MISC_UTILS_H */