1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __APP_GIMP_UTILS_H__ 19 #define __APP_GIMP_UTILS_H__ 20 21 22 #define GIMP_TIMER_START() \ 23 { GTimer *_timer = g_timer_new (); 24 25 #define GIMP_TIMER_END(message) \ 26 g_printerr ("%s: %s took %0.4f seconds\n", \ 27 G_STRFUNC, message, g_timer_elapsed (_timer, NULL)); \ 28 g_timer_destroy (_timer); } 29 30 31 #define MIN4(a,b,c,d) MIN (MIN ((a), (b)), MIN ((c), (d))) 32 #define MAX4(a,b,c,d) MAX (MAX ((a), (b)), MAX ((c), (d))) 33 34 35 gint gimp_get_pid (void); 36 guint64 gimp_get_physical_memory_size (void); 37 gchar * gimp_get_default_language (const gchar *category); 38 GimpUnit gimp_get_default_unit (void); 39 40 gchar ** gimp_properties_append (GType object_type, 41 gint *n_properties, 42 gchar **names, 43 GValue **values, 44 ...) G_GNUC_NULL_TERMINATED; 45 gchar ** gimp_properties_append_valist (GType object_type, 46 gint *n_properties, 47 gchar **names, 48 GValue **values, 49 va_list args); 50 void gimp_properties_free (gint n_properties, 51 gchar **names, 52 GValue *values); 53 54 gchar * gimp_markup_extract_text (const gchar *markup); 55 56 const gchar* gimp_enum_get_value_name (GType enum_type, 57 gint value); 58 59 gboolean gimp_get_fill_params (GimpContext *context, 60 GimpFillType fill_type, 61 GimpRGB *color, 62 GimpPattern **pattern, 63 GError **error); 64 65 /* Common values for the n_snap_lines parameter of 66 * gimp_constrain_line. 67 */ 68 #define GIMP_CONSTRAIN_LINE_90_DEGREES 2 69 #define GIMP_CONSTRAIN_LINE_45_DEGREES 4 70 #define GIMP_CONSTRAIN_LINE_15_DEGREES 12 71 72 void gimp_constrain_line (gdouble start_x, 73 gdouble start_y, 74 gdouble *end_x, 75 gdouble *end_y, 76 gint n_snap_lines, 77 gdouble offset_angle, 78 gdouble xres, 79 gdouble yres); 80 81 gint gimp_file_compare (GFile *file1, 82 GFile *file2); 83 gboolean gimp_file_is_executable (GFile *file); 84 gchar * gimp_file_get_extension (GFile *file); 85 GFile * gimp_file_with_new_extension (GFile *file, 86 GFile *ext_file); 87 88 gchar * gimp_data_input_stream_read_line_always (GDataInputStream *stream, 89 gsize *length, 90 GCancellable *cancellable, 91 GError **error); 92 93 gboolean gimp_ascii_strtoi (const gchar *nptr, 94 gchar **endptr, 95 gint base, 96 gint *result); 97 gboolean gimp_ascii_strtod (const gchar *nptr, 98 gchar **endptr, 99 gdouble *result); 100 101 gint gimp_g_list_compare (GList *list1, 102 GList *list2); 103 104 GimpAsync * gimp_idle_run_async (GimpRunAsyncFunc func, 105 gpointer user_data); 106 GimpAsync * gimp_idle_run_async_full (gint priority, 107 GimpRunAsyncFunc func, 108 gpointer user_data, 109 GDestroyNotify user_data_destroy_func); 110 111 GimpImage * gimp_create_image_from_buffer (Gimp *gimp, 112 GeglBuffer *buffer, 113 const gchar *image_name); 114 115 116 #endif /* __APP_GIMP_UTILS_H__ */ 117