3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #define FREE(x) if (x) g_free(x), x = NULL
27 #define COMBO_LIST_LENGTH \
28 anjuta_preferences_get_int (app->preferences, MAXIMUM_COMBO_HISTORY)
30 #define _STR(S) ((S)?(S):"")
32 /* Any addition to this enum must be synced with the
33 function get_file_ext_type() */
79 typedef enum _FileExtType FileExtType
;
81 /****************************************************************************/
82 /* Functions that dynamic allocate memory. Return value(s) should be g_freed */
83 /****************************************************************************/
85 /* Removes while spaces in the text */
86 gchar
* remove_white_spaces(gchar
* text
);
88 /* Get a unique temporary filename */
89 /* This filename is not valid beyond the present session */
90 gchar
* get_a_tmp_file(void);
92 /* Retruns the contents of the file a buffer */
93 gchar
* get_file_as_buffer (gchar
* filename
);
95 /* Creates a space separated string from the list of strings */
96 gchar
* string_from_glist (GList
* list
);
98 /* Returns true if the given line is parsable for */
99 /* file name and line number */
100 /* filename is set at (*filename), line number in lineno*/
101 /* Don't forget to g_free (*filename)*/
102 gboolean
parse_error_line(const gchar
*line
, gchar
**filename
, int *lineno
);
104 /***********************************************************************************/
105 /* Functions that do not dynamic allocate memory. Return value should not be g_freed */
106 /***********************************************************************************/
108 /* Get a fixed font */
109 PangoFontDescription
* get_fixed_font (void);
112 gboolean
read_string(FILE* stream
, gchar
* token
, gchar
**str
);
113 gboolean
read_line(FILE* stream
, gchar
**str
);
114 gboolean
write_string(FILE* stream
, gchar
* token
, gchar
*str
);
115 gboolean
write_line(FILE* stream
, gchar
*str
);
117 /* Get the filename */
118 const gchar
* extract_filename (const gchar
* full_filename
);
120 /* Get directory of file, return value must be g_freed */
121 gchar
* extract_directory (const gchar
* full_filename
);
123 /* Adds the given string in the list, if it does not already exist. */
124 /* The added string will come at the top of the list */
125 /* The list will be then truncated to (length) items only */
126 GList
* update_string_list(GList
*p_list
, const gchar
*p_str
, gint length
);
128 /* Gets the extension of the file */
129 gchar
* get_file_extension(gchar
* file
);
131 /* Gets the file extension type */
132 FileExtType
get_file_ext_type(gchar
* file
);
135 void fast_widget_repaint(GtkWidget* w);
138 /* Comapares the two data */
139 /* Don't use this func. Define your own */
140 gint
compare_string_func(gconstpointer a
, gconstpointer b
);
142 /* Checks if the file is of the given type */
143 gboolean
file_is_regular(const gchar
* fn
);
144 gboolean
file_is_directory(const gchar
* fn
);
145 gboolean
file_is_link(const gchar
* fn
);
146 gboolean
file_is_char_device(const gchar
* fn
);
147 gboolean
file_is_block_device(const gchar
* fn
);
148 gboolean
file_is_fifo(const gchar
* fn
);
149 gboolean
file_is_socket(const gchar
* fn
);
150 gboolean
file_is_readable(const gchar
* fn
);
151 gboolean
file_is_readonly(const gchar
* fn
);
152 gboolean
file_is_readwrite(const gchar
* fn
);
153 gboolean
file_is_writable(const gchar
* fn
);
154 gboolean
file_is_executable(const gchar
* fn
);
155 gboolean
file_is_suid(const gchar
* fn
);
156 gboolean
file_is_sgid(const gchar
* fn
);
157 gboolean
file_is_sticky(const gchar
* fn
);
159 /* copies src to dest */
160 /* if (show_error) is true, then a dialog box will be shown for the error */
161 gboolean
copy_file(gchar
* src
, gchar
* dest
, gboolean show_error
);
163 /* (src) will be renamed, ie moved, to (dest) if they are not same */
164 /* Used to avoid unnecessary change in modified time of the dest file */
165 /* Which may result in recompilation, etc */
166 gboolean
move_file_if_not_same (gchar
* src
, gchar
* dest
);
168 /* Check if two files/dirs/etc are the same one */
169 gboolean
is_file_same(gchar
*a
, gchar
*b
);
171 /* Update, flush and paint all gtk widgets */
172 void update_gtk(void);
174 /* Sets a text (chars) in the entry (w) */
175 /* Text will be selected if use_selection is true */
176 void entry_set_text_n_select(GtkWidget
* w
, gchar
* chars
, gboolean use_selection
);
178 /* Creates a dir, if it already doesnot exists */
179 /* All the required parent dirs are also created if they don't exist */
180 gboolean
force_create_dir(gchar
* d
);
182 /* Checks if the (parent) is parent widget of the (child)*/
183 gboolean
widget_is_child(GtkWidget
*parent
, GtkWidget
* child
);
185 /* Fast string assignment to avoid memory leaks */
186 /* Assigns a new string (value), if not NULL, with g_strdup() to (*string) */
187 /* The previous string, if not NULL, is g_freed */
188 void string_assign (gchar
** string
, const gchar
* value
);
190 /* Returns true if the e->d_name is a regular file */
191 /* Used as the callback for scandir() */
192 int select_only_file (const struct dirent
*e
);
194 /* Returns the alphabatically sorted list for files in dir */
195 /* select is the func that approves (returning 1)each file */
196 GList
* scan_files_in_dir (const char *dir
, int (*select
)(const struct dirent
*));
198 /*******************************************************************/
199 /* In this case only GList must be freed and not the data */
200 /* Because output data are the input data. Only GList is allocated */
201 /*******************************************************************/
202 GList
* remove_blank_lines(GList
* lines
);
204 /* Create a new hbox with an image and a label packed into it
205 * and return the box. */
207 create_xpm_label_box( GtkWidget
*parent
,
208 const gchar
*xpm_filename
, gboolean gnome_pixmap
,
209 const gchar
*label_text
);
210 /* Excluding the final 0 */
211 gint
calc_string_len( const gchar
*szStr
);
212 gint
calc_gnum_len( void /*const gint iVal*/ );
214 /* Allocates a struct of pointers if sep = 0 use ',' */
215 gchar
**string_parse_separator( const gint nItems
, gchar
*szStrIn
, const gchar chSep
/*= ','*/ );
216 #define PARSE_STR(nItems,szStr) string_parse_separator( nItems, szStr, ',' );
217 gchar
* GetStrCod( const gchar
*szIn
);
219 /* Write in file....*/
220 gchar
*WriteBufUL( gchar
* szDst
, const gulong ulVal
);
221 gchar
*WriteBufI( gchar
* szDst
, const gint iVal
);
222 gchar
*WriteBufB( gchar
* szDst
, const gboolean bVal
);
223 gchar
*WriteBufS( gchar
* szDst
, const gchar
* szVal
);
226 free_string_list ( GList
* pList
);
228 /********************************************************
229 * Escapes single and double quotes in the given string *
230 * Return string must be g_freed() *
231 ********************************************************/
232 gchar
* anjuta_util_escape_quotes(const gchar
* str
);
234 /********************************************************
235 * Use this function instead of kill() to send a signal *
236 * to the process which runs in separate process group, *
237 * because normally kill() wouldn't work *
238 * Returns: status of the kill *
239 ********************************************************/
240 gint
anjuta_util_kill(pid_t process_id
, const gchar
* signal_name
);
242 /********************************************************
243 * This function parses a string and returns a GList of *
244 * program args, just like shell parses the program args*
245 ********************************************************/
246 GList
* anjuta_util_parse_args_from_string (const gchar
* string
);
248 /* Gets the relative filename w.r.t the given directory */
249 gchar
*get_relative_file_name(gchar
*dir
, gchar
*file
);
251 /* Checks if the file exists in the given directory or any of it's subdirectories */
252 gboolean
is_file_in_dir(const gchar
*file
, const gchar
*dir
);
254 GList
*glist_path_dedup(GList
*list
);
256 /* Check which gnome-terminal is installed
257 Returns: 0 -- No gnome-terminal
258 Returns: 1 -- Gnome1 gnome-terminal
259 Returns: 2 -- Gnome2 gnome-terminal */
260 gint
anjuta_util_check_gnome_terminal (void);
262 /* Return must be freed. Works even if str is already UTF8 string */
263 gchar
*anjuta_util_convert_to_utf8 (const gchar
*str
);
265 GtkWidget
* anjuta_util_toolbar_append_button (GtkWidget
*toolbar
,
266 const gchar
*iconfile
,
268 const gchar
*tooltip
,
269 GtkSignalFunc callback
,
272 anjuta_util_toolbar_append_stock (GtkWidget
*toolbar
, const gchar
*stock_icon
,
273 const gchar
*tooltip
, GtkSignalFunc callback
,
277 anjuta_dialog_add_button (GtkDialog
*dialog
, const gchar
* text
,
278 const gchar
* stock_id
, gint response_id
);
280 anjuta_button_new_with_stock_image (const gchar
* text
, const gchar
* stock_id
);