Skip to content

Commit

Permalink
Note: this breaks the plugin API.
Browse files Browse the repository at this point in the history
Replace doc_array with documents_array, a pointer array. This is
necessary to avoid breaking the ABI every time a field is added to
GeanyDocument.
Remove deprecated pluginmacros.h documents macro, to avoid a
conflict.
Replace doc_list[] macro with documents[] macro, which returns a
GeanyDocument pointer.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2624 ea778897-0a13-0410-b9d1-a72fbfd435f5
  • Loading branch information
ntrel committed May 29, 2008
1 parent 4198167 commit be0d9e8
Show file tree
Hide file tree
Showing 34 changed files with 1,033 additions and 1,010 deletions.
21 changes: 21 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
2008-05-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

* src/build.c, src/utils.c, src/win32.c, src/keybindings.c,
src/printing.c, src/tools.c, src/prefs.c, src/dialogs.c,
src/navqueue.c, src/plugindata.h, src/treeviews.c, src/msgwindow.c,
src/callbacks.c, src/notebook.c, src/keyfile.c, src/vte.c,
src/filetypes.c, src/search.c, src/document.c, src/plugins.c,
src/document.h, src/main.c, src/editor.c, src/symbols.c,
src/socket.c, src/ui_utils.c, plugins/export.c, plugins/vcdiff.c,
plugins/filebrowser.c, plugins/htmlchars.c, plugins/autosave.c,
plugins/pluginmacros.h, plugins/classbuilder.c:
Note: this breaks the plugin API.
Replace doc_array with documents_array, a pointer array. This is
necessary to avoid breaking the ABI every time a field is added to
GeanyDocument.
Remove deprecated pluginmacros.h documents macro, to avoid a
conflict.
Replace doc_list[] macro with documents[] macro, which returns a
GeanyDocument pointer.


2008-05-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

* doc/geany.css, doc/geany.html:
Expand Down
4 changes: 2 additions & 2 deletions plugins/autosave.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ gboolean auto_save(gpointer data)
idx = p_document->get_n_idx(i);

/* skip current file to save it lastly, skip files without name */
if (idx != cur_idx && doc_list[idx].file_name != NULL)
if (idx != cur_idx && documents[idx]->file_name != NULL)
if (p_document->save_file(idx, FALSE))
saved_files++;
}
}
/* finally save current file, do it after all other files to get correct window title and
* symbol list */
if (doc_list[cur_idx].file_name != NULL)
if (documents[cur_idx]->file_name != NULL)
if (p_document->save_file(cur_idx, FALSE))
saved_files++;

Expand Down
4 changes: 2 additions & 2 deletions plugins/classbuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,15 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
{
text = get_template_class_source(class_info);
idx = p_document->new_file(class_info->source, NULL, NULL);
p_sci->set_text(doc_list[idx].sci, text);
p_sci->set_text(documents[idx]->sci, text);
g_free(text);
}

if (! p_utils->str_equal(class_info->header, ""))
{
text = get_template_class_header(class_info);
idx = p_document->new_file(class_info->header, NULL, NULL);
p_sci->set_text(doc_list[idx].sci, text);
p_sci->set_text(documents[idx]->sci, text);
g_free(text);
}

Expand Down
56 changes: 28 additions & 28 deletions plugins/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,

/* if the current document has a filename we use it as the default. */
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
if (doc_list[idx].file_name != NULL)
if (documents[idx]->file_name != NULL)
{
gchar *base_name = g_path_get_basename(doc_list[idx].file_name);
gchar *base_name = g_path_get_basename(documents[idx]->file_name);
gchar *short_name = p_utils->remove_ext_from_filename(base_name);
gchar *file_name;
gchar *locale_filename;
gchar *locale_dirname;
gchar *suffix = "";

if (g_str_has_suffix(doc_list[idx].file_name, extension))
if (g_str_has_suffix(documents[idx]->file_name, extension))
suffix = "_export";

file_name = g_strconcat(short_name, suffix, extension, NULL);
locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);
locale_dirname = g_path_get_dirname(locale_filename);
/* set the current name to base_name.html which probably doesn't exist yet so
* gtk_file_chooser_set_filename() can't be used and we need
Expand Down Expand Up @@ -357,25 +357,25 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
GString *body;
GString *cmds;
GString *latex;
gint style_max = pow(2, p_sci->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
gint style_max = pow(2, p_sci->send_message(documents[idx]->sci, SCI_GETSTYLEBITS, 0, 0));

/* first read all styles from Scintilla */
for (i = 0; i < style_max; i++)
{
styles[i][FORE] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0);
styles[i][BOLD] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETITALIC, i, 0);
styles[i][FORE] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBACK, i, 0);
styles[i][BOLD] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETITALIC, i, 0);
styles[i][USED] = 0;
}

/* read the document and write the LaTeX code */
body = g_string_new("");
for (i = 0; i < p_sci->get_length(doc_list[idx].sci); i++)
for (i = 0; i < p_sci->get_length(documents[idx]->sci); i++)
{
style = p_sci->get_style_at(doc_list[idx].sci, i);
c = p_sci->get_char_at(doc_list[idx].sci, i);
c_next = p_sci->get_char_at(doc_list[idx].sci, i + 1);
style = p_sci->get_style_at(documents[idx]->sci, i);
c = p_sci->get_char_at(documents[idx]->sci, i);
c_next = p_sci->get_char_at(documents[idx]->sci, i + 1);

if (style != old_style || ! block_open)
{
Expand Down Expand Up @@ -538,10 +538,10 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
p_utils->string_replace_all(latex, "{export_content}", body->str);
p_utils->string_replace_all(latex, "{export_styles}", cmds->str);
p_utils->string_replace_all(latex, "{export_date}", get_date(DATE_TYPE_DEFAULT));
if (doc_list[idx].file_name == NULL)
if (documents[idx]->file_name == NULL)
p_utils->string_replace_all(latex, "{export_filename}", GEANY_STRING_UNTITLED);
else
p_utils->string_replace_all(latex, "{export_filename}", doc_list[idx].file_name);
p_utils->string_replace_all(latex, "{export_filename}", documents[idx]->file_name);

write_data(filename, latex->str);

Expand All @@ -564,15 +564,15 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
GString *body;
GString *css;
GString *html;
gint style_max = pow(2, p_sci->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
gint style_max = pow(2, p_sci->send_message(documents[idx]->sci, SCI_GETSTYLEBITS, 0, 0));

/* first read all styles from Scintilla */
for (i = 0; i < style_max; i++)
{
styles[i][FORE] = ROTATE_RGB(p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0));
styles[i][BOLD] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETITALIC, i, 0);
styles[i][FORE] = ROTATE_RGB(p_sci->send_message(documents[idx]->sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBACK, i, 0));
styles[i][BOLD] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETITALIC, i, 0);
styles[i][USED] = 0;
}

Expand All @@ -581,18 +581,18 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
font_name = pango_font_description_get_family(font_desc);
/*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/
/* take the zoom level also into account */
font_size = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETSIZE, 0, 0);
font_size = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETSIZE, 0, 0);
if (use_zoom)
font_size += p_sci->send_message(doc_list[idx].sci, SCI_GETZOOM, 0, 0);
font_size += p_sci->send_message(documents[idx]->sci, SCI_GETZOOM, 0, 0);

/* read the document and write the HTML body */
body = g_string_new("");
for (i = 0; i < p_sci->get_length(doc_list[idx].sci); i++)
for (i = 0; i < p_sci->get_length(documents[idx]->sci); i++)
{
style = p_sci->get_style_at(doc_list[idx].sci, i);
c = p_sci->get_char_at(doc_list[idx].sci, i);
style = p_sci->get_style_at(documents[idx]->sci, i);
c = p_sci->get_char_at(documents[idx]->sci, i);
/* p_sci->get_char_at() takes care of index boundaries and return 0 if i is too high */
c_next = p_sci->get_char_at(doc_list[idx].sci, i + 1);
c_next = p_sci->get_char_at(documents[idx]->sci, i + 1);

if ((style != old_style || ! span_open) && ! isspace(c))
{
Expand Down Expand Up @@ -690,10 +690,10 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
p_utils->string_replace_all(html, "{export_date}", get_date(DATE_TYPE_HTML));
p_utils->string_replace_all(html, "{export_content}", body->str);
p_utils->string_replace_all(html, "{export_styles}", css->str);
if (doc_list[idx].file_name == NULL)
if (documents[idx]->file_name == NULL)
p_utils->string_replace_all(html, "{export_filename}", GEANY_STRING_UNTITLED);
else
p_utils->string_replace_all(html, "{export_filename}", doc_list[idx].file_name);
p_utils->string_replace_all(html, "{export_filename}", documents[idx]->file_name);

write_data(filename, html->str);

Expand Down
6 changes: 3 additions & 3 deletions plugins/filebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ static void on_current_path(void)
gchar *dir;
gint idx = p_document->get_cur_idx();

if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL ||
! g_path_is_absolute(doc_list[idx].file_name))
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL ||
! g_path_is_absolute(documents[idx]->file_name))
{
setptr(current_dir, get_default_dir());
refresh();
return;
}
fname = doc_list[idx].file_name;
fname = documents[idx]->file_name;
fname = p_utils->get_locale_from_utf8(fname);
dir = g_path_get_dirname(fname);
g_free(fname);
Expand Down
6 changes: 3 additions & 3 deletions plugins/htmlchars.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ static gboolean sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
if (DOC_IDX_VALID(idx))
{
gchar *str;
gint pos = p_sci->get_current_position(doc_list[idx].sci);
gint pos = p_sci->get_current_position(documents[idx]->sci);

gtk_tree_model_get(model, iter, COLUMN_HTML_NAME, &str, -1);
if (str && *str)
{
p_sci->insert_text(doc_list[idx].sci, pos, str);
p_sci->insert_text(documents[idx]->sci, pos, str);
g_free(str);
result = TRUE;
}
Expand Down Expand Up @@ -510,7 +510,7 @@ item_activate(GtkMenuItem *menuitem, gpointer gdata)
/* refuse opening the dialog if we don't have an active tab */
gint idx = p_document->get_cur_idx();

if (idx == -1 || ! doc_list[idx].is_valid) return;
if (idx == -1 || ! documents[idx]->is_valid) return;

tools_show_dialog_insert_special_chars();
}
Expand Down
6 changes: 2 additions & 4 deletions plugins/pluginmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
/* common data structs */
#define app geany_data->app
#define main_widgets geany_data->main_widgets
#define doc_array geany_data->doc_array /**< Allows use of @c doc_list[] macro */
#define documents_array geany_data->documents_array /**< Allows use of @c documents[] macro */
#define filetypes_array geany_data->filetypes_array /**< Allows use of @c filetypes[] macro */
#define prefs geany_data->prefs
#define project app->project


/* New function macros should be added here */
#define p_document geany_functions->p_document /**< See document.h */
#define p_filetypes geany_functions->p_filetypes /**< See filetypes.h */
#define p_navqueue geany_functions->p_navqueue /**< See navqueue.h */
#define p_editor geany_functions->p_editor /**< See editor.h */
Expand All @@ -53,7 +54,6 @@
#ifdef GEANY_DISABLE_DEPRECATED

#define p_dialogs geany_functions->p_dialogs /**< See dialogs.h */
#define p_document geany_functions->p_document /**< See document.h */
#define p_encodings geany_functions->p_encodings /**< See encodings.h */
#define p_highlighting geany_functions->p_highlighting /**< See highlighting.h */
#define p_keybindings geany_functions->p_keybindings /**< See keybindings.h */
Expand All @@ -69,7 +69,6 @@
#else

#define p_dialogs dialogs
#define p_document documents
#define p_encodings encodings
#define p_highlighting highlighting
#define p_keybindings keybindings
Expand All @@ -85,7 +84,6 @@

/* Temporary source compatibility macros - do not use these in new code, they may get removed. */
#define dialogs geany_functions->p_dialogs
#define documents geany_functions->p_document
#define encodings geany_functions->p_encodings
#define highlighting geany_functions->p_highlighting
#define keybindings geany_functions->p_keybindings
Expand Down
28 changes: 14 additions & 14 deletions plugins/vcdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ static int find_by_filename(const gchar* filename)
{
guint i;

for (i = 0; i < doc_array->len; i++)
for (i = 0; i < documents_array->len; i++)
{
if (doc_list[i].is_valid && doc_list[i].file_name &&
strcmp(doc_list[i].file_name, filename) == 0)
if (documents[i]->is_valid && documents[i]->file_name &&
strcmp(documents[i]->file_name, filename) == 0)
return i;
}
return -1;
Expand Down Expand Up @@ -295,11 +295,11 @@ static void show_output(const gchar *std_output, const gchar *name_prefix,
}
else
{
p_sci->set_text(doc_list[idx].sci, text);
p_sci->set_text(documents[idx]->sci, text);
book = GTK_NOTEBOOK(main_widgets->notebook);
page = gtk_notebook_page_num(book, GTK_WIDGET(doc_list[idx].sci));
page = gtk_notebook_page_num(book, GTK_WIDGET(documents[idx]->sci));
gtk_notebook_set_current_page(book, page);
doc_list[idx].changed = FALSE;
documents[idx]->changed = FALSE;
p_document->set_text_changed(idx);
}

Expand Down Expand Up @@ -403,14 +403,14 @@ static void vcdirectory_activated(GtkMenuItem *menuitem, gpointer gdata)

idx = p_document->get_cur_idx();

g_return_if_fail(DOC_IDX_VALID(idx) && doc_list[idx].file_name != NULL);
g_return_if_fail(DOC_IDX_VALID(idx) && documents[idx]->file_name != NULL);

if (doc_list[idx].changed)
if (documents[idx]->changed)
{
p_document->save_file(idx, FALSE);
}

locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);
base_name = g_path_get_dirname(locale_filename);

text = make_diff(base_name, VC_COMMAND_DIFF_DIR);
Expand All @@ -436,7 +436,7 @@ static void vcproject_activated(GtkMenuItem *menuitem, gpointer gdata)

g_return_if_fail(project != NULL && NZV(project->base_path));

if (DOC_IDX_VALID(idx) && doc_list[idx].changed && doc_list[idx].file_name != NULL)
if (DOC_IDX_VALID(idx) && documents[idx]->changed && documents[idx]->file_name != NULL)
{
p_document->save_file(idx, FALSE);
}
Expand All @@ -460,19 +460,19 @@ static void vcfile_activated(GtkMenuItem *menuitem, gpointer gdata)

idx = p_document->get_cur_idx();

g_return_if_fail(DOC_IDX_VALID(idx) && doc_list[idx].file_name != NULL);
g_return_if_fail(DOC_IDX_VALID(idx) && documents[idx]->file_name != NULL);

if (doc_list[idx].changed)
if (documents[idx]->changed)
{
p_document->save_file(idx, FALSE);
}

locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);

text = make_diff(locale_filename, VC_COMMAND_DIFF_FILE);
if (text)
{
show_output(text, doc_list[idx].file_name, doc_list[idx].encoding);
show_output(text, documents[idx]->file_name, documents[idx]->encoding);
g_free(text);
}
g_free(locale_filename);
Expand Down
Loading

0 comments on commit be0d9e8

Please sign in to comment.