Updated Spanish translation
[anjuta-git-plugin.git] / libanjuta / anjuta-utils.h
blobc7a083c6b9e93b9c78977fb23b467f8a39edcacd
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta-utils.h
4 * Copyright (C) Naba Kumar <naba@gnome.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _ANJUTA_UTILS_H_
21 #define _ANJUTA_UTILS_H_
23 #include <glib.h>
24 #include <gtk/gtk.h>
25 #include <sys/types.h>
27 #include <libanjuta/anjuta-preferences.h>
29 G_BEGIN_DECLS
31 gboolean anjuta_util_copy_file (gchar * src, gchar * dest, gboolean show_error);
33 gboolean anjuta_util_diff(const gchar* uri, const gchar* text);
35 void anjuta_util_color_from_string (const gchar * val, guint16 * r,
36 guint16 * g, guint16 * b);
38 gchar* anjuta_util_string_from_color (guint16 r, guint16 g, guint16 b);
40 GdkColor* anjuta_util_convert_color(AnjutaPreferences* prefs, const gchar* pref_name);
42 GtkWidget* anjuta_util_button_new_with_stock_image (const gchar* text,
43 const gchar* stock_id);
45 GtkWidget* anjuta_util_dialog_add_button (GtkDialog *dialog, const gchar* text,
46 const gchar* stock_id,
47 gint response_id);
49 void anjuta_util_dialog_error (GtkWindow *parent, const gchar * mesg, ...);
50 void anjuta_util_dialog_warning (GtkWindow *parent, const gchar * mesg, ...);
51 void anjuta_util_dialog_info (GtkWindow *parent, const gchar * mesg, ...);
52 void anjuta_util_dialog_error_system (GtkWindow* parent, gint errnum,
53 const gchar * mesg, ... );
54 gboolean anjuta_util_dialog_boolean_question (GtkWindow *parent,
55 const gchar * mesg, ...);
56 gboolean anjuta_util_dialog_input (GtkWindow *parent, const gchar *label,
57 const gchar *default_value, gchar **value);
59 gboolean anjuta_util_prog_is_installed (gchar * prog, gboolean show);
61 gchar* anjuta_util_get_a_tmp_file (void);
63 gchar* anjuta_util_convert_to_utf8 (const gchar *str);
65 GList* anjuta_util_parse_args_from_string (const gchar* string);
67 /***********************************************/
68 /* String integer mapping utility functions */
69 /***********************************************/
70 typedef struct _AnjutaUtilStringMap
72 int type;
73 char *name;
74 } AnjutaUtilStringMap;
76 int anjuta_util_type_from_string(AnjutaUtilStringMap *map, const char *str);
77 const char *anjuta_util_string_from_type(AnjutaUtilStringMap *map, int type);
78 GList *anjuta_util_glist_from_map(AnjutaUtilStringMap *map);
80 /***********************************************/
81 /* Functions that operate on list of strings. */
82 /***********************************************/
83 void anjuta_util_glist_strings_free(GList* list);
84 void anjuta_util_glist_strings_prefix (GList * list, const gchar *prefix);
85 void anjuta_util_glist_strings_sufix (GList * list, const gchar *sufix);
86 GList* anjuta_util_glist_strings_sort (GList * list);
88 /**********************************************************/
89 /* Both the returned glist and the data should be g_freed */
90 /* Call g_list_strings_free() to do that. */
91 /**********************************************************/
92 GList* anjuta_util_glist_from_string (const gchar* id);
93 GList* anjuta_util_glist_strings_dup (GList * list);
95 /* Dedup a list of paths - duplicates are removed from the tail.
96 ** Useful for deduping Recent Files and Recent Projects */
97 GList* anjuta_util_glist_path_dedup(GList *list);
99 /* Adds the given string in the list, if it does not already exist. */
100 /* The added string will come at the top of the list */
101 /* The list will be then truncated to (length) items only */
102 GList * anjuta_util_update_string_list (GList *p_list, const gchar *p_str,
103 gint length);
105 gboolean anjuta_util_create_dir (const gchar * d);
106 pid_t anjuta_util_execute_shell (const gchar *dir, const gchar *command);
108 gchar* anjuta_util_escape_quotes(const gchar* str);
110 gboolean anjuta_util_path_has_extension (const gchar *path, const gchar *ext);
111 gchar* anjuta_util_get_real_path (const gchar *path);
113 gchar* anjuta_util_get_uri_mime_type (const gchar *uri);
115 /* Temporarily copied here */
117 #define ANJUTA_TYPE_BEGIN(class_name, prefix, parent_type) \
118 GType \
119 prefix##_get_type (void) \
121 static GType type = 0; \
122 if (!type) \
124 static const GTypeInfo type_info = \
126 sizeof (class_name##Class), \
127 (GBaseInitFunc) NULL, \
128 (GBaseFinalizeFunc) NULL, \
129 (GClassInitFunc) prefix##_class_init, \
130 (GClassFinalizeFunc) NULL, \
131 NULL, \
132 sizeof (class_name), \
133 0, /* n_preallocs */ \
134 (GInstanceInitFunc) prefix##_instance_init, \
135 }; \
137 type = g_type_register_static (parent_type, \
138 #class_name, \
139 &type_info, 0);
140 #define ANJUTA_TYPE_END \
142 return type; \
145 #define ANJUTA_TYPE_ADD_INTERFACE(prefix,interface_type) \
147 GInterfaceInfo iface_info = { \
148 (GInterfaceInitFunc)prefix##_iface_init, \
149 NULL, \
150 NULL \
151 }; \
152 g_type_add_interface_static (type, \
153 interface_type, \
154 &iface_info); \
157 #define ANJUTA_TYPE_BOILERPLATE(class_name, prefix, parent_type) \
158 ANJUTA_TYPE_BEGIN(class_name, prefix, parent_type); \
159 ANJUTA_TYPE_END
161 G_END_DECLS
163 #endif