Updated Spanish translation
[anjuta-git-plugin.git] / libanjuta / anjuta-utils.h
blobd74a113829145994c16ec3e0911a5bdc90b046c0
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);
87 gchar* anjuta_util_glist_strings_join (GList * list, gchar *delimiter);
89 /**********************************************************/
90 /* Both the returned glist and the data should be g_freed */
91 /* Call g_list_strings_free() to do that. */
92 /**********************************************************/
93 GList* anjuta_util_glist_from_string (const gchar* id);
94 GList* anjuta_util_glist_strings_dup (GList * list);
96 /* Dedup a list of paths - duplicates are removed from the tail.
97 ** Useful for deduping Recent Files and Recent Projects */
98 GList* anjuta_util_glist_path_dedup(GList *list);
100 /* Adds the given string in the list, if it does not already exist. */
101 /* The added string will come at the top of the list */
102 /* The list will be then truncated to (length) items only */
103 GList * anjuta_util_update_string_list (GList *p_list, const gchar *p_str,
104 gint length);
106 gboolean anjuta_util_create_dir (const gchar * d);
107 pid_t anjuta_util_execute_shell (const gchar *dir, const gchar *command);
109 gchar* anjuta_util_escape_quotes(const gchar* str);
111 gboolean anjuta_util_path_has_extension (const gchar *path, const gchar *ext);
112 gchar* anjuta_util_get_real_path (const gchar *path);
114 gchar* anjuta_util_uri_get_dirname (const gchar *uri);
115 gchar* anjuta_util_replace_home_dir_with_tilde (const gchar *uri);
116 gchar* anjuta_util_str_middle_truncate (const gchar *string,
117 guint truncate_length);
119 gchar* anjuta_util_get_uri_mime_type (const gchar *uri);
121 void anjuta_util_help_display (GtkWindow *parent,
122 const gchar *doc_id,
123 const gchar *file_name);
125 gchar *anjuta_util_get_user_config_dir (void);
128 /* Temporarily copied here */
130 #define ANJUTA_TYPE_BEGIN(class_name, prefix, parent_type) \
131 GType \
132 prefix##_get_type (void) \
134 static GType type = 0; \
135 if (!type) \
137 static const GTypeInfo type_info = \
139 sizeof (class_name##Class), \
140 (GBaseInitFunc) NULL, \
141 (GBaseFinalizeFunc) NULL, \
142 (GClassInitFunc) prefix##_class_init, \
143 (GClassFinalizeFunc) NULL, \
144 NULL, \
145 sizeof (class_name), \
146 0, /* n_preallocs */ \
147 (GInstanceInitFunc) prefix##_instance_init, \
148 }; \
150 type = g_type_register_static (parent_type, \
151 #class_name, \
152 &type_info, 0);
153 #define ANJUTA_TYPE_END \
155 return type; \
158 #define ANJUTA_TYPE_ADD_INTERFACE(prefix,interface_type) \
160 GInterfaceInfo iface_info = { \
161 (GInterfaceInitFunc)prefix##_iface_init, \
162 NULL, \
163 NULL \
164 }; \
165 g_type_add_interface_static (type, \
166 interface_type, \
167 &iface_info); \
170 #define ANJUTA_TYPE_BOILERPLATE(class_name, prefix, parent_type) \
171 ANJUTA_TYPE_BEGIN(class_name, prefix, parent_type); \
172 ANJUTA_TYPE_END
174 G_END_DECLS
176 #endif