Rename document struct to GeanyDocument.

Rename filetype struct to GeanyFiletype.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2594 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-05-16 14:17:54 +00:00
parent 72f6acde81
commit 311b82ebb2
21 changed files with 166 additions and 138 deletions

View File

@ -1,3 +1,15 @@
2008-05-16 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* plugins/pluginmacros.h, plugins/vcdiff.c, src/build.c,
src/callbacks.c, src/dialogs.c, src/document.c, src/document.h,
src/editor.c, src/filetypes.c, src/filetypes.h, src/geany.h,
src/keybindings.c, src/keyfile.c, src/main.c, src/msgwindow.c,
src/notebook.c, src/plugindata.h, src/printing.c, src/symbols.c,
src/templates.c, src/templates.h:
Rename document struct to GeanyDocument.
Rename filetype struct to GeanyFiletype.
2008-05-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/templates.c, src/build.c, src/utils.c, src/ui_utils.h,

View File

@ -90,6 +90,9 @@
#define ui geany_data->ui
#define utils geany_data->utils
typedef struct _GeanyDocument document;
typedef struct _GeanyFiletype filetype;
#endif
#endif

View File

@ -286,7 +286,7 @@ static void show_output(const gchar *std_output, const gchar *name_prefix,
idx = find_by_filename(filename);
if ( idx == -1)
{
filetype *ft = p_filetypes->lookup_by_name("Diff");
GeanyFiletype *ft = p_filetypes->lookup_by_name("Diff");
idx = p_document->new_file(filename, ft, text);
}
else
@ -481,7 +481,7 @@ static GtkWidget *menu_vcdiff_project = NULL;
static void update_menu_items(void)
{
document *doc;
GeanyDocument *doc;
gboolean have_file;
gboolean have_vc = FALSE;

View File

@ -591,7 +591,7 @@ static gchar *prepare_run_script(gint idx, gchar **vte_cmd_nonscript)
gchar *locale_filename = NULL;
gboolean have_project;
GeanyProject *project = app->project;
filetype *ft = doc_list[idx].file_type;
GeanyFiletype *ft = doc_list[idx].file_type;
gboolean check_exists;
gchar *cmd = NULL;
gchar *executable = NULL;
@ -1276,7 +1276,7 @@ on_includes_arguments_tex_dialog_response (GtkDialog *dialog,
gint response,
gpointer user_data)
{
filetype *ft = user_data;
GeanyFiletype *ft = user_data;
g_return_if_fail(ft != NULL);
if (response == GTK_RESPONSE_ACCEPT)
@ -1325,7 +1325,7 @@ static void show_includes_arguments_tex(void)
GtkWidget *dialog, *label, *entries[4], *vbox, *table;
gint idx = document_get_cur_idx();
gint response;
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
if (DOC_IDX_VALID(idx)) ft = doc_list[idx].file_type;
g_return_if_fail(ft != NULL);
@ -1441,7 +1441,7 @@ on_includes_arguments_dialog_response (GtkDialog *dialog,
gint response,
gpointer user_data)
{
filetype *ft = user_data;
GeanyFiletype *ft = user_data;
g_return_if_fail(ft != NULL);
@ -1494,7 +1494,7 @@ static void show_includes_arguments_gen(void)
gint row = 0;
gint idx = document_get_cur_idx();
gint response;
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
if (DOC_IDX_VALID(idx)) ft = doc_list[idx].file_type;
g_return_if_fail(ft != NULL);
@ -1612,7 +1612,7 @@ static void
on_build_arguments_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
if (user_data && FILETYPE_ID((filetype*) user_data) == GEANY_FILETYPES_LATEX)
if (user_data && FILETYPE_ID((GeanyFiletype*) user_data) == GEANY_FILETYPES_LATEX)
show_includes_arguments_tex();
else
show_includes_arguments_gen();
@ -1635,7 +1635,7 @@ static gboolean is_c_header(const gchar *fname)
* Uses current document (if there is one) when idx == -1 */
void build_menu_update(gint idx)
{
filetype *ft;
GeanyFiletype *ft;
gboolean have_path, can_build, can_make, can_run, can_stop, can_set_args, have_errors;
BuildMenuItems *menu_items;
@ -1784,7 +1784,7 @@ BuildMenuItems *build_get_menu_items(gint filetype_idx)
if (filetype_idx == -1)
{
gint idx = document_get_cur_idx();
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
if (DOC_IDX_VALID(idx))
ft = doc_list[idx].file_type;
@ -1923,7 +1923,7 @@ on_build_make_activate (GtkMenuItem *menuitem,
}
static gboolean use_html_builtin(gint idx, filetype *ft)
static gboolean use_html_builtin(gint idx, GeanyFiletype *ft)
{
gboolean use_builtin = FALSE;
if (ft->id == GEANY_FILETYPES_HTML)
@ -1957,7 +1957,7 @@ on_build_execute_activate (GtkMenuItem *menuitem,
{
gint idx = document_get_cur_idx();
filetype_id ft_id;
filetype *ft;
GeanyFiletype *ft;
if (! DOC_IDX_VALID(idx))
return;

View File

@ -1038,7 +1038,7 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
{
gboolean definition = (menuitem ==
GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")));
document *doc = document_get_current();
GeanyDocument *doc = document_get_current();
g_return_if_fail(doc);
@ -1370,7 +1370,7 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx();
gchar *text;
gchar *fname;
filetype *ft;
GeanyFiletype *ft;
g_return_if_fail(DOC_IDX_VALID(idx));
@ -2111,7 +2111,7 @@ void
on_line_breaking1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
document *doc;
GeanyDocument *doc;
if (app->ignore_callback)
return;

View File

@ -82,7 +82,7 @@ on_file_open_dialog_response (GtkDialog *dialog,
lookup_widget(GTK_WIDGET(dialog), "filetype_combo")));
gint encoding_idx = gtk_combo_box_get_active(GTK_COMBO_BOX(
lookup_widget(GTK_WIDGET(dialog), "encoding_combo")));
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
gchar *charset = NULL;
gboolean ro = (response == GEANY_RESPONSE_VIEW); /* View clicked */

View File

@ -152,7 +152,7 @@ gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename)
for (i = 0; i < doc_array->len; i++)
{
document *doc = &doc_list[i];
GeanyDocument *doc = &doc_list[i];
gchar *docname;
if (doc->file_name == NULL) continue;
@ -245,7 +245,7 @@ gint document_get_cur_idx()
*
* @return A pointer to the current %document or @c NULL if there are no opened documents.
**/
document *document_get_current()
GeanyDocument *document_get_current()
{
gint idx = document_get_cur_idx();
@ -255,7 +255,7 @@ document *document_get_current()
void document_init_doclist()
{
doc_array = g_array_new(FALSE, FALSE, sizeof(document));
doc_array = g_array_new(FALSE, FALSE, sizeof(GeanyDocument));
}
@ -311,7 +311,7 @@ void document_apply_update_prefs(gint idx)
/* Sets is_valid to FALSE and initializes some members to NULL, to mark it uninitialized.
* The flag is_valid is set to TRUE in document_create(). */
static void init_doc_struct(document *new_doc)
static void init_doc_struct(GeanyDocument *new_doc)
{
new_doc->is_valid = FALSE;
new_doc->has_tags = FALSE;
@ -432,7 +432,7 @@ static gint document_create(const gchar *utf8_filename)
PangoFontDescription *pfd;
gchar *fname;
gint new_idx;
document *this;
GeanyDocument *this;
gint tabnum;
gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
@ -446,7 +446,7 @@ static gint document_create(const gchar *utf8_filename)
new_idx = document_get_new_idx();
if (new_idx == -1) /* expand the array, no free places */
{
document new_doc;
GeanyDocument new_doc;
new_idx = doc_array->len;
g_array_append_val(doc_array, new_doc);
}
@ -573,7 +573,7 @@ gint document_new_file_if_non_open()
*
* @return The index of the new file in the @ref doc_list array.
**/
gint document_new_file(const gchar *filename, filetype *ft, const gchar *text)
gint document_new_file(const gchar *filename, GeanyFiletype *ft, const gchar *text)
{
gint idx = document_create(filename);
@ -654,7 +654,7 @@ gint document_new_file(const gchar *filename, filetype *ft, const gchar *text)
* @return The index of the opened file or -1 if an error occurred.
**/
gint document_open_file(const gchar *locale_filename, gboolean readonly,
filetype *ft, const gchar *forced_enc)
GeanyFiletype *ft, const gchar *forced_enc)
{
/* This is a wrapper for document_open_file_full().
* Do not use this when opening multiple files (unless using document_delay_colourise()). */
@ -960,13 +960,13 @@ static gboolean detect_use_tabs(ScintillaObject *sci)
* This avoids unnecessary recolourising, saving significant processing when a lot of files
* are open of a filetype that supports user typenames, e.g. C. */
gint document_open_file_full(gint idx, const gchar *filename, gint pos, gboolean readonly,
filetype *ft, const gchar *forced_enc)
GeanyFiletype *ft, const gchar *forced_enc)
{
gint editor_mode;
gboolean reload = (idx == -1) ? FALSE : TRUE;
gchar *utf8_filename = NULL;
gchar *locale_filename = NULL;
filetype *use_ft;
GeanyFiletype *use_ft;
FileData filedata;
/*struct timeval tv, tv1;*/
@ -1167,7 +1167,7 @@ void document_open_file_list(const gchar *data, gssize length)
*
* @return The index of the opened file or -1 if an error occurred.
**/
void document_open_files(const GSList *filenames, gboolean readonly, filetype *ft,
void document_open_files(const GSList *filenames, gboolean readonly, GeanyFiletype *ft,
const gchar *forced_enc)
{
const GSList *item;
@ -1270,7 +1270,7 @@ gboolean document_save_file_as(gint idx)
/* detect filetype */
if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_NONE)
{
filetype *ft = filetypes_detect_from_file(idx);
GeanyFiletype *ft = filetypes_detect_from_file(idx);
document_set_filetype(idx, ft);
if (document_get_cur_idx() == idx)
@ -2062,7 +2062,7 @@ static gboolean update_type_keywords(ScintillaObject *sci, gint lang)
/* sets the filetype of the document (sets syntax highlighting and tagging) */
void document_set_filetype(gint idx, filetype *type)
void document_set_filetype(gint idx, GeanyFiletype *type)
{
gboolean colourise = FALSE;
gboolean ft_changed;
@ -2388,7 +2388,7 @@ GdkColor *document_get_status_color(gint idx)
/* useful debugging function (usually debug macros aren't enabled) */
#ifdef GEANY_DEBUG
document *doc(gint idx)
GeanyDocument *doc(gint idx)
{
return DOC_IDX_VALID(idx) ? &doc_list[idx] : NULL;
}

View File

@ -71,7 +71,7 @@ typedef struct FileEncoding
/**
* Structure for representing an open tab with all its properties.
**/
typedef struct document
typedef struct _GeanyDocument
{
/** General flag to represent this document is active and all properties are set correctly. */
gboolean is_valid;
@ -89,7 +89,7 @@ typedef struct document
gboolean has_bom;
/** The filetype for this %document, it's only a reference to one of the elements of the global
* filetypes array. */
filetype *file_type;
GeanyFiletype *file_type;
/** TMWorkObject object for this %document. */
TMWorkObject *tm_file;
/** The Scintilla object for this %document. */
@ -127,7 +127,7 @@ typedef struct document
/** %Document-specific tab setting. */
gboolean use_tabs;
gboolean line_breaking; /**< Whether to split long lines as you type. */
} document;
} GeanyDocument;
/* Dynamic array of document elements to hold all information of the notebook tabs. */
@ -137,7 +137,7 @@ extern GArray *doc_array;
* doc_list wraps doc_array so it can be used with C array syntax.
* Example: doc_list[0].sci = NULL;
**/
#define doc_list ((document *)doc_array->data)
#define doc_list ((GeanyDocument *)doc_array->data)
/**
* DOC_IDX_VALID checks whether the passed index points to a valid %document object by checking
@ -166,7 +166,7 @@ gint document_get_n_idx(guint page_num);
gint document_get_cur_idx(void);
document *document_get_current(void);
GeanyDocument *document_get_current(void);
void document_init_doclist(void);
@ -184,19 +184,19 @@ gboolean document_close_all(void);
gint document_new_file_if_non_open();
gint document_new_file(const gchar *filename, filetype *ft, const gchar *text);
gint document_new_file(const gchar *filename, GeanyFiletype *ft, const gchar *text);
gint document_clone(gint old_idx, const gchar *utf8_filename);
gint document_open_file(const gchar *locale_filename, gboolean readonly,
filetype *ft, const gchar *forced_enc);
GeanyFiletype *ft, const gchar *forced_enc);
gint document_open_file_full(gint idx, const gchar *filename, gint pos, gboolean readonly,
filetype *ft, const gchar *forced_enc);
GeanyFiletype *ft, const gchar *forced_enc);
void document_open_file_list(const gchar *data, gssize length);
void document_open_files(const GSList *filenames, gboolean readonly, filetype *ft,
void document_open_files(const GSList *filenames, gboolean readonly, GeanyFiletype *ft,
const gchar *forced_enc);
gboolean document_reload_file(gint idx, const gchar *forced_enc);
@ -222,7 +222,7 @@ void document_replace_sel(gint idx, const gchar *find_text, const gchar *replace
void document_update_tag_list(gint idx, gboolean update);
void document_set_filetype(gint idx, filetype *type);
void document_set_filetype(gint idx, GeanyFiletype *type);
void document_set_encoding(gint idx, const gchar *new_encoding);

View File

@ -67,11 +67,11 @@ static gchar indent[100];
static void on_new_line_added(gint idx);
static gboolean handle_xml(gint idx, gchar ch);
static void get_indent(document *doc, gint pos, gboolean use_this_line);
static void get_indent(GeanyDocument *doc, gint pos, gboolean use_this_line);
static void auto_multiline(gint idx, gint pos);
static gboolean is_comment(gint lexer, gint prev_style, gint style);
static void auto_close_bracket(ScintillaObject *sci, gint pos, gchar c);
static void editor_auto_table(document *doc, gint pos);
static void editor_auto_table(GeanyDocument *doc, gint pos);
/* calls the edit popup menu in the editor */
@ -211,7 +211,7 @@ static void on_update_ui(gint idx, G_GNUC_UNUSED SCNotification *nt)
static void check_line_breaking(gint idx, gint pos, gchar c)
{
document *doc = &doc_list[idx];
GeanyDocument *doc = &doc_list[idx];
ScintillaObject *sci = doc->sci;
gint line, lstart;
@ -582,7 +582,7 @@ get_whitespace(gint width, gboolean use_tabs)
static void check_python_indent(gint idx, gint pos)
{
document *doc = &doc_list[idx];
GeanyDocument *doc = &doc_list[idx];
gint last_char = pos - editor_get_eol_char_len(idx) - 1;
/* add extra indentation for Python after colon */
@ -674,7 +674,7 @@ static void do_indent(gchar *buf, gsize len, guint *idx, gboolean use_tabs)
/* "use_this_line" to auto-indent only if it is a real new line
* and ignore the case of editor_close_block */
static void get_indent(document *doc, gint pos, gboolean use_this_line)
static void get_indent(GeanyDocument *doc, gint pos, gboolean use_this_line)
{
ScintillaObject *sci = doc->sci;
guint i, len, j = 0;
@ -958,7 +958,7 @@ static gboolean append_calltip(GString *str, const TMTag *tag, filetype_id ft_id
}
static gchar *find_calltip(const gchar *word, filetype *ft)
static gchar *find_calltip(const gchar *word, GeanyFiletype *ft)
{
const GPtrArray *tags;
const gint arg_types = tm_tag_function_t | tm_tag_prototype_t |
@ -1163,7 +1163,7 @@ gboolean editor_start_auto_complete(gint idx, gint pos, gboolean force)
ScintillaObject *sci;
gboolean ret = FALSE;
gchar *wordchars;
filetype *ft;
GeanyFiletype *ft;
if ((! editor_prefs.auto_complete_symbols && ! force) ||
! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL)
@ -1578,7 +1578,7 @@ static gboolean handle_xml(gint idx, gchar ch)
}
static void editor_auto_table(document *doc, gint pos)
static void editor_auto_table(GeanyDocument *doc, gint pos)
{
ScintillaObject *sci = doc->sci;
gchar *table;
@ -1681,7 +1681,7 @@ gint editor_do_uncomment(gint idx, gint line, gboolean toggle)
gsize co_len;
gchar sel[256], *co, *cc;
gboolean break_loop = FALSE, single_line = FALSE;
filetype *ft;
GeanyFiletype *ft;
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL)
return 0;
@ -1839,7 +1839,7 @@ void editor_do_comment_toggle(gint idx)
gboolean first_line_was_comment = FALSE;
gsize co_len;
gsize tm_len = strlen(GEANY_TOGGLE_MARK);
filetype *ft;
GeanyFiletype *ft;
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL)
return;
@ -2010,7 +2010,7 @@ void editor_do_comment(gint idx, gint line, gboolean allow_empty_lines, gboolean
gint sel_start, sel_end, co_len;
gchar sel[256], *co, *cc;
gboolean break_loop = FALSE, single_line = FALSE;
filetype *ft;
GeanyFiletype *ft;
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL) return;
@ -3170,7 +3170,7 @@ void editor_set_font(gint idx, const gchar *font_name, gint size)
void editor_set_line_wrapping(gint idx, gboolean wrap)
{
document *doc = &doc_list[idx];
GeanyDocument *doc = &doc_list[idx];
g_return_if_fail(DOC_IDX_VALID(idx));
@ -3181,7 +3181,7 @@ void editor_set_line_wrapping(gint idx, gboolean wrap)
void editor_set_use_tabs(gint idx, gboolean use_tabs)
{
document *doc = &doc_list[idx];
GeanyDocument *doc = &doc_list[idx];
g_return_if_fail(DOC_IDX_VALID(idx));

View File

@ -43,10 +43,10 @@
/* This type 'inherits' from filetype so FullFileType* can be cast to filetype*. */
typedef struct FullFileType
{
filetype public;
GeanyFiletype public;
/* Private fields */
GtkWidget *menu_item; /* holds a pointer to the menu item for this filetype */
gboolean keyfile_loaded;
GtkWidget *menu_item; /* holds a pointer to the menu item for this filetype */
gboolean keyfile_loaded;
}
FullFileType;
@ -56,7 +56,7 @@ GPtrArray *filetypes_array = NULL; /* Dynamic array of filetype pointers */
GHashTable *filetypes_hash = NULL; /* Hash of filetype pointers based on name keys */
static void create_radio_menu_item(GtkWidget *menu, const gchar *label, filetype *ftype);
static void create_radio_menu_item(GtkWidget *menu, const gchar *label, GeanyFiletype *ftype);
static void init_builtin_filetypes(void)
@ -381,10 +381,10 @@ static void init_builtin_filetypes(void)
/* initialize fields. */
static filetype *filetype_new(void)
static GeanyFiletype *filetype_new(void)
{
FullFileType *fft = g_new0(FullFileType, 1);
filetype *ft = (filetype*) fft;
GeanyFiletype *ft = (GeanyFiletype*) fft;
ft->lang = -2; /* assume no tagmanager parser */
ft->programs = g_new0(struct build_programs, 1);
@ -395,7 +395,7 @@ static filetype *filetype_new(void)
/* Add a filetype pointer to the list of available filetypes,
* and set the filetype::id field. */
static void filetype_add(filetype *ft)
static void filetype_add(GeanyFiletype *ft)
{
g_return_if_fail(ft);
g_return_if_fail(ft->name);
@ -456,7 +456,7 @@ static void create_set_filetype_menu()
/* Append all filetypes to the filetype menu */
for (ft_id = 0; ft_id < filetypes_array->len; ft_id++)
{
filetype *ft = filetypes[ft_id];
GeanyFiletype *ft = filetypes[ft_id];
const gchar *title = ft->title;
/* insert separators for different filetype groups */
@ -502,17 +502,17 @@ void filetypes_init()
}
typedef gboolean FileTypesPredicate(filetype *ft, gpointer user_data);
typedef gboolean FileTypesPredicate(GeanyFiletype *ft, gpointer user_data);
/* Find a filetype that predicate returns TRUE for, otherwise return NULL. */
static filetype *filetypes_find(gboolean source_only,
static GeanyFiletype *filetypes_find(gboolean source_only,
FileTypesPredicate predicate, gpointer user_data)
{
guint i;
for (i = 0; i < filetypes_array->len; i++)
{
filetype *ft = filetypes[i];
GeanyFiletype *ft = filetypes[i];
if (source_only && i == GEANY_FILETYPES_NONE)
continue; /* None is not for source files */
@ -524,7 +524,7 @@ static filetype *filetypes_find(gboolean source_only,
}
static gboolean match_basename(filetype *ft, gpointer user_data)
static gboolean match_basename(GeanyFiletype *ft, gpointer user_data)
{
const gchar *base_filename = user_data;
gint j;
@ -548,10 +548,10 @@ static gboolean match_basename(filetype *ft, gpointer user_data)
/* Detect filetype only based on the filename extension.
* utf8_filename can include the full path. */
filetype *filetypes_detect_from_extension(const gchar *utf8_filename)
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename)
{
gchar *base_filename;
filetype *ft;
GeanyFiletype *ft;
/* to match against the basename of the file (because of Makefile*) */
base_filename = g_path_get_basename(utf8_filename);
@ -569,9 +569,9 @@ filetype *filetypes_detect_from_extension(const gchar *utf8_filename)
}
static filetype *find_shebang(const gchar *utf8_filename, const gchar *line)
static GeanyFiletype *find_shebang(const gchar *utf8_filename, const gchar *line)
{
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
if (strlen(line) > 2 && line[0] == '#' && line[1] == '!')
{
@ -639,9 +639,10 @@ static filetype *find_shebang(const gchar *utf8_filename, const gchar *line)
/* Detect the filetype checking for a shebang, then filename extension. */
static filetype *filetypes_detect_from_file_internal(const gchar *utf8_filename, const gchar *line)
static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_filename,
const gchar *line)
{
filetype *ft;
GeanyFiletype *ft;
/* try to find a shebang and if found use it prior to the filename extension
* also checks for <?xml */
@ -657,9 +658,9 @@ static filetype *filetypes_detect_from_file_internal(const gchar *utf8_filename,
/* Detect the filetype for document idx. */
filetype *filetypes_detect_from_file(gint idx)
GeanyFiletype *filetypes_detect_from_file(gint idx)
{
filetype *ft;
GeanyFiletype *ft;
gchar *line;
if (! DOC_IDX_VALID(idx))
@ -674,7 +675,7 @@ filetype *filetypes_detect_from_file(gint idx)
/* Detect filetype based on the filename extension.
* utf8_filename can include the full path. */
filetype *filetypes_detect_from_filename(const gchar *utf8_filename)
GeanyFiletype *filetypes_detect_from_filename(const gchar *utf8_filename)
{
gchar line[1024];
FILE *f;
@ -695,7 +696,7 @@ filetype *filetypes_detect_from_filename(const gchar *utf8_filename)
}
void filetypes_select_radio_item(const filetype *ft)
void filetypes_select_radio_item(const GeanyFiletype *ft)
{
FullFileType *fft;
@ -717,11 +718,11 @@ on_filetype_change (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx();
if (app->ignore_callback || idx < 0 || ! doc_list[idx].is_valid) return;
document_set_filetype(idx, (filetype*)user_data);
document_set_filetype(idx, (GeanyFiletype*)user_data);
}
static void create_radio_menu_item(GtkWidget *menu, const gchar *label, filetype *ftype)
static void create_radio_menu_item(GtkWidget *menu, const gchar *label, GeanyFiletype *ftype)
{
static GSList *group = NULL;
GtkWidget *tmp;
@ -738,7 +739,7 @@ static void create_radio_menu_item(GtkWidget *menu, const gchar *label, filetype
#if 0
/* Remove a filetype pointer from the list of available filetypes. */
static void filetype_remove(filetype *ft)
static void filetype_remove(GeanyFiletype *ft)
{
g_return_if_fail(ft);
@ -752,7 +753,7 @@ static void filetype_remove(filetype *ft)
static void filetype_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
filetype *ft = data;
GeanyFiletype *ft = data;
g_return_if_fail(ft != NULL);
@ -786,7 +787,7 @@ void filetypes_free_types()
}
static void load_settings(gint ft, GKeyFile *config, GKeyFile *configh)
static void load_settings(gint ft_id, GKeyFile *config, GKeyFile *configh)
{
gchar *result;
GError *error = NULL;
@ -797,7 +798,7 @@ static void load_settings(gint ft, GKeyFile *config, GKeyFile *configh)
if (result == NULL) result = g_key_file_get_string(config, "settings", "extension", NULL);
if (result != NULL)
{
setptr(filetypes[ft]->extension, result);
setptr(filetypes[ft_id]->extension, result);
}
/* read comment notes */
@ -805,16 +806,16 @@ static void load_settings(gint ft, GKeyFile *config, GKeyFile *configh)
if (result == NULL) result = g_key_file_get_string(config, "settings", "comment_open", NULL);
if (result != NULL)
{
g_free(filetypes[ft]->comment_open);
filetypes[ft]->comment_open = result;
g_free(filetypes[ft_id]->comment_open);
filetypes[ft_id]->comment_open = result;
}
result = g_key_file_get_string(configh, "settings", "comment_close", NULL);
if (result == NULL) result = g_key_file_get_string(config, "settings", "comment_close", NULL);
if (result != NULL)
{
g_free(filetypes[ft]->comment_close);
filetypes[ft]->comment_close = result;
g_free(filetypes[ft_id]->comment_close);
filetypes[ft_id]->comment_close = result;
}
tmp = g_key_file_get_boolean(configh, "settings", "comment_use_indent", &error);
@ -824,16 +825,16 @@ static void load_settings(gint ft, GKeyFile *config, GKeyFile *configh)
error = NULL;
tmp = g_key_file_get_boolean(config, "settings", "comment_use_indent", &error);
if (error) g_error_free(error);
else filetypes[ft]->comment_use_indent = tmp;
else filetypes[ft_id]->comment_use_indent = tmp;
}
else filetypes[ft]->comment_use_indent = tmp;
else filetypes[ft_id]->comment_use_indent = tmp;
/* read context action */
result = g_key_file_get_string(configh, "settings", "context_action_cmd", NULL);
if (result == NULL) result = g_key_file_get_string(config, "settings", "context_action_cmd", NULL);
if (result != NULL)
{
filetypes[ft]->context_action_cmd = result;
filetypes[ft_id]->context_action_cmd = result;
}
/* read build settings */
@ -841,32 +842,32 @@ static void load_settings(gint ft, GKeyFile *config, GKeyFile *configh)
if (result == NULL) result = g_key_file_get_string(config, "build_settings", "compiler", NULL);
if (result != NULL)
{
filetypes[ft]->programs->compiler = result;
filetypes[ft]->actions->can_compile = TRUE;
filetypes[ft_id]->programs->compiler = result;
filetypes[ft_id]->actions->can_compile = TRUE;
}
result = g_key_file_get_string(configh, "build_settings", "linker", NULL);
if (result == NULL) result = g_key_file_get_string(config, "build_settings", "linker", NULL);
if (result != NULL)
{
filetypes[ft]->programs->linker = result;
filetypes[ft]->actions->can_link = TRUE;
filetypes[ft_id]->programs->linker = result;
filetypes[ft_id]->actions->can_link = TRUE;
}
result = g_key_file_get_string(configh, "build_settings", "run_cmd", NULL);
if (result == NULL) result = g_key_file_get_string(config, "build_settings", "run_cmd", NULL);
if (result != NULL)
{
filetypes[ft]->programs->run_cmd = result;
filetypes[ft]->actions->can_exec = TRUE;
filetypes[ft_id]->programs->run_cmd = result;
filetypes[ft_id]->actions->can_exec = TRUE;
}
result = g_key_file_get_string(configh, "build_settings", "run_cmd2", NULL);
if (result == NULL) result = g_key_file_get_string(config, "build_settings", "run_cmd2", NULL);
if (result != NULL)
{
filetypes[ft]->programs->run_cmd2 = result;
filetypes[ft]->actions->can_exec = TRUE;
filetypes[ft_id]->programs->run_cmd2 = result;
filetypes[ft_id]->actions->can_exec = TRUE;
}
}
@ -1006,7 +1007,7 @@ GtkFileFilter *filetypes_create_file_filter_all_source()
}
GtkFileFilter *filetypes_create_file_filter(filetype *ft)
GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft)
{
GtkFileFilter *new_filter;
gint i;
@ -1026,7 +1027,7 @@ GtkFileFilter *filetypes_create_file_filter(filetype *ft)
/* Indicates whether there is a tag parser for the filetype or not. */
gboolean filetype_has_tags(filetype *ft)
gboolean filetype_has_tags(GeanyFiletype *ft)
{
g_return_val_if_fail(ft != NULL, FALSE);
@ -1035,9 +1036,9 @@ gboolean filetype_has_tags(filetype *ft)
/** Find a filetype pointer from its @c name field. */
filetype *filetypes_lookup_by_name(const gchar *name)
GeanyFiletype *filetypes_lookup_by_name(const gchar *name)
{
filetype *ft;
GeanyFiletype *ft;
g_return_val_if_fail(NZV(name), NULL);

View File

@ -102,7 +102,7 @@ struct build_programs
gboolean modified;
};
struct filetype
struct _GeanyFiletype
{
filetype_id id;
langType lang; /* represents the langType of tagmanager(see the table */
@ -123,10 +123,10 @@ extern GPtrArray *filetypes_array;
/* Wrap filetypes_array so it can be used with C array syntax.
* Example: filetypes[GEANY_FILETYPES_C]->name = ...; */
#define filetypes ((filetype **)filetypes_array->pdata)
#define filetypes ((GeanyFiletype **)filetypes_array->pdata)
filetype *filetypes_lookup_by_name(const gchar *name);
GeanyFiletype *filetypes_lookup_by_name(const gchar *name);
/* Calls filetypes_init_types() and creates the filetype menu. */
@ -136,13 +136,13 @@ void filetypes_init(void);
void filetypes_init_types(void);
/* Detect the filetype for document idx, checking for a shebang, then filename extension. */
filetype *filetypes_detect_from_file(gint idx);
GeanyFiletype *filetypes_detect_from_file(gint idx);
filetype *filetypes_detect_from_extension(const gchar *utf8_filename);
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
/* Detect filetype based on the filename extension.
* utf8_filename can include the full path. */
filetype *filetypes_detect_from_filename(const gchar *utf8_filename);
GeanyFiletype *filetypes_detect_from_filename(const gchar *utf8_filename);
/* frees the array and all related pointers */
void filetypes_free_types(void);
@ -151,14 +151,14 @@ void filetypes_load_config(gint ft_id);
void filetypes_save_commands(void);
void filetypes_select_radio_item(const filetype *ft);
void filetypes_select_radio_item(const GeanyFiletype *ft);
GtkFileFilter *filetypes_create_file_filter(filetype *ft);
GtkFileFilter *filetypes_create_file_filter(const GeanyFiletype *ft);
GtkFileFilter *filetypes_create_file_filter_all_source(void);
gchar *filetypes_get_conf_extension(gint filetype_idx);
gboolean filetype_has_tags(filetype *ft);
gboolean filetype_has_tags(GeanyFiletype *ft);
#endif

View File

@ -55,7 +55,7 @@
/* useful forward declarations */
typedef struct filetype filetype;
typedef struct _GeanyFiletype GeanyFiletype;
typedef struct _GeanyProject GeanyProject;

View File

@ -1082,7 +1082,7 @@ static void cb_func_build_action(guint key_id)
{
gint idx = document_get_cur_idx();
GtkWidget *item;
filetype *ft;
GeanyFiletype *ft;
BuildMenuItems *menu_items;
if (! DOC_IDX_VALID(idx)) return;

View File

@ -119,7 +119,7 @@ static void save_recent_files(GKeyFile *config)
static gchar *get_session_file_string(gint idx)
{
gchar *fname;
filetype *ft = doc_list[idx].file_type;
GeanyFiletype *ft = doc_list[idx].file_type;
if (ft == NULL) /* can happen when saving a new file when quitting */
ft = filetypes[GEANY_FILETYPES_NONE];
@ -839,7 +839,7 @@ static gboolean open_session_file(gchar **tmp)
if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
{
filetype *ft = filetypes_lookup_by_name(ft_name);
GeanyFiletype *ft = filetypes_lookup_by_name(ft_name);
gint new_idx = document_open_file_full(
-1, locale_filename, pos, ro, ft,
(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?

View File

@ -594,7 +594,7 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
if (data->file_idx == -1)
{
/* we have no filename in the error message, so take the current one and hope it's correct */
document *doc = document_get_current();
GeanyDocument *doc = document_get_current();
if (doc != NULL)
*filename = g_strdup(doc->file_name);
g_strfreev(fields);

View File

@ -319,7 +319,7 @@ gint notebook_new_tab(gint doc_idx)
GtkWidget *hbox, *ebox;
gint tabnum;
gchar *title;
document *this = &(doc_list[doc_idx]);
GeanyDocument *this = &(doc_list[doc_idx]);
GtkWidget *page;
g_return_val_if_fail(doc_idx >= 0 && this != NULL, -1);

View File

@ -194,21 +194,21 @@ GeanyData;
/* See document.h */
typedef struct DocumentFuncs
{
gint (*new_file) (const gchar *filename, struct filetype *ft, const gchar *text);
gint (*new_file) (const gchar *filename, struct _GeanyFiletype *ft, const gchar *text);
gint (*get_cur_idx) (void);
gint (*get_n_idx) (guint i);
gint (*find_by_filename) (const gchar *filename, gboolean is_tm_filename);
struct document* (*get_current) (void);
struct _GeanyDocument* (*get_current) (void);
gboolean (*save_file) (gint idx, gboolean force);
gint (*open_file) (const gchar *locale_filename, gboolean readonly,
struct filetype *ft, const gchar *forced_enc);
void (*open_files) (const GSList *filenames, gboolean readonly, struct filetype *ft,
struct _GeanyFiletype *ft, const gchar *forced_enc);
void (*open_files) (const GSList *filenames, gboolean readonly, struct _GeanyFiletype *ft,
const gchar *forced_enc);
gboolean (*remove) (guint page_num);
gboolean (*reload_file) (gint idx, const gchar *forced_enc);
void (*set_encoding) (gint idx, const gchar *new_encoding);
void (*set_text_changed) (gint idx);
void (*set_filetype) (gint idx, filetype *type);
void (*set_filetype) (gint idx, struct _GeanyFiletype *type);
}
DocumentFuncs;
@ -378,8 +378,8 @@ HighlightingFuncs;
/* See filetypes.h */
typedef struct FiletypeFuncs
{
filetype* (*detect_from_filename) (const gchar *utf8_filename);
filetype* (*lookup_by_name) (const gchar *name);
GeanyFiletype* (*detect_from_filename) (const gchar *utf8_filename);
GeanyFiletype* (*lookup_by_name) (const gchar *name);
}
FiletypeFuncs;

View File

@ -409,12 +409,24 @@ static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context,
{
DocInfo *dinfo = user_data;
PangoFontDescription *desc;
GtkPrintSettings *lsettings;
GtkPageRange range;
gint i;
gint style_max;
if (dinfo == NULL)
return;
/* printing a range of pages or only the current page is not yet supported, so force printing
* of all pages */
lsettings = gtk_print_operation_get_print_settings(operation);
gtk_print_settings_set_print_pages(lsettings, GTK_PRINT_PAGES_ALL);
gtk_print_settings_set_page_set(lsettings, GTK_PAGE_SET_ALL);
range.start = 0;
range.end = dinfo->n_pages;
gtk_print_settings_set_page_ranges(lsettings, &range, 1);
gtk_print_operation_set_print_settings(operation, lsettings);
desc = pango_font_description_from_string(interface_prefs.editor_font);
/* init dinfo fields */

View File

@ -964,11 +964,11 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
/* Detects a global tags filetype from the *.lang.* language extension.
* Returns NULL if there was no matching TM language. */
static filetype *detect_global_tags_filetype(const gchar *utf8_filename)
static GeanyFiletype *detect_global_tags_filetype(const gchar *utf8_filename)
{
gchar *tags_ext;
gchar *shortname = g_strdup(utf8_filename);
filetype *ft = NULL;
GeanyFiletype *ft = NULL;
tags_ext = strstr(shortname, ".tags");
if (tags_ext)
@ -1002,7 +1002,7 @@ int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess
char *command;
const char *tags_file = argv[1];
char *utf8_fname;
filetype *ft;
GeanyFiletype *ft;
utf8_fname = utils_get_utf8_from_locale(tags_file);
ft = detect_global_tags_filetype(utf8_fname);
@ -1068,7 +1068,7 @@ void symbols_show_load_tags_dialog(void)
{
gchar *fname = item->data;
gchar *utf8_fname;
filetype *ft;
GeanyFiletype *ft;
utf8_fname = utils_get_utf8_from_locale(fname);
ft = detect_global_tags_filetype(utf8_fname);
@ -1098,7 +1098,7 @@ static GHashTable *get_tagfile_hash(const GSList *file_list)
GList *fnames;
gchar *fname = node->data;
gchar *utf8_fname = utils_get_utf8_from_locale(fname);
filetype *ft = detect_global_tags_filetype(utf8_fname);
GeanyFiletype *ft = detect_global_tags_filetype(utf8_fname);
g_free(utf8_fname);
@ -1142,7 +1142,7 @@ static void load_user_tags(filetype_id ft_id)
static GHashTable *lang_hash = NULL;
GList *fnames;
const GList *node;
const filetype *ft = filetypes[ft_id];
const GeanyFiletype *ft = filetypes[ft_id];
g_return_if_fail(ft_id < GEANY_FILETYPES_NONE);

View File

@ -329,7 +329,7 @@ static void
on_new_with_template (GtkMenuItem *menuitem,
gpointer user_data)
{
filetype *ft = user_data;
GeanyFiletype *ft = user_data;
gchar *template = templates_get_template_new_file(ft);
document_new_file(NULL, ft, template);
@ -345,7 +345,7 @@ static void create_new_menu_items(void)
for (ft_id = 0; ft_id < GEANY_MAX_BUILT_IN_FILETYPES; ft_id++)
{
GtkWidget *tmp_menu, *tmp_button;
filetype *ft = filetypes[ft_id];
GeanyFiletype *ft = filetypes[ft_id];
const gchar *label = ft->title;
if (ft_templates[ft_id] == NULL)
@ -366,7 +366,7 @@ static void create_new_menu_items(void)
}
static gchar *get_template_from_file(const gchar *locale_fname, filetype *ft)
static gchar *get_template_from_file(const gchar *locale_fname, GeanyFiletype *ft)
{
GString template = {NULL, 0, 0};
@ -390,7 +390,7 @@ static void
on_new_with_file_template(GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer user_data)
{
gchar *fname = ui_menu_item_get_text(menuitem);
filetype *ft;
GeanyFiletype *ft;
gchar *template;
ft = filetypes_detect_from_extension(fname);
@ -433,8 +433,8 @@ static void add_file_item(gpointer data, gpointer user_data)
static gint compare_filenames_by_filetype(gconstpointer a, gconstpointer b)
{
filetype *ft_a = filetypes_detect_from_extension(a);
filetype *ft_b = filetypes_detect_from_extension(b);
GeanyFiletype *ft_a = filetypes_detect_from_extension(a);
GeanyFiletype *ft_b = filetypes_detect_from_extension(b);
/* sort by filetype name first */
if (ft_a != ft_b)
@ -661,7 +661,7 @@ gchar *templates_get_template_fileheader(gint filetype_idx, const gchar *fname)
gchar *result;
gchar *date = utils_get_date_time(TEMPLATE_DATETIME_FORMAT, NULL);
filetype_id ft_id = filetype_idx;
filetype *ft = filetypes[ft_id];
GeanyFiletype *ft = filetypes[ft_id];
filetypes_load_config(ft_id); /* load any user extension setting */
@ -689,7 +689,7 @@ gchar *templates_get_template_fileheader(gint filetype_idx, const gchar *fname)
}
static gchar *get_file_template(filetype *ft)
static gchar *get_file_template(GeanyFiletype *ft)
{
filetype_id ft_id = FILETYPE_ID(ft);
@ -697,7 +697,7 @@ static gchar *get_file_template(filetype *ft)
}
gchar *templates_get_template_new_file(struct filetype *ft)
gchar *templates_get_template_new_file(GeanyFiletype *ft)
{
gchar *ft_template = NULL;
gchar *file_header = NULL;

View File

@ -54,7 +54,7 @@ void templates_init(void);
gchar *templates_get_template_fileheader(gint filetype_idx, const gchar *fname);
gchar *templates_get_template_new_file(struct filetype *ft);
gchar *templates_get_template_new_file(GeanyFiletype *ft);
gchar *templates_get_template_changelog(void);