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
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/>.
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."
26 #ifndef E_MISC_UTILS_H
27 #define E_MISC_UTILS_H
29 #include <sys/types.h>
33 #include <libedataserver/libedataserver.h>
35 #include <e-util/e-marshal.h>
36 #include <e-util/e-util-enums.h>
48 E_RESTORE_WINDOW_SIZE
= 1 << 0,
49 E_RESTORE_WINDOW_POSITION
= 1 << 1
50 } ERestoreWindowFlags
;
52 typedef void (*EForeachFunc
) (gint model_row
,
55 const gchar
* e_get_accels_filename (void);
56 void e_show_uri (GtkWindow
*parent
,
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
,
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
,
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
,
88 /* String to/from double conversion functions */
89 gdouble
e_flexible_strtod (const gchar
*nptr
,
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
,
101 gchar
* e_str_without_underscores (const gchar
*string
);
102 GString
* e_str_replace_string (const gchar
*text
,
104 const gchar
*replace
);
105 gint
e_str_compare (gconstpointer x
,
107 gint
e_str_case_compare (gconstpointer x
,
109 gint
e_collate_compare (gconstpointer x
,
111 gint
e_int_compare (gconstpointer x
,
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
,
120 void e_utils_get_theme_color (GtkWidget
*widget
,
121 const gchar
*color_names
,
122 const gchar
*fallback_color_ident
,
125 void e_utils_get_theme_color_color (GtkWidget
*widget
,
126 const gchar
*color_names
,
127 const gchar
*fallback_color_ident
,
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
,
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
,
153 void e_bsearch (gconstpointer key
,
157 ESortCompareFunc compare
,
162 gsize
e_strftime_fix_am_pm (gchar
*str
,
165 const struct tm
*tm
);
166 gsize
e_utf8_strftime_fix_am_pm (gchar
*str
,
169 const struct tm
*tm
);
170 gsize e_utf8_strftime_match_lc_messages
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
,
183 GDateWeekday
e_weekday_subtract_days (GDateWeekday weekday
,
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
,
198 GSList
* e_util_get_category_filter_options
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
,
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
,
213 struct _EClientCache
;
214 EClient
* e_util_open_client_sync (struct _EAlertSinkThreadJobData
*job_data
,
215 struct _EClientCache
*client_cache
,
216 const gchar
*extension_name
,
218 guint32 wait_for_connected_seconds
,
219 GCancellable
*cancellable
,
222 /* Useful GBinding transform functions */
223 gboolean e_binding_transform_color_to_string
225 const GValue
*source_value
,
226 GValue
*target_value
,
228 gboolean e_binding_transform_string_to_color
230 const GValue
*source_value
,
231 GValue
*target_value
,
233 gboolean e_binding_transform_source_to_uid
235 const GValue
*source_value
,
236 GValue
*target_value
,
237 ESourceRegistry
*registry
);
238 gboolean e_binding_transform_uid_to_source
240 const GValue
*source_value
,
241 GValue
*target_value
,
242 ESourceRegistry
*registry
);
244 gboolean e_binding_transform_text_non_null
246 const GValue
*source_value
,
247 GValue
*target_value
,
250 GBinding
* e_binding_bind_object_text_property
252 const gchar
*source_property
,
254 const gchar
*target_property
,
255 GBindingFlags flags
);
257 gulong
e_signal_connect_notify (gpointer instance
,
258 const gchar
*notify_name
,
261 gulong
e_signal_connect_notify_after (gpointer instance
,
262 const gchar
*notify_name
,
265 gulong
e_signal_connect_notify_swapped (gpointer instance
,
266 const gchar
*notify_name
,
269 gulong
e_signal_connect_notify_object (gpointer instance
,
270 const gchar
*notify_name
,
273 GConnectFlags connect_flags
);
274 void e_signal_disconnect_notify_handler
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
,
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
,
293 guint
e_util_normalize_font_size (GtkWidget
*widget
,
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
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
,
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
,
329 GCancellable
*cancellable
,
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
338 #endif /* E_MISC_UTILS_H */